美文网首页
在 NCBI 中获取数据

在 NCBI 中获取数据

作者: 兰宇轩 | 来源:发表于2019-07-13 09:25 被阅读0次

现在我们来进入我们的第一个实例,在这里我们是使用的Linux中的ipython3,如果没有这一环境请先自行配置。推荐的配置是首先安装 Oracle VM VirtualBox,然后安装 ubuntu 镜像,最后安装 ipython3

NCBI (National Center for Biotechnology Information )是指美国国立生物技术信息中心。它致力于 1)建立关于分子生物学,生物化学,和遗传学知识的存储和分析的自动系统,2)实行关于用于分析生物学重要分子和复合物的结构和功能的基于计算机的信息处理的,先进方法的研究,3)加速生物技术研究者和医药治疗人员对数据库和软件的使用,和 4)全世界范围内的生物技术信息收集的合作努力。这一部分让我们首先了解如何获取和使用NCBI的数据。

第一步,我们先导入相关的模块。

from Bio import Entrez, SeqIO
Entrez.email = 'put@your.email.here'

我们现在需要在核苷酸数据库里(nucleotide database)找来自恶性疟原虫(Plasmodium falciparum)的氯喹抗性转运体(Cholroquine Resistance Transporter,CRT)。

handle = Entrez.esearch(db='nucleotide', term='CRT [Gene Name] AND "Plasmodium falciparum"[Organism]')
rec_list = Entrez.read(handle)
if rec_list['RetMax'] < rec_list['Count']:
    handle = Entrez.esearch(db='nucleotide', term='CRT [Gene Name] AND "Plasmodium falciparum"[Organism]', retmax=rec_list['Count'])
    rec_list = Entrez.read(handle)

标准搜索只会返回20条结果,我们现在需要获取其所有结果。

id_list = rec_list['IdList']
hdl = Entrez.efetch(db='nucleotide', id=id_list, rettype='gb')

现在我们解析结果。

recs = list(SeqIO.parse(hdl, 'gb'))

现在我们提取其中的一条结果。

for rec in recs:
    if rec.name == 'KM288867':
        break

我们现在来获取这条记录的一些特征,比如基因产物和外显子位置。

for feature in rec.features:
    if feature.type == 'gene':
        print(feature.qualifiers['gene'])
    elif feature.type == 'exon':
        loc = feature.location
        print(loc.start, loc.end, loc.strand)
    else:
        print('not processed:\n%s' % feature)

我们再来看一下其中的注释信息。

for name, value in rec.annotations.items():
    print('%s=%s' % (name, value))

最后,必不可少的是序列。

sequence = rec.seq

在下一章节中我们主要需要用到的就是序列了。

小结

在这一章中我们学习了:

  • 如何通过 Entrez 在 NCBI 中获取数据
  • 如何通过 SeqIO 解析数据

相关文章

网友评论

      本文标题:在 NCBI 中获取数据

      本文链接:https://www.haomeiwen.com/subject/alkpkctx.html