Skip to content

Commit

Permalink
Fix problem with the gene counts in merge_results
Browse files Browse the repository at this point in the history
  • Loading branch information
jfnavarro committed Feb 12, 2021
1 parent 56837d8 commit 7676579
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
33 changes: 6 additions & 27 deletions hlapipeline/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions merge_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7676579

Please sign in to comment.