Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filter bam naming bug #112

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions binchicken/workflow/coassemble.smk
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ rule qc_reads:
quality_cutoff = 15,
unqualified_percent_limit = 40,
min_length = 80,
threads: 16
threads: 32
resources:
mem_mb=get_mem_mb,
runtime = lambda wildcards, attempt: 4*60*attempt,
Expand Down Expand Up @@ -520,7 +520,7 @@ rule map_reads:
output:
dir = temp(directory(output_dir + "/mapping/{read}_coverm")),
group: "unmapping"
threads: 16
threads: 32
resources:
mem_mb=get_mem_mb,
runtime = lambda wildcards, attempt: 12*60*attempt,
Expand All @@ -547,10 +547,10 @@ rule filter_bam_files:
group: "unmapping"
params:
genomes = "{read}_reference.fna",
reads_1 = lambda wildcards: os.path.basename(config["reads_1"][wildcards.read]),
reads_1 = lambda wildcards: os.path.basename(config["reads_1"][wildcards.read]) if not config["run_qc"] else wildcards.read + "_1.fastq.gz",
sequence_identity = config["unmapping_max_identity"],
alignment_percent = config["unmapping_max_alignment"],
threads: 16
threads: 32
resources:
mem_mb=get_mem_mb,
runtime = lambda wildcards, attempt: 4*60*attempt,
Expand All @@ -577,7 +577,7 @@ rule bam_to_fastq:
reads_1 = output_dir + "/mapping/{read}_unmapped.1.fq.gz",
reads_2 = output_dir + "/mapping/{read}_unmapped.2.fq.gz",
group: "unmapping"
threads: 16
threads: 32
resources:
mem_mb=get_mem_mb,
runtime = lambda wildcards, attempt: 4*60*attempt,
Expand Down
61 changes: 61 additions & 0 deletions test/test_coassemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,67 @@ def test_coassemble_taxa_of_interest(self):
with open(recover_path) as f:
self.assertEqual(expected, f.read())

def test_coassemble_unmap_runqc(self):
with in_tempdir():
cmd = (
f"binchicken coassemble "
f"--assemble-unmapped "
f"--run-qc "
f"--forward {SAMPLE_READS_FORWARD} "
f"--reverse {SAMPLE_READS_REVERSE} "
f"--genomes {GENOMES} "
f"--genome-transcripts {GENOME_TRANSCRIPTS} "
f"--sample-singlem {SAMPLE_SINGLEM} "
f"--sample-read-size {SAMPLE_READ_SIZE} "
f"--genome-singlem {GENOME_SINGLEM} "
f"--singlem-metapackage {METAPACKAGE} "
f"--output test "
f"--conda-prefix {path_to_conda} "
)
extern.run(cmd)

config_path = os.path.join("test", "config.yaml")
self.assertTrue(os.path.exists(config_path))

edges_path = os.path.join("test", "coassemble", "target", "targets.tsv")
self.assertTrue(os.path.exists(edges_path))

edges_path = os.path.join("test", "coassemble", "target", "elusive_edges.tsv")
self.assertTrue(os.path.exists(edges_path))

cluster_path = os.path.join("test", "coassemble", "target", "elusive_clusters.tsv")
self.assertTrue(os.path.exists(cluster_path))

qc_sample_1F_path = os.path.join("test", "coassemble", "qc", "sample_1_1.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_1F_path))
qc_sample_1R_path = os.path.join("test", "coassemble", "qc", "sample_1_2.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_1R_path))

qc_sample_2F_path = os.path.join("test", "coassemble", "qc", "sample_2_1.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_2F_path))
qc_sample_2R_path = os.path.join("test", "coassemble", "qc", "sample_2_2.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_2R_path))

qc_sample_3F_path = os.path.join("test", "coassemble", "qc", "sample_3_1.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_3F_path))
qc_sample_3R_path = os.path.join("test", "coassemble", "qc", "sample_3_2.fastq.gz")
self.assertTrue(os.path.exists(qc_sample_3R_path))

map_sample_1F_path = os.path.join("test", "coassemble", "mapping", "sample_1_unmapped.1.fq.gz")
self.assertTrue(os.path.exists(map_sample_1F_path))
map_sample_1R_path = os.path.join("test", "coassemble", "mapping", "sample_1_unmapped.2.fq.gz")
self.assertTrue(os.path.exists(map_sample_1R_path))

map_sample_2F_path = os.path.join("test", "coassemble", "mapping", "sample_2_unmapped.1.fq.gz")
self.assertTrue(os.path.exists(map_sample_2F_path))
map_sample_2R_path = os.path.join("test", "coassemble", "mapping", "sample_2_unmapped.2.fq.gz")
self.assertTrue(os.path.exists(map_sample_2R_path))

map_sample_3F_path = os.path.join("test", "coassemble", "mapping", "sample_3_unmapped.1.fq.gz")
self.assertTrue(os.path.exists(map_sample_3F_path))
map_sample_3R_path = os.path.join("test", "coassemble", "mapping", "sample_3_unmapped.2.fq.gz")
self.assertTrue(os.path.exists(map_sample_3R_path))

def test_coassemble_query_input(self):
with in_tempdir():
cmd = (
Expand Down
Loading