Ejemplo n.º 1
0
def checkRF(snp):
    #this function will check the other 2 bases in the reading frame to see whether fixing them may result in a quiet result
    if snp.readingFrame=="1":
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(snp.snpID, zero_seq5, zero_seq3, zero_wt, zero_mutation, 1, 1, 1, 1)
        first_seq5=snp.seq5+snp.mutation
        first_mutation=snp.seq3[0]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.seq3[1:]
        snp1=BEseqType(snp.snpID,first_seq5,first_seq3,first_wt,first_mutation,2,1,1,1)
        second_seq5 = snp.seq5 + snp.mutation+snp.seq3[0]
        second_mutation = snp.seq3[1]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.seq3[2:]
        snp2 = BEseqType(snp.snpID, second_seq5, second_seq3, second_wt,second_mutation, 3,1,1,1)
        return snp0, snp1,snp2

    elif snp.readingFrame=="2":
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(snp.snpID, zero_seq5, zero_seq3, zero_wt, zero_mutation, 2, 1, 1, 1)
        first_seq5=snp.seq5[:-1]
        first_mutation=snp.seq5[-1]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.mutation+snp.seq3
        snp1=BEseqType(snp.snpID,first_seq5,first_seq3,first_wt,first_mutation,1,1,1,1)
        second_seq5 = snp.seq5 + snp.mutation
        second_mutation = snp.seq3[0]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.seq3[1:]
        snp2 = BEseqType(snp.snpID, second_seq5, second_seq3, second_wt,second_mutation, 3,1,1,1)
        return snp0,snp1,snp2

    # elif snp.readingFrame==3:
    else:
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(snp.snpID, zero_seq5, zero_seq3, zero_wt, zero_mutation, 3, 1, 1, 1)
        first_seq5=snp.seq5[:-2]
        first_mutation=snp.seq5[-2]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.seq5[-1]+snp.mutation+snp.seq3
        snp1=BEseqType(snp.snpID,first_seq5,first_seq3,first_wt,first_mutation,1,1,1,1)
        second_seq5 = snp.seq5[:-1]
        second_mutation = snp.seq5[-1]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.mutation+snp.seq3
        snp2 = BEseqType(snp.snpID, second_seq5, second_seq3,second_wt, second_mutation,2,1,1,1)
        return snp0, snp1,snp2
Ejemplo n.º 2
0
def checkRF(snp):
    if snp.readingFrame=='1':
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(12, zero_seq5, zero_seq3, zero_wt, zero_mutation, 1, 1, 1, 1)
        first_seq5=snp.seq5+snp.mutation
        first_mutation=snp.seq3[0]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.seq3[1:]
        snp1=BEseqType(12,first_seq5,first_seq3,first_wt,first_mutation,2,1,1,1)
        second_seq5 = snp.seq5 + snp.mutation+snp.seq3[0]
        second_mutation = snp.seq3[1]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.seq3[2:]
        snp2 = BEseqType(12, second_seq5, second_seq3, second_wt,second_mutation, 3,1,1,1)
        return snp0, snp1,snp2

    elif snp.readingFrame=='2':
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(12, zero_seq5, zero_seq3, zero_wt, zero_mutation, 2, 1, 1, 1)
        first_seq5=snp.seq5[:-1]
        first_mutation=snp.seq5[-1]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.mutation+snp.seq3
        snp1=BEseqType(12,first_seq5,first_seq3,first_wt,first_mutation,1,1,1,1)
        second_seq5 = snp.seq5 + snp.mutation
        second_mutation = snp.seq3[0]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.seq3[1:]
        snp2 = BEseqType(12, second_seq5, second_seq3, second_wt,second_mutation, 3,1,1,1)
        return snp0,snp1,snp2

    # elif snp.readingFrame==3:
    else:
        zero_seq5 = snp.seq5
        zero_mutation = snp.mutation
        zero_wt = find_cor(zero_mutation)
        zero_seq3 = snp.seq3
        snp0 = BEseqType(12, zero_seq5, zero_seq3, zero_wt, zero_mutation, 3, 1, 1, 1)
        first_seq5=snp.seq5[:-2]
        first_mutation=snp.seq5[-2]
        first_wt=find_cor(first_mutation)
        first_seq3=snp.seq5[-1]+snp.mutation+snp.seq3
        snp1=BEseqType(12,first_seq5,first_seq3,first_wt,first_mutation,1,1,1,1)
        second_seq5 = snp.seq5[:-1]
        second_mutation = snp.seq5[-1]
        second_wt = find_cor(second_mutation)
        second_seq3 = snp.mutation+snp.seq3
        snp2 = BEseqType(12, second_seq5, second_seq3,second_wt, second_mutation,2,1,1,1)
        return snp0, snp1,snp2
Ejemplo n.º 3
0
def importSNPS(SNPfile):
    rslts = []
    with open(SNPfile, "r") as csv_file:
        try:
            csv_read = csv.reader(csv_file, delimiter=",")
        except MemoryError:
            print("MemoryError, try splitting your file into smaller files")
            exit()

        for row in csv_read:
            snpID = row[0]
            find_mut_len = len(row[9])
            """
            the sequence is given as a string, with 25 bases before mutation and 25 after. 
            need to find length of mutation to splice properly
            """
            mut_len = (find_mut_len - 1) / 2
            mutation = row[9][2]
            wt = row[9][0]
            sequence5 = row[7][0:25]
            sequence3 = row[7][26:]
            readingFrame = row[14]
            aaPosition = row[15]
            geneName = row[12]
            geneID = row[13]
            newSNP = BEseqType(snpID, sequence5, sequence3, wt, mutation,
                               readingFrame, aaPosition, geneName, geneID)
            rslts.append(newSNP)
        rsltsDic = {}
        num = 0
        for snp in rslts:
            rsltsDic[snp.snpID] = snp.geneName
            num = num + 1

        return rslts, rsltsDic
Ejemplo n.º 4
0
def importSNPS(SNPfile):
    rslts=[]
    with open(SNPfile,"r") as csv_file:
        try:
            csv_read = csv.reader(csv_file, delimiter=",")
        except MemoryError:
            print("MemoryError, try splitting your file into smaller files")
            exit()

        for row in csv_read:
            if row[0]=="Sample ID/ name":
                continue
            snpID=row[0]
            if len(row[2])>1:
                continue

            mutation=row[2]
            wt=row[1][25]
            sequence5 = row[1][0:25]
            sequence3 = row[1][26:]
            readingFrame=row[3]
            aaPosition=0
            geneName=0
            geneID=0
            newSNP=BEseqType(snpID,sequence5, sequence3, wt, mutation, readingFrame, aaPosition, geneName, geneID)
            rslts.append(newSNP)
        rsltsDic={}
        num=0
        for snp in rslts:
            rsltsDic[snp.snpID]=snp.geneName
            num=num+1

        return rslts, rsltsDic
Ejemplo n.º 5
0
def getRevComp(snp):
    len3=len(snp.seq3)
    totalSeq= snp.seq5+snp.mutation+snp.seq3
    total_seq=Seq(totalSeq)
    rc_seq=total_seq.reverse_complement()
    seq5=str(rc_seq[0:len3])
    seq3=str(rc_seq[len3+1:])
    new_snp=BEseqType(snp.snpID,seq5 ,seq3,snp.mutation,snp.wt, snp.readingFrame, snp.aaPosition,snp.geneName,snp.geneID)
    return new_snp
