[Biopython] How to run PAL2NAL commandline via python

Zheng Ruan zruan1991 at gmail.com
Fri Jan 17 15:18:22 UTC 2014


Hey Edson,

There are a couple of issues in your code. You need to make sure the
command called by os.system() is able to run in the shell (my_pal2nal
should not be called; you also missed a space between my_prot_file and
my_nucl_file; the '-nogap' option should be placed before redirecting).

Biopython do have a codeml wrapper. see
http://biopython.org/wiki/PAML#codeml. To run codeml, you also need a tree
file specified. You'd better make sure that you can successfully run codeml
in the command line before including it in your script.

Hope it helps,

Best,
Zheng Ruan


On Fri, Jan 17, 2014 at 2:11 AM, Edson Ishengoma
<ishengomae at nm-aist.ac.tz>wrote:

> Dear all,
>
> I recently was introduced to pal2nal as a convenient tool to convert
> aligned protein residues (from tblastn, for example) back to their original
> nucleotide sequences. My boss suggested I use a python or perl script to
> call the tool and feed the resulting nucleotide alignments to the 'codeml'
> program to calculate Ka, Ks.
>
> I don't know perl, so I would like to know how to do this from python -- a
> python script which includes the way to feed the resulting codon alignments
> to  PAML for "codeml" program to calculate Ka, Ks values.
>
> I tried to check for the pre-existence of  Biopython wrapper for Pal2Nal I
> didnt see one. I am on linux machine (Ubuntu 13.04) and my installed python
> is Python 2.7.4.
> I tried this script which I expected to produce a file containing aligned
> nucleotide sequences. But no error message is shown but it outputs an empty
> file (nothing written on the file).
>
> import os
> > my_pal2nal = os.path.join(os.getcwd(), 'pal2nal.v14')
> > my_prot_file = os.path.join(os.getcwd(), 'pal2nal.v14', 'dnds.aln')
> > my_nucl_file = os.path.join(os.getcwd(), 'pal2nal.v14', 'dnds.nuc')
> > output_file = '/home/edson/pal2nal.v14/output'
> > os.system(my_pal2nal + 'perl pal2nal.pl' + my_prot_file + my_nucl_file +
> > ' -output paml' + '>' + output_file + ' -nogap')
> >
>
> What perfect way should I proceed and how do I include a script for
> 'codeml'?
>
> Thanks.
>
> Regards,
>
> Edson.
>
>
>
> Edson B. Ishengoma
> PhD-Candidate
> *School of Life Sciences and Engineering
> Nelson Mandela African Institute of Science and Technology
> Nelson Mandela Road
> P. O. Box 447, Arusha
> Tanzania (255)
> *
> *ishengomae at nm-aist.ac.tz  *ebarongo82 at yahoo.co.uk
> *
>
> <http://www.nm-aist.ac.tz/>Mobile: +255 762 348 037, +255 714 789 360,
>   Website: www.nm-aist.ac.tz
> Skype: edson.ishengoma
>
> *
> *
> **
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>



More information about the Biopython mailing list