与ncbi e-utilities的结构化python接口。
eutils的Python项目详细描述
eutils是一个python包,用于简化搜索、获取和 使用ncbi的E-utilities接口解析记录。
新闻
- 0.5.0于2018年11月20日发布。见0.5 Change Log。
功能
- 用于搜索和获取的简单pythonic接口
- 根据NCBI指南自动查询速率限制
- 可选的基于sqlite的压缩回复缓存
- 有助于在答复中获得基本属性的“正面”
一个简单的例子
截至2018年5月1日,NCBI根据客户机是否 已注册。未注册的客户端限制为每秒3个请求; 注册客户每秒被授予10个请求,并且可以请求 更多。见NCBI Announcement 更多信息。
eutils包将根据 NCBI指南(每秒3或10个请求,不带或带API密钥, 分别)。
$ pip install eutils $ ipython >>> from eutils import Client # Initialize a client. This client handles all caching and query # throttling. For example: >>> ec = Client(api_key=os.environ.get("NCBI_API_KEY", None)) # search for tumor necrosis factor genes # any valid NCBI query may be used >>> esr = ec.esearch(db='gene',term='tumor necrosis factor') # fetch one of those (gene id 7157 is human TNF) >>> egs = ec.efetch(db='gene', id=7157) # One may fetch multiple genes at a time. These are returned as an # EntrezgeneSet. We'll grab the first (and only) child, which returns # an instance of the Entrezgene class. >>> eg = egs.entrezgenes[0] # Easily access some basic information about the gene >>> eg.hgnc, eg.maploc, eg.description, eg.type, eg.genus_species ('TP53', '17p13.1', 'tumor protein p53', 'protein-coding', 'Homo sapiens') # get a list of genomic references >>> sorted([(r.acv, r.label) for r in eg.references]) [('NC_000017.11', 'Chromosome 17 Reference GRCh38...'), ('NC_018928.2', 'Chromosome 17 Alternate ...'), ('NG_017013.2', 'RefSeqGene')] # Get the first three products defined on GRCh38 #>>> [p.acv for p in eg.references[0].products][:3] #['NM_001126112.2', 'NM_001276761.1', 'NM_000546.5'] # As a sample, grab the first product defined on this reference (order is arbitrary) >>> mrna = eg.references[0].products[0] >>> str(mrna) 'GeneCommentary(acv=NM_001126112.2,type=mRNA,heading=Reference,label=transcript variant 2)' # mrna.genomic_coords provides access to the exon definitions on this reference >>> mrna.genomic_coords.gi, mrna.genomic_coords.strand ('568815581', -1) >>> mrna.genomic_coords.intervals [(7687376, 7687549), (7676520, 7676618), (7676381, 7676402), (7675993, 7676271), (7675052, 7675235), (7674858, 7674970), (7674180, 7674289), (7673700, 7673836), (7673534, 7673607), (7670608, 7670714), (7668401, 7669689)] # and the mrna has a product, the resulting protein: >>> str(mrna.products[0]) 'GeneCommentary(acv=NP_001119584.1,type=peptide,heading=Reference,label=isoform a)'
重要注意事项
- 我们鼓励您browse issues。请报告任何 你发现的问题
- 使用pip包规范确保保持在minor 用于API稳定性的版本。例如,eutils >=0.1,<0.2。
开发和贡献
错误报告、代码补丁和文档的贡献如下 欢迎!
在默认分支中进行开发。请在功能区工作 默认分支的分支或书签。功能分支应 以他们解决的eutils问题命名,如 121更新xml外观合并时,使用提交消息,如 “closes#121:将xml facades更新为新样式的接口”(“关闭n” 自动识别并在按下时关闭车票。)
包含的makefile自动化了许多任务。尤其是 开发准备开发环境并进行测试运行 单元测试。(请在提交之前运行测试!)
再次感谢你的贡献。