Exemplo n.º 1
0
# Only write a new alignment if there is a new alignment
if empty_seq_count >= 1:
    if len(trimmed_alignment) >= 1:
        SeqIO.write(trimmed_alignment, handle=alignment_file, \
                    format=alignment_format)

tree = EvolTree(tree_file)
out_tree_name = os.path.basename(tree_file)
out_tree_name = os.path.splitext(out_tree_name)[0]
out_tree_name = out_tree_name + '_' + gene_name + '.tre'

# If there is a new alignment, prune the tree down to the taxa that remain in
# the new alignment
if empty_seq_count >= 1:
    if len(taxa_in_alignment) >= 1:
        tree.prune(taxa_in_alignment, preserve_branch_length=True)

test_taxa = []
with open(test_taxa_file, 'r') as test_taxa_list:
    for taxon in test_taxa_list:
        taxon = taxon.rstrip()
        test_taxa.append(taxon)

nodes_to_mark = set()  # set since we want it to be all unique ids

# Mark the test taxa
for taxon in test_taxa:
    taxon_node = tree & taxon  # ete3 notation for finding a node within a tree
    taxon_id = taxon_node.node_id  # mark_tree only takes node_ids, not labels
    nodes_to_mark.add(taxon_id)