Commit 9a46725d authored by van den Berg's avatar van den Berg
Browse files

Fix bug when VEP is run on an empty VCF file

parent 00bca9c4
Pipeline #6900 canceled with stages
......@@ -14,7 +14,7 @@ localrules: create_summary, generate_report, package_results
containers = {
"debian": "docker://debian:buster-slim",
"fsnviz": "docker://quay.io/biocontainers/fsnviz:0.3.0--pyhdfd78af_5",
"crimson": "docker://quay.io/biocontainers/crimson:1.0.0--pyh5e36f6f_0",
"hamlet-scripts": "docker://quay.io/redmar_van_den_berg/hamlet-scripts:0.3",
"zip": "docker://quay.io/redmar_van_den_berg/zip:3.0"
}
......@@ -119,7 +119,7 @@ rule create_summary:
run_name=RUN_NAME,
output:
js=OUTPUTS["summary"]
singularity: containers["fsnviz"]
singularity: containers["crimson"]
shell:
"python {input.scr}"
" {input.idm}"
......
......@@ -225,6 +225,7 @@ rule annotate_vars:
" --custom {input.ref_gonl},GONL,vcf,exact,0,AF"
" --fork {threads} --offline --cache_version 97 --assembly GRCh38 --everything --merged"
" --allele_number --stats_text --vcf --cache --force_overwrite"
" --format vcf"
" --stats_file {output.stats} -o STDOUT | bgzip -c > {output.vcf}"
rule extract_vars:
......
......@@ -3,6 +3,7 @@
import json
import csv
from pathlib import Path
from collections import defaultdict
import click
from crimson import picard, vep
......@@ -119,16 +120,20 @@ def process_insert_stats(path):
def process_var_stats(path):
pd = vep.parse(path)
# If there are no variants, insert an empty defaultdict so that any queried
# value returns 0
if "Variants by chromosome" not in pd:
pd["Variants by chromosome"] = defaultdict(int)
return {
"coding_consequences":
{k: v for k, v in pd["Coding consequences"].items()},
"coding_consequences": {k: v for k, v in pd["Coding consequences"].items()},
"num_deletions": pd["Variant classes"].get("deletion", 0),
"num_insertions": pd["Variant classes"].get("insertion", 0),
"num_snvs": pd["Variant classes"].get("SNV", 0),
"per_chromosome":
{k: v
for k, v in pd["Variants by chromosome"].items()
if k in {str(i) for i in range(1, 23)}.union({"X", "Y", "MT"})},
"per_chromosome": {k: v
for k, v in pd["Variants by chromosome"].items()
if k in {str(i) for i in range(1, 23)}.union({"X", "Y", "MT"})},
"polyphen": {
"num_benign_variants": pd["PolyPhen summary"].get("benign", 0),
"num_possibly_damaging_variants":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment