output translations of internal nodes
@@ -34,10 +34,14 @@ if __name__ == '__main__':
tt = TreeAnc(tree=T, aln=MultipleSeqAlignment(seqs), alphabet='aa')
tt.infer_ancestral_sequences(reconstruct_tip_states=True)
+
+ with open(translation.replace('.fasta', '_withInternalNodes.fasta'), 'w') as fh:
for n in tt.tree.find_clades():
if n.name not in node_data:
node_data[n.name] = {"aa_muts":{}}
node_data[n.name]["aa_muts"][gene] = [f"{a}{p+1}{d}" for a,p,d in n.mutations]
+ fh.write(f">{n.name}\n{tt.sequence(n, as_string=True)}\n")
+
with open(args.output, 'w') as fh:
json.dump({"nodes":node_data}, fh)
