bacdive


Namebacdive JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://bacdive.dsmz.de/
SummaryBacDive-API - Programmatic Access to the BacDive Database
upload_time2024-01-25 06:34:58
maintainer
docs_urlNone
authorJulia Koblitz
requires_python>=3.6
license
keywords microbiology bacteria strains phenotypes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://bacdive.dsmz.de/about) for details.

Please register [here](https://api.bacdive.dsmz.de/login).

The Python package can be initialized using your login credentials:


```python
import bacdive

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

# [optional] You may define the search type as one of the following: 
# 'exact' (default), 'contains', 'startswith', 'endswith'
client.setSearchType('exact')

# 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)
```

## Example queries:

```python
# 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"}
# New in v1.0: Search by culture collection number with multiple numbers:
query = {"culturecolno": ["DSM 26640", "DSM 26646"]}
query = {"culturecolno": "DSM 26640;DSM 26646"} # semicolon may be used as separator

# Search by culture collection number with search type 'startswith':
client.setSearchType('startswith')
query = {"culturecolno": "DSM"}

# 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 16S sequence accession numbers:
query = {"16s": "AF000162"}
# New in v1.0: Search by 16S sequence with multiple sequence accession numbers:
query = {"16s": ["AB681963", "JN566021", "AY027686"]}
# New in v1.0: Search by 16S sequence with search type 'startswith':
client.setSearchType('startswith')
query = {"16s": "AB"}

# Search by genome sequence accession numbers:
query = {"genome": "GCA_006094295"}
# New in v1.0: Search by genome sequence with multiple sequence accession numbers:
query = {"genome": ["GCA_003332855", "GCA_024623325", "GCA_017377855"]}
# New in v1.0: Search by genome sequence with search type 'startswith':
client.setSearchType('startswith')
query = {"genome": "DSM"}


# run query
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:

```python
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:

```python
{'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 [Bac*Dive* Advanced Search](https://bacdive.dsmz.de/advsearch), 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 Bac*Dive* database. Predicted traits are excluded by default. To include them, you have to call the method `includePredictions()`:

```python
client.includePredictions()
```

You can exclude predictions again by calling: 

```python
client.excludePredictions()
```

## New in v1.0

Thanks to [phenolophthaleinum](https://github.com/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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://bacdive.dsmz.de/",
    "name": "bacdive",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "microbiology bacteria strains phenotypes",
    "author": "Julia Koblitz",
    "author_email": "julia.koblitz@dsmz.de",
    "download_url": "https://files.pythonhosted.org/packages/6c/b5/867cc07fef2d2bb31316c9b28e4dac29f87afd2dcf65c352b06a8e2c4938/bacdive-1.0.0.tar.gz",
    "platform": null,
    "description": "# BacDive API\n\nUsing 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](https://bacdive.dsmz.de/about) for details.\n\nPlease register [here](https://api.bacdive.dsmz.de/login).\n\nThe Python package can be initialized using your login credentials:\n\n\n```python\nimport bacdive\n\nclient = bacdive.BacdiveClient('name@mail.example', 'password')\n\n# [optional] You may define the search type as one of the following: \n# 'exact' (default), 'contains', 'startswith', 'endswith'\nclient.setSearchType('exact')\n\n# The search method fetches all BacDive-IDs matching your query\n# and returns the number of IDs found\ncount = client.search(taxonomy='Bacillus subtilis subtilis')\nprint(count, 'strains found.')\n\n# the retrieve method lets you iterate over all strains\n# and returns the full entry as dict\n# Entries can be further filtered using a list of keys (e.g. ['keywords'])\nfor strain in client.retrieve():\n    print(strain)\n```\n\n## Example queries:\n\n```python\n# Search by BacDive-IDs (either semicolon separated or as list):\nquery = {\"id\": 24493}\nquery = {\"id\": \"24493;12;132485\"}\nquery = {\"id\": [24493, 12, 132485]}\n\n# Search by culture collection number\nquery = {\"culturecolno\": \"DSM 26640\"}\n# New in v1.0: Search by culture collection number with multiple numbers:\nquery = {\"culturecolno\": [\"DSM 26640\", \"DSM 26646\"]}\nquery = {\"culturecolno\": \"DSM 26640;DSM 26646\"} # semicolon may be used as separator\n\n# Search by culture collection number with search type 'startswith':\nclient.setSearchType('startswith')\nquery = {\"culturecolno\": \"DSM\"}\n\n# Search by taxonomy (either as full name or as list):\n# With genus name, species epithet (optional), and subspecies (optional).\nquery = {\"taxonomy\": \"Bacillus subtilis subsp. subtilis\"}\nquery = {\"taxonomy\": (\"Escherichia\", \"coli\")}\n\n# Search by 16S sequence accession numbers:\nquery = {\"16s\": \"AF000162\"}\n# New in v1.0: Search by 16S sequence with multiple sequence accession numbers:\nquery = {\"16s\": [\"AB681963\", \"JN566021\", \"AY027686\"]}\n# New in v1.0: Search by 16S sequence with search type 'startswith':\nclient.setSearchType('startswith')\nquery = {\"16s\": \"AB\"}\n\n# Search by genome sequence accession numbers:\nquery = {\"genome\": \"GCA_006094295\"}\n# New in v1.0: Search by genome sequence with multiple sequence accession numbers:\nquery = {\"genome\": [\"GCA_003332855\", \"GCA_024623325\", \"GCA_017377855\"]}\n# New in v1.0: Search by genome sequence with search type 'startswith':\nclient.setSearchType('startswith')\nquery = {\"genome\": \"DSM\"}\n\n\n# run query\nclient.search(**query)\n```\n\n## Filtering\n\nResults from the `retrieve` Method of both clients can be further filtered. The result contains a list of matched keyword dicts:\n\n```python\nfilter=['keywords', 'culture collection no.']\nresult = client.retrieve(filter)\nprint({k:v for x in result for k,v in x.items()})\n```\n\nThe printed result will look like this:\n\n```python\n{'1161': [{'keywords': ['human pathogen', 'Bacteria']},\n          {'culture collection no.': 'DSM 4393, pC194, SB202'}],\n '1162': [{'keywords': ['human pathogen', 'Bacteria']},\n          {'culture collection no.': 'DSM 4514, ATCC 37015, BD170, NCIB 11624, '\n                                     'pUB110'}],\n '1163': [{'keywords': ['human pathogen', 'Bacteria']},\n          {'culture collection no.': 'DSM 4554, ATCC 37128, BGSC 1E18, pE194'}],\n '1164': [{'keywords': 'Bacteria'},\n          {'culture collection no.': 'DSM 4750, 1E7, BGSC 1E7, pE194-cop6'}],\n...\n```\n\n## Hints for more advanced queries\nIf you have more advanced queries that are currently not covered by the API, we recommend you to use the [Bac*Dive* Advanced Search](https://bacdive.dsmz.de/advsearch), 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.\n\n\n## New in v0.3\n\nWe added AI-based predictions to the Bac*Dive* database. Predicted traits are excluded by default. To include them, you have to call the method `includePredictions()`:\n\n```python\nclient.includePredictions()\n```\n\nYou can exclude predictions again by calling: \n\n```python\nclient.excludePredictions()\n```\n\n## New in v1.0\n\nThanks to [phenolophthaleinum](https://github.com/phenolophthaleinum) for improving the error handling and Joaquim Sard\u00e1 for improving the BacDive-API and adding new search possibilities.\n\nExamples for search type definitions and array requests are included in the examples above.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "BacDive-API - Programmatic Access to the BacDive Database",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://bacdive.dsmz.de/"
    },
    "split_keywords": [
        "microbiology",
        "bacteria",
        "strains",
        "phenotypes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfa1b306d6f16c9134d1fad44f8649967c0359e2b1e398eea2c3bbede8f0f9cf",
                "md5": "a60121afb9631ca90d45c4ca537ee327",
                "sha256": "7a473e1f9b8026fc70c72eecf849030a1b6492b92b5d9d82609e2683504587c3"
            },
            "downloads": -1,
            "filename": "bacdive-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a60121afb9631ca90d45c4ca537ee327",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7609,
            "upload_time": "2024-01-25T06:34:55",
            "upload_time_iso_8601": "2024-01-25T06:34:55.495254Z",
            "url": "https://files.pythonhosted.org/packages/cf/a1/b306d6f16c9134d1fad44f8649967c0359e2b1e398eea2c3bbede8f0f9cf/bacdive-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cb5867cc07fef2d2bb31316c9b28e4dac29f87afd2dcf65c352b06a8e2c4938",
                "md5": "cb1785f2e29370347a27dfb2b05bdee0",
                "sha256": "1be7547a88c4d005d24424b6cbd4feed39bde88f8443f3bbe8ad79feb243b4f6"
            },
            "downloads": -1,
            "filename": "bacdive-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cb1785f2e29370347a27dfb2b05bdee0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8137,
            "upload_time": "2024-01-25T06:34:58",
            "upload_time_iso_8601": "2024-01-25T06:34:58.572465Z",
            "url": "https://files.pythonhosted.org/packages/6c/b5/867cc07fef2d2bb31316c9b28e4dac29f87afd2dcf65c352b06a8e2c4938/bacdive-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-25 06:34:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bacdive"
}
        
Elapsed time: 0.22603s