Skip to main content

BacDive-API - 对 BacDive 数据库的编程访问

项目描述

BacDive API

使用 BacDive API 需要注册。注册是免费的,但只有在遵守 BacDive 使用条款的情况下才允许使用 BacDive 数据。有关详细信息,请参阅关于 BacDive

在这里注册。

可以使用您的登录凭据初始化 Python 包:

import bacdive

client = bacdive.BacdiveClient('name@mail.example', 'password')

# the search method fetches all BacDive-IDs matching your query
# and returns the number of IDs found
count = client.search(taxonomy='Bacillus subtilis subtilis')
print(count, 'strains found.')

# the retrieve method lets you iterate over all strains
# and returns the full entry as dict
# Entries can be further filtered using a list of keys (e.g. ['keywords'])
for strain in client.retrieve():
    print(strain)

示例查询:

# Search by BacDive-IDs (either semicolon separated or as list):
query = {"id": 24493}
query = {"id": "24493;12;132485"}
query = {"id": [24493, 12, 132485]}

# Search by culture collection number
query = {"culturecolno": "DSM 26640"}

# Search by taxonomy (either as full name or as list):
# With genus name, species epithet (optional), and subspecies (optional).
query = {"taxonomy": "Bacillus subtilis subsp. subtilis"}
query = {"taxonomy": ("Escherichia", "coli")}

# Search by sequence accession numbers:
query = {"16s": "AF000162"} # 16S sequence
query = {"genome": "GCA_006094295"} # genome sequence

# run query
client.search(**query)

过滤

retrieve可以进一步过滤来自两个客户端的方法的结果。结果包含匹配的关键字字典列表:

filter=['keywords', 'culture collection no.']
result = client.retrieve(filter)
print({k:v for x in result for k,v in x.items()})

打印的结果将如下所示:

{'1161': [{'keywords': ['human pathogen', 'Bacteria']},
          {'culture collection no.': 'DSM 4393, pC194, SB202'}],
 '1162': [{'keywords': ['human pathogen', 'Bacteria']},
          {'culture collection no.': 'DSM 4514, ATCC 37015, BD170, NCIB 11624, '
                                     'pUB110'}],
 '1163': [{'keywords': ['human pathogen', 'Bacteria']},
          {'culture collection no.': 'DSM 4554, ATCC 37128, BGSC 1E18, pE194'}],
 '1164': [{'keywords': 'Bacteria'},
          {'culture collection no.': 'DSM 4750, 1E7, BGSC 1E7, pE194-cop6'}],
...

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

bacdive-0.2.tar.gz (5.7 kB 查看哈希)

已上传 source

内置分布

bacdive-0.2-py3-none-any.whl (6.1 kB 查看哈希

已上传 py3