-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: read length filter rule * fix: made filtered fastq a tempfile * fix: unconditional uncompress * fix: added .fq functionality * fix: updated profile/config.yaml default resources and removed redundancy * fix: new raise TypeError + command line message for rule filter_reads * fix: formatting - no valid f-string was give --------- Co-authored-by: cmeesters <meesters@uni-mainz.de>
- Loading branch information
Showing
4 changed files
with
66 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,50 @@ | ||
default-resources: | ||
slurm_account: "m2_zdvhpc" | ||
slurm_partition: "smp" | ||
cpus_per_task: 1 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "1h" | ||
|
||
set-resources: | ||
genome_to_transcriptome: | ||
cpus_per_task: 1 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "2h" | ||
|
||
build_minimap_index: | ||
cpus_per_task: 4 | ||
mem_mb_per_cpu: 3600 | ||
runtime: "1h" | ||
|
||
map_reads: | ||
cpus_per_task: 40 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "3h" | ||
slurm_partition: "parallel" | ||
|
||
plot_samples: | ||
cpus_per_task: 4 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "3h" | ||
|
||
plot_all_samples: | ||
cpus_per_task: 8 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "2h" | ||
|
||
map_qc: | ||
cpus_per_task: 8 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "1h" | ||
|
||
sam_sort: | ||
cpus_per_task: 4 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "2h" | ||
|
||
sam_view: | ||
cpus_per_task: 1 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "1h" | ||
|
||
sam_index: | ||
cpus_per_task: 8 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "30m" | ||
|
||
sam_stats: | ||
cpus_per_task: 8 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "30m" | ||
|
||
count_reads: | ||
cpus_per_task: 8 | ||
mem_mb_per_cpu: 1800 | ||
runtime: "1h" | ||
|
||
de_analysis: | ||
cpus_per_task: 4 | ||
mem_mb_per_cpu: 5000 | ||
runtime: "1h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from Bio import SeqIO | ||
import gzip | ||
import shutil | ||
|
||
# start logging | ||
sys.stderr = sys.stdout = open(snakemake.log[0], "wt") | ||
|
||
|
||
def is_zipped(fname): | ||
return fname.endswith(".gz") | ||
|
||
|
||
if not isinstance(snakemake.config["min_length"], int): | ||
raise TypeError( | ||
"Your configuration has no valid minimum read length, allowed are: ('int'), check the 'min_length' parameter, please." | ||
) | ||
|
||
if snakemake.config["min_length"] <= 0: | ||
if is_zipped(snakemake.input[0]): | ||
with gzip.open(snakemake.input[0], "wb") as f_in, open( | ||
snakemake.output[0], "wb" | ||
) as f_out: | ||
shutil.copyfileobj(f_in, f_out) | ||
else: | ||
shutil.copy2(snakemake.input[0], snakemake.output[0]) | ||
else: | ||
open_fh = gzip.open if is_zipped(snakemake.input[0]) else open | ||
with open_fh(snakemake.input[0], "rt") as sample: | ||
input_iterator = SeqIO.parse(sample, "fastq") | ||
|
||
filter_iterator = ( | ||
read | ||
for read in input_iterator | ||
if len(read.seq) >= snakemake.config["min_length"] | ||
) | ||
|
||
SeqIO.write(filter_iterator, snakemake.output[0], "fastq") |