From f55c02dd1b321ce1fc3a1aa931ab0914206c8209 Mon Sep 17 00:00:00 2001 From: MarvinDo Date: Mon, 3 Jun 2024 15:56:22 +0200 Subject: [PATCH] fixed a bug in consequence job when a variant would not recieve any consequences --- .../annotation_jobs/consequence_job.py | 16 ++++++++++++++++ src/annotation_service/main.py | 2 +- src/common/functions.py | 1 - 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/annotation_service/annotation_jobs/consequence_job.py b/src/annotation_service/annotation_jobs/consequence_job.py index 00b7f39a..79c1bbe7 100644 --- a/src/annotation_service/annotation_jobs/consequence_job.py +++ b/src/annotation_service/annotation_jobs/consequence_job.py @@ -98,12 +98,28 @@ def annotate_consequence(self, input_vcf, output_vcf): functions.rm(tmp_vcf) return returncode, err_msg, vcf_errors + + with open(tmp_vcf, "r") as tmp_file: + tmp_text = tmp_file.read() + new_annotation = functions.find_between(tmp_text, "CSQ_ensembl=", '(;|$)') + if new_annotation is not None and new_annotation == '': + functions.rm(tmp_vcf) + os.rename(input_vcf, tmp_vcf) + # annotate refseq consequences command = [os.path.join(paths.ngs_bits_path, "VcfAnnotateConsequence")] command.extend([ "-gff", paths.refseq_transcript_4_consequence_path, "-ref", paths.ref_genome_path, "-all", "-tag", "CSQ_refseq", "-in", tmp_vcf, "-out", output_vcf]) returncode, err_msg, vcf_errors = functions.execute_command(command, 'VcfAnnotateConsequenceRefSeq') + with open(output_vcf, "r") as tmp_file: + tmp_text = tmp_file.read() + new_annotation = functions.find_between(tmp_text, "CSQ_refseq=", '(;|$)') + if new_annotation is not None and new_annotation == '': + functions.rm(output_vcf) + os.rename(tmp_vcf, output_vcf) + functions.rm(tmp_vcf) + return returncode, err_msg, vcf_errors diff --git a/src/annotation_service/main.py b/src/annotation_service/main.py index 13e5876c..d96df730 100644 --- a/src/annotation_service/main.py +++ b/src/annotation_service/main.py @@ -29,7 +29,7 @@ def get_default_job_config(): # consequences 'do_consequence': True, - 'do_vep': True, + 'do_vep': False, #vcf annotate from vcf 'do_dbsnp': True, diff --git a/src/common/functions.py b/src/common/functions.py index 73a9ac38..96296743 100644 --- a/src/common/functions.py +++ b/src/common/functions.py @@ -669,7 +669,6 @@ def rm(path): if os.path.exists(path): os.remove(path) - def remove_oldest_file(folder, maxfiles=10): if os.path.exists(folder): list_of_files = os.listdir(folder)