Alignment file format conversion for the efficient
Today, I needed to convert a series of alignments, which were stored in the common nexus format, into newick format. In order to do this efficiently, I wrote the following few-liner.
#!/usr/bin/env python2.7
import sys
from Bio import AlignIO
inFn = sys.argv[1]
inp = open(inFn, 'rU')
outp = open(inFn+'.phy', 'w')
aln = AlignIO.parse(inp, 'nexus')
AlignIO.write(aln, outp, 'phylip')
outp.close()
inp.close()
The above-code is very ordinary and great to have handy.