Bioinformatics/Transcriptomics

[Python] Find Open Reading Frame (ORF) | 파이썬 코드

2021. 6. 14. 14:52

파이썬 코드

def findReadingFrame(seq,num):
    i=0
    while i+2<len(seq):
        if seq[i:i+3]=='ATG':
            j=i+3
            while j+2<len(seq):
                if seq[j:j+3] in ['TGA', 'TAA', 'TAG']:
                    num=num+1
                    print(">ORF"+str(num))
                    print(seq[i:j+3])
                j=j+3
        i=i+3
    return num

def getReverseComplement(seq):
    complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
    bases = list(seq) 
    bases = reversed([complement.get(base,base) for base in bases])
    bases = ''.join(bases)
    return bases
   
def findORF(seq):
    num=0
    seqRC=getReverseComplement(seq)
    for i in [0,1,2]:
        num=findReadingFrame(seq[i:],num)
        num=findReadingFrame(seqRC[i:],num)

Example

Result

 

 

728x90
반응형