Python|将CDS序列转为PEP序列

本文介绍如何利用Python的Biopython模块,从包含蛋白编码基因的CDS序列中生成对应的PEP氨基酸序列,并在转换过程中保留原始序列的ID信息。
摘要由CSDN通过智能技术生成

  有蛋白编码基因的核苷酸序列,想要转化成对应的氨基酸序列,可以利用Python的Biopython Module来实现。

  1. 提取核苷酸序列信息

  原始的保存着核苷酸序列的fasta文件里还有着序列的id等说明信息,我们只需要核苷酸序列,可以用for循环遍历每一行,将偶数行输出到一个新的文本文档中。

# opening the file
file1 = open('D:/.../PCGs/cytb/cytb.fas', 'r')

# creating another file to store even lines
file2 = open('D:/.../PCGs/cytb/cytb_no_label.fas', 'w')

# reading content of the files and writing even lines to another file
lines = file1.readlines()

for i in range(0, len(lines)):
    if (i % 2 != 0):
        file2.write(lines[i])

# closing the files
file1.close()
file2.close()
  1. 利用Biopython将CDS转为PEP
#importing the Biopython package 
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC

#opening the file
file1 = open('D:/.../PCGs/atp6/atp6_no_label.fas')
file2 = open('D:/.../PCGs/atp6/atp6_aa_no_label.fas', 'w'
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值