Commit 0669a295 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

Merge branch '32-unmapped-reads' into 'master'

Resolve "get unmapped reads"

Closes #32

See merge request !7
parents 05042bc7 bb2d822a
__bedtools_bamtofastq_pairs_bedtools_exec_command = config.get(
'bedtools_bamtofastq_pairs', {}
).get('bedtools_exec_command', 'bedtools')
__bedtools_bamtofastq_pairs_modules = config.get('bedtools_bamtofastq_pairs', {}).get('modules')
rule bedtools_bamtofastq_pairs:
input:
__bedtools_bamtofastq_pairs_input
output:
forward = f"{__bedtools_bamtofastq_pairs_output_forward_name}.fq.gz",
reverse = f"{__bedtools_bamtofastq_pairs_output_reverse_name}.fq.gz"
params:
forward_name = __bedtools_bamtofastq_pairs_output_forward_name,
reverse_name = __bedtools_bamtofastq_pairs_output_reverse_name,
exec_command = __bedtools_bamtofastq_pairs_bedtools_exec_command,
modules = __bedtools_bamtofastq_pairs_modules
run:
command = []
if params.modules:
command.append("module load {params.modules}")
command.append(
"{params.exec_command} bamtofastq -i {input} -fq {params.forward_name}.fq -fq2 {params.reverse_name}.fq"
)
command.append("gzip {params.forward_name}.fq")
command.append("gzip {params.reverse_name}.fq")
shell(" && ".join(command))
configfile: "config.yaml"
# ==== Snakefile path ====
__bedtools_bamtofastq_pairs_rules = config.get("snakefiles", {}).get("bedtools_bamtofastq_pairs")
__main_output_dir = config.get('output_dir', 'output')
# ==== Main config ====
SAMPLES = config.get('samples')
__input_dir = config.get('input_dir', 'data')
# ==== Bedtools bamtofastq ====
__bedtools_bamtofastq_pairs_output_dir = f"{__main_output_dir}/bedtools_bamtofastq_pairs"
__bedtools_bamtofastq_pairs_input = "{dir}/{{sample}}.bam".format(dir=__input_dir, sample="{sample}")
__bedtools_bamtofastq_pairs_output_forward_name = "{dir}/{{sample}}_1".format(
dir=__bedtools_bamtofastq_pairs_output_dir, sample="{sample}"
)
__bedtools_bamtofastq_pairs_output_reverse_name = "{dir}/{{sample}}_2".format(
dir=__bedtools_bamtofastq_pairs_output_dir, sample="{sample}"
)
include: __bedtools_bamtofastq_pairs_rules
rule all:
input:
forward = expand(f"{__bedtools_bamtofastq_pairs_output_forward_name}.fq.gz", sample=SAMPLES),
reverse = expand(f"{__bedtools_bamtofastq_pairs_output_reverse_name}.fq.gz", sample=SAMPLES)
snakefiles:
bedtools_bamtofastq_pairs: /pasteur/zeus/projets/p02/metasig/gitlab/snakemake/tools/bedtools/bamtofastq_pairs/Snakefile
input_dir: /some/input/directory
output_dir: /some/output/directory
samples:
- test_00000
- test_00001
- test_00002
bedtools_bamtofastq_pairs:
bedtools_exec_command: bedtools
modules: bedtools
__extract_unmapped_pairs_samtools_exec_command = config.get(
'extract_unmapped_pairs', {}
).get('samtools_exec_command', 'samtools')
__extract_unmapped_pairs_modules = config.get('extract_unmapped_pairs', {}).get('modules')
rule extract_unmapped_pairs:
input:
__extract_unmapped_pairs_input
output:
__extract_unmapped_pairs_output
params:
exec_command = __extract_unmapped_pairs_samtools_exec_command,
modules = __extract_unmapped_pairs_modules
run:
command = []
if params.modules:
command.append("module load {params.modules}")
command.append("{params.exec_command} view -u -f 4 -F 264 {input} > {output}.tmps1.bam")
command.append("{params.exec_command} view -u -f 8 -F 260 {input} > {output}.tmps2.bam")
command.append("{params.exec_command} view -u -f 12 -F 256 {input} > {output}.tmps3.bam")
command.append(
"{params.exec_command} merge -u - {output}.tmps[123].bam | {params.exec_command} sort -n > {output}"
)
command.append("rm {output}.tmps[123].bam")
shell(" && ".join(command))
configfile: "config.yaml"
# ==== Snakefile path ====
__extract_unmapped_pairs_rules = config.get("snakefiles", {}).get("extract_unmapped_pairs")
__main_output_dir = config.get('output_dir', 'output')
# ==== Main config ====
SAMPLES = config.get('samples')
__input_dir = config.get('input_dir', 'data')
# ==== Extract unmapped pairs ====
__extract_unmapped_pairs_output_dir = f"{__main_output_dir}/extract_unmapped_pairs"
__extract_unmapped_pairs_input = "{dir}/{{sample}}.bam".format(dir=__input_dir, sample="{sample}")
__extract_unmapped_pairs_output = "{dir}/{{sample}}_unmapped.bam".format(dir=__extract_unmapped_pairs_output_dir, sample="{sample}")
include: __extract_unmapped_pairs_rules
rule all:
input: expand("{dir}/{{sample}}_unmapped.bam".format(dir=__extract_unmapped_pairs_output_dir), sample=SAMPLES)
snakefiles:
extract_unmapped_pairs: /pasteur/zeus/projets/p02/metasig/gitlab/snakemake/tools/samtools/extract_unmapped_pairs/Snakefile
input_dir: /some/input/directory
output_dir: /some/output/directory
samples:
- test_00000
- test_00001
- test_00002
extract_unmapped_pairs:
samtools_exec_command: samtools
modules: samtools
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment