Skip to content

Commit

Permalink
Merge pull request #712 from dorbarker/fix-broken-join
Browse files Browse the repository at this point in the history
Fix broken str.join() in ncbiquery.generate_table()
  • Loading branch information
jhcepas authored Oct 2, 2023
2 parents 8670138 + 7532c5b commit d3e0574
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions ete4/ncbi_taxonomy/ncbiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,24 +642,23 @@ def load_ncbi_tree_from_dump(tar):
return t, synonyms

def generate_table(t):
OUT = open("taxa.tab", "w")
for j, n in enumerate(t.traverse()):
if j % 1000 == 0:
print("\r",j,"generating entries...", end=' ')
temp_node = n
track = []
while temp_node:
track.append(temp_node.name)
temp_node = temp_node.up
if n.up:
print('\t'.join(n.name, n.up.name, n.props.get('taxname'),
n.props.get("common_name", ''), n.props.get("rank"),
','.join(track)), file=OUT)
else:
print('\t'.join(n.name, "", n.props.get('taxname'),
n.props.get("common_name", ''), n.props.get("rank"),
','.join(track)), file=OUT)
OUT.close()
with open("taxa.tab", "w") as out:
for j, n in enumerate(t.traverse()):
if j % 1000 == 0:
print("\r",j,"generating entries...", end=' ')
temp_node = n
track = []
while temp_node:
track.append(temp_node.name)
temp_node = temp_node.up

n_up_name = n.up.name if n.up else ""

row = '\t'.join([n.name, n_up_name, n.props.get('taxname'),
n.props.get("common_name", ''), n.props.get("rank"),
','.join(track)])

print(row, file=out)

def update_db(dbfile, targz_file=None):
basepath = os.path.split(dbfile)[0]
Expand Down

0 comments on commit d3e0574

Please sign in to comment.