Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def makeDNA(countAT, countCG):
- countA = int(countAT / 2)
- countT = int(countAT / 2)
- countC = int(countCG / 2)
- countG = int(countCG / 2)
- strA = ''.join(random.choice("A") for _ in range(countA))
- strT = ''.join(random.choice("T") for _ in range(countT))
- strC = ''.join(random.choice("C") for _ in range(countC))
- strG = ''.join(random.choice("G") for _ in range(countG))
- listDNA = list(strA + strT + strC + strG)
- random.shuffle(listDNA)
- DNA = ''.join(listDNA)
- return DNA
- def findORF(strDNA):
- listORF = list(strDNA[0 + i:3 + i] for i in range(0, len(strDNA), 3))
- for i in range(len(listORF)):
- newORF = []
- if listORF[i] == "ATG":
- newORF.append(listORF[i])
- for j in range(i + 1, len(listORF)):
- if listORF[j] != 'TAA' and listORF[j] != 'TAG' and listORF[j] != 'TGA' and listORF[j] != 'ATG':
- newORF.append(listORF[j])
- else:
- if listORF[j] != 'ATG':
- newORF.append(listORF[j])
- return newORF
- def secondFrame(strDNA):
- strDNA2 = strDNA[1:]
- return findORF(strDNA2)
- def thirdFrame(strDNA):
- strDNA2 = strDNA[2:]
- return findORF(strDNA2)
- def check(newORF):
- if newORF is None:
- return 0
- else:
- strORF = ''
- for i in range(0, len(newORF)):
- strORF = strORF + newORF[i]
- if len(strORF) % 3 == 0 and len(strORF) >= 90:
- return 1
- else:
- return 0
- def reverseDNA(strDNA):
- rDNA = ""
- for i in strDNA:
- if i == "A":
- rDNA = rDNA + "G"
- elif i == "T":
- rDNA = rDNA + "C"
- if i == "G":
- rDNA = rDNA + "A"
- elif i == "C":
- rDNA = rDNA + "T"
- revDNA = rDNA[::-1]
- return revDNA
- def print3(frame):
- newStr = ''
- for i in frame:
- newStr += i + ' '
- return newStr
- if __name__ == '__main__':
- dnaSize = 1000
- for i in range(20, 81):
- k = 0
- for j in range(1, 10000):
- percentGC = i
- percentAT = 100 - percentGC
- countGC = int((dnaSize * percentGC) / 100)
- countAT = int((dnaSize * percentAT) / 100)
- strDNA = makeDNA(countAT, countGC)
- dfirstFrame = findORF(strDNA)
- dsecondFrame = secondFrame(strDNA)
- dthirdFrame = thirdFrame(strDNA)
- rDNA = reverseDNA(strDNA)
- rfirstFrame = findORF(rDNA)
- rsecondFrame = secondFrame(rDNA)
- rthirdFrame = thirdFrame(rDNA)
- if check(dfirstFrame) | check(dsecondFrame) | check(dthirdFrame) | check(rfirstFrame) | check(rfirstFrame) | check(rsecondFrame) | check(rthirdFrame):
- k += 1
- print(percentGC,";", k / 10000)
Add Comment
Please, Sign In to add comment