Skip to content
Snippets Groups Projects
Commit eeec5bf1 authored by Blaise Li's avatar Blaise Li
Browse files

More adaptable mapping wrapper.

parent 379e744e
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,8 @@ from libworkflows import read_htseq_counts, sum_htseq_counts ...@@ -55,6 +55,8 @@ from libworkflows import read_htseq_counts, sum_htseq_counts
from libworkflows import read_feature_counts, sum_feature_counts from libworkflows import read_feature_counts, sum_feature_counts
from smincludes import rules as irules from smincludes import rules as irules
alignment_settings = {"bowtie2": ""},
#TRIMMERS = ["cutadapt", "fastx_clipper"] #TRIMMERS = ["cutadapt", "fastx_clipper"]
TRIMMERS = ["cutadapt"] TRIMMERS = ["cutadapt"]
COUNTERS = ["feature_count"] COUNTERS = ["feature_count"]
...@@ -312,6 +314,7 @@ rule map_on_genome: ...@@ -312,6 +314,7 @@ rule map_on_genome:
sam = temp(OPJ(output_dir, "{trimmer}", aligner, "mapped_C_elegans", "{lib}_{rep}_{type}_on_C_elegans.sam")), sam = temp(OPJ(output_dir, "{trimmer}", aligner, "mapped_C_elegans", "{lib}_{rep}_{type}_on_C_elegans.sam")),
nomap_fastq = OPJ(output_dir, "{trimmer}", aligner, "not_mapped_C_elegans", "{lib}_{rep}_{type}_unmapped_on_C_elegans.fastq.gz"), nomap_fastq = OPJ(output_dir, "{trimmer}", aligner, "not_mapped_C_elegans", "{lib}_{rep}_{type}_unmapped_on_C_elegans.fastq.gz"),
params: params:
aligner = aligner,
index = index, index = index,
settings = "", settings = "",
message: message:
......
...@@ -129,6 +129,7 @@ from libworkflows import filter_combinator, sum_feature_counts, sum_htseq_counts ...@@ -129,6 +129,7 @@ from libworkflows import filter_combinator, sum_feature_counts, sum_htseq_counts
from smincludes import rules as irules from smincludes import rules as irules
strip = str.strip strip = str.strip
alignment_settings = {"bowtie2": "-L 6 -i S,1,0.8 -N 0"},
# Positions in small RNA sequences for which to analyse nucleotide distribution # Positions in small RNA sequences for which to analyse nucleotide distribution
#POSITIONS = ["first", "last"] #POSITIONS = ["first", "last"]
...@@ -733,8 +734,9 @@ rule map_on_genome: ...@@ -733,8 +734,9 @@ rule map_on_genome:
sam = temp(OPJ(output_dir, aligner, "mapped_C_elegans", "{lib}_{rep}", "%s_on_C_elegans.sam" % size_selected)), sam = temp(OPJ(output_dir, aligner, "mapped_C_elegans", "{lib}_{rep}", "%s_on_C_elegans.sam" % size_selected)),
nomap_fastq = OPJ(output_dir, aligner, "not_mapped_C_elegans", "{lib}_{rep}_%s_unmapped_on_C_elegans.fastq.gz" % size_selected), nomap_fastq = OPJ(output_dir, aligner, "not_mapped_C_elegans", "{lib}_{rep}_%s_unmapped_on_C_elegans.fastq.gz" % size_selected),
params: params:
aligner = aligner,
index = index, index = index,
settings = "-L 6 -i S,1,0.8 -N 0", settings = alignment_settings[aligner],
message: message:
"Mapping {wildcards.lib}_{wildcards.rep}_%s on C. elegans genome." % size_selected "Mapping {wildcards.lib}_{wildcards.rep}_%s on C. elegans genome." % size_selected
benchmark: benchmark:
......
from snakemake.shell import shell from snakemake.shell import shell
cmd = """ def mapping_command(aligner):
genome_dir="${{HOME}}/Genomes" """This function returns the shell commands to run given the *aligner*."""
genome="C_elegans" if aligner == "hisat2":
cmd="bowtie2 --seed 123 -t {snakemake.params.settings} --mm -x {snakemake.params.index} -U {snakemake.input.fastq} --no-unal --un-gz {snakemake.output.nomap_fastq} -S {snakemake.output.sam}" shell_commands = """
echo ${{cmd}} > {snakemake.log.log} cmd="hisat2 -p {snakemake.threads} --dta --seed 123 -t {snakemake.params.settings} --mm -x {snakemake.params.index} -U {snakemake.input.fastq} --no-unal --un-gz {snakemake.output.nomap_fastq} -S {snakemake.output.sam}"
eval ${{cmd}} 1>> {snakemake.log.log} 2> {snakemake.log.err} echo ${{cmd}} 1> {log.log}
eval ${{cmd}} 1>> {log.log} 2> {log.err}
""" """
elif aligner == "bowtie2":
shell_commands = """
cmd="bowtie2 -p {snakemake.threads} --seed 123 -t {snakemake.params.settings} --mm -x {snakemake.params.index} -U {snakemake.input.fastq} --no-unal --un-gz {snakemake.output.nomap_fastq} -S {snakemake.output.sam}"
echo ${{cmd}} > {snakemake.log.log}
eval ${{cmd}} 1>> {snakemake.log.log} 2> {snakemake.log.err}
"""
elif aligner == "crac":
shell_commands = """
cmd="crac --nb-threads {snakemake.threads} --summary %s --all %s {snakemake.params.settings} -i {snakemake.params.index} -r {snakemake.input.fastq} --sam {snakemake.output.sam}"
echo ${{cmd}} > {snakemake.log.log}
eval ${{cmd}} 1>> {snakemake.log.log} 2> {snakemake.log.err}
# TODO: extract non mappers from the sam output
> {snakemake.output.nomap_fastq}
""" % (snakemake.output.nomap_fastq.split("_unmapped")[0] + "_summary.txt", snakemake.output.nomap_fastq.split("_unmapped")[0] + "_output.txt")
else:
raise NotImplementedError("%s is not yet handled." % aligner)
return shell_commands
shell(cmd) shell(mapping_command(snakemake.params.aligner))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment