Skip to content

Commit

Permalink
without pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
crosenth committed Sep 14, 2016
1 parent 0834539 commit d9819d2
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions taxtastic/subcommands/taxtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ def action(args):
else:
log.info('building taxtable from ' + args.database_file)
nodes = pandas.read_sql_table('nodes', engine, index_col='tax_id')
if args.from_taxid:
log.info('pruning nodes above taxid ' + args.from_taxid)
nodes = prune_nodes(nodes, ranks, nodes.loc[args.from_taxid])
names = pandas.read_sql_table(
'names', engine, columns=['tax_id', 'tax_name', 'is_primary'])
names = names[names['is_primary']].set_index('tax_id')
Expand Down Expand Up @@ -258,20 +255,3 @@ def build_taxtable(df, ranks):
sys.stderr.write('built {} of {} rank lineages\r'.format(i, rank_count))

return lineages.drop('rank_parent', axis=1).set_index(df_index_name)


def prune_nodes(nodes, ranks, from_node):
keep = from_node.name
keep_ids = set(['1', keep]) # root, keep
while keep != '1':
keep_ids.add(keep)
keep = nodes.loc[keep]['parent_id']

# remove nodes in upper ranks
rank = from_node['rank']
drop_ids = set()
for r in ranks[:ranks.index(rank)]:
idrop = ((nodes['rank'] == r) & (~nodes.index.isin(keep_ids)))
drop_ids.update(nodes[idrop].index)

return nodes.drop(drop_ids)

0 comments on commit d9819d2

Please sign in to comment.