-
Notifications
You must be signed in to change notification settings - Fork 0
/
orfr.py
23 lines (17 loc) · 1.51 KB
/
orfr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Finding Genes with ORFs
# https://rosalind.info/problems/orfr/
from Bio.Seq import translate, reverse_complement
dna_string = "TCCAAAGCCCTCCCCGCATATCACGGGATAATACATAAGATAACACCTTCGTGTAGCGTACCGCTGCACAGTGGCGTTGACTGATTCGACGCCCCTTGGGACGTAATAACACACATCGCGAAAGATGTCCCGATTAGTCTCACTAAGGCCACAATCGGTAAGCCGATACGGAATTTGCTAAAGGAATTTATGACCGGGTGGAAGCTGATTATCTGCGGTGGACACCACAGATTTAGAGGTCGAATTGCTGCCACGCTGACCCAATACAACCGTCTCTCCTTTGTGTTCGCGTGCAACTTCTGATCGGCTCAGTAAGACACTAATCACATTCATTGTGTGAGCTTCGGACCTAAGCATAGGATCGGCCCCCGACTTCAGCAGTTATAATTATAGCAACGAGGACAACGTTTTCTGGGAGATCAAGCGTTGTGACAAGGATGGAGCCGCTGCTCGATGCGGGCCGGCCATGGCCCATCACCTCACTTAGCTAAGTGAGGTGATGGGCCATTAGGGTAGACAACCGGCGTTTCCGCATGAGTAGAGAATACAGATCCGGTCAGGACAAATTCACTGCATCCATAGCGGGGTCGCGGAATTGCAACACAGAAATGTGAACCTTCCCAGCCTGTGATTGTACGCACCAGATGTAACGCTGCAATTACAAGTCCATGCATGTCCAAGGGTTGTAAACAGATATCATCAGCACGCCAAATACCTCTCGAGTGCGGCAGGACCTTCGCTCCTCTAAATCAAAAGTAGAAGCGGCGTCGCCATTTGGGACGGAATATTCTATGTAGGCTAAATGTGTAACGTCGCACCAGGTCCGTACCAGTCGGGATGCGGATACTCAACACTGCATCTTCGTCAACTGGTATGCGGCGCGGTCTGATGATGGAGGTATCACGAATGGTTCAGTGTGAGGATGTAATATATCATAGTAAGTCGACCGTACTACTACCGGAATCACGATGAAC"
def gen_orfs(seq):
frames = []
for i in range(0, len(seq)):
orfs = translate(seq[i:] + seq[:i]).split("*")
for o in orfs:
try:
frames.append(longest(["M"+t for t in o[o.index("M"):].split("M")]))
except:
pass
return frames
def longest(orfs):
return max(orfs, key=len)
print(longest(gen_orfs(dna_string)+gen_orfs(reverse_complement(dna_string))))