我想通过python执行这个shell命令,我尝试使用
shell="ls *R1.fastq.gz|while read a; do b=${a%R1.fastq.gz}R2.fastq.gz; c=${a%R1.fastq.gz}R1.out.fq; d=${a%R1.fastq.gz}R2.out.fq; e=${a%R1.fastq.gz}.s.fq; echo "sickle pe -t sanger -f $a -r $b -o $c -p $d -s $e"; done >SICKLE.sh"
system.os(shell)
但是得到SythaxError: InvalidSyntax
我做了一些研究,也许我应该使用subprocces
?但我对此很新,我们可以帮助我吗?
答案 0 :(得分:0)
escape
引号(在字符串中的引号前添加\
)
shell="*R1.fastq.gz|while read a; do b=${a%R1.fastq.gz}R2.fastq.gz; c=${a%R1.fastq.gz}R1.out.fq; d=${a%R1.fastq.gz}R2.out.fq; e=${a%R1.fastq.gz}.s.fq; echo \"sickle pe -t sanger -f $a -r $b -o $c -p $d -s $e\"; done >SICKLE.sh"
<强> subprocess.call
强>:
import subprocess
subprocess.call(["ls", shell])