【发布时间】:2018-02-01 18:54:49
【问题描述】:
我正在尝试通过 subprocess.call() 传递以下命令
command = ['htseq-count', '-t', 'miRNA', '-i', 'Name', f, annot_file, out_file]
在运行时,我收到 htseq-count 至少需要 2 个参数的通知,这意味着它无法识别命令中有输入文件。
在运行时打印命令会得到以下结果:
['htseq-count', '-t', 'miRNA', '-i', 'Name', 'KDRD1XX_ACAGTG_L001_R1_001_trimmedaligned.sam', 'hsa.gff3', 'KDRD1XX.htseq.sam']
哪个是正确的文件输入。
插入打印出来的命令(当然没有逗号和引号)工作正常,所以没有问题。
在使用 subprocess.call() 之前使用变量列表没有任何问题,因此我们将不胜感激!
完整代码:
import sys
import subprocess
import os
annot_file='hsa.gff3'
dirs= os.listdir('.')
for f in dirs:
if f.endswith("_trimmedaligned.sam"):
of=f.split('_')
outfile='>'+of[0]+'.htseq.sam'
command=['htseq-count','-t','miRNA','-i','Name',f,annot_file, out_file]
#print(command)
subprocess.call(command)
【问题讨论】:
标签: python linux subprocess