def nameVars(vars, snpeffFiles): var2name = {} for afile in snpeffFiles: with open(snpeffFile) as f: for line in f: if line[0] != '#': sp = line.split('\t') if sp[0] in vars: if sp[1] in vars[ sp[0] ]: info = sp[-1] gene = limitDbnsfpVcfSNVs.getGene(info) if sp[0] == '1' and sp[1] == '865696': print(info, gene) print(gene) if gene != '??': var = sp[0] + ':' + sp[1] var2name[var] = gene return var2name
with open(vcfFile) as f: with open(outFile, 'w') as fout: print >> fout, header for line in f: l = line.strip() if l[0] != '#': (cgControlStatus, chrom, pos, rs, ref, alts, qual, filterPass, info) = l.split('\t') if filterPass == 'PASS': lof = parseLof(l.split('\t')) euroAlleleCount = l.split('AC_NFE=')[1].split(';')[0] euroTotalCount = l.split('AN_NFE=')[1].split(';')[0] afrAlleleCount = l.split('AC_AFR=')[1].split(';')[0] afrTotalCount = l.split('AN_AFR=')[1].split(';')[0] gene = limitDbnsfpVcfSNVs.getGene(l) # scoreClinvar.parseGene(l.split('\t')) # found = False # for alt in alts.split(','): # if len(alt) == len(ref): #or not 'rs' in l: #len(alt) == len(ref):# or not 'rs' in l: # found = True # if found: print >> fout, '\t'.join((gene, chrom, pos, ref, alts, '0', str(euroAlleleCount), str(euroTotalCount), str(afrAlleleCount), str(afrTotalCount), cgControlStatus, lof))