Skip to content

Commit

Permalink
feat(filtering): add filter options and implement BAM filtering rule
Browse files Browse the repository at this point in the history
  • Loading branch information
alsmith151 committed Nov 18, 2024
1 parent 7bdd54b commit 9d6dbef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions seqnado/workflow/config/config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ plotting_coordinates: "{{plotting_coordinates}}"
plotting_genes: "{{plotting_genes}}"
plotting_format: "svg"

filter_options:

#################################
# Tool specific options #
#################################
Expand Down
24 changes: 23 additions & 1 deletion seqnado/workflow/rules/alignment_post_processing.smk
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,32 @@ else:
"""


rule move_bam_to_final_location:
rule filter_bam:
input:
bam="seqnado_output/aligned/shifted_for_tn5_insertion/{sample}.bam",
bai="seqnado_output/aligned/shifted_for_tn5_insertion/{sample}.bam.bai",
output:
bam="seqnado_output/aligned/filtered/{sample}.bam",
bai="seqnado_output/aligned/filtered/{sample}.bam.bai",
threads: 1
resources:
mem="500MB",
log:
"seqnado_output/logs/filter/{sample}.log",
params:
options=check_options(config["filter_options"]),
shell:
"""
samtools view -h {input.bam} {options} | samtools view -b - > {output.bam} &&
samtools index {output.bam} &&
echo 'Filtered reads' > {log} 2>&1 &&
samtools view -f 2 -c {output.bam} >> {log} 2>&1
"""

rule move_bam_to_final_location:
input:
bam="seqnado_output/aligned/filtered/{sample}.bam",
bai="seqnado_output/aligned/filtered/{sample}.bam.bai",
output:
bam="seqnado_output/aligned/{sample,[A-Za-z\\d\\-_]+}.bam",
bai="seqnado_output/aligned/{sample,[A-Za-z\\d\\-_]+}.bam.bai",
Expand Down

0 comments on commit 9d6dbef

Please sign in to comment.