Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Add user error for insufficient coverage #191

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions consensus-genome/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ RUN apt-get -qq update && apt-get -qq -y install \
# These newer versions of infernal and ncbi-blast+ are required by VADR
RUN curl -O -L https://ftp.osuosl.org/pub/ubuntu/pool/universe/i/infernal/infernal_1.1.4-1_amd64.deb && \
dpkg -i infernal_1.1.4-1_amd64.deb && \
curl -O -L https://ftp.osuosl.org/pub/ubuntu/pool/universe/n/ncbi-blast+/ncbi-blast+_2.10.1-2_amd64.deb && \
dpkg -i ncbi-blast+_2.10.1-2_amd64.deb
curl -O -L https://ftp.osuosl.org/pub/ubuntu/pool/universe/n/ncbi-blast+/ncbi-blast+_2.10.1+ds-1_amd64.deb && \
dpkg -i ncbi-blast+_2.10.1+ds-1_amd64.deb

# See https://github.com/ablab/quast/issues/157
RUN pip3 install multiqc==1.8 quast==5.0.2 && \
Expand Down
6 changes: 4 additions & 2 deletions consensus-genome/run.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -897,18 +897,20 @@ task ComputeStats {
import json
import re
import pysam
import sys
from Bio import SeqIO
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns


error = lambda err, cause: sys.exit(json.dumps(dict(wdl_error_message=True, error=err, cause=cause)))
stats = {"sample_name": "~{sample}"}

depths = open("~{prefix}samtools_depth.txt").read().splitlines()
if depths:
depths = np.array([int(d) for d in depths])
else:
raise Exception("Insufficient coverage to proceed with CG analysis")
error("InsufficientReadsError", "Insufficient coverage to proceed with CG analysis")

stats["depth_avg"] = depths.mean()
stats["depth_q.25"] = np.quantile(depths, .25)
Expand Down
Binary file added consensus-genome/test/empty.bam
Binary file not shown.
21 changes: 21 additions & 0 deletions consensus-genome/test/test_wdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ def test_fetch_sequence_by_expired_accession_id(self):
self.assertRunFailed(ecm, task="FetchSequenceByAccessionId",
error="AccessionIdNotFound", cause="Accession ID NO_ACCESSION_ID not found in the index")

def test_no_coverage_error(self):
ref_host_blank = os.path.join(os.path.dirname(__file__), "blank.fastq.gz")
assembly_blank = os.path.join(os.path.dirname(__file__), "blank.fastq.gz")
vcf_blank = os.path.join(os.path.dirname(__file__), "blank.fastq.gz")
fastqs_blank = os.path.join(os.path.dirname(__file__), "blank.fastq.gz")
cleaned_bam = os.path.join(os.path.dirname(__file__), "empty.bam")
with self.assertRaises(CalledProcessError) as ecm:
self.run_miniwdl(task="ComputeStats", args=[
f"ref_host={ref_host_blank}",
f"assembly={assembly_blank}",
f"vcf={vcf_blank}",
f"fastqs={fastqs_blank}",
"technology=Illumina",
f"cleaned_bam={cleaned_bam}"],
task_input={
"sample": "sample",
"prefix": "",
})
self.assertRunFailed(ecm, task="ComputeStats",
error="InsufficientReadsError", cause="Insufficient coverage to proceed with CG analysis")

def test_max_reads_illumina(self):
fastq_0 = os.path.join(os.path.dirname(__file__), "SRR11741455_65054_nh_R1.fastq.gz")
fastq_1 = os.path.join(os.path.dirname(__file__), "SRR11741455_65054_nh_R2.fastq.gz")
Expand Down
4 changes: 2 additions & 2 deletions short-read-mngs/test/postprocess/test_RunAssembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def test_RunAssembly_defaults(util, short_read_mngs_bench3_viral_outputs):
min_contig_length filter)
"""
assembly_contigs_fasta = short_read_mngs_bench3_viral_outputs["outputs"][
"idseq_short_read_mngs.postprocess.assembly_out_assembly_contigs_fasta"
"czid_short_read_mngs.postprocess.assembly_out_assembly_contigs_fasta"
]
assembly_contigs_all_fasta = short_read_mngs_bench3_viral_outputs["outputs"][
"idseq_short_read_mngs.postprocess.assembly_out_assembly_contigs_all_fasta"
"czid_short_read_mngs.postprocess.assembly_out_assembly_contigs_all_fasta"
]
assembly_contigs = list(SeqIO.parse(assembly_contigs_fasta, "fasta"))
assembly_contigs_all = list(SeqIO.parse(assembly_contigs_all_fasta, "fasta"))
Expand Down