0

我想用来MafftCommandline对齐我的数据,但出现以下错误:

Traceback (most recent call last):


 File "C:\Users\Rimvis\Desktop\asd\bioinformatika2_Working.py", line 35, in <mo
dule>
    stdout, stderr = mafftCline()  # Note that MAFFT will write the alignment to
 stdout, which you may want to save to a file and then parse
  File "C:\Python27\lib\site-packages\Bio\Application\__init__.py", line 475, in
 __call__
    shell=(sys.platform!="win32"))
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

我的代码如下:

dataToProcess = "dataToProcess.fa"
file = open(dataToProcess, "w")

arrayOfSequences = []
for sequence in blast.alignments:
    if sequence.length > blast.alignments[0].length * 80 / 100:
        sequenceToAppend = SeqRecord(Seq(sequence.hsps[0].sbjct), id=sequence.title)
        arrayOfSequences.append(sequenceToAppend)
SeqIO.write(arrayOfSequences, file, "fasta")
file.close()

maffPath = "..\mafft-win\mafft.bat"     
mafftCline = MafftCommandline(maffPath, input=dataToProcess)
stdout, stderr = mafftCline()  # Note that MAFFT will write the alignment to stdout, which you may want to save to a file and then parse
alignedData = "aligned.fa"
alignedFile = open(alignedData, "w") 
alignedFile.write(stdout) 
alignedFile.close() 
aligned = AlignIO.read(alignedData, "fasta")

我以教程为例

4

2 回答 2

0

正如@willOEM所说,该脚本正在相对目录中查找文件。

您的脚本假定其文件与“dataToProcess”fasta 文件位于同一目录中。

如果您移动了脚本或试图打开位于其他位置的文件,则会引发此错误。

您需要更改dataToProcess,maffPathalignedFile引用绝对路径。

于 2013-11-12T23:48:58.433 回答
0

问题是我需要逃避斜线。并使用maffPath = "..\\mafft-win\\mafft.bat"而不是maffPath = "..\mafft-win\mafft.bat"

于 2013-11-13T17:00:00.343 回答