Skip to content

Commit

Permalink
Merge pull request #35 from didillysquat/master
Browse files Browse the repository at this point in the history
check for no root decomposition when updating toplogy
  • Loading branch information
meren authored Mar 9, 2021
2 parents 2b9c774 + 7e82e7c commit aaa0b89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Oligotyping/lib/decomposer.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,11 @@ def _generate_raw_topology(self):
self.progress.new('Raw Topology')
# main loop
while 1:
self.decomposition_depth += 1

if not len(self.node_ids_to_analyze):
self.progress.end()
break

self.decomposition_depth += 1
# following for loop will go through all nodes that are stored in
# self.node_ids_to_analyze list. while those nodes are being decomposed,
# new nodes will appear and need to be analyzed next round. following
Expand Down Expand Up @@ -564,7 +564,7 @@ def _generate_raw_topology(self):

#finally:
self.progress.end()
self.topology.update_final_nodes()
self.topology.update_final_nodes(decomposition_depth=self.decomposition_depth)

self.run.info('num_raw_nodes', utils.pretty_print(len(self.topology.final_nodes)))

Expand All @@ -575,7 +575,7 @@ def _refresh_topology(self):
self.progress.new('Refreshing the topology')
self.progress.update('Updating final nodes...')

self.topology.update_final_nodes()
self.topology.update_final_nodes(decomposition_depth=self.decomposition_depth)

dirty_nodes = []
for node_id in self.topology.final_nodes:
Expand Down
7 changes: 5 additions & 2 deletions Oligotyping/lib/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,14 @@ def get_parent_node(self, node_id):
return self.nodes[self.nodes[node_id].parent]


def update_final_nodes(self):
def update_final_nodes(self, decomposition_depth):
self.alive_nodes = [n for n in sorted(self.nodes.keys()) if not self.nodes[n].killed]

# get final nodes sorted by abundance
final_nodes_tpls = [(self.nodes[n].size, n) for n in self.alive_nodes if not self.nodes[n].children]
final_nodes_tpls = [
(self.nodes[n].size, n) for n in self.alive_nodes if not self.nodes[n].children or (
decomposition_depth == 0 and
n == 'root')]
final_nodes_tpls.sort(reverse = True)
self.final_nodes = [n[1] for n in final_nodes_tpls]

Expand Down

0 comments on commit aaa0b89

Please sign in to comment.