pal2nal

PAL2NAL is a program that converts a multiple sequence alignment of proteins and the corresponding DNA (or mRNA) sequences into a codon alignment. 

http://www.bork.embl.de/pal2nal/

map the nucleotide sequences to the multiple alignment of amino acid sequences.

import tempfile
from Bio import SeqIO
import subprocess

pal2nal = 'C:\Users\dell\Desktop\pal2nal.v14\pal2nal.pl'
p = subprocess.check_output('perl %s %s %s -codontable 1 -output fasta' % (pal2nal, alnFile, nucFile), stderr = subprocess.PIPE, shell = True)
tmf = tempfile.TemporaryFile()
tmf.write(p)
tmf.seek(0)
seq = list(SeqIO.parse(tmf, 'fasta'))
tmf.close()

简单用了几个模块将pal2nal的进程在python里封装一下。suprocess里面的PIPE不是很懂,大概就是定义输出输入流吧。用临时文件存储输出,再解析临时文件。

原文地址:https://www.cnblogs.com/hluo/p/4060649.html