Skip to content

Commit

Permalink
Adding steps to ensure continuation of pipeline with low coverage or …
Browse files Browse the repository at this point in the history
…viral load samples
  • Loading branch information
skchronicles committed Dec 9, 2024
1 parent edff154 commit 42eaca9
Showing 1 changed file with 57 additions and 5 deletions.
62 changes: 57 additions & 5 deletions workflow/rules/paired-end.smk
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,15 @@ rule metaspades:
{output.k2txt} > {output.krona}
cp {output.krona} {output.tmp1}
# Check the number of assembled contigs
# prior to running CAT. CAT contigs can
# fail if this file is empty or only
# contains a few contigs.
mkdir -p {params.cat_dir}
CAT contigs -n {threads} \\
n_contigs=$(grep -c '^>' {output.contigs} || true)
echo "Number of contigs from metaspades: ${{n_contigs}}"
{{ CAT contigs -n {threads} \\
--force \\
-c {output.contigs} \\
-d {params.cat_db} \\
Expand All @@ -544,7 +551,21 @@ rule metaspades:
-c {output.contigs} \\
-i {output.cat_names} \\
-o {output.cat_summary}
}} || {{
# CAT can fail if provided an empty FASTA file
echo "WARNING: CAT failed!"
echo "This could be due to an issue upstream,"
echo "such as insufficent sequencing depth,"
echo "low viral load, or poor quality reads."
echo "Each of these issues can lead to poor"
echo "quality assemblies and a low number of"
echo "assembled contigs."
echo "Please check the input and output of"
echo "metaspades to troubleshoot the issue!"
touch {output}
exit 0
}}
# Try to grep for Virsuses, may pipefail
# if nothing is found, touch output file
{{ grep "Viruses:" {output.cat_names} \\
Expand Down Expand Up @@ -660,8 +681,14 @@ rule megahit:
{output.k2txt} > {output.krona}
cp {output.krona} {output.tmp1}
# Check the number of assembled contigs
# prior to running CAT. CAT contigs can
# fail if this file is empty or only
# contains a few contigs.
mkdir -p {params.cat_dir}/
CAT contigs -n {threads} \\
n_contigs=$(grep -c '^>' {output.contigs} || true)
echo "Number of contigs from metaspades: ${{n_contigs}}"
{{ CAT contigs -n {threads} \\
--force \\
-c {output.contigs} \\
-d {params.cat_db} \\
Expand All @@ -676,7 +703,21 @@ rule megahit:
-c {output.contigs} \\
-i {output.cat_names} \\
-o {output.cat_summary}
}} || {{
# CAT can fail if provided an empty FASTA file
echo "WARNING: CAT failed!"
echo "This could be due to an issue upstream,"
echo "such as insufficent sequencing depth,"
echo "low viral load, or poor quality reads."
echo "Each of these issues can lead to poor"
echo "quality assemblies and a low number of"
echo "assembled contigs."
echo "Please check the input and output of"
echo "megahit to troubleshoot the issue!"
touch {output}
exit 0
}}
# Try to grep for Virsuses, may pipefail
# if nothing is found, touch output file
{{ grep "Viruses:" {output.cat_names} \\
Expand Down Expand Up @@ -1063,7 +1104,18 @@ rule metaquast:
--gene-finding \\
--unique-mapping \\
-o {params.outdir} \\
--threads {threads}
--threads {threads} || {{
# metaquast can fail if provided an empty FASTA file
echo "WARNING: metaquast failed!"
echo "This could be due to an issue upstream,"
echo "such as insufficent sequencing depth,"
echo "low viral load, or poor quality reads."
echo "Each of these issues can lead to poor"
echo "quality assemblies and a low number of"
echo "assembled contigs."
touch {output}
exit 0
}}
"""


Expand Down

0 comments on commit 42eaca9

Please sign in to comment.