假设有以下脚本:
import csv
import re
#this script is designed to take a list of probe files and
#generate a corresponding swarm file for blasting them against
#some user defined database.
def __main__():
#args
infile = sys.argv[1] #list of sequences to run
outfile = sys.argv[2] #location of resulting swarm file
outdir = sys.argv[3] #location to store results from blast run
db = sys.argv[4] #database to query against
with open(infile) as fi:
data = [x[0].strip('\n') for x in list(csv.reader(fi))]
cmd = open(outfile, 'w')
blast = 'module load blast/2.2.26; blastall -v 5 -b 5 -a 4 -p blastn '
db = ' -d ' + db
def f(x):
input = ' -i ' + str(x)
out = re.search('(?<=./)([^\/]*)(?=\.)', x).group(0)
out = ' -o ' + outdir + out + '.out'
cmd.write(blast + db + input + out + '\n')
map(f, data)
__main__()
如果我运行它:
python blast-probes.py /data/cornishjp/array-annotations/agilent_4x44k_human/probe-seq-fasta-list.csv ./human.cmd ./ x
human.cmd 的一个例子是:
module load blast/2.2.26; blastall -v 5 -b 5 -a 4 -p blastn -d x -i /data/corni
shjp/array-annotations/agilent_4x44k_human/probe-seqs/A_33_P3344603.fas -o ./A_3
3_P3344603.out
如果我运行它:
python blast-probes.py /data/cornishjp/array-annotations/agilent_4x44k_mouse/probe-seq-fasta-list.csv ./mouse.cmd ./ x
mouse.cmd 的一个例子是:
module load blast/2.2.26; blastall -v 5 -b 5 -a 4 -p blastn -d x -i /data/cornishp/array-annotations/agilent_4x44k_mouse/probe-seqs/A_51_P100327.fas -o ./A_51_P100327.out
不同之处在于当 is 结尾时agilent_4x44k_
,human
目录被正确写入文件cornishjp
。当结尾是mouse
时,目录被错误地写为cornishp
,j
被遗漏。我已经交换了所有内容(将人类保存为mouse.cmd,等等),但我终其一生都无法弄清楚。
唯一想到的是,当我为 python 脚本生成参数时,我使用 tab 来自动完成(linux)。这可能是问题吗?它正在正确读取输入文件,因为脚本会失败。