for gene_acid_base in record.attributes["amino_acid"].split("/"): # get amino acid change x = gene_acid_base.split(" ",1) gene = x[0] amino_acid_change_and_position = x[1] # starting with F123V, build a list of ways # this might appear in the PharmGKB data, # ie. F123V 123F/V Phe123Val 123Phe>Val acid_changes = [] acid_changes.append(re.sub(r' .*',r'', amino_acid_change_and_position)) acid_changes.append(re.sub(r'([A-Z])(\d+)([A-Z]+)', r'\2\1/\3', acid_changes[0])) for x in range(2): acid_changes.append(re.sub(r'[A-Z]', lambda x: codon_123(x.group(0)), acid_changes[x])) acid_changes[3] = re.sub(r'/', r'>', acid_changes[3]) # query the database cursor.execute(query, (rs, alleles[0], alleles[1], gene, acid_changes[0], acid_changes[1], acid_changes[2], acid_changes[3])) data = cursor.fetchall() # if this gene/AA change caused a hit, stop here and report it if cursor.rowcount > 0: break
def codon_1to3(aa): threeletter = codon_123(aa) if threeletter == "TERM": threeletter = "Stop" return threeletter
continue if rs_number > 0: found_aa_for_rsid[rs_number] = 1 for gene_acid_base in record.attributes["amino_acid"].split("/"): # get amino acid change x = gene_acid_base.split(" ", 1) gene = x[0] amino_acid_change_and_position = x[1] # convert to long form acid_change = re.sub(r" .*", r"", amino_acid_change_and_position) acid_change = re.sub(r"[A-Z]", lambda x: codon_123(x.group(0)), acid_change) acid_change = re.sub(r"TERM", "Stop", acid_change) # query the database cursor.execute(query_aa, (gene, acid_change)) data = cursor.fetchall() # if this gene/AA change caused a hit, stop here and report it if cursor.rowcount > 0: break if cursor.rowcount > 0: for d in data: inheritance = d[0] impact = d[1]
def codon_1to3(aa): threeletter = codon_123(aa) if (threeletter == "TERM"): threeletter = "Stop" return threeletter