現(xiàn)在我們來進入我們的第一個實例,在這里我們是使用的Linux中的ipython3,如果沒有這一環(huán)境請先自行配置。推薦的配置是首先安裝 Oracle VM VirtualBox,然后安裝 ubuntu 鏡像,最后安裝 ipython3。
NCBI (National Center for Biotechnology Information )是指美國國立生物技術信息中心。它致力于 1)建立關于分子生物學,生物化學,和遺傳學知識的存儲和分析的自動系統(tǒng),2)實行關于用于分析生物學重要分子和復合物的結構和功能的基于計算機的信息處理的,先進方法的研究,3)加速生物技術研究者和醫(yī)藥治療人員對數(shù)據(jù)庫和軟件的使用,和 4)全世界范圍內(nèi)的生物技術信息收集的合作努力。這一部分讓我們首先了解如何獲取和使用NCBI的數(shù)據(jù)。
第一步,我們先導入相關的模塊。
from Bio import Entrez, SeqIO
Entrez.email = 'put@your.email.here'
我們現(xiàn)在需要在核苷酸數(shù)據(jù)庫里(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條結果,我們現(xiàn)在需要獲取其所有結果。
id_list = rec_list['IdList']
hdl = Entrez.efetch(db='nucleotide', id=id_list, rettype='gb')
現(xiàn)在我們解析結果。
recs = list(SeqIO.parse(hdl, 'gb'))
現(xiàn)在我們提取其中的一條結果。
for rec in recs:
if rec.name == 'KM288867':
break
我們現(xiàn)在來獲取這條記錄的一些特征,比如基因產(chǎn)物和外顯子位置。
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
在下一章節(jié)中我們主要需要用到的就是序列了。
小結
在這一章中我們學習了:
- 如何通過 Entrez 在 NCBI 中獲取數(shù)據(jù)
- 如何通過 SeqIO 解析數(shù)據(jù)