Ejemplo n.º 6
0
def checkRF(snp):
    #this function will check the other 2 bases in the reading frame to see whether fixing them may result in a quiet result
    if snp.readingFrame == 1:
        first_seq5 = snp.seq5 + snp.mutation
        first_mutation = snp.seq3[0]
        first_wt = str(Seq(snp.mutation).reverse_complement())
        first_seq3 = snp.seq3[1:]
        snp1 = BEseqType(12, first_seq5, first_seq3, first_wt, first_mutation,
                         2, 1, 1, 1)
        second_seq5 = snp.seq5 + snp.mutation + snp.seq3[0]
        second_mutation = snp.seq3[1]
        second_wt = str(Seq(snp.mutation).reverse_complement())
        second_seq3 = snp.seq3[2:]
        snp2 = BEseqType(12, second_seq5, second_seq3, second_wt,
                         second_mutation, 3, 1, 1, 1)
        return snp1, snp2

    elif snp.readingFrame == 2:
        first_seq5 = snp.seq5[:-1]
        first_mutation = snp.seq5[-1]
        first_wt = str(Seq(snp.mutation).reverse_complement())
        first_seq3 = snp.mutation + snp.seq3
        snp1 = BEseqType(12, first_seq5, first_seq3, first_wt, first_mutation,
                         1, 1, 1, 1)
        second_seq5 = snp.seq5 + snp.mutation
        second_mutation = snp.seq3[0]
        second_wt = str(Seq(snp.mutation).reverse_complement())
        second_seq3 = snp.seq3[1:]
        snp2 = BEseqType(12, second_seq5, second_seq3, second_wt,
                         second_mutation, 3, 1, 1, 1)
        return snp1, snp2

    # elif snp.readingFrame==3:
    else:
        first_seq5 = snp.seq5[:-2]
        first_mutation = snp.seq5[-2]
        first_wt = str(Seq(snp.mutation).reverse_complement())
        first_seq3 = snp.seq5[-1] + snp.mutation + snp.seq3
        snp1 = BEseqType(12, first_seq5, first_seq3, first_wt, first_mutation,
                         1, 1, 1, 1)
        second_seq5 = snp.seq5[:-1]
        second_mutation = snp.seq3[-1]
        second_wt = str(Seq(snp.mutation).reverse_complement())
        second_seq3 = snp.mutation + snp.seq3
        snp2 = BEseqType(12, second_seq5, second_seq3, second_wt,
                         second_mutation, 2, 1, 1, 1)
        return snp1, snp2
Ejemplo n.º 7
0
def MainBE(upSeq, downSeq, mutation, wt, readingFrame=2):
    upSeq = upSeq.upper()
    downSeq = downSeq.upper()
    mutation = mutation.upper()
    wt = wt.upper()
    snp = BEseqType(1234, upSeq, downSeq, wt, mutation, readingFrame, 1, 12,
                    12)
    refSeq = snp.seq5 + "<b>" + snp.wt + "</b>" + snp.seq3
    mutSeq = snp.seq5 + "<b>" + snp.mutation + "</b>" + snp.seq3
    rev = False
    if snp.mutation == "C" and snp.wt == "T":
        BElist = CBElist
        MinorBElist = CBElistMinor
    elif snp.mutation == "A" and snp.wt == "G":
        BElist = ABElist
        MinorBElist = ABElistMinor
    elif snp.mutation == "T" and snp.wt == "C":
        snp = getRevComp(snp)
        rev = True
        snp.mutation = "A"
        snp.wt = "G"
        BElist = ABElist
        MinorBElist = ABElistMinor
    elif snp.mutation == "G" and snp.wt == "A":
        snp = getRevComp(snp)
        rev = True
        snp.mutation = "C"
        snp.wt = "T"
        BElist = CBElist
        MinorBElist = CBElistMinor

    snp2, snp3 = checkRF(snp)
    print(2, 3)
    if snp2.mutation == "C":
        BElist2 = CBElist
    elif snp2.mutation == "A":
        BElist2 = ABElist
    elif snp2.mutation == "T":
        snp2 = getRevComp(snp)
        rev = True
        snp2.mutation = "A"
        snp2.wt = "G"
        BElist2 = ABElist
    elif snp2.mutation == "G":
        snp2 = getRevComp(snp)
        rev = True
        snp2.mutation = "C"
        snp2.wt = "T"
        BElist2 = CBElist

    if snp3.mutation == "C":
        BElist3 = CBElist
    elif snp3.mutation == "A":
        BElist3 = ABElist
    elif snp3.mutation == "T":
        snp3 = getRevComp(snp)
        rev = True
        snp3.mutation = "A"
        snp3.wt = "G"
        BElist3 = ABElist
    elif snp3.mutation == "G":
        snp3 = getRevComp(snp)
        rev = True
        snp3.mutation = "C"
        snp3.wt = "T"
        BElist3 = CBElist
    try:
        #check for matches in major window
        check_match = matchBE(snp, BElist)
        check_match2 = matchBE(snp2, BElist2)
        check_match3 = matchBE(snp3, BElist3)
        #check for clean match
        clean_dic, quiet_dic, origMutSeq, origRevSeq, locations_dic = cleanMatch(
            snp, check_match, BElist, rev)
        clean_dic2, quiet_dic2, origMutSeq2, origRevSeq2, locations_dic2 = cleanMatch(
            snp2, check_match2, BElist, rev)
        clean_dic3, quiet_dic3, origMutSeq3, origRevSeq3, locations_dic3 = cleanMatch(
            snp3, check_match3, BElist, rev)
        for key in quiet_dic2:
            if key not in quiet_dic:
                quiet_dic[key] = quiet_dic2[key]
        for key in quiet_dic3:
            if key not in quiet_dic:
                quiet_dic[key] = quiet_dic3[key]
    except:
        return [], [], [], [], [], [], []
    return clean_dic, quiet_dic, refSeq, mutSeq, origMutSeq, origRevSeq, locations_dic
Ejemplo n.º 8
0
def MainBE(upSeq, downSeq, mutation, wt, readingFrame,personalPAM,start,end,fromto,stream):
    upSeq_=delete_chars(upSeq.upper())
    downSeq_=delete_chars(downSeq.upper())
    wt_=delete_chars(wt.upper())
    mutation_=delete_chars(mutation.upper())
    snp=BEseqType(1234,upSeq_, downSeq_, wt_, mutation_, readingFrame, 1, 12, 12)
    refSeq=snp.seq5+"<b>"+snp.wt+"</b>"+snp.seq3
    mutSeq = snp.seq5 + "<b>" + snp.mutation + "</b>" + snp.seq3
    ## initiating vars
    minor_clean_list=[]
    minor_quiet_list=[]
    origMutSeq = {}
    locations_dic = {}
    rev,rev0,rev2,rev3=False,False,False,False
    snp=beginningCut(snp)
    if snp.mutation == "C" and snp.wt == "T":
        BElist = CBElist
        MinorBElist=CBElistMinor
        if fromto == '1' and personalPAM!="" and start!="" and end!="":
            BElist.update({'User customized BE': [personalPAM, start, end, 'C', 'T', stream]})
    elif snp.mutation == "A" and snp.wt == "G":
        BElist = ABElist
        MinorBElist = ABElistMinor
        if fromto == '2' and personalPAM!="" and start!="" and end!="":
            BElist.update({'User customized BE': [personalPAM, start, end, 'A', 'G', stream]})
    elif snp.mutation == "T" and snp.wt == "C":
        snp=getRevComp(snp)
        rev=True
        snp.mutation = "A"
        snp.wt="G"
        BElist = ABElist
        MinorBElist = ABElistMinor
    elif snp.mutation == "G" and snp.wt == "A":
        snp = getRevComp(snp)
        rev=True
        snp.mutation = "C"
        snp.wt="T"
        BElist = CBElist
        MinorBElist = CBElistMinor
    else:
        BElist={}
        MinorBElist = None

    snp0,snp2,snp3=checkRF(snp)
    rev0, rev2, rev3 = False, False, False
    BElist0,BElist2,BElist3={},{},{}
    if snp0.mutation == "C":
        BElist0 = CBElist
        if fromto == '1' and personalPAM!="" and start!="" and end!="":
            BElist0.update({'User customized BE': [personalPAM, start, end, 'C', 'T', stream]})
    elif snp0.mutation == "A":
        BElist0 = ABElist
        if fromto == '2' and personalPAM!="" and start!="" and end!="":
            BElist0.update({'User customized BE': [personalPAM, start, end, 'A', 'G', stream]})
    elif snp0.mutation == "T":
        snp0 = getRevComp(snp0)
        rev0 = True
        snp0.mutation = "A"
        snp0.wt = "G"
        BElist0 = ABElist
    elif snp0.mutation == "G":
        snp0 = getRevComp(snp0)
        rev0 = True
        snp0.mutation = "C"
        snp0.wt = "T"
        BElist0 = CBElist

    if snp2.mutation == "C":
        BElist2 = CBElist
        if fromto == '1' and personalPAM!="" and start!="" and end!="":
            BElist2.update({'User customized BE': [personalPAM, start, end, 'C', 'T', stream]})
    elif snp2.mutation == "A":
        BElist2 = ABElist
        if fromto == '2' and personalPAM!="" and start!="" and end!="":
            BElist2.update({'User customized BE': [personalPAM, start, end, 'A', 'G', stream]})
    elif snp2.mutation == "T":
        snp2 = getRevComp(snp2)
        rev2 = True
        snp2.mutation = "A"
        snp2.wt = "G"
        BElist2 = ABElist
    elif snp2.mutation == "G":
        snp2 = getRevComp(snp2)
        rev2 = True
        snp2.mutation = "C"
        snp2.wt = "T"
        BElist2 = CBElist

    if snp3.mutation == "C":
        BElist3 = CBElist
        if fromto == '1' and personalPAM!="" and start!="" and end!="":
            BElist3.update({'User customized BE': [personalPAM, start, end, 'C', 'T', stream]})
    elif snp3.mutation == "A":
        BElist3 = ABElist
        if fromto == '2' and personalPAM!="" and start!="" and end!="":
            BElist3.update({'User customized BE': [personalPAM, start, end, 'A', 'G', stream]})
    elif snp3.mutation =="T":
        snp3 = getRevComp(snp3)
        rev3 = True
        snp3.mutation = "A"
        snp3.wt = "G"
        BElist3 = ABElist
    elif snp3.mutation == "G":
        snp3 = getRevComp(snp3)
        rev3 = True
        snp3.mutation = "C"
        snp3.wt = "T"
        BElist3 = CBElist

    try:
        check_match = matchBE(snp, BElist)
    except:
        pass
    try:
        check_match_minor = matchBE(snp, MinorBElist)
    except:
        pass
    try:
        check_match0 = matchBE(snp0, BElist0)
    except:
        pass
    try:
        check_match2=matchBE(snp2,BElist2)
    except:
        pass
    try:
        check_match3=matchBE(snp3,BElist3)
    except:
        pass
    #check for clean match
    try:
        clean_dic,quiet_dic,origMutSeq, locations_dic,orig_protein= cleanMatch(snp, check_match, BElist,rev)
    except:
        clean_dic = {}
        quiet_dic = {}
        orig_protein = origPro(snp, rev)

    try:
        clean_dic_m, quiet_dic_m, origMutSeq_m, locations_dic_m, orig_protein_m = cleanMatch(snp, check_match_minor, MinorBElist, rev)
        for BE in clean_dic_m:
            if BE in clean_dic:
                minor_clean_list.append(BE)
        for BE in clean_dic_m:
            if BE in clean_dic:
                minor_quiet_list.append(BE)
    except:
        pass
    try:
        clean_dic0,quiet_dic0,origMutSeq0,locations_dic0 = SpecialCleanMatch(snp0, check_match0, BElist0, rev0, orig_protein)
    except:
        quiet_dic0={}
    try:
        clean_dic2,quiet_dic2,origMutSeq2,locations_dic2 = SpecialCleanMatch(snp2, check_match2, BElist2, rev2, orig_protein)
    except:
        quiet_dic2={}
    try:
        clean_dic3,quiet_dic3,origMutSeq3,locations_dic3 = SpecialCleanMatch(snp3, check_match3, BElist3, rev3, orig_protein)
    except:
        quiet_dic3={}
    ## FOR VISUAL OUTPUT
    syn_quiet={}
    for key in quiet_dic0:
        if key in quiet_dic:
            for loc in quiet_dic0[key][5]:
                if loc not in quiet_dic[key][5]:
                    syn_quiet.update({key:quiet_dic0[key]})
        else:
            syn_quiet.update({key: quiet_dic0[key]})
    for key in quiet_dic2:
        if key in quiet_dic:
            for loc in quiet_dic2[key][5]:
                if loc not in quiet_dic[key][5]:
                    syn_quiet.update({key: quiet_dic2[key]})
        elif key not in syn_quiet:
            syn_quiet.update({key: quiet_dic2[key]})
    for key in quiet_dic3:
        if key in quiet_dic:
            for loc in quiet_dic3[key][5]:
                if loc not in quiet_dic[key][5]:
                    syn_quiet.update({key:quiet_dic3[key]})
        elif key not in syn_quiet:
            syn_quiet.update({key: quiet_dic3[key]})
    try:
        return clean_dic, quiet_dic,refSeq,mutSeq, origMutSeq,locations_dic,syn_quiet,minor_clean_list,minor_quiet_list
    except:
        return [],[],[],[],[],[],[],[]