[Biopython-dev] Phylip interface questions

Brad Chapman chapmanb at 50mail.com
Mon Jul 27 22:34:16 UTC 2009

Hi Marshall;

> I am wondering if there is already an interface to the Phylip programs in 
> biopython.  I am pretty sure there is not, but I wanted to ask before 
> doing a chunk of work on one.  I know that AlignIO can read and write the 
> phylip alignment files, but I think that is it.
> Assuming such a thing doesn't already exist, I will write some functions 
> for calling various combinations of programs in phylip to make some common 
> tasks easier.  Mostly this will use the pexpect module.  What is the most 
> appropriate place to put such an interface within biopython?

I did a lot of work with Phylip a while back, and generally
interfacing with it is hideous looking but not impossible. I would
create input files with the data for all of the menu items, and then
feed this into the program. Then you need to handle renaming the
generically named output files. Here's a chunk of it to give you the

pars_outfile = os.path.join(work_dir, "outgroup_phy.pars")
pars_tree_outfile = os.path.join(work_dir, "outgroup_phy.parstree")

hack_phylip_file = os.path.join(work_dir, "protpars.hack")
hack_output = "%s\nM\nD\n%s\n13\n10\nO\n1\nY\n" % (align_file, num_boot)
hack_handle = open(hack_phylip_file, "w")

cl = PhylipHackCommandline("protpars", hack_phylip_file)
os.rename("outfile", pars_outfile)
os.rename("outtree", pars_tree_outfile)

I would second Peter in using the EMBOSS interfaces to Phylip. There
are ones already in Biopython for protdist, neighbor, protpars,
consense and seqboot:


Why do you prefer the pexpect module for running applications? From
a quick glance, the subprocess module included in Python should let
you do most of what you can do with pexpect and it doesn't require
an extra install.

Finally, I am not as plugged in on the latest in phylogeny building but
is Phylip still in favor? I know there has been a lot of work on
Maximum Likelihood and Bayesian methods, like:

FastTree: http://www.microbesonline.org/fasttree/index.html
RAxML: http://icwww.epfl.ch/~stamatak/index-Dateien/Page443.htm
MrBayes: http://mrbayes.csit.fsu.edu/

In terms of Python support for these, Frank Kauff has some things to
deal with RAxML:


The latest PyCogent had support for FastTree and I believe they also
tackle RAxML:


Hope this helps. Glad to have someone thinking about these

More information about the Biopython-dev mailing list