Updated CLI to output more useful information.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser, Namespace
|
||||
import asyncio
|
||||
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex
|
||||
from automlst.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))
|
||||
|
||||
|
@@ -1,27 +1,39 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import datetime
|
||||
from importlib import metadata
|
||||
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
|
||||
import importlib
|
||||
|
||||
root_parser = argparse.ArgumentParser()
|
||||
subparsers = root_parser.add_subparsers(required=True)
|
||||
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 autoMLST.CLI version, and the autoMLST.Engine version."
|
||||
)
|
||||
|
||||
|
||||
def run():
|
||||
args = root_parser.parse_args()
|
||||
args.func(args)
|
||||
if args.version:
|
||||
print(f'autoMLST.CLI is running version {
|
||||
metadata.version("automlst-cli")}.')
|
||||
print(f'autoMLST.Engine is running version {
|
||||
metadata.version("automlst-engine")}.')
|
||||
if hasattr(args, "run"):
|
||||
args.run(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
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 automlst.engine.data.local.csv import write_mlst_profiles_as_csv
|
||||
from automlst.engine.data.local.fasta import read_multiple_fastas
|
||||
from automlst.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:
|
||||
|
Reference in New Issue
Block a user