Skip to content

Commit

Permalink
Refactor align_single rule in align.smk
Browse files Browse the repository at this point in the history
  • Loading branch information
alsmith151 committed Jan 3, 2024
1 parent 9edb74a commit 7bd95af
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions seqnado/workflow/rules/align.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import seqnado.utils as utils

if config["split_fastq"] == "False":

rule align_paired:
input:
fq1="seqnado_output/trimmed/{sample}_1.fastq.gz",
Expand All @@ -22,6 +23,7 @@ if config["split_fastq"] == "False":
mv {output.bam}_sorted {output.bam}
"""


rule align_paired:
input:
fq1="seqnado_output/trimmed/{sample}_1.fastq.gz",
Expand All @@ -34,7 +36,7 @@ rule align_paired:
threads: config["bowtie2"]["threads"]
resources:
mem_mb=4000,
time='0-04:00:00',
time="0-04:00:00",
log:
"seqnado_output/logs/align/{sample}.log",
shell:
Expand All @@ -44,22 +46,26 @@ rule align_paired:
mv {output.bam}_sorted {output.bam}
"""

# rule align_single:
# input:
# fq1="seqnado_output/trimmed/{sample}.fastq.gz",
# params:
# index=config["genome"]["indicies"],
# options=config["bowtie2"]["options"],
# output:
# bam=temp("seqnado_output/aligned/raw/{sample}.bam"),
# resources:
# mem_mb=4000 // int(config["bowtie2"]["threads"])
# threads: config["bowtie2"]["threads"]
# log:
# "seqnado_output/logs/align/{sample}.log",
# shell:
# """bowtie2 -p {threads} -x {params.index} -U {input.fq1} {params.options} 2> {log} |
# samtools view -bS - > {output.bam} &&
# samtools sort -@ {threads} -o {output.bam}_sorted {output.bam} &&
# mv {output.bam}_sorted {output.bam}
# """

rule align_single:
input:
fq1="seqnado_output/trimmed/{sample}.fastq.gz",
params:
index=config["genome"]["indicies"],
options=utils.check_options(config["bowtie2"]["options"]),
output:
bam=temp("seqnado_output/aligned/raw/{sample}.bam"),
resources:
mem_mb=4000,
threads: config["bowtie2"]["threads"]
log:
"seqnado_output/logs/align/{sample}.log",
shell:
"""bowtie2 -p {threads} -x {params.index} -U {input.fq1} {params.options} 2> {log} |
samtools view -bS - > {output.bam} &&
samtools sort -@ {threads} -o {output.bam}_sorted {output.bam} &&
mv {output.bam}_sorted {output.bam}
"""


ruleorder: align_paired > align_single

0 comments on commit 7bd95af

Please sign in to comment.