Skip to content

Commit c3cb0c9

Browse files
committed
bump to version v1.4.0
1 parent 8b7ad09 commit c3cb0c9

File tree

9 files changed

+324
-249
lines changed

9 files changed

+324
-249
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 1.4.0
44

5-
5+
- added:
6+
- `bactopia-pubmlst-setup` to setup PubMLST REST API connections
7+
- `bactopia-pubmlst-build` to build PubMLST databases compatible with `mlst` Bactopia Tool
68

79
## 1.3.0
810

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ A Python package for working with [Bactopia](https://bactopia.github.io/)
99

1010
There are many subcommands available in Bactopia. Here is a brief description of each command:
1111

12-
| Command | Description |
13-
|----------------------|----------------------------------------------------------------------------|
14-
| `bactopia-citations` | Print out tools and citations used throughout Bactopia |
15-
| `bactopia-datasets` | Download optional datasets to supplement your analyses with Bactopia |
16-
| `bactopia-download` | Builds Bactopia environments for use with Nextflow. |
17-
| `bactopia-prepare` | Create a 'file of filenames' (FOFN) of samples to be processed by Bactopia |
18-
| `bactopia-search` | Query against ENA and SRA for public accessions to process with Bactopia |
19-
| `bactopia-summary` | Generate a summary table from the Bactopia results. |
12+
| Command | Description |
13+
|---------------------------|----------------------------------------------------------------------------|
14+
| `bactopia-citations` | Print out tools and citations used throughout Bactopia |
15+
| `bactopia-datasets` | Download optional datasets to supplement your analyses with Bactopia |
16+
| `bactopia-download` | Builds Bactopia environments for use with Nextflow. |
17+
| `bactopia-prepare` | Create a 'file of filenames' (FOFN) of samples to be processed by Bactopia |
18+
| `bactopia-search` | Query against ENA and SRA for public accessions to process with Bactopia |
19+
| `bactopia-summary` | Generate a summary table from the Bactopia results. |
20+
| `bactopia-atb-downloader` | Download assemblies from AllTheBacteria for use with Bactopia Tools |
21+
| `bactopia-atb-formatter` | Restructure All-the-Bacteria assemblies to allow usage with Bactopia Tools |
22+
| `bactopia-pubmlst-setup` | One-time setup for interacting with the PubMLST API |
23+
| `bactopia-pubmlst-build` | Build PubMLST databases for use with the 'mlst' Bactopia Tool. |
2024

2125
Below is the `--help` output for each subcommand.
2226

bactopia/cli/pubmlst/build.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
available_databases,
1414
build_blast_db,
1515
download_database,
16+
print_citation,
1617
)
1718

1819
# Set up Rich
@@ -21,7 +22,7 @@
2122
click.rich_click.USE_RICH_MARKUP = True
2223
click.rich_click.OPTION_GROUPS = {
2324
# Use underscores in parameters, since these are also passed to Nextflow
24-
"bactopia-pubmlst-download": [
25+
"bactopia-pubmlst-build": [
2526
{
2627
"name": "Required Options",
2728
"options": [
@@ -63,9 +64,7 @@
6364
@click.option(
6465
"--database",
6566
"-d",
66-
default="pubmlst_yersinia_seqdef",
67-
show_default=True,
68-
help="The organism database to interact with for setup. (Use 'all' to download all databases.)",
67+
help="A known organism database to download. (Use 'all' to download all databases.)",
6968
)
7069
@click.option(
7170
"--site",
@@ -78,7 +77,7 @@
7877
@click.option(
7978
"--token-dir",
8079
"-t",
81-
default=".bactopia/pubmlst",
80+
default=f"{Path.home()}/.bactopia",
8281
show_default=True,
8382
help="The directory where the token file is saved.",
8483
)
@@ -114,7 +113,7 @@ def pubmlst_download(
114113
verbose: bool,
115114
silent: bool,
116115
):
117-
"""Download specific database files from PubMLST or Pasteur."""
116+
"""Build PubMLST databases for use with the 'mlst' Bactopia Tool."""
118117
# Setup logs
119118
logging.basicConfig(
120119
format="%(asctime)s:%(name)s:%(levelname)s - %(message)s",
@@ -184,9 +183,11 @@ def pubmlst_download(
184183
if not skip_blast:
185184
# Build MLST database
186185
build_blast_db(
187-
f"{out_dir}/mlstdb",
186+
out_dir,
188187
)
189188

189+
print_citation()
190+
190191

191192
def main():
192193
if len(sys.argv) == 1:

bactopia/cli/pubmlst/setup.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from rich.logging import RichHandler
1010

1111
import bactopia
12-
from bactopia.databases.pubmlst.utils import setup_pubmlst
12+
from bactopia.databases.pubmlst.utils import print_citation, setup_pubmlst
1313

1414
# Set up Rich
1515
stderr = rich.console.Console(stderr=True)
@@ -58,6 +58,7 @@
5858
@click.option(
5959
"--site",
6060
"-s",
61+
default="pubmlst",
6162
show_default=True,
6263
type=click.Choice(["pubmlst", "pasteur"], case_sensitive=True),
6364
help="Only print citation matching a given name",
@@ -72,7 +73,7 @@
7273
@click.option(
7374
"--save-dir",
7475
"-sd",
75-
default=".bactopia/pubmlst",
76+
default=f"{Path.home()}/.bactopia",
7677
show_default=True,
7778
help="The directory to save the token",
7879
)
@@ -95,7 +96,14 @@ def pubmlst_setup(
9596
format="%(asctime)s:%(name)s:%(levelname)s - %(message)s",
9697
datefmt="%Y-%m-%d %H:%M:%S",
9798
handlers=[
98-
RichHandler(rich_tracebacks=True, console=rich.console.Console(stderr=True))
99+
RichHandler(
100+
rich_tracebacks=True,
101+
console=rich.console.Console(stderr=True),
102+
show_time=True if verbose else False,
103+
show_level=True if verbose else False,
104+
show_path=True,
105+
markup=True,
106+
)
99107
],
100108
)
101109
logging.getLogger().setLevel(
@@ -114,6 +122,7 @@ def pubmlst_setup(
114122
)
115123
sys.exit(1)
116124
setup_pubmlst(site, database, token_file, client_id, client_secret)
125+
print_citation()
117126

118127

119128
def main():

bactopia/databases/pubmlst/utils.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
from bactopia.utils import execute
1717

1818

19+
def print_citation():
20+
"""
21+
Print the citation for PubMLST and Bactopia
22+
"""
23+
logging.info(
24+
"\n\n"
25+
"If you make use of 'bactopia-pubmlst-(setup|build)' commands and 'PubMLST' database files, please cite the following:\n\n"
26+
"'PubMLST'\n"
27+
"Jolley, K. A., Bray, J. E., & Maiden, M. C. J. (2018). Open-access bacterial population genomics: BIGSdb software, the Pubmlst.org website and their applications. Wellcome Open Research, 3, 124. https://doi.org/10.12688/wellcomeopenres.14826.1\n\n"
28+
"'Bactopia'\n"
29+
"Petit III RA, Read TD Bactopia - a flexible pipeline for complete analysis of bacterial genomes. mSystems 5 (2020) https://doi.org/10.1128/mSystems.00190-20\n\n"
30+
"adios!"
31+
)
32+
33+
1934
def setup_pubmlst(
2035
site: str, database: str, token_file: str, client_id: str, client_secret: str
2136
):
@@ -115,7 +130,7 @@ def check_session(site: str, token_file: str, database: str = "yersinia") -> dic
115130
tokens = parse_json(token_file)
116131

117132
if not tokens["session_token"] or not tokens["session_secret"]:
118-
logging.warning("Session token not found, will request a new one")
133+
logging.debug("Session token not found, will request a new one")
119134
needs_update = True
120135
else:
121136
# Try querying the API to see if the session token is still valid
@@ -548,13 +563,14 @@ def download_database(
548563
logging.info(f"'{database}' complete")
549564

550565

551-
def build_blast_db(database_dir: str):
566+
def build_blast_db(out_dir: str):
552567
"""
553568
Build a BLAST database from the loci FASTA files that is compatible with 'tseemann/mlst'
554569
555570
Args:
556-
database_dir (str): The directory containing the loci FASTA files
571+
out_dir (str): The directory containing the loci FASTA files
557572
"""
573+
database_dir = f"{out_dir}/mlstdb"
558574
blast_db_dir = f"{database_dir}/blast"
559575
if not Path(blast_db_dir).exists():
560576
Path(blast_db_dir).mkdir(parents=True, exist_ok=True)
@@ -579,7 +595,7 @@ def build_blast_db(database_dir: str):
579595

580596
# Build the BLAST database
581597
execute(
582-
f"makeblastdb -hash_index -in mlst.fa -dbtype nucl -title 'PubMLST' -parse_seqids",
598+
"makeblastdb -hash_index -in mlst.fa -dbtype nucl -title 'PubMLST' -parse_seqids",
583599
directory=blast_db_dir,
584600
)
585601

@@ -589,4 +605,5 @@ def build_blast_db(database_dir: str):
589605

590606
# Tar the BLAST database
591607
logging.info(f"Save BLAST database to '{database_dir}/mlst.tar.gz'")
592-
execute(f"tar -czvf mlst.tar.gz mlstdb/", directory=database_dir)
608+
execute("tar -czvf mlst.tar.gz mlstdb/", directory=out_dir)
609+
shutil.move(f"{out_dir}/mlst.tar.gz", f"{database_dir}/mlst.tar.gz")

bactopia/reports/__init__.py

Whitespace-only changes.

bactopia/reports/templates/__init__.py

Whitespace-only changes.

environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ channels:
22
- conda-forge
33
- bioconda
44
dependencies:
5+
- blast
56
- pigz
6-
- poetry =1.3
7-
- python >=3.8
7+
- poetry
8+
- python >=3.8,<3.12
89
- wget

0 commit comments

Comments
 (0)