diff --git a/mess/workflow/rules/processing/reads.smk b/mess/workflow/rules/processing/reads.smk index b4c8659..3060633 100644 --- a/mess/workflow/rules/processing/reads.smk +++ b/mess/workflow/rules/processing/reads.smk @@ -455,7 +455,7 @@ if ERRFREE: input: lambda wildcards: aggregate(wildcards, dir.out.ef, "bam"), output: - os.path.join(dir.out.ef, "{sample}", "{fasta}.bam"), + os.path.join(dir.out.ef, "{sample}.bam"), log: os.path.join( dir.out.logs, @@ -477,71 +477,44 @@ if ERRFREE: samtools merge -@ {threads} -o {output} {input} 2> {log} """ - rule merge_sample_bams_ef: - input: - lambda wildcards: aggregate(wildcards, dir.out.ef, "bam"), - output: - temp(os.path.join(dir.out.ef, "{sample}.unsorted")), - benchmark: - os.path.join(dir.out.bench, "samtools", "merge", "{sample}_ef.txt") - log: - os.path.join(dir.out.logs, "samtools", "merge", "{sample}_ef.log"), - resources: - mem_mb=config.resources.sml.mem, - mem=str(config.resources.sml.mem) + "MB", - time=config.resources.sml.time, - threads: config.resources.norm.cpu - conda: - os.path.join(dir.conda, "bioconvert.yml") - container: - containers.bioconvert - shell: - """ - samtools merge -@ {threads} -o {output} {input} 2> {log} - """ - - rule sort_bams_ef: + rule index_bams_ef: input: - os.path.join(dir.out.ef, "{sample}.unsorted"), - output: os.path.join(dir.out.ef, "{sample}.bam"), + output: + os.path.join(dir.out.ef, "{sample}.bam.bai"), benchmark: - os.path.join(dir.out.bench, "samtools", "sort", "{sample}_ef.txt"), - log: - os.path.join(dir.out.logs, "samtools", "sort", "{sample}_ef.log"), + os.path.join(dir.out.bench, "samtools", "index", "{sample}_ef.txt") resources: mem_mb=config.resources.sml.mem, mem=str(config.resources.sml.mem) + "MB", - time=config.resources.sml.time, + time=config.resources.norm.time, threads: config.resources.norm.cpu conda: - os.path.join(dir.conda, "bioconvert.yml") + os.path.join(dir.conda, "samtools.yml") container: - containers.bioconvert + containers.samtools shell: """ - samtools sort -@ {threads} {input} -o {output} 2> {log} + samtools index -@ {threads} {input} """ - rule index_bams_ef: + rule get_bam_coverage_ef: input: os.path.join(dir.out.ef, "{sample}.bam"), output: - os.path.join(dir.out.ef, "{sample}.bam.bai"), - benchmark: - os.path.join(dir.out.bench, "samtools", "index", "{sample}_ef.txt") + temp(os.path.join(dir.out.ef, "{sample}.txt")), resources: mem_mb=config.resources.sml.mem, mem=str(config.resources.sml.mem) + "MB", - time=config.resources.norm.time, - threads: config.resources.norm.cpu + time=config.resources.sml.time, + threads: config.resources.sml.cpu conda: - os.path.join(dir.conda, "bioconvert.yml") + os.path.join(dir.conda, "samtools.yml") container: - containers.bioconvert + containers.samtools shell: """ - samtools index -@ {threads} {input} + samtools coverage {input} > {output} """