Skip to content

Commit

Permalink
Merge pull request #216 from BZhao95/BZhao95-patch-1
Browse files Browse the repository at this point in the history
Update poppunk_iterate.py
  • Loading branch information
johnlees committed Sep 12, 2022
2 parents 434408b + 254a47c commit 3b4ab31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion PopPUNK/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'''PopPUNK (POPulation Partitioning Using Nucleotide Kmers)'''

__version__ = '2.5.0'
__version__ = '2.5.1'

# Minimum sketchlib version
SKETCHLIB_MAJOR = 2
Expand Down
23 changes: 14 additions & 9 deletions scripts/poppunk_iterate.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,22 @@ def is_nested(cluster_dict, child_members, node_list):
for leaf in tree.traverse_leaves():
parent_node = leaf.get_parent()
if not parent_node.is_root():
if parent_node.get_edge_length() < args.cutoff and parent_node.get_parent().is_root():
cut_clusters.add(parent_node)
elif parent_node.get_edge_length() < args.cutoff and not parent_node.get_parent().is_root():
# For each leaf, go back up the tree to find the cluster which
# crosses the cutoff threshold
while not parent_node.is_root() and\
parent_node.get_edge_length() < args.cutoff:
# Go up a level
child_node = parent_node
parent_node = child_node.get_parent()
if parent_node.is_root() or \
(child_node.get_edge_length() < args.cutoff and \
parent_node.get_edge_length() > args.cutoff):
cut_clusters.add(parent_node)
while parent_node.get_edge_length() < args.cutoff:
# Go up a level
child_node = parent_node
parent_node = child_node.get_parent()
if parent_node.is_root():
cut_clusters.add(child_node)
break
if (child_node.get_edge_length() < args.cutoff and \
parent_node.get_edge_length() > args.cutoff):
cut_clusters.add(child_node)
break

# In the case where a grand-parent node's average core distance is smaller
# than child node's both great parent node and child node will be selected
Expand Down

0 comments on commit 3b4ab31

Please sign in to comment.