Package Bio :: Package Align :: Package Applications :: Module _Mafft :: Class MafftCommandline
[hide private]
[frames] | no frames]

Class MafftCommandline

source code

                     object --+    
                              |    
Application.AbstractCommandline --+
                                  |
                                 MafftCommandline

Command line wrapper for the multiple alignment program MAFFT.

http://align.bmr.kyushu-u.ac.jp/mafft/software/

Example:

>>> from Bio.Align.Applications import MafftCommandline
>>> mafft_exe = "/opt/local/mafft"
>>> in_file = "../Doc/examples/opuntia.fasta"
>>> mafft_cline = MafftCommandline(mafft_exe, input=in_file)
>>> print(mafft_cline)
/opt/local/mafft ../Doc/examples/opuntia.fasta

If the mafft binary is on the path (typically the case on a Unix style operating system) then you don't need to supply the executable location:

>>> from Bio.Align.Applications import MafftCommandline
>>> in_file = "../Doc/examples/opuntia.fasta"
>>> mafft_cline = MafftCommandline(input=in_file)
>>> print(mafft_cline)
mafft ../Doc/examples/opuntia.fasta

You would typically run the command line with mafft_cline() or via the Python subprocess module, as described in the Biopython tutorial. Note that MAFFT will write the alignment to stdout, which you may want to save to a file and then parse, e.g.:

stdout, stderr = mafft_cline()
with open("aligned.fasta", "w") as handle:
    handle.write(stdout)
from Bio import AlignIO
align = AlignIO.read("aligned.fasta", "fasta")

Alternatively, to parse the output with AlignIO directly you can use StringIO to turn the string into a handle:

stdout, stderr = mafft_cline()
from StringIO import StringIO
from Bio import AlignIO
align = AlignIO.read(StringIO(stdout), "fasta")

Citations:

Katoh, Toh (BMC Bioinformatics 9:212, 2008) Improved accuracy of multiple ncRNA alignment by incorporating structural information into a MAFFT-based framework (describes RNA structural alignment methods)

Katoh, Toh (Briefings in Bioinformatics 9:286-298, 2008) Recent developments in the MAFFT multiple sequence alignment program (outlines version 6)

Katoh, Toh (Bioinformatics 23:372-374, 2007) Errata PartTree: an algorithm to build an approximate tree from a large number of unaligned sequences (describes the PartTree algorithm)

Katoh, Kuma, Toh, Miyata (Nucleic Acids Res. 33:511-518, 2005) MAFFT version 5: improvement in accuracy of multiple sequence alignment (describes [ancestral versions of] the G-INS-i, L-INS-i and E-INS-i strategies)

Katoh, Misawa, Kuma, Miyata (Nucleic Acids Res. 30:3059-3066, 2002)

Last checked against version: MAFFT v6.717b (2009/12/03)

Instance Methods [hide private]
 
__init__(self, cmd='mafft', **kwargs)
Create a new instance of a command line wrapper object.
source code

Inherited from Application.AbstractCommandline: __call__, __repr__, __setattr__, __str__, set_parameter

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cmd='mafft', **kwargs)
(Constructor)

source code 
Create a new instance of a command line wrapper object.
Overrides: object.__init__
(inherited documentation)