根据指定碱基序列给出互补序列的方法

根据指定碱基序列给出互补序列的方法
 1 #!/usr/bin/env python3
 2 # -*- coding: utf-8 -*-
 3 """
 4 Created on Tue May 29 22:42:47 2018
 5 
 6 @author: biok
 7 """
 8 
 9 def checkSeq(seq):
10     if not isinstance(seq, str): raise TypeError
11     
12     
13 ATGC_dict = {
14             'A': 'T',
15             'T': 'A',
16             'G': 'C',
17             'C': 'G',
18             'a': 't',
19             't': 'a',
20             'g': 'c',
21             'c': 'g',
22             }
23 
24 
25 def reverse_seq(a):
26     checkSeq(a)                             # 检查传入参数是否为字符串
27     bases = []                              # 创建新的minus_seq容器
28     list_a = list(a)
29     
30     try:                                    # 检查变量是否为碱基
31         for base in list_a:
32             bases.append(ATGC_dict[base])
33         minus_seq = ''.join(bases)
34         return minus_seq
35     except KeyError:
36         print("Wrong base, please check!")
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/kristoff/p/9108546.html