Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e6d127369b | |||
2f189c8741 | |||
53cd2e1260 | |||
ffee4ee2e1 | |||
9498fe7a45 | |||
6305f5dbc9 | |||
706f127195 | |||
47c8951916 | |||
ba72199efc | |||
ca59751c35 |
@@ -12,7 +12,7 @@
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "pip3 install --user -r requirements.txt && pip3 install -e .",
|
||||
"postCreateCommand": "pip3 install --user -r requirements.txt",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
|
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
@@ -30,11 +30,26 @@ pipeline {
|
||||
}
|
||||
}
|
||||
stage("publish") {
|
||||
parallel {
|
||||
stage ("git.reslate.systems") {
|
||||
environment {
|
||||
CREDS = credentials('4d6f64be-d26d-4f95-8de3-b6a9b0beb311')
|
||||
TOKEN = credentials('git.reslate.systems')
|
||||
}
|
||||
steps {
|
||||
sh returnStatus: true, script: 'python -m twine upload --repository-url https://git.reslate.systems/api/packages/${CREDS_USR}/pypi -u ${CREDS_USR} -p ${CREDS_PSW} --non-interactive --disable-progress-bar --verbose dist/*'
|
||||
sh returnStatus: true, script: 'python -m twine upload --repository-url https://git.reslate.systems/api/packages/ydeng/pypi -u __token__ -p ${TOKEN} --non-interactive --disable-progress-bar --verbose dist/*'
|
||||
}
|
||||
}
|
||||
stage ("pypi.org") {
|
||||
when {
|
||||
tag '*.*'
|
||||
}
|
||||
environment {
|
||||
TOKEN = credentials('pypi.org')
|
||||
}
|
||||
steps {
|
||||
sh returnStatus: true, script: 'python -m twine upload -u __token__ -p ${TOKEN} --non-interactive --disable-progress-bar --verbose dist/*'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
README.md
Normal file
45
README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# autoBIGS.cli
|
||||
|
||||
A command-line interface (CLI) based program that allows quickly batched requests for obtaining MLST profiles on multiple FASTA sequences and exporting it as a convenient CSV. Capable of querying a variety of MLST databases from both Institut Pasteur and PubMLST.
|
||||
|
||||
This program is simply a command-line interface for [autoBIGS.engine](https://pypi.org/project/autoBIGS.engine).
|
||||
|
||||
## Features
|
||||
|
||||
This CLI is capable of exactly what [autoBIGS.engine](https://pypi.org/project/autoBIGS.engine) is capable of:
|
||||
- Import multiple whole genome FASTA files
|
||||
- Fetch the available BIGSdb databases that is currently live and available
|
||||
- Fetch the available BIGSdb database schemas for a given MLST database
|
||||
- Retrieve exact/non-exact MLST allele variant IDs based off a sequence
|
||||
- Retrieve MLST sequence type IDs based off a sequence
|
||||
- Output all results to a single CSV
|
||||
|
||||
## Planned Features for CLI
|
||||
- Specifications of multi-threading capacity
|
||||
- Session authentication for updated database schemas (as required by both PubMLST and Institut Pasteur)
|
||||
|
||||
Please refer to [autoBIGS.engine](https://pypi.org/project/autoBIGS.engine) for more planned features.
|
||||
|
||||
## Usage
|
||||
|
||||
This CLI can be installed with `pip`. Please ensure [pip is installed](https://pip.pypa.io/en/stable/installation/). Then:
|
||||
|
||||
1. Run `pip install autoBIGS-cli` to install the latest version of the CLI for autoBIGS.
|
||||
|
||||
2. Once installation is complete, run `autoBIGS --version` to test that the installation succeeded (and that you are running the appropriate version).
|
||||
|
||||
3. Run `autoBIGS -h` to get information on how to get started.
|
||||
|
||||
### Example
|
||||
|
||||
Let's say you have a fasta called `seq.fasta` which contains several sequences. You know all sequences in `seq.fasta` are Bordetella pertussis sequences, and you know you have the sequences for the necessary targets of your schema in each of them. You want to retrieve MLST profiles for all of them. This can be done by:
|
||||
|
||||
1. Running `autobigs info -l` to list all available `seqdef` databases and find the database associated with Bordetella (you should see one called `pubmlst_bordetella_seqdef`).
|
||||
|
||||
2. Then, run `autobigs info -lschema pubmlst_bordetella_seqdef` to get the available typing schemas and their associated IDs. In this example, let's assume we want a normal MLST scheme. In this case, we would pay attention to the number next to `MLST` (it should be `3`).
|
||||
|
||||
3. Then, run `autobigs st -h` and familiarize yourself with the parameters needed for sequence typing.
|
||||
|
||||
4. Namely, you should find that you will need to run `autobigs st seq.fasta pubmlst_bordetella_seqdef 3 output.csv`. You can optionally include multiple `FASTA` files, and/or `--exact` to only retrieve exact sequence types, and/or `--stop-on-fail` to stop typing if one of your sequences fail to retrieve any type.
|
||||
|
||||
5. Sit tight, and wait. The `output.csv` will contain your results once completed.
|
@@ -3,17 +3,23 @@ requires = ["setuptools>=64", "setuptools_scm>=8"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "automlst.cli"
|
||||
name = "autoBIGS.cli"
|
||||
dynamic = ["version"]
|
||||
readme = "README.md"
|
||||
|
||||
dependencies = [
|
||||
"automlst-engine"
|
||||
"autoBIGS-engine"
|
||||
]
|
||||
requires-python = ">=3.11"
|
||||
requires-python = ">=3.12"
|
||||
description = "A CLI tool to rapidly fetch fetch MLST profiles given sequences for various diseases."
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/RealYHD/autoBIGS.cli"
|
||||
Issues = "https://github.com/RealYHD/autoBIGS.cli/issues"
|
||||
|
||||
|
||||
[project.scripts]
|
||||
automlst = "automlst.cli.program:run"
|
||||
autoBIGS = "autobigs.cli.program:run"
|
||||
|
||||
[tool.setuptools_scm]
|
||||
|
||||
|
@@ -4,4 +4,4 @@ pytest-cov
|
||||
build
|
||||
twine
|
||||
setuptools_scm
|
||||
automlst-engine
|
||||
autoBIGS.engine
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser, Namespace
|
||||
import asyncio
|
||||
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex
|
||||
from autobigs.engine.data.remote.databases.bigsdb import BIGSdbIndex
|
||||
|
||||
def setup_parser(parser: ArgumentParser):
|
||||
parser.description = "Fetches the latest BIGSdb MLST database definitions."
|
||||
@@ -24,9 +24,10 @@ def setup_parser(parser: ArgumentParser):
|
||||
help="Lists the known schema IDs for a given BIGSdb sequence definition database name. The name, and then the ID of the schema is given."
|
||||
)
|
||||
|
||||
parser.set_defaults(func=run_asynchronously)
|
||||
parser.set_defaults(run=run_asynchronously)
|
||||
return parser
|
||||
|
||||
async def run(args):
|
||||
async def run(args: Namespace):
|
||||
async with BIGSdbIndex() as bigsdb_index:
|
||||
if args.list_dbs:
|
||||
known_seqdef_dbs = await bigsdb_index.get_known_seqdef_dbs(force=False)
|
||||
@@ -37,6 +38,9 @@ async def run(args):
|
||||
for schema_desc, schema_id in schemas.items():
|
||||
print(f"{schema_desc}: {schema_id}")
|
||||
|
||||
def run_asynchronously(args):
|
||||
if not (args.list_dbs or len(args.list_bigsdb_schemas) > 0):
|
||||
print("Nothing to do. Try specifying \"-l\".")
|
||||
|
||||
def run_asynchronously(args: Namespace):
|
||||
asyncio.run(run(args))
|
||||
|
39
src/autobigs/cli/program.py
Normal file
39
src/autobigs/cli/program.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import argparse
|
||||
from importlib import metadata
|
||||
from os import path
|
||||
import os
|
||||
|
||||
from autobigs.cli import info, st
|
||||
from autobigs.cli.meta import get_module_base_name
|
||||
import importlib
|
||||
|
||||
root_parser = argparse.ArgumentParser(epilog='Use "%(prog)s info -h" to learn how to get available MLST databases, and their available schemas.'
|
||||
+ ' Once that is done, use "%(prog)s st -h" to learn how to retrieve MLST profiles.'
|
||||
)
|
||||
subparsers = root_parser.add_subparsers(required=False)
|
||||
|
||||
info.setup_parser(subparsers.add_parser(get_module_base_name(info.__name__)))
|
||||
st.setup_parser(subparsers.add_parser(get_module_base_name(st.__name__)))
|
||||
|
||||
root_parser.add_argument(
|
||||
"--version",
|
||||
action="store_true",
|
||||
default=False,
|
||||
required=False,
|
||||
help="Displays the autoBIGS.CLI version, and the autoBIGS.Engine version."
|
||||
)
|
||||
|
||||
|
||||
def run():
|
||||
args = root_parser.parse_args()
|
||||
if args.version:
|
||||
print(f'autoBIGS.CLI is running version {
|
||||
metadata.version("autoBIGS-cli")}.')
|
||||
print(f'autoBIGS.Engine is running version {
|
||||
metadata.version("autoBIGS-engine")}.')
|
||||
if hasattr(args, "run"):
|
||||
args.run(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
@@ -1,10 +1,10 @@
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser, Namespace
|
||||
import asyncio
|
||||
import datetime
|
||||
from automlst.engine.local.csv import write_mlst_profiles_as_csv
|
||||
from automlst.engine.local.fasta import read_multiple_fastas
|
||||
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex
|
||||
from autobigs.engine.data.local.csv import write_mlst_profiles_as_csv
|
||||
from autobigs.engine.data.local.fasta import read_multiple_fastas
|
||||
from autobigs.engine.data.remote.databases.bigsdb import BIGSdbIndex
|
||||
|
||||
|
||||
def setup_parser(parser: ArgumentParser):
|
||||
@@ -52,9 +52,10 @@ def setup_parser(parser: ArgumentParser):
|
||||
default=False,
|
||||
help="Should the algorithm stop in the case there are no matches (or partial matches when expecting exact matches)."
|
||||
)
|
||||
parser.set_defaults(func=run_asynchronously)
|
||||
parser.set_defaults(run=run_asynchronously)
|
||||
return parser
|
||||
|
||||
async def run(args):
|
||||
async def run(args: Namespace):
|
||||
async with BIGSdbIndex() as bigsdb_index:
|
||||
gen_strings = read_multiple_fastas(args.fastas)
|
||||
async with await bigsdb_index.build_profiler_from_seqdefdb(args.seqdefdb, args.schema) as mlst_profiler:
|
@@ -1,27 +0,0 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import datetime
|
||||
from os import path
|
||||
import os
|
||||
|
||||
from automlst.cli import info, st
|
||||
from automlst.cli.meta import get_module_base_name
|
||||
from automlst.engine.data.genomics import NamedString
|
||||
from automlst.engine.local.abif import read_abif
|
||||
from automlst.engine.local.csv import write_mlst_profiles_as_csv
|
||||
from automlst.engine.local.fasta import read_fasta
|
||||
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex
|
||||
|
||||
root_parser = argparse.ArgumentParser()
|
||||
subparsers = root_parser.add_subparsers(required=True)
|
||||
|
||||
info.setup_parser(subparsers.add_parser(get_module_base_name(info.__name__)))
|
||||
st.setup_parser(subparsers.add_parser(get_module_base_name(st.__name__)))
|
||||
|
||||
|
||||
def run():
|
||||
args = root_parser.parse_args()
|
||||
args.func(args)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
58377
tests/resources/tohama_I_bpertussis.fasta
Normal file
58377
tests/resources/tohama_I_bpertussis.fasta
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user