生物信息:找出基因,生物學家使用字母A、C、T和G構成的字符串建模一個基因組。
一個基因是基因組的子串,它從三元組ATG后開始在三元組TAG、TAA或TGA之前結束。
此外,基因字符串的長度是3的倍數,而且基因不包含三元組ATG、TAG、TAA和TGA。
編寫程序提示用戶輸入一個基因組,然后顯示基因組里的所有基因。
如果在輸入序列中沒有找到基因,那么程序顯示“no gene is found”
s=input('Please input the Gene String:\r\n') endsplit=['TAG','TAA','TGA'] if 'ATG' in s: for i in s.split('ATG'): for j in endsplit: if j in i: print(i.split(j)[0], end='\t') else: print('no gene is found')