我当前正在运行一个snakemake检查点,即使正确完成命令后,该检查点似乎仍在抛出非零退出代码,并且不确定如何解决该问题。
以下脚本的目的是解析坐标文件bed_file
,从bam文件rna_file
中提取所有区域,并最终组合这些区域。下面的代码,我的snakemake版本是5.6.0。
#Pull coordinates from a BAM file, and use the command samtools view to extract the corresponding #data, naming the output as the coordinate file, here named "6:25274434-25278245.bam". There are #an unknown number of output files
checkpoint pull_reads_for_BAM:
input:
¦ bed_file = get_lncRNA_file,
¦ rna_file = get_RNA_file
conda:
¦ "envs/pydev_1.yml"
params:
¦ "01.pulled_reads"
output:
¦ directory("01.pulled_reads/{tissue}")
shell:"""
mkdir 01.pulled_reads/{wildcards.tissue}
store_regions=$(cat {input.bed_file} | awk -F'\t' '{{ print $1 ":" $2 "-" $3 }}')
for i in $store_regions ; do
¦ samtools view -b -h {input.rna_file} ${{i}} > 01.pulled_reads/{wildcards.tissue}/${{i}}.bam ;
done
echo "This completed fine"
"""
rule samtools_sort:
input:
¦ "01.pulled_reads/{tissue}/{i}.bam"
params:
¦ "{i}"
output:
¦ "01.pulled_reads/{tissue}/{i}.sorted.bam"
shell:
¦ "samtools sort -T sorted_reads/{params}.tmp {input} > {output}"
rule samtools_index:
input:
¦ "01.pulled_reads/{tissue}/{i}.sorted.bam"
output:
¦ "01.pulled_reads/{tissue}/{i}.sorted.bam.bai"
shell:
"samtools index {input}"
rule string_tie_assembly:
input:
¦ "01.pulled_reads/{tissue}/{i}.sorted.bam"
output:
¦ "02.string_tie_assembly/{tissue}/{i}_assembly.gtf"
shell:
"stringtie {input} -f 0.0 -a 0 -m 50 -c 3.0 -f 0.0 -o {output}"
def trigger_aggregate(wildcards):
checkpoint_output = checkpoints.pull_reads_for_BAM.get(**wildcards).output[0]
x = expand("02.string_tie_assembly/{tissue}/{i}_assembly.merged.gtf",
¦ tissue = wildcards.tissue,
¦ i=glob_wildcards(os.path.join(checkpoint_output, "{i}.bam")).i)
return x
#Aggregate function that triggers rule
rule combine_all_gtf_things:
input:
¦ trigger_aggregate
output:
¦ "03.final_stuff/{tissue}.merged.gtf"
shell:"""
cat {input} > {output}
"""
命令执行完毕后,snakemake出于某种神秘原因返回(exited with non-zero exit code)
。我可以看到文件中生成了输出,它看起来是正确的,所以我不确定为什么会引发此错误。
我生成的检查点是在此之后建模的: https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html
尚未回答的相关问题: Snakemake checkpoint (exited with non-zero exit code)
答案 0 :(得分:1)
该问题似乎是由{tissue}
中的通配符设置为目录引起的。至于为什么会抛出非零退出状态,我不确定。只需将{tissue}_dir
附加到上面的路径即可解决此问题。
有关此问题的更多信息,请参见: https://bitbucket.org/snakemake/snakemake/issues/1303/snakemake-checkpoint-throws-exited-with
答案 1 :(得分:0)
不确定这是否是问题,但是在执行mkdir之前,如果目录存在或mkdir 01.pulled_reads/{wildcards.tissue}
不存在,01.pulled_reads
将失败。
尝试将-p
选项添加到mkidr,即mkdir -p 01.pulled_reads/{wildcards.tissue}