通过访问Uniprot使用Python获取蛋白质序列

问题描述

我有一个蛋白质ID列表,我正在尝试使用python从Uniprot访问蛋白质序列。 我碰到了这篇文章:Protein sequence from uniprot protein id python,但给出了元素列表,而不是实际顺序:

代码

import requests as r
from Bio import SeqIO
from io import StringIO

cID='P04637'

baseUrl="http://www.uniprot.org/uniprot/"
currentUrl=baseUrl+cID+".fasta"
response = r.post(currentUrl)
cData=''.join(response.text)

Seq=StringIO(cData)
pSeq=list(SeqIO.parse(Seq,'fasta'))

给出输出:

输出

[SeqRecord(seq=Seq('MQAALIGLNFPLQRRFLSGVLTTTSSAKRCYSGDTGKPYDCTSAEHKKELEECY...SSS',SingleLetterAlphabet()),id='sp|O45228|PROD_CAEEL',name='sp|O45228|PROD_CAEEL',description='sp|O45228|PROD_CAEEL Proline dehydrogenase 1,mitochondrial OS=Caenorhabditis elegans OX=6239 GN=prdh-1 PE=2 SV=2',dbxrefs=[])]

我只是好奇如何真正获得序列本身。

解决方法

[record.seq for record in pSeq]

编辑: 您需要str(pSeq[0].seq)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...