# How to create a .phy file for constructing a phylogenetic tree?

I'm new here. I need to construct a phylogenetic tree from 16s Sequence data (merged 151 bp) and color the branches/nodes based on my experimental conditions. From this blog, it looks like I need a .phy file to make the tree. I want to use Biopython for this since I'm reasonably comfortable with python.

I have a csv file with the 16s sequences, the phylogenetic information, and the "name" of the sequence, and the experimental conditions. How can I make a .phy file from this?

I would appreciate any help. Thank you.

You simply use Biopython's SeqIO and AlignIO. The documentation is https://biopython.org/wiki/AlignIO etc ... The format you seek is phylip

• Thank you for your response. I made a .phy file similar to the one here link (except that in mine, the length of the sequences is 253). I ensured that they all have the same length. But when I ran al=AlignIO.read(open("for_tree_top10.phy"),"phylip"), I got "ValueError: Sequences must all be the same length". I'm not sure why, because I explicitly checked that the sequences have the same length. Not sure what to do now :( Any thoughts? Feb 18 '20 at 23:12
• Possibly it is not a programming issue but formating. There is no simple answer to trouble shoot this. Could you ask this as a separate question please? Obviously it is solvable but there's several possibilities and the Moderators will intervene if there are multiple questions within a thread
– M__
Feb 19 '20 at 0:03
• I have asked the question here link Feb 19 '20 at 15:31
os.system("mafft --auto {} > {}" .format("unaligned_16s_seq_in_file.fasta", "alignment_out_file.fasta"))