Skip to content

Commit

Permalink
Fix imports and finalisation for tools, resolves #325
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemms committed Feb 6, 2020
1 parent 074c5e7 commit b588cf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions tools/convert_orthofinder_tree_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print(sys.path[-1])

from orthofinder.scripts import tree, util
from scripts_of import tree, util

def ReplaceFileWithNewIDs(idsMap, treeFilename, newTreeFilename):
qHaveSupport = False
Expand Down Expand Up @@ -50,7 +51,7 @@ def GetSpeciesSequenceIDsDict(sequenceIDsFilename, speciesIDsFN = None):
idsDict = {seqID:speciesDict[seqID.split("_")[0]] + "_" + name for seqID, name in idsDict.items()}
return idsDict

def main():
def main_convert():
with util.Finalise():
parser = argparse.ArgumentParser(description="Takes a tree with OrthoFinder IDs and outputs a tree with gene accessions")
parser.add_argument("TreeInput", help="Tree filename or directory")
Expand All @@ -76,4 +77,4 @@ def main():
print("")

if __name__ == "__main__":
main()
main_convert()
5 changes: 3 additions & 2 deletions tools/make_ultrametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from orthofinder.scripts import tree
from scripts_of import tree, util

def AveDist(node):
return np.average([node.get_distance(l) for l in node.get_leaf_names()])
Expand Down Expand Up @@ -69,4 +69,5 @@ def main():
print("\nUltrametric tree written to: %s\n" % outfn)

if __name__ == "__main__":
main()
with util.Finalise():
main()

0 comments on commit b588cf5

Please sign in to comment.