生物信息学 几个程序
程序员文章站
2024-03-04 12:22:05
...
f = 'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC'
for i in f:
b = list(f) # 把‘AAA’变成 ['A','A'',A']
c = {}
for i in b:
c[i] = b.count(i) # 把key 和value 写入字典,如 A:1
print (c.values()) # 最后的结果为 [20,12,21,17]
f = 'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC'
counts = []
for i in ['A','C','G','T']: # 把输出的顺序定好
counts.append(f.count(i))
print ('\t'.join(map(str, counts))) #map() 这里的意思是吧输出的[20,12,17,21]变为 20 12 17 21
f='AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC'
counts = []
for i in ['A','C','G','T']:
counts.append(f.count(i))
print('\t'.join(map(str,counts)))
#join() 方法用于将(序列中的元素)以.join前指定的元素连接生成一个新的字符串。
# #map(str,counts):['20', '12', '17', '21']
DNAseq="TTGCAC"
mRNAseq=DNAseq.replace("T","U")
print(mRNAseq)
def transcribing_RNA(string):
return string.replace("T", "U")
print(transcribing_RNA("GATGGAACTTGACTACGTAAATT"))
import operator
dict= {'a': 1, 'b': 4, 'c': 2, 'f' : 12}
s= sorted(dict.items(), key=operator.itemgetter(1),reverse=True)
print(s)
上一篇: 可持久化数组