【问题标题】:Biopython: Getting XML-file by Protein accessionBiopython:通过蛋白质加入获取 XML 文件
【发布时间】:2015-03-31 09:19:03
【问题描述】:

我有一个包含 Uniprot ID 的文件。 现在我正在寻找一种方法来下载每个 ID 的整个 XML 条目。

【问题讨论】:

标签: xml biopython


【解决方案1】:

首先,您为每个 UniProt ID 构建一个 URL,以检索蛋白质的 XML 定义。

uniprot_id = 'P12345'
url = 'http://www.uniprot.org/uniprot/'+uniprot_id+'.xml'

您可以通过更改字符串的结尾(即“.txt、.fasta、.rdf”)来构造 URL 以检索不同的数据格式。这个link 提供了有关 uniprot 访问模式的更多具体细节。

接下来,您打开 url 并使用 BioPython 解析输出。或者,您可以将 XML 字符串保存到磁盘。

import urllib2
from Bio import SeqIO

uniprot_id = 'P12345'
url = 'http://www.uniprot.org/uniprot/'+uniprot_id+'.xml'
s = urllib2.urlopen(url)
contents = s.read()

record = SeqIO.read(contents, 'uniprot-xml')

【讨论】:

  • 非常感谢。我发现我实际上可以在 Uniprot 上上传文本文件并以 xml 格式下载所有结果。有时答案太容易想出来了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-01
相关资源
最近更新 更多