Ejemplo n.º 1
0
def getCodonFromSequence(genomes_rule, map, pos, seq=None):
    if not seq:
        seq = fetch_mapping_rna(genomes_rule, map)
    if pos < 1 or pos > len(seq):
        raise Exception( "translate.py:getCodonFromSequence - pos out of range [1,len(sequence)]")
    ofst=None
    cod_num = None
    len5=0
    for lexon in map["utr5"]:
        len5 += lexon[1]-lexon[0]
    lencds = 0
    for cexon in map["cds"]:
        lencds += cexon[1]-cexon[0]
    if pos <= len5:
        codon = "utr5"
        aa= None
    elif pos > len5+lencds:
        codon= "utr3"
        aa=None
    else:
        ofst = (pos-len5-1) % 3
	cod_num = (pos-len5-1) / 3 + 1 
        codon =  seq[pos-ofst-1:pos-ofst+2]
        aa = codons.translate(codon)
    base = seq[pos-1]
    result = {  "mapping_uid": map["uid"],
                "pos":pos,
                "allele":base,
                "codon":codon,
                "aa":aa, 
		        "aa_pos":cod_num,
                "offset":ofst }
    return result
Ejemplo n.º 2
0
def getMutationEffects(genomes_rule, map, pos, newbases):
    if map.has_key("rna"):
        seq = map["rna"]
    else:
        seq = None
    original = getCodonFromSequence(genomes_rule, map, pos, seq)
    mutations = []
    for newbase in newbases:
        ncod = None
        naa = None
        if newbase == "-":
            if original["codon"].startswith("utr"):
                effect = ["deletion","untranslated"]
            else:
                effect = ["deletion", "frameshift"]
        elif len(newbase) > 1 and (len(newbase)-1) % 3 != 0:
            if original["codon"].startswith("utr"):
                effect = ["insertion","untranslated"]
            else:
                effect = ["insertion", "frameshift"]
        elif len(newbase) > 1 and (len(newbase)-1) % 3 == 0:
            if original["codon"].startswith("utr"):
                effect = ["insertion","untranslated"]
            else:
                effect = ["insertion", "inframe"]
        elif newbase == original["allele"]:
            effect = ["reference"]
            ncod = original["codon"]
            naa = original["aa"]
        elif len(newbase) == 1:
            effect = []
            ofs = original["offset"]
            ocod = original["codon"]
            if ocod.startswith("utr"):
                effect.append("untranslated")
                ncod=ocod
                naa = original["aa"]
            else:
                ncod = ocod[0:ofs] + newbase + ocod[ofs+1:3]
                naa = codons.translate(ncod)
                if naa == original["aa"]:
                    effect.append("synonymous")
                elif original["aa"] == "*":
                    effect.append("runon")
                elif naa == "*":
                    effect.append("nonsense")
                else:
                    effect.append("missense")
        mutations.append( { "allele" : newbase,
                            "codon" : ncod,
                            "aa" : naa,
                            "effect" : effect } )
    original["mutations"] = mutations
    return original