BacDive API
Using the BacDive API requires registration. Registration is free but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See About BacDive for details.
Please register here.
The Python package can be initialized using your login credentials:
import bacdive
client = bacdive.BacdiveClient('name@mail.example', 'password')
client.setSearchType('exact')
count = client.search(taxonomy='Bacillus subtilis subtilis')
print(count, 'strains found.')
for strain in client.retrieve():
print(strain)
Example queries:
query = {"id": 24493}
query = {"id": "24493;12;132485"}
query = {"id": [24493, 12, 132485]}
query = {"culturecolno": "DSM 26640"}
query = {"culturecolno": ["DSM 26640", "DSM 26646"]}
query = {"culturecolno": "DSM 26640;DSM 26646"}
client.setSearchType('startswith')
query = {"culturecolno": "DSM"}
query = {"taxonomy": "Bacillus subtilis subsp. subtilis"}
query = {"taxonomy": ("Escherichia", "coli")}
query = {"16s": "AF000162"}
query = {"16s": ["AB681963", "JN566021", "AY027686"]}
client.setSearchType('startswith')
query = {"16s": "AB"}
query = {"genome": "GCA_006094295"}
query = {"genome": ["GCA_003332855", "GCA_024623325", "GCA_017377855"]}
client.setSearchType('startswith')
query = {"genome": "DSM"}
client.search(**query)
Filtering
Results from the retrieve
Method of both clients can be further filtered. The result contains a list of matched keyword dicts:
filter=['keywords', 'culture collection no.']
result = client.retrieve(filter)
print({k:v for x in result for k,v in x.items()})
The printed result will look like this:
{'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'}],
...
Hints for more advanced queries
If you have more advanced queries that are currently not covered by the API, we recommend you to use the BacDive Advanced Search, which is very flexible and powerful. You can then download the resulting table as CSV (button at the top right), import the CSV into your Python script, and use the BacDive-IDs to download all relevant information via the API.
New in v0.3
We added AI-based predictions to the BacDive database. Predicted traits are excluded by default. To include them, you have to call the method includePredictions()
:
client.includePredictions()
You can exclude predictions again by calling:
client.excludePredictions()
New in v1.0
Thanks to phenolophthaleinum for improving the error handling and Joaquim Sardá for improving the BacDive-API and adding new search possibilities.
Examples for search type definitions and array requests are included in the examples above.