Skip to content

Commit

Permalink
Add new example from JLacey and tidy up repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaguire committed Aug 22, 2024
1 parent 4abe658 commit 6aff7fd
Show file tree
Hide file tree
Showing 10 changed files with 800 additions and 33 deletions.
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
.PHONY : docs
docs :
rm -rf docs/build/
sphinx-autobuild -b html --watch convast/ docs/source/ docs/build/

.PHONY : run-checks
run-checks :
black --check .
ruff check .
pytest -v --color=yes --doctest-modules tests/ convast/
.PHONY : check
check :
black convast
ruff check convast
pytest -v --color=yes tests/

.PHONY : build
build :
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ EMR/LIMs exports?
- Standardised INSDC AST format dataclass imported from linkML (e.g., [linkML documentation example](https://linkml.io/linkml/intro/tutorial05.html))
- Input parent class with generic functions for parsing, iterating, write, applying mappings (e.g., [hAMRonizedResultIterator](https://github.com/pha4ge/hAMRonization/blob/master/hAMRonization/Interfaces.py#L15))
- For each Vitek/Phoenix/Microtitre etc an iterator subclass that inherits from this input parent class including specific mappings and any adjustments to generic functions needed (e.g., [tool specific hAMRonization classes](https://github.com/pha4ge/hAMRonization/blob/master/hAMRonization/StarAmrIO.py#L14))

Using the linkml runtime - the dataclasses are generated as follows:

gen-python convast/schema/NCBI_schema.yaml > convast/schema.py
1 change: 1 addition & 0 deletions convast/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Module init"""

from .version import VERSION, VERSION_SHORT
8 changes: 3 additions & 5 deletions convast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
import argparse
from .utils import check_file_exists, initialise_logger


def generate_cli():
"""
Create the CLI interface for the AST entrypoint
"""
parser = argparse.ArgumentParser(
description="Converts antibiotic susceptibility "
"testing data to INSDC standardised format"
description="Converts antibiotic susceptibility " "testing data to INSDC standardised format"
)

# takes input file and confirms it exists
parser.add_argument("input_file", help="The input file to convert", type=check_file_exists)
parser.add_argument(
"-f", "--format", help="Origin of input file", required=True, choices=["VITEK"]
)
parser.add_argument("-f", "--format", help="Origin of input file", required=True, choices=["VITEK"])
parser.add_argument("-o", "--output", help="The output file destination")
return parser

Expand Down
21 changes: 20 additions & 1 deletion convast/convast.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python
import dataclasses

# implement parent convast class including linkml output

@dataclasses.dataclass
class ConvAST:
"""
Single INSDC compatible AST result entry
Should be generated directly from LinkML yaml
"""

def to_ena(self):
"""
Export just ENA fields
"""
raise NotImplementedError("ENA export not implemented")

def to_ncbi(self):
"""
Export just NCBI fields
"""
raise NotImplementedError("NCBI export not implemented")
763 changes: 763 additions & 0 deletions convast/schema.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions convast/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""General utility functions for convast"""

from pathlib import Path
import logging
import argparse
Expand Down
1 change: 1 addition & 0 deletions convast/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Version information for the package"""

_MAJOR = "0"
_MINOR = "1"
# On main and in a nightly release the patch should be one ahead of the last
Expand Down
19 changes: 2 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ Changelog = "https://github.com/pha4ge/convast/blob/main/CHANGELOG.md"
dev = [
"ruff",
"black",
"pylint",
"pytest",
"pytest-cov",
"twine>=1.11.0",
"build",
"setuptools",
Expand All @@ -57,15 +55,13 @@ include-package-data = true
version = {attr = "convast.version.VERSION"}

[tool.black]
line-length = 100
line-length = 115
include = '\.pyi?$'
exclude = '''
(
__pycache__
| \.git
| \.mypy_cache
| \.pytest_cache
| \.vscode
| \.venv
| \bdist\b
| \bdoc\b
Expand All @@ -75,19 +71,8 @@ exclude = '''
[tool.ruff]
line-length = 115
target-version = "py39"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.pylint.'MESSAGES CONTROL']
max-line-length = 115
disable = """
logging-fstring-interpolation
"""

[tool.pytest.ini_options]
testpaths = "tests/"
python_classes = [
"Test*",
"*Test"
]
Binary file added tests/data/sensititre_output.txt
Binary file not shown.

0 comments on commit 6aff7fd

Please sign in to comment.