Skip to content

Commit

Permalink
Add reference selection functionality for multiref schemes (currently…
Browse files Browse the repository at this point in the history
… only artic-inrb-mpox) (#147)

* First commit

* make model dir if it doesn't exist

* scheme length isn't an int
  • Loading branch information
BioWilko authored Dec 4, 2024
1 parent 6cc5f5d commit 6054b5f
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 36 deletions.
3 changes: 3 additions & 0 deletions artic/get_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tarfile
import sys
from artic.utils import clair3_manifest
from clint.textui import colored


def download_file(url: str, local_path: Path):
Expand All @@ -18,6 +19,8 @@ def get_model(model_dir: Path, model_fname: str, model_url: str):

model_path = Path(model_dir, model_fname)

os.makedirs(model_dir, exist_ok=True)

download_file(model_url, model_path)

with tarfile.open(model_path, "r") as tar:
Expand Down
50 changes: 50 additions & 0 deletions artic/get_scheme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from artic.utils import get_scheme
from pathlib import Path


def main():
import argparse
import os

parser = argparse.ArgumentParser()
parser.add_argument(
"--scheme-name",
type=str,
required=True,
help="Name of the scheme you wish to fetch",
)
parser.add_argument(
"--scheme-version",
type=str,
required=True,
help="Version of the scheme you wish to fetch",
)
parser.add_argument(
"--scheme-directory",
type=Path,
help="Directory where schemes are stored",
default=f"{os.getcwd()}/primer-schemes",
)
parser.add_argument(
"--scheme-length",
type=str,
help="Length of the scheme to fetch, only required if the scheme has multiple possible lengths.",
)
parser.add_argument(
"--read-file",
type=Path,
help="FASTQ file containing reads sequenced with the scheme in question, this is only required when fetching a scheme with reference selection functionality.",
)
args = parser.parse_args()

get_scheme(
scheme_name=args.scheme_name,
scheme_version=args.scheme_version,
scheme_directory=args.scheme_directory,
scheme_length=args.scheme_length,
read_file=args.read_file,
)


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion artic/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run(parser, args):
else:
if not os.getenv("CONDA_PREFIX"):
print(
f"CONDA_PREFIX is not set, this probably means you are not running this inside a conda environment, please provide a model path argument '--model-path'",
"CONDA_PREFIX is not set, this probably means you are not running this inside a conda environment, please provide a model path argument '--model-path'",
file=sys.stderr,
)
raise SystemExit(1)
Expand Down Expand Up @@ -85,6 +85,7 @@ def run(parser, args):
scheme_version=args.scheme_version,
scheme_directory=args.scheme_directory,
scheme_length=args.scheme_length,
read_file=args.read_file,
)

if not os.path.exists(bed) or not os.path.exists(ref):
Expand Down
2 changes: 1 addition & 1 deletion artic/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def init_pipeline_parser():
)
remote_scheme_options.add_argument(
"--scheme-length",
type=int,
type=str,
metavar="scheme_length",
default=False,
help="Length of the scheme to fetch from the scheme repository (https://github.com/quick-lab/primerschemes). This is only required if the --scheme-name has multiple possible lengths.",
Expand Down
Loading

0 comments on commit 6054b5f

Please sign in to comment.