【发布时间】:2015-05-29 19:52:33
【问题描述】:
我想首先说非常感谢任何帮助。我是 Python 和一般脚本的新手。我正在尝试使用一个名为 samtools view 的程序将文件从 .sam 转换为 .bam 我需要能够执行此 BASH 命令在 Python 中执行的操作:
samtools view -bS aln.sam > aln.bam
我知道 BASH 命令像 | >
cmd = subprocess.call(["samtools view","-bS"], stdin=open(aln.sam,'r'), stdout=open(aln.bam,'w'), shell=True)
和
from subprocess import Popen
with open(SAMPLE+ "."+ TARGET+ ".sam",'wb',0) as input_file:
with open(SAMPLE+ "."+ TARGET+ ".bam",'wb',0) as output_file:
cmd = Popen([Dir+ "samtools-1.1/samtools view",'-bS'],
stdin=(input_file), stdout=(output_file), shell=True)
在 Python 中,我仍然没有让 samtools 将 .sam 转换为 .bam 文件。我究竟做错了什么?
【问题讨论】:
标签: python linux bash shell python-2.7