Skip to content

Commit

Permalink
updated version and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JKoblitz committed Jan 25, 2024
1 parent aa56f08 commit 53ddaf6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import bacdive

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

# the search method fetches all BacDive-IDs matching your query
# [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.')
Expand All @@ -34,15 +38,35 @@ 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 sequence accession numbers:
query = {"16s": "AF000162"} # 16S sequence
query = {"genome": "GCA_006094295"} # genome sequence
# 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)
Expand Down Expand Up @@ -73,6 +97,10 @@ The printed result will look like this:
...
```

## 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()`:
Expand All @@ -87,3 +115,8 @@ You can exclude predictions again by calling:
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.
2 changes: 1 addition & 1 deletion bacdive/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def excludePredictions(self):

def setSearchType(self, search_type):
if search_type:
allowed = ['exact ', 'contains', 'startswith', 'endswith']
allowed = ['exact', 'contains', 'startswith', 'endswith']
if search_type not in allowed:
print("WARNING - Search Type is not allowed.")
self.search_type = "exact"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="bacdive",
version="0.3.1",
version="1.0.0",
description="BacDive-API - Programmatic Access to the BacDive Database",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 53ddaf6

Please sign in to comment.