我将以下命令传递到python脚本中。你知道吗
awk '/^>/{n=split($0,a,"_")} /string/{sum+=a[n]} END{print sum}' filein.fasta
不管我做什么,都会搞得一团糟(操作系统,波本,子流程调用...) 我最后一次尝试是:
string = this variable is a string like "acgactactgtcagtgctgac" provided in a loop
filein = open("filein.fasta")
with open('fileout.txt', 'a+') as outputd:
subprocess.call(['awk', '\'/^>/{n=split($0,a,"_")}', '/' + line + '/{sum+=a[n]}', 'END{print sum}\'', filein], stdout=outputd, shell=True)
通过这种方式,我在这一点上没有错误,但它不能正常工作,因为它会在脚本中出现错误。 如何在python中正确地传递这个命令?在这种情况下,引号是个棘手的问题
请避免在
python
脚本中使用awk
命令。你知道吗我真的很喜欢
awk
,但是python
可以轻松地做awk
可以做的事情。你知道吗是吗
使用python:
调用子进程会降低代码的可移植性,并且更难调试或监视。你知道吗
顺便说一句,
awk
脚本不好,应该是:相关问题 更多 >
编程相关推荐