Skip to content

Commit f74cfff

Browse files
committed
fix(itol): Fix an issue where phyla could not be determined.
1 parent 469a405 commit f74cfff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gtdb_itol_decorate/itol.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ def get_phylum_to_lca(tree: dendropy.Tree):
5151
"""Calculate the LCA for each phylum. Considers singletons."""
5252
out = defaultdict(list)
5353
for node in tree.postorder_node_iter():
54-
if len(node.tax_label) > 0 and node.tax_label[0].startswith('p__'):
55-
out[node.tax_label[0]].append(get_lca_str(node))
54+
# Consider the case where the domain shares the same label as the phylum
55+
if len(node.tax_label) > 0:
56+
if len(node.tax_label) >= 2:
57+
if node.tax_label[0].startswith('d__') and node.tax_label[1].startswith('p__'):
58+
out[node.tax_label[1]].append(get_lca_str(node))
59+
else:
60+
if node.tax_label[0].startswith('p__'):
61+
out[node.tax_label[0]].append(get_lca_str(node))
5662
return out
5763

5864

0 commit comments

Comments
 (0)