Example #1
0
def get_mutation_effects(snp):
    cdsSt = snp["cds_st"]
    cdsEn = snp["cds_en"]
    get_position(snp)
    pos = snp["snp_start"]
    pos_end = snp["snp_end"]
    get_codon_for_snp(snp)
    mutations = []
    for (newbase, al_freq) in snp["mut_freqs"].items():
        ncod = None
        naa = None
        mut_freq = float(al_freq)*float(snp["ref_freq"])
        confs = getSNPpvals(float(snp["hits"]),mut_freq)
        (c_het,p_homo) = confs
        if pos < cdsSt:
            effect = ["5utr"]
        elif pos > cdsEn:
            effect = ["3utr"]
        else:
            if newbase == "-" and (pos_end -pos)%3 == 0:
                effect = ["deletion", "inframe"]
            if newbase == "-" and (pos_end -pos)%3 != 0:
                effect = ["deletion", "frameshift"]
            elif len(newbase) > 1 and (len(newbase)-1) % 3 != 0:
                effect = ["insertion", "frameshift"]
            elif len(newbase) > 1 and (len(newbase)-1) % 3 == 0:
                effect = ["insertion", "inframe"]
            elif newbase == snp["allele"]:
                effect = ["reference"]
                ncod = snp["codon"]
                naa = snpl["aa"]
            elif len(newbase) == 1:
                effect = []
                ofs = snp["offset"]
                ocod = snp["codon"]
                if ocod.startswith("utr"):
                    effect.append("untranslated")
                    ncod=ocod
                    naa = snp["aa"]
                else:
                    ncod = ocod[0:ofs] + newbase + ocod[ofs+1:3]
                    naa = codons.translate(ncod)
                    if naa == snp["aa"]:
                        effect.append("synonymous")
                    elif snp["aa"] == "*":
                        effect.append("runon")
                    elif naa == "*":
                        effect.append("nonsense")
                    else:
                        effect.append("missense")
        mutations.append( { "allele" : newbase,
                            "codon" : ncod,
                            "aa" : naa,
                            "effect" : effect,
                            "conf_het": c_het,
                            "p_homo": p_homo,
                            "frequency": mut_freq,
                            "mut_map": snp["mut_maps"][newbase]  } )
    snp["mutations"] = mutations
Example #2
0
def get_codon_for_snp(snp):
    cdsSt = snp["cds_st"]
    cdsEn = snp["cds_en"]
    pos = snp["snp_start"]
    aa_pos = None
    frame = None
    codon = None
    aa = None
    if pos < cdsSt:
        codon = "5utr"
    elif pos > cdsEn:
        codon = "3utr"
    else:
        codonSt = snp["flank_offset"]
        frame = (pos-cdsSt) % 3
        aa_pos = (pos-cdsSt)/3
        codonSt -= frame
        codon = snp["bare_flank"][codonSt:codonSt+3]
        aa = codons.translate(codon) 
    snp["offset"]=frame
    snp["codon"]=codon
    snp["aa"]=aa
    snp["aa_pos"]=aa_pos