Exemplo n.º 1
0
 def EXAC(self):
     if 'EXAC' in self.__dict__:
         self.__dict__['EXAC']['total_homs']=self.__dict__['EXAC']['AC_Hom']/2
         return 
     if 'EXAC_freq' in self.__dict__: return self.__dict__['EXAC_freq']
     print('EXAC')
     self.__dict__['EXAC_freq']=rest.exac_anno(self.data['variant_id'],update=False)
     if len(self.__dict__['EXAC_freq'])>0:
        self.__dict__['in_exac']=True
     else:
        self.__dict__['in_exac']=False
     #print(self.save())
     return self.__dict__['EXAC_freq']
Exemplo n.º 2
0
def get_rare_var_p_hpo(gene_id, db, patient_db):
    #return {'hom_comp':{p_id1:{hpo: [(HP:1234,hell)], exac_af:[0.0021], uclex_af:[0.001]},
    #        'het':{p_id2: {hpo:[(HP:2345,yeah)], exac_af:[0.001,0.002],uclex_af:[0.002,0.001]}}

    # sometimes variant is not in vcf. move it to debug/bad_variants for inspection and later clean
    bad_var_file = open('views/debug/bad_variants', 'w')
    # get all variants on this gene
    all_vars = db.genes.find_one({'gene_id':gene_id})['variant_ids']
    results = {'hom_comp':{}, 'het':{}} 
    for v in all_vars:
        var = db.variants.find_one({'variant_id':v})
        exac_af = 0
        if var['in_exac']:
            if 'allele_freq' not in var['EXAC']:
                VAR = annotation.exac_anno(v)
                exac_af = VAR['allele_freq']
            else:
                exac_af = var['EXAC']['allele_freq']
        # not interested if af is > 0.01
        if float(exac_af) > 0.01:
            continue
        # get relevant info from vcf
        this = vcf_query(variant_str=v)
        if not this:
            bad_var_file.write(v+'\n')
            continue
        uclex_af = this['allele_freq']

        # dealing with hom patients. also add it to het. count hom as twice
        # will need to deal with both_het !!! their af are different!!!
        hom_p = this['hom_samples']
        for p in hom_p:
            populate_mode_p(results, 2, ['hom_comp', 'het'], p, exac_af, uclex_af, patient_db)

        # dealing with het patients. note to check length of exac_af. longer than one?
        # also added it to 'hom_comp'
        het = this['het_samples']
        for p in het:
            results['het'][p] = results['het'].get(p, {'exac_af':[], 'uclex_af':[]})
            modes = ['het']
            if results['het'][p]['exac_af']:
                # this patient has more than one var on this gene. copy it to hom_comp
                modes.append('hom_comp')
            populate_mode_p(results, 1, modes, p, exac_af, uclex_af, patient_db)
    return results
Exemplo n.º 3
0
 def ExAC_freq(self):
     if 'ExAC_freq' in self.__dict__ and 'total_homs' in self.__dict__['ExAC_freq']: return self.__dict__['ExAC_freq']
     self.__dict__['ExAC_freq']=rest.exac_anno(self.variant_id,update=False)
     print(self.__dict__['ExAC_freq'].keys())
     #print(self.save())
     return self.__dict__['ExAC_freq']
Exemplo n.º 4
0
 def ExAC_freq(self):
     if 'ExAC_freq' in self.__dict__ and 'total_homs' in self.__dict__['ExAC_freq']: return self.__dict__['ExAC_freq']
     self.__dict__['ExAC_freq']=rest.exac_anno(self.variant_id,update=False)
     print(self.__dict__['ExAC_freq'].keys())
     #print(self.save())
     return self.__dict__['ExAC_freq']