python中将DNA链转换为RNA链

发布时间 2023-08-26 19:55:31作者: 小鲨鱼2018

 

001、利用循环结构

[root@PC1 test01]# ls
a.fa  test.py
[root@PC1 test01]# cat a.fa        ## 测试DNA序列
GATGGAACTTGACTACGTAAATT
[root@PC1 test01]# cat test.py     ## 转换程序
#!/usr/bin/env python
# -*- coding: utf-8 -*-

in_file = open("a.fa", "r")

str1 = ""
for i in in_file:
        i = i.strip()
        for j in i:
                if j == "T":
                        str1 += "U"
                else:
                        str1 += j
in_file.close()
print(str1)
[root@PC1 test01]# python test.py    ## 转换结果
GAUGGAACUUGACUACGUAAAUU

 

002、