From 767657901cda7fb0a3c189e21d4365b7d3d115f9 Mon Sep 17 00:00:00 2001 From: jfnavarro Date: Fri, 12 Feb 2021 13:28:14 +0100 Subject: [PATCH] Fix problem with the gene counts in merge_results --- hlapipeline/variants.py | 33 ++++++--------------------------- merge_results.py | 3 +-- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/hlapipeline/variants.py b/hlapipeline/variants.py index 66bb833..d8d27ec 100644 --- a/hlapipeline/variants.py +++ b/hlapipeline/variants.py @@ -24,38 +24,12 @@ def __init__(self): self.dbsnp = None self.gnomad = None self.cosmic = None + self.gene = None @property def key(self): return "{}:{} {}>{}".format(self.chrom, self.start, self.ref, self.alt) - @property - def ensGene(self): - gene = None - for effect in self.epitopes: - if 'ensGene' in effect.func: - gene = effect.func.split("_")[1] - break - return gene - - @property - def knownGene(self): - gene = None - for effect in self.epitopes: - if 'knownGene' in effect.func: - gene = effect.func.split("_")[1] - break - return gene - - @property - def refGene(self): - gene = None - for effect in self.epitopes: - if 'refGene' in effect: - gene = effect.func.split("_")[1] - break - return gene - def __str__(self): return '{}:{} {}>{} {} {}'.format(self.chrom, self.start, self.ref, self.alt, self.type, self.status) @@ -141,6 +115,8 @@ def filter_variants_rna(file, tumor_coverage, tumor_var_depth, gnomad_AF = record.INFO['AF'][0] if record.INFO['AF'] != [] else 'NA' cosmic70 = ';'.join(record.INFO['cosmic70']).split(":")[1].split("-")[0] if record.INFO[ 'cosmic70'] != [] else 'NA' + gene = record.INFO['Gene.knownGene'][0] if record.INFO['Gene.knownGene'] != [] else None + if has_func_ens or has_func_known or has_func_ref: called = {x.sample: x.data for x in record.calls if x.called} filtered = dict() @@ -177,6 +153,7 @@ def filter_variants_rna(file, tumor_coverage, tumor_var_depth, variant.gnomad = gnomad_AF variant.cosmic = cosmic70 variant.type = 'rna' + variant.gene = gene variants.append(variant) return variants @@ -218,6 +195,7 @@ def filter_variants_dna(file, normal_coverage, tumor_coverage, tumor_var_depth, gnomad_AF = record.INFO['AF'][0] if record.INFO['AF'] != [] else 'NA' cosmic70 = ';'.join(record.INFO['cosmic70']).split(":")[1].split("-")[0] if record.INFO[ 'cosmic70'] != [] else 'NA' + gene = record.INFO['Gene.knownGene'][0] if record.INFO['Gene.knownGene'] != [] else None if has_func_ens or has_func_known or has_func_ref: called = {x.sample: x.data for x in record.calls if x.called} @@ -351,6 +329,7 @@ def filter_variants_dna(file, normal_coverage, tumor_coverage, tumor_var_depth, variant.gnomad = gnomad_AF variant.cosmic = cosmic70 variant.type = 'dna' + variant.gene = gene variants.append(variant) return variants diff --git a/merge_results.py b/merge_results.py index 062edd8..8fb4bbc 100644 --- a/merge_results.py +++ b/merge_results.py @@ -154,8 +154,7 @@ def main(dna_variants, dbsnp = value[0][0].dbsnp gnomad = value[0][0].gnomad cosmic = value[0][0].cosmic - # Get the gene information of the gene (we want to make sure we use the gene name annotation) - gene = value[0][0].knownGene + gene = value[0][0].gene # Create a dictionary of epitopes so to keep unique ones (different mut peptide) epitopes_dict = defaultdict(list)