码迷,mamicode.com
首页 > 其他好文 > 详细

碱基序列转换成氨基酸序列

时间:2018-01-04 10:58:40      阅读:377      评论:0      收藏:0      [点我收藏+]

标签:lis   body   ace   序列   ==   nes   zip   range   color   

#!coding:utf-8
# Author:pymingming
import pyperclip
def code_table():
    f = open(code.txt,r)
    s = f.readlines()
    l1,l2 = [],[]
    for line in s:
        key = line.split()[4]
        l1.append(key)
        value = line.split()[3]
        l2.append(value)
    code_dict = dict(zip(l1,l2))
    return code_dict

def geneseq():
    seq = input(输入cds基因序列:)
    seq = seq.replace(T,U)
    seq_code = [seq[x:x+3] for x in range(0,len(seq.strip()),3)]
    return seq_code

def match():
    list_aa_seq = []
    seq_code = geneseq()
    code_dict = code_table()
    for code in seq_code:
        for key in code_dict.keys():
            if code in key:
                list_aa_seq.append(code_dict[key])
        if code not in str(code_dict.keys()):
            list_aa_seq.append(*)
    aa_seq = ‘‘.join(list_aa_seq)
    protein = \n.join(aa_seq[x:x+40] for x in range(0,len(aa_seq),40))
    return  protein

if __name__ == __main__:
    result = match()
    print(result)
    pyperclip.copy(result)

 

碱基序列转换成氨基酸序列

标签:lis   body   ace   序列   ==   nes   zip   range   color   

原文地址:https://www.cnblogs.com/Zhu-Xueming/p/8191216.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!