简体   繁体   中英

Running sequence alignment using biopython

I am interested in running mafft from biopython. It works fine (code below).

from Bio.Align.Applications import MafftCommandline
mafft_cline=MafftCommandline(input="file.fasta")
print(mafft_cline) 
stdout, stderr = mafft_cline()
output.write(stdout) 

But I wanted to add in the additional parameter of adjusting the direction of the sequences based on the first sequence (the reference one). In the documentation, I found this written down, but I am not sure how to incorporate it into my code above:

Mafft V6 beta function

_Switch(["--adjustdirection", "adjustdirection"], 
"Adjust direction according to the first sequence. " 
"Default off."), 
# Adjust direction according to the first sequence 
# for highly diverged data; very slow 
# Mafft V6 beta function 
_Switch(["--adjustdirectionaccurately", "adjustdirectionaccurately"], 
"Adjust direction according to the first sequence," 
"for highly diverged data; very slow" 
"Default off."), 

I tried a few things like mafft_cline=MafftCommandline(input="file.fasta", --adjustdirection) but it comes back with an error.

Thanks!

You do this by setting the adjustdirection property of mafft_cline . By default, it is False .

>> from Bio.Align.Applications import MafftCommandline
>> mafft_cline = MafftCommandline(input="file.fasta")
>> print(mafft_cline.adjustdirection)
False
>> mafft_cline.adjustdirection = True

We now see that the --adjustdirection switch is added to the commandline.

>> print(mafft_cline)
mafft --adjustdirection file.fasta

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM