我正在编写一个python脚本,该脚本必须启动一个子进程,并给出大量输出(此输出不能在我的工作环境中编写)。所以我使用Subprocess.Popen
然后subprocess.stdout.readline()
不幸的是,经过几次测试和研究,我无法解决我的记忆问题。在process.stdout.readline()的多次迭代之后,我得到了一个列表索引超出范围的错误,但是因为我可以打印“问题”值我认为这是一个记忆问题
我知道subprocess.Popen()
正在独立于主进程启动一个新的子进程,有没有办法给这个子进程一定量的内存减少使用的内存量
我尝试直接在shell中运行子进程,如果有帮助的话,它在大约8小时内消耗了803MB
以下是我的部分代码和返回的错误:
process = subprocess.Popen(["samtools mpileup -a -Q 0 -r " + REFERENCE + " -f " + REFERENCE + " " + BAM], stdout = subprocess.PIPE, shell=True, universal_newlines=True)
mpileup_line = process.stdout.readline().strip("\n").split("\t")
while ((int(mpileup_line[3])<COVERAGE) and (int(mpileup_line[1]) != int(gff_line[3]))):
if (i != int(gff_line[7])-1):
mpileup_line = process.stdout.readline().strip("\n").split("\t")
下面是错误:
[mpileup] 1 samples in 1 input files
Traceback (most recent call last):
File "/work/cbirbes/axis1-assembly/errorCorrection_Pipeline/bin/Reductor.py", line 109, in <module>
while ((int(mpileup_line[3])<COVERAGE) and (int(mpileup_line[1]) != int(gff_line[3]))):
IndexError: list index out of range
正如我所说,在错误发生之前,我们可以同时打印int(mpileup_line[3]), COVERAGE, int(mpileup_line[1])
和int(gff_line[3])
目前没有回答
相关问题 更多 >
编程相关推荐