在biopython中获取ID和蛋白质序列
我有这个代码。
from Bio import SeqIO
for seq_record in SeqIO.parse("aminoacids.txt", "fasta"):
print(seq_record.id)
print(repr(seq_record.seq))
输出:
NP_414584.1
Seq('MNTFSQVWVFSDTPSRLPELMNGAQALANQINTFVLNDADGAQAIQLGANHVWK...LAR')
NP_414563.1
Seq('MASVSISCPSCSATDGVVRNGKSTAGHQRYLCSHCRKTWQLQFTYTASQPGTHQ...RSR')
NP_414564.1
Seq('MANIKSAKKRAIQSEKARKHNASRRSMMRTFIKKVYAAIEAGDKAAAQKAFNEM...KLA')
NP_414565.1
Seq('MCRHSLRSDGAGFYQLAGCEYSFSAIKIAAGGQFLPVICAMAMKSHFFLISVLN...SLF')
NP_414566.1
Seq('MKLIRGIHNLSQAPQEGCVLTIGNFDGVHRGHRALLQGLQEEGRKRNLPVMVML...KPA')
问题:我应该在刚刚和一个字符串中获得ID和完整序列,而无需“ seq”。 这样的事情:
NP_414584.1
MNTFSQVWVFSDTPSRLPELMNGAQALANQINTFVLNDADGAQAIQLGANHVWKLNGKPDDRMIEDYAGVMADTIRQHGADGLVLLPNTRRGKLLAAKLGYRLKAAVSNDASTVSVQDGKATVKHMVYGGLAIGEERIATPYAVLTISSGTFDAAQPDASRTGETHTVEWQAPAVAITRTATQARQSNSVDLDKARLVVSVGRGIGSKENIALAEQLCKAIGAELACSRPVAENEKWMEHERYVGISNLMLKPELYLAVGISGQIQHMVGANASQTIFAI NKDKNAPIFQYADYGIVGDAVKILPALTAALAR
如何获得此输出?
I have this code.
from Bio import SeqIO
for seq_record in SeqIO.parse("aminoacids.txt", "fasta"):
print(seq_record.id)
print(repr(seq_record.seq))
Output:
NP_414584.1
Seq('MNTFSQVWVFSDTPSRLPELMNGAQALANQINTFVLNDADGAQAIQLGANHVWK...LAR')
NP_414563.1
Seq('MASVSISCPSCSATDGVVRNGKSTAGHQRYLCSHCRKTWQLQFTYTASQPGTHQ...RSR')
NP_414564.1
Seq('MANIKSAKKRAIQSEKARKHNASRRSMMRTFIKKVYAAIEAGDKAAAQKAFNEM...KLA')
NP_414565.1
Seq('MCRHSLRSDGAGFYQLAGCEYSFSAIKIAAGGQFLPVICAMAMKSHFFLISVLN...SLF')
NP_414566.1
Seq('MKLIRGIHNLSQAPQEGCVLTIGNFDGVHRGHRALLQGLQEEGRKRNLPVMVML...KPA')
Problem: I should get the ID and the full sequence without "Seq" at the beggining and in just one string.
Something like this:
NP_414584.1
MNTFSQVWVFSDTPSRLPELMNGAQALANQINTFVLNDADGAQAIQLGANHVWKLNGKPDDRMIEDYAGVMADTIRQHGADGLVLLPNTRRGKLLAAKLGYRLKAAVSNDASTVSVQDGKATVKHMVYGGLAIGEERIATPYAVLTISSGTFDAAQPDASRTGETHTVEWQAPAVAITRTATQARQSNSVDLDKARLVVSVGRGIGSKENIALAEQLCKAIGAELACSRPVAENEKWMEHERYVGISNLMLKPELYLAVGISGQIQHMVGANASQTIFAI NKDKNAPIFQYADYGIVGDAVKILPALTAALAR
How can I get this output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
repr
不是为执行最终输出而设计的。本质上是调试工具。您拥有的是seq
对象。您可能需要做:使用
str
方法。repr
is not designed for doing final output. It's essentially a debug tool. What you have is aSeq
object. You probably need to be doing:which uses the
str
method.