Added untested partial matching

This commit is contained in:
Harrison Deng 2025-01-10 16:12:56 +00:00
parent f20a656f45
commit e634647774
2 changed files with 13 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import datetime
from os import path
import os
from automlst.cli import info, type
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
@ -16,7 +16,7 @@ root_parser = argparse.ArgumentParser()
subparsers = root_parser.add_subparsers(required=True)
info.setup_parser(subparsers.add_parser(get_module_base_name(info.__name__)))
type.setup_parser(subparsers.add_parser(get_module_base_name(type.__name__)))
st.setup_parser(subparsers.add_parser(get_module_base_name(st.__name__)))
def run():

View File

@ -38,17 +38,27 @@ def setup_parser(parser: ArgumentParser):
parser.add_argument(
"--exact", "-ex",
action="store_true",
dest="exact",
required=False,
default=False,
help="Should run exact matching rather than returning all similar ones"
)
parser.add_argument(
"--stop-on-fail", "-sof",
action="store_true",
dest="stop_on_fail",
required=False,
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)
async def run(args):
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:
mlst_profiles = mlst_profiler.profile_multiple_strings(gen_strings)
mlst_profiles = mlst_profiler.profile_multiple_strings(gen_strings, exact=args.exact)
failed = await write_mlst_profiles_as_csv(mlst_profiles, args.out)
if len(failed) > 0:
print(f"A total of {len(failed)} IDs failed:\n{"\n".join(failed)}")