首页 > 编程语言 >python 中实现将fasta中DNA序列转换为RNA

python 中实现将fasta中DNA序列转换为RNA

时间:2022-08-15 18:15:34浏览次数:48  
标签:dict1 DNA python RNA PC1 test home fasta

 

001、

root@PC1:/home/test# ls
a.fasta  test.py
root@PC1:/home/test# cat test.py            ## 测试程序
#!/usr/bin/python

in_file = open("a.fasta", "r")
dict1 = {}

for i in in_file:
    i = i.strip()
    if i.startswith(">"):
        key = i
        dict1[key] = []
    else:
        i = i.replace("T","U")
        dict1[key].append(i)

for i,j in dict1.items():
    print(i)
    j = "".join(j)
    for k in range(0, len(j), 6):
        print(j[k:k+6])
in_file.close()
root@PC1:/home/test# cat a.fasta        ## 测试fasta文件
>gene1 myc
AGCTGCCTAAGC
GGCATAGCTAATCG
>gene2 jun
ACCGAATCGGAGCGATG
GGCATTAAAGATCTAGCT
>gene3 malat1
AGGCTAGCGAG
GCGCGAG
GATTAGGCG
root@PC1:/home/test# python test.py           ## 执行程序
>gene1 myc
AGCUGC
CUAAGC
GGCAUA
GCUAAU
CG
>gene2 jun
ACCGAA
UCGGAG
CGAUGG
GCAUUA
AAGAUC
UAGCU
>gene3 malat1
AGGCUA
GCGAGG
CGCGAG
GAUUAG
GCG

参考:https://www.jianshu.com/p/5ee54bea4cb0

 

标签:dict1,DNA,python,RNA,PC1,test,home,fasta
From: https://www.cnblogs.com/liujiaxin2018/p/16589185.html

相关文章