From 841ad711ed5410355b10cc941a5aa8b797c2d609 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 15 Jul 2024 09:03:44 -0400 Subject: [PATCH 1/5] cicd: update precommit (#558) --- .pre-commit-config.yaml | 5 ++++- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e29f947..c26e7201 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,15 +2,18 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 # pre-commit-hooks version hooks: - id: check-added-large-files - id: detect-private-key - id: trailing-whitespace - id: end-of-file-fixer + - id: check-merge-conflict + - id: detect-aws-credentials - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.2.0 hooks: - id: ruff-format - id: ruff args: [ --fix, --exit-non-zero-on-fix ] +minimum_pre_commit_version: 3.7.1 diff --git a/pyproject.toml b/pyproject.toml index 8bf197ac..50beb708 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dynamic = ["version"] [project.optional-dependencies] test = ["pytest>=6.0", "pytest-cov", "pytest-asyncio"] -dev = ["pre-commit", "ruff==0.2.0", "psycopg2-binary", "jupyter", "ipykernel"] +dev = ["pre-commit>=3.7.1", "ruff==0.2.0", "psycopg2-binary", "jupyter", "ipykernel"] [project.urls] Homepage = "https://github.com/cancervariants/variation-normalization" From 4e1fd34fa968fa7face12b8daed90c78652193ba Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 15 Jul 2024 09:13:40 -0400 Subject: [PATCH 2/5] cicd: update workflows/templates from template repo (#556) --- .github/ISSUE_TEMPLATE/bug-report.yaml | 85 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yaml | 60 +++++++++++++++ .github/workflows/checks.yaml | 8 +- .github/workflows/release.yml | 6 +- .github/workflows/stale.yaml | 27 +++++++ 5 files changed, 179 insertions(+), 7 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yaml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yaml create mode 100644 .github/workflows/stale.yaml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml new file mode 100644 index 00000000..5b3f7c8d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -0,0 +1,85 @@ +name: Bug Report +description: Report a bug. +labels: ["bug"] +body: + - type: textarea + attributes: + label: Describe the bug + description: Provide a clear and concise description of what the bug is. + validations: + required: true + - type: textarea + attributes: + label: Steps to reproduce + description: Provide detailed steps to replicate the bug. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: true + - type: textarea + attributes: + label: Expected behavior + description: What did you expect to happen? + validations: + required: true + - type: textarea + attributes: + label: Current behavior + description: | + What actually happened? + + Include full errors, stack traces, and/or relevant logs. + validations: + required: true + - type: textarea + attributes: + label: Possible reason(s) + description: Provide any insights into what might be causing the issue. + validations: + required: false + - type: textarea + attributes: + label: Suggested fix + description: Provide any suggestions on how to resolve the bug. + validations: + required: false + - type: textarea + attributes: + label: Branch, commit, and/or version + description: Provide the branch, commit, and/or version you're using. + placeholder: | + branch: issue-1 + commit: abc123d + validations: + required: true + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots with descriptions to help explain your problem. + validations: + required: false + - type: textarea + attributes: + label: Environment details + description: Provide environment details (OS name and version, etc). + validations: + required: true + - type: textarea + attributes: + label: Additional details + description: Provide any other additional details about the problem. + validations: + required: false + - type: dropdown + attributes: + label: Contribution + description: Can you contribute to the development of this feature? + options: + - "Yes, I can create a PR for this fix." + - "Yes, but I can only provide ideas and feedback." + - "No, I cannot contribute." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yaml b/.github/ISSUE_TEMPLATE/feature-request.yaml new file mode 100644 index 00000000..2e1ae644 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yaml @@ -0,0 +1,60 @@ +name: Feature Request +description: Suggest an idea for this project. +labels: ["enhancement"] +body: + - type: textarea + attributes: + label: Feature description + description: Provide a clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Use case + description: | + Why do you need this feature? For example: "I'm always frustrated when..." + validations: + required: true + - type: textarea + attributes: + label: Proposed solution + description: Provide proposed solution. + validations: + required: false + - type: textarea + attributes: + label: Alternatives considered + description: Describe any alternative solutions you've considered. + validations: + required: false + - type: textarea + attributes: + label: Implementation details + description: Provide any technical details on how the feature might be implemented. + validations: + required: false + - type: textarea + attributes: + label: Potential Impact + description: | + Discuss any potential impacts of this feature on existing functionality or performance, if known. + Will this feature cause breaking changes? + What challenges might arise? + validations: + required: false + - type: textarea + attributes: + label: Additional context + description: Provide any other context or screenshots about the feature. + validations: + required: false + - type: dropdown + attributes: + label: Contribution + description: Can you contribute to the development of this feature? + options: + - "Yes, I can create a PR for this feature." + - "Yes, but I can only provide ideas and feedback." + - "No, I cannot contribute." + validations: + required: false diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index be38f3bf..9ffadd69 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -9,10 +9,10 @@ jobs: matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -23,10 +23,10 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d8c7ac3..c3bff3c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install pypa/build @@ -25,7 +25,7 @@ jobs: - name: Build a binary wheel and a source tarball run: python3 -m build - name: Store the distribution packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ @@ -42,7 +42,7 @@ jobs: id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Download all the dists - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml new file mode 100644 index 00000000..6a7b1339 --- /dev/null +++ b/.github/workflows/stale.yaml @@ -0,0 +1,27 @@ +name: "Stalebot for issues and PRs" + +on: + schedule: + - cron: "30 13 * * 1-5" + +jobs: + stale-high-priority: + uses: genomicmedlab/software-templates/.github/workflows/reusable-stale.yaml + with: + days-before-issue-stale: 90 + days-before-pr-stale: 1 + labels: priority:high + + stale-medium-priority: + uses: genomicmedlab/software-templates/.github/workflows/reusable-stale.yaml + with: + days-before-issue-stale: 135 + days-before-pr-stale: 3 + labels: priority:medium + + stale-low-priority: + uses: genomicmedlab/software-templates/.github/workflows/reusable-stale.yaml + with: + days-before-issue-stale: 180 + days-before-pr-stale: 7 + labels: priority:low From a774a11eef15d2c7b5694f345efe73844270b0d8 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 15 Jul 2024 09:26:06 -0400 Subject: [PATCH 3/5] feat: enable more precise logging configuration (#559) --- src/variation/__init__.py | 29 ------------- src/variation/log_config.py | 55 ++++++++++++++++++++++++ src/variation/main.py | 28 +++++++++--- src/variation/validators/genomic_base.py | 5 +-- tests/conftest.py | 28 ++++++++++++ 5 files changed, 107 insertions(+), 38 deletions(-) create mode 100644 src/variation/log_config.py diff --git a/src/variation/__init__.py b/src/variation/__init__.py index a7a9ad81..552cb43a 100644 --- a/src/variation/__init__.py +++ b/src/variation/__init__.py @@ -1,30 +1 @@ """The Variation Normalization package.""" -import logging -from os import environ - -if "VARIATION_NORM_EB_PROD" in environ: - LOG_FN = "/tmp/variation.log" # noqa: S108 -else: - LOG_FN = "variation.log" - -logging.basicConfig( - filename=LOG_FN, format="[%(asctime)s] - %(name)s - %(levelname)s : %(message)s" -) -logger = logging.getLogger("variation") -logger.setLevel(logging.DEBUG) -logger.handlers = [] - -logging.getLogger("cool_seq_tool").setLevel(logging.INFO) -logging.getLogger("boto3").setLevel(logging.INFO) -logging.getLogger("botocore").setLevel(logging.INFO) -logging.getLogger("urllib3").setLevel(logging.INFO) -logging.getLogger("python_jsonschema_objects").setLevel(logging.INFO) -logging.getLogger("hgvs.parser").setLevel(logging.INFO) -logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel(logging.INFO) -logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO) -logging.getLogger("asyncio").setLevel(logging.INFO) - -if "VARIATION_NORM_EB_PROD" in environ: - ch = logging.StreamHandler() - ch.setLevel(logging.INFO) - logger.addHandler(ch) diff --git a/src/variation/log_config.py b/src/variation/log_config.py new file mode 100644 index 00000000..4360dfe8 --- /dev/null +++ b/src/variation/log_config.py @@ -0,0 +1,55 @@ +"""Provide functions and variables for logging setup. + +We may need to set up common logging protocols for a few different entry points when +running the Variation Normalizer as an app, but we shouldn't dictate anything to +downstream users. Functions in this module should only be called from locations in code +that are being executed directly by users, not from anywhere that might be imported as +a library. +""" + +import logging +import os + + +def _quiet_upstream_libs() -> None: + """Turn off debug logging for chatty upstream library loggers.""" + for lib in ( + "boto3", + "botocore", + "urllib3", + "hgvs.parser", + "biocommons.seqrepo.seqaliasdb.seqaliasdb", + "biocommons.seqrepo.fastadir.fastadir", + "asyncio", + ): + logging.getLogger(lib).setLevel(logging.INFO) + + +def configure_logging( + log_level: int = logging.DEBUG, quiet_upstream: bool = True +) -> None: + """Configure logging. + + :param log_level: global log level to set + :param quiet_upstream: if True, turn off debug logging for a selection of libraries + """ + log_filename = ( + "/tmp/variation.log" # noqa: S108 + if "VARIATION_NORM_EB_PROD" in os.environ + else "variation.log" + ) + if quiet_upstream: + _quiet_upstream_libs() + logging.basicConfig( + filename=log_filename, + format="[%(asctime)s] - %(name)s - %(levelname)s : %(message)s", + ) + logger = logging.getLogger("variation") + logger.setLevel(log_level) + + if "VARIATION_NORM_EB_PROD" in os.environ: + # force debug logging in production server + logger.handlers = [] + handler = logging.StreamHandler() + handler.setLevel(logging.DEBUG) + logger.addHandler(handler) diff --git a/src/variation/main.py b/src/variation/main.py index bdb675d2..e5becbda 100644 --- a/src/variation/main.py +++ b/src/variation/main.py @@ -1,6 +1,9 @@ """Main application for FastAPI.""" import datetime +import logging import traceback +from collections.abc import AsyncGenerator +from contextlib import asynccontextmanager from enum import Enum from typing import List, Optional, Union from urllib.parse import unquote @@ -14,7 +17,7 @@ from hgvs.exceptions import HGVSError from pydantic import ValidationError -from variation import logger +from variation.log_config import configure_logging from variation.query import QueryHandler from variation.schemas import ServiceMeta from variation.schemas.copy_number_schema import ( @@ -42,6 +45,8 @@ ) from variation.version import __version__ +_logger = logging.getLogger(__name__) + class Tag(Enum): """Define tag names for endpoints""" @@ -57,6 +62,17 @@ class Tag(Enum): query_handler = QueryHandler() +@asynccontextmanager +async def lifespan(app: FastAPI) -> AsyncGenerator: + """Configure FastAPI instance lifespan. + + :param app: FastAPI app instance + :return: async context handler + """ + configure_logging() + yield + + app = FastAPI( title="The VICC Variation Normalizer", description="Services and guidelines for normalizing variations.", @@ -537,7 +553,7 @@ def parsed_to_cn_var(request_body: ParsedToCnVarQuery) -> dict: resp = query_handler.to_copy_number_handler.parsed_to_copy_number(request_body) except Exception: traceback_resp = traceback.format_exc().splitlines() - logger.exception(traceback_resp) + _logger.exception(traceback_resp) return ParsedToCnVarService( copy_number_count=None, @@ -570,7 +586,7 @@ def parsed_to_cx_var(request_body: ParsedToCxVarQuery) -> dict: resp = query_handler.to_copy_number_handler.parsed_to_copy_number(request_body) except Exception: traceback_resp = traceback.format_exc().splitlines() - logger.exception(traceback_resp) + _logger.exception(traceback_resp) return ParsedToCxVarService( copy_number_count=None, @@ -664,7 +680,7 @@ async def p_to_c( p_ac, p_start_pos, p_end_pos, residue_mode ) except Exception as e: - logger.error("Unhandled exception: %s", str(e)) + _logger.error("Unhandled exception: %s", str(e)) w = "Unhandled exception. See logs for more information." c_data = None return ToCdnaService( @@ -724,7 +740,7 @@ async def c_to_g( target_genome_assembly=target_genome_assembly, ) except Exception as e: - logger.error("Unhandled exception: %s", str(e)) + _logger.error("Unhandled exception: %s", str(e)) w = "Unhandled exception. See logs for more information." g_data = None return ToGenomicService( @@ -778,7 +794,7 @@ async def p_to_g( target_genome_assembly=target_genome_assembly, ) except Exception as e: - logger.error("Unhandled exception: %s", str(e)) + _logger.error("Unhandled exception: %s", str(e)) w = "Unhandled exception. See logs for more information." g_data = None return ToGenomicService( diff --git a/src/variation/validators/genomic_base.py b/src/variation/validators/genomic_base.py index eafad2df..95b5d615 100644 --- a/src/variation/validators/genomic_base.py +++ b/src/variation/validators/genomic_base.py @@ -10,8 +10,7 @@ Nomenclature, ) -logger = logging.getLogger("variation") -logger.setLevel(logging.DEBUG) +_logger = logging.getLogger(__name__) class GenomicBase: @@ -58,7 +57,7 @@ def get_nc_accession(self, identifier: str) -> Optional[str]: identifier ) except KeyError: - logger.warning("Data Proxy unable to get metadata for %s", identifier) + _logger.warning("Data Proxy unable to get metadata for %s", identifier) else: aliases = [a for a in translated_identifiers if a.startswith("refseq:NC_")] if aliases: diff --git a/tests/conftest.py b/tests/conftest.py index 09865eed..dd872a60 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ """Create methods used throughout tests.""" import asyncio import contextlib +import logging import pytest from cool_seq_tool.app import CoolSeqTool @@ -14,6 +15,33 @@ from variation.tokenizers import GeneSymbol +def pytest_addoption(parser): + """Add custom commands to pytest invocation. + See https://docs.pytest.org/en/7.1.x/reference/reference.html#parser + """ + parser.addoption( + "--verbose-logs", + action="store_true", + default=False, + help="show noisy module logs", + ) + + +def pytest_configure(config): + """Configure pytest setup.""" + if not config.getoption("--verbose-logs"): + logging.getLogger("cool_seq_tool").setLevel(logging.INFO) + logging.getLogger("boto3").setLevel(logging.ERROR) + logging.getLogger("botocore").setLevel(logging.ERROR) + logging.getLogger("urllib3.connectionpool").setLevel(logging.ERROR) + logging.getLogger("hgvs.parser").setLevel(logging.INFO) + logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel( + logging.INFO + ) + logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO) + logging.getLogger("asyncio").setLevel(logging.INFO) + + @pytest.fixture(scope="session") def event_loop(): """Create an instance of the default event loop for each test case.""" From f8e2c8380e21511073eaea86b5620691116c53df Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 15 Jul 2024 11:20:42 -0400 Subject: [PATCH 4/5] cicd: update precommit dependency in pipfile (#560) --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index ae4f085d..d4a1a865 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ verify_ssl = true pytest = "*" pytest-asyncio = "*" pytest-cov = "*" -pre-commit = "*" +pre-commit = ">=3.7.1" variation-normalizer = {editable = true, path = "."} jupyter = "*" ipykernel = "*" From a659989332a7375e67112add495ada2e9f6ebeaa Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 15 Jul 2024 11:20:54 -0400 Subject: [PATCH 5/5] style: update ruff (#557) --- .pre-commit-config.yaml | 2 +- Pipfile | 2 +- pyproject.toml | 32 ++++++-- src/variation/classifiers/__init__.py | 1 + .../classifiers/amplification_classifier.py | 1 + .../classifiers/cdna_deletion_classifier.py | 1 + .../classifiers/cdna_delins_classifier.py | 1 + .../classifiers/cdna_insertion_classifier.py | 1 + .../cdna_reference_agree_classifier.py | 1 + .../cdna_substitution_classifier.py | 1 + src/variation/classifiers/classifier.py | 9 +-- .../classifiers/genomic_deletion_ambiguous.py | 1 + .../genomic_deletion_classifier.py | 1 + .../classifiers/genomic_delins_classifier.py | 1 + .../genomic_duplication_ambiguous.py | 1 + .../genomic_duplication_classifier.py | 1 + .../genomic_insertion_classifier.py | 1 + .../genomic_reference_agree_classifier.py | 1 + .../genomic_substitution_classifier.py | 1 + .../classifiers/gnomad_vcf_classifier.py | 1 + src/variation/classifiers/hgvs_classifier.py | 1 + .../protein_deletion_classifier.py | 1 + .../classifiers/protein_delins_classifier.py | 1 + .../protein_insertion_classifier.py | 1 + .../classifiers/protein_reference_agree.py | 1 + .../protein_stop_gain_classifier.py | 1 + .../protein_substitution_classifier.py | 1 + src/variation/classify.py | 1 + .../gnomad_vcf_to_protein_variation.py | 7 +- src/variation/hgvs_dup_del_mode.py | 1 + src/variation/main.py | 5 +- src/variation/normalize.py | 1 + src/variation/query.py | 1 + src/variation/regex.py | 1 + src/variation/schemas/__init__.py | 1 + src/variation/schemas/app_schemas.py | 1 + .../schemas/classification_response_schema.py | 81 ++++++++++--------- src/variation/schemas/copy_number_schema.py | 3 +- .../schemas/gnomad_vcf_to_protein_schema.py | 1 + .../schemas/hgvs_to_copy_number_schema.py | 1 + .../schemas/normalize_response_schema.py | 5 +- src/variation/schemas/service_schema.py | 1 + .../schemas/to_vrs_response_schema.py | 1 + .../schemas/token_response_schema.py | 17 ++-- .../schemas/translation_response_schema.py | 1 + .../schemas/validation_response_schema.py | 1 + src/variation/schemas/variation_schema.py | 1 + .../schemas/vrs_python_translator_schema.py | 5 +- src/variation/to_copy_number_variation.py | 1 + src/variation/to_vrs.py | 1 + src/variation/tokenize.py | 1 + src/variation/tokenizers/__init__.py | 1 + .../cdna_and_genomic_reference_agree.py | 1 + src/variation/tokenizers/cdna_deletion.py | 1 + src/variation/tokenizers/cdna_delins.py | 1 + src/variation/tokenizers/cdna_insertion.py | 1 + src/variation/tokenizers/cdna_substitution.py | 1 + .../tokenizers/free_text_categorical.py | 1 + src/variation/tokenizers/gene_symbol.py | 1 + src/variation/tokenizers/genomic_deletion.py | 1 + src/variation/tokenizers/genomic_delins.py | 1 + .../tokenizers/genomic_duplication.py | 1 + src/variation/tokenizers/genomic_insertion.py | 1 + .../tokenizers/genomic_substitution.py | 1 + src/variation/tokenizers/gnomad_vcf.py | 1 + src/variation/tokenizers/hgvs.py | 1 + src/variation/tokenizers/protein_deletion.py | 1 + src/variation/tokenizers/protein_delins.py | 1 + src/variation/tokenizers/protein_insertion.py | 1 + .../tokenizers/protein_reference_agree.py | 1 + .../tokenizers/protein_substitution.py | 1 + src/variation/tokenizers/tokenizer.py | 1 + src/variation/translate.py | 1 + src/variation/translators/__init__.py | 1 + .../translators/ambiguous_translator_base.py | 1 + src/variation/translators/amplification.py | 1 + src/variation/translators/cdna_deletion.py | 1 + src/variation/translators/cdna_delins.py | 1 + src/variation/translators/cdna_insertion.py | 1 + .../translators/cdna_reference_agree.py | 1 + .../translators/cdna_substitution.py | 1 + .../translators/genomic_del_dup_base.py | 1 + src/variation/translators/genomic_deletion.py | 1 + .../translators/genomic_deletion_ambiguous.py | 1 + src/variation/translators/genomic_delins.py | 1 + .../translators/genomic_duplication.py | 1 + .../genomic_duplication_ambiguous.py | 1 + .../translators/genomic_insertion.py | 1 + .../translators/genomic_reference_agree.py | 1 + .../translators/genomic_substitution.py | 1 + src/variation/translators/protein_deletion.py | 1 + src/variation/translators/protein_delins.py | 1 + .../translators/protein_insertion.py | 1 + .../translators/protein_reference_agree.py | 1 + .../translators/protein_stop_gain.py | 1 + .../translators/protein_substitution.py | 1 + src/variation/translators/translator.py | 1 + src/variation/utils.py | 1 + src/variation/validate.py | 1 + src/variation/validators/__init__.py | 1 + src/variation/validators/amplification.py | 1 + src/variation/validators/cdna_deletion.py | 1 + src/variation/validators/cdna_delins.py | 1 + src/variation/validators/cdna_insertion.py | 1 + .../validators/cdna_reference_agree.py | 1 + src/variation/validators/cdna_substitution.py | 1 + src/variation/validators/genomic_base.py | 1 + src/variation/validators/genomic_deletion.py | 1 + .../validators/genomic_deletion_ambiguous.py | 1 + src/variation/validators/genomic_delins.py | 1 + .../validators/genomic_duplication.py | 1 + .../genomic_duplication_ambiguous.py | 1 + src/variation/validators/genomic_insertion.py | 1 + .../validators/genomic_reference_agree.py | 1 + .../validators/genomic_substitution.py | 1 + src/variation/validators/protein_deletion.py | 1 + src/variation/validators/protein_delins.py | 1 + src/variation/validators/protein_insertion.py | 1 + .../validators/protein_reference_agree.py | 1 + src/variation/validators/protein_stop_gain.py | 1 + .../validators/protein_substitution.py | 1 + src/variation/validators/validator.py | 1 + src/variation/version.py | 1 + src/variation/vrs_representation.py | 1 + tests/__init__.py | 1 + tests/conftest.py | 1 + tests/test_classifier.py | 1 + tests/test_gnomad_vcf_to_protein.py | 1 + tests/test_hgvs_dup_del_mode.py | 1 + tests/test_normalize.py | 3 +- tests/test_tokenizer.py | 1 + tests/test_translator.py | 1 + tests/test_validator.py | 1 + .../test_amplification_to_cx_var.py | 1 + .../test_parsed_to_copy_number.py | 1 + 135 files changed, 222 insertions(+), 72 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c26e7201..947ee236 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: check-merge-conflict - id: detect-aws-credentials - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.5.0 # ruff version hooks: - id: ruff-format - id: ruff diff --git a/Pipfile b/Pipfile index d4a1a865..1c845f67 100644 --- a/Pipfile +++ b/Pipfile @@ -12,7 +12,7 @@ variation-normalizer = {editable = true, path = "."} jupyter = "*" ipykernel = "*" psycopg2-binary = "*" -ruff = "==0.2.0" +ruff = "==0.5.0" [packages] "biocommons.seqrepo" = "*" diff --git a/pyproject.toml b/pyproject.toml index 50beb708..6ba29f00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dynamic = ["version"] [project.optional-dependencies] test = ["pytest>=6.0", "pytest-cov", "pytest-asyncio"] -dev = ["pre-commit>=3.7.1", "ruff==0.2.0", "psycopg2-binary", "jupyter", "ipykernel"] +dev = ["pre-commit>=3.7.1", "ruff==0.5.0", "psycopg2-binary", "jupyter", "ipykernel"] [project.urls] Homepage = "https://github.com/cancervariants/variation-normalization" @@ -72,6 +72,9 @@ branch = true [tool.ruff] src = ["src"] +extend-exclude = [ + "codebuild/*" +] [tool.ruff.lint] select = [ @@ -90,16 +93,22 @@ select = [ "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + "LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g + "INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp "PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q "RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse "RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret + "SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim + "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg "PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh + "PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf + "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf ] fixable = [ @@ -110,15 +119,19 @@ fixable = [ "ANN", "B", "C4", + "LOG", "G", "PIE", "PT", "RSE", "SIM", + "PERF", + "FURB", "RUF" ] -# ANN101 - missing-type-self # ANN003 - missing-type-kwargs +# ANN101 - missing-type-self +# ANN102 - missing-type-cls # D203 - one-blank-line-before-class # D205 - blank-line-after-summary # D206 - indent-with-spaces* @@ -134,7 +147,7 @@ fixable = [ # PGH003 - blanket-type-ignore # *ignored for compatibility with formatter ignore = [ - "ANN101", "ANN003", + "ANN003", "ANN101", "ANN102", "D203", "D205", "D206", "D213", "D300", "D400", "D415", "E111", "E114", "E117", "E501", "W191", @@ -146,15 +159,22 @@ ignore = [ # ANN001 - missing-type-function-argument # ANN2 - missing-return-type # ANN201 - Missing type annotation -# ANN102 - missing-type-cls # N805 - invalid-first-argument-name-for-method # S101 - assert # B011 - assert-false +# SLF001 - private-member-access +# INP001 - implicit-namespace-package # RUF001 - ambiguous-unicode-character-string -"tests/*" = ["ANN001", "ANN102", "ANN2", "S101", "B011"] +# ARG002 - unused-method-argument +"tests/*" = ["ANN001", "ANN2", "S101", "B011", "SLF001", "INP001"] "src/variation/schemas/*" = ["ANN001", "ANN201", "N805", "S101"] -"codebuild/*" = ["T201"] +"codebuild/*" = ["T201", "INP001"] +"src/variation/validators/*" = ["ARG002"] +"src/variation/translators/*" = ["ARG002"] [tool.ruff.lint.flake8-bugbear] # Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`. extend-immutable-calls = ["fastapi.Query"] + +[tool.ruff.format] +docstring-code-format = true diff --git a/src/variation/classifiers/__init__.py b/src/variation/classifiers/__init__.py index 6b68ec5f..fd43e822 100644 --- a/src/variation/classifiers/__init__.py +++ b/src/variation/classifiers/__init__.py @@ -1,4 +1,5 @@ """Classifier package level import.""" + from .amplification_classifier import AmplificationClassifier from .cdna_deletion_classifier import CdnaDeletionClassifier from .cdna_delins_classifier import CdnaDelInsClassifier diff --git a/src/variation/classifiers/amplification_classifier.py b/src/variation/classifiers/amplification_classifier.py index 69bb6832..6f9ed19f 100644 --- a/src/variation/classifiers/amplification_classifier.py +++ b/src/variation/classifiers/amplification_classifier.py @@ -1,4 +1,5 @@ """A module for the Amplification Classifier""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/cdna_deletion_classifier.py b/src/variation/classifiers/cdna_deletion_classifier.py index 929854c1..173b1865 100644 --- a/src/variation/classifiers/cdna_deletion_classifier.py +++ b/src/variation/classifiers/cdna_deletion_classifier.py @@ -1,4 +1,5 @@ """A module for the Cdna Deletion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/cdna_delins_classifier.py b/src/variation/classifiers/cdna_delins_classifier.py index 891906e1..2a66716f 100644 --- a/src/variation/classifiers/cdna_delins_classifier.py +++ b/src/variation/classifiers/cdna_delins_classifier.py @@ -1,4 +1,5 @@ """A module for the Cdna DelIns Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/cdna_insertion_classifier.py b/src/variation/classifiers/cdna_insertion_classifier.py index dd4daf01..a488c53d 100644 --- a/src/variation/classifiers/cdna_insertion_classifier.py +++ b/src/variation/classifiers/cdna_insertion_classifier.py @@ -1,4 +1,5 @@ """A module for the Cdna insertion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/cdna_reference_agree_classifier.py b/src/variation/classifiers/cdna_reference_agree_classifier.py index 297dc7eb..2c544d23 100644 --- a/src/variation/classifiers/cdna_reference_agree_classifier.py +++ b/src/variation/classifiers/cdna_reference_agree_classifier.py @@ -1,4 +1,5 @@ """A module for the cDNA Reference Agree Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/cdna_substitution_classifier.py b/src/variation/classifiers/cdna_substitution_classifier.py index aad05ba1..f82f2214 100644 --- a/src/variation/classifiers/cdna_substitution_classifier.py +++ b/src/variation/classifiers/cdna_substitution_classifier.py @@ -1,4 +1,5 @@ """A module for the Cdna Substitution Classifier.""" + from typing import List, Optional from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/classifier.py b/src/variation/classifiers/classifier.py index beaea3ce..799381a4 100644 --- a/src/variation/classifiers/classifier.py +++ b/src/variation/classifiers/classifier.py @@ -1,4 +1,5 @@ """Module for Classification methods.""" + from abc import ABC, abstractmethod from typing import List, Optional @@ -35,10 +36,8 @@ def can_classify(self, tokens: List[Token]) -> bool: matters, to represent a given classification. `False`, otherwise. """ token_types = [t.token_type for t in tokens] - exact_matches: List[List[str]] = [] - - for candidate in self.exact_match_candidates(): - if token_types == candidate: - exact_matches.append(candidate) + exact_matches: List[List[TokenType]] = [ + c for c in self.exact_match_candidates() if token_types == c + ] return len(exact_matches) == 1 diff --git a/src/variation/classifiers/genomic_deletion_ambiguous.py b/src/variation/classifiers/genomic_deletion_ambiguous.py index 6173b651..17333bde 100644 --- a/src/variation/classifiers/genomic_deletion_ambiguous.py +++ b/src/variation/classifiers/genomic_deletion_ambiguous.py @@ -1,4 +1,5 @@ """A module for the Genomic Deletion Ambiguous Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_deletion_classifier.py b/src/variation/classifiers/genomic_deletion_classifier.py index e5b60f07..c31e8299 100644 --- a/src/variation/classifiers/genomic_deletion_classifier.py +++ b/src/variation/classifiers/genomic_deletion_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic Deletion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_delins_classifier.py b/src/variation/classifiers/genomic_delins_classifier.py index 9be0530b..4801a3fa 100644 --- a/src/variation/classifiers/genomic_delins_classifier.py +++ b/src/variation/classifiers/genomic_delins_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic DelIns Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_duplication_ambiguous.py b/src/variation/classifiers/genomic_duplication_ambiguous.py index 6bcf9a5b..80ed1dbe 100644 --- a/src/variation/classifiers/genomic_duplication_ambiguous.py +++ b/src/variation/classifiers/genomic_duplication_ambiguous.py @@ -1,4 +1,5 @@ """A module for the Genomic Duplication Ambiguous Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_duplication_classifier.py b/src/variation/classifiers/genomic_duplication_classifier.py index 271eb962..0c777bee 100644 --- a/src/variation/classifiers/genomic_duplication_classifier.py +++ b/src/variation/classifiers/genomic_duplication_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic Duplication Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_insertion_classifier.py b/src/variation/classifiers/genomic_insertion_classifier.py index 09a362e8..68133968 100644 --- a/src/variation/classifiers/genomic_insertion_classifier.py +++ b/src/variation/classifiers/genomic_insertion_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic Insertion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_reference_agree_classifier.py b/src/variation/classifiers/genomic_reference_agree_classifier.py index ccf9d939..b8c6eaa7 100644 --- a/src/variation/classifiers/genomic_reference_agree_classifier.py +++ b/src/variation/classifiers/genomic_reference_agree_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic Reference Agree Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/genomic_substitution_classifier.py b/src/variation/classifiers/genomic_substitution_classifier.py index 0c2c47a7..64015813 100644 --- a/src/variation/classifiers/genomic_substitution_classifier.py +++ b/src/variation/classifiers/genomic_substitution_classifier.py @@ -1,4 +1,5 @@ """A module for the Genomic Substitution Classifier.""" + from typing import List, Optional from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/gnomad_vcf_classifier.py b/src/variation/classifiers/gnomad_vcf_classifier.py index 9a5b8a3e..3d2fc7bd 100644 --- a/src/variation/classifiers/gnomad_vcf_classifier.py +++ b/src/variation/classifiers/gnomad_vcf_classifier.py @@ -1,4 +1,5 @@ """A module for the gnomAD VCF Classifier""" + from typing import List, Optional, Union from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/hgvs_classifier.py b/src/variation/classifiers/hgvs_classifier.py index f81b8391..7921b874 100644 --- a/src/variation/classifiers/hgvs_classifier.py +++ b/src/variation/classifiers/hgvs_classifier.py @@ -1,4 +1,5 @@ """A module for the HGVS Classifier.""" + from re import Match, Pattern from typing import Dict, List, Optional diff --git a/src/variation/classifiers/protein_deletion_classifier.py b/src/variation/classifiers/protein_deletion_classifier.py index 402df0a4..29587fc9 100644 --- a/src/variation/classifiers/protein_deletion_classifier.py +++ b/src/variation/classifiers/protein_deletion_classifier.py @@ -1,4 +1,5 @@ """A module for the Protein Deletion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/protein_delins_classifier.py b/src/variation/classifiers/protein_delins_classifier.py index 2574288e..4ee65090 100644 --- a/src/variation/classifiers/protein_delins_classifier.py +++ b/src/variation/classifiers/protein_delins_classifier.py @@ -1,4 +1,5 @@ """A module for the Protein DelIns Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/protein_insertion_classifier.py b/src/variation/classifiers/protein_insertion_classifier.py index e0f6cb4d..1d8327ab 100644 --- a/src/variation/classifiers/protein_insertion_classifier.py +++ b/src/variation/classifiers/protein_insertion_classifier.py @@ -1,4 +1,5 @@ """A module for the Protein Insertion Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/protein_reference_agree.py b/src/variation/classifiers/protein_reference_agree.py index b0c6cd91..b25acc8f 100644 --- a/src/variation/classifiers/protein_reference_agree.py +++ b/src/variation/classifiers/protein_reference_agree.py @@ -1,4 +1,5 @@ """A module for the Reference Agree Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/protein_stop_gain_classifier.py b/src/variation/classifiers/protein_stop_gain_classifier.py index 1c959865..ff3879f2 100644 --- a/src/variation/classifiers/protein_stop_gain_classifier.py +++ b/src/variation/classifiers/protein_stop_gain_classifier.py @@ -1,4 +1,5 @@ """A module for the Protein Stop Gain Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classifiers/protein_substitution_classifier.py b/src/variation/classifiers/protein_substitution_classifier.py index 7181f340..a225a42e 100644 --- a/src/variation/classifiers/protein_substitution_classifier.py +++ b/src/variation/classifiers/protein_substitution_classifier.py @@ -1,4 +1,5 @@ """A module for the Protein Substitution Classifier.""" + from typing import List from variation.classifiers.classifier import Classifier diff --git a/src/variation/classify.py b/src/variation/classify.py index cd1a4728..60573342 100644 --- a/src/variation/classify.py +++ b/src/variation/classify.py @@ -1,4 +1,5 @@ """Module for classification.""" + from typing import ClassVar, List, Optional from variation.classifiers import ( diff --git a/src/variation/gnomad_vcf_to_protein_variation.py b/src/variation/gnomad_vcf_to_protein_variation.py index 2cb8e4b0..e9d9fade 100644 --- a/src/variation/gnomad_vcf_to_protein_variation.py +++ b/src/variation/gnomad_vcf_to_protein_variation.py @@ -1,4 +1,5 @@ """Module for translating VCF-like to protein VRS Allele representation""" + import datetime from typing import List, Optional, Tuple @@ -67,7 +68,7 @@ def _trim_prefix_or_suffix( len_aa_alt = len(aa_alt) # Trim prefixes - range_len = len_aa_ref if len_aa_ref < len_aa_alt else len_aa_alt + range_len = min(len_aa_alt, len_aa_ref) aa_match = _get_char_match_count( range_len, aa_ref, aa_alt, trim_prefix=trim_prefix ) @@ -271,8 +272,8 @@ def _get_genomic_pos_range( for the original position change """ # Get cDNA reading frame - start_reading_frame = self.mane_transcript._get_reading_frame(c_start_pos + 1) - end_reading_frame = self.mane_transcript._get_reading_frame(c_end_pos) + start_reading_frame = self.mane_transcript._get_reading_frame(c_start_pos + 1) # noqa: SLF001 + end_reading_frame = self.mane_transcript._get_reading_frame(c_end_pos) # noqa: SLF001 # Get genomic position range change # This ensures that there 3 nucleotides needed for codon diff --git a/src/variation/hgvs_dup_del_mode.py b/src/variation/hgvs_dup_del_mode.py index c7df9e1c..4f92a0c9 100644 --- a/src/variation/hgvs_dup_del_mode.py +++ b/src/variation/hgvs_dup_del_mode.py @@ -1,4 +1,5 @@ """Module for hgvs_dup_del_mode in normalize endpoint.""" + from typing import Dict, List, Optional, Union from cool_seq_tool.handlers import SeqRepoAccess diff --git a/src/variation/main.py b/src/variation/main.py index e5becbda..70a15de3 100644 --- a/src/variation/main.py +++ b/src/variation/main.py @@ -1,4 +1,5 @@ """Main application for FastAPI.""" + import datetime import logging import traceback @@ -63,7 +64,7 @@ class Tag(Enum): @asynccontextmanager -async def lifespan(app: FastAPI) -> AsyncGenerator: +async def lifespan(app: FastAPI) -> AsyncGenerator: # noqa: ARG001 """Configure FastAPI instance lifespan. :param app: FastAPI app instance @@ -454,7 +455,7 @@ async def vrs_python_to_hgvs(request_body: TranslateToHGVSQuery) -> dict: variations = [] if allele: try: - variations = query_handler.vrs_python_tlr._to_hgvs( + variations = query_handler.vrs_python_tlr._to_hgvs( # noqa: SLF001 allele, namespace=request_body.get("namespace") or "refseq" ) except ValueError as e: diff --git a/src/variation/normalize.py b/src/variation/normalize.py index 699d7f81..7d67115b 100644 --- a/src/variation/normalize.py +++ b/src/variation/normalize.py @@ -1,4 +1,5 @@ """Module for Variation Normalization.""" + import datetime from typing import List, Optional, Tuple from urllib.parse import unquote diff --git a/src/variation/query.py b/src/variation/query.py index c0c68a3e..6f924a3b 100644 --- a/src/variation/query.py +++ b/src/variation/query.py @@ -1,4 +1,5 @@ """Module for providing methods for handling queries.""" + from typing import Optional from cool_seq_tool.app import CoolSeqTool diff --git a/src/variation/regex.py b/src/variation/regex.py index 182e98c7..b4fa7be9 100644 --- a/src/variation/regex.py +++ b/src/variation/regex.py @@ -1,4 +1,5 @@ """Module containing regex patterns""" + import re from typing import Any, List, Tuple diff --git a/src/variation/schemas/__init__.py b/src/variation/schemas/__init__.py index e6bfc5d6..40a7591e 100644 --- a/src/variation/schemas/__init__.py +++ b/src/variation/schemas/__init__.py @@ -1,4 +1,5 @@ """Package level import.""" + from .normalize_response_schema import NormalizeService, ServiceMeta from .to_vrs_response_schema import ToVRSService diff --git a/src/variation/schemas/app_schemas.py b/src/variation/schemas/app_schemas.py index 17f9d09b..15c71b29 100644 --- a/src/variation/schemas/app_schemas.py +++ b/src/variation/schemas/app_schemas.py @@ -1,4 +1,5 @@ """Module for schemas used throughout the app""" + from enum import Enum, IntEnum diff --git a/src/variation/schemas/classification_response_schema.py b/src/variation/schemas/classification_response_schema.py index 9b66fd9f..527e3374 100644 --- a/src/variation/schemas/classification_response_schema.py +++ b/src/variation/schemas/classification_response_schema.py @@ -1,4 +1,5 @@ """Module for Classification schema.""" + from enum import Enum from typing import List, Literal, Optional @@ -67,137 +68,137 @@ class Classification(BaseModel): class ProteinSubstitutionClassification(Classification, Substitution): """Define protein substitution classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_SUBSTITUTION] = ( ClassificationType.PROTEIN_SUBSTITUTION - ] = ClassificationType.PROTEIN_SUBSTITUTION + ) class GenomicSubstitutionClassification(Classification, Substitution): """Define genomic substitution classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_SUBSTITUTION] = ( ClassificationType.GENOMIC_SUBSTITUTION - ] = ClassificationType.GENOMIC_SUBSTITUTION + ) class CdnaSubstitutionClassification(Classification, Substitution): """Define cdna substitution classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.CDNA_SUBSTITUTION] = ( ClassificationType.CDNA_SUBSTITUTION - ] = ClassificationType.CDNA_SUBSTITUTION + ) class ProteinStopGainClassification(Classification, StopGain): """Define protein stop gain classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_STOP_GAIN] = ( ClassificationType.PROTEIN_STOP_GAIN - ] = ClassificationType.PROTEIN_STOP_GAIN + ) class ProteinReferenceAgreeClassification(Classification, ProteinReferenceAgree): """Define protein reference agree classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_REFERENCE_AGREE] = ( ClassificationType.PROTEIN_REFERENCE_AGREE - ] = ClassificationType.PROTEIN_REFERENCE_AGREE + ) class CdnaReferenceAgreeClassification(Classification, ReferenceAgree): """Define cdna reference agree classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.CDNA_REFERENCE_AGREE] = ( ClassificationType.CDNA_REFERENCE_AGREE - ] = ClassificationType.CDNA_REFERENCE_AGREE + ) class GenomicReferenceAgreeClassification(Classification, ReferenceAgree): """Define genomic reference agree classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_REFERENCE_AGREE] = ( ClassificationType.GENOMIC_REFERENCE_AGREE - ] = ClassificationType.GENOMIC_REFERENCE_AGREE + ) class ProteinInsertionClassification(Classification, ProteinInsertion): """Define protein insertion classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_INSERTION] = ( ClassificationType.PROTEIN_INSERTION - ] = ClassificationType.PROTEIN_INSERTION + ) class CdnaInsertionClassification(Classification, Insertion): """Define cdna insertion classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.CDNA_INSERTION] = ( ClassificationType.CDNA_INSERTION - ] = ClassificationType.CDNA_INSERTION + ) class GenomicInsertionClassification(Classification, Insertion): """Define genomic insertion classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_INSERTION] = ( ClassificationType.GENOMIC_INSERTION - ] = ClassificationType.GENOMIC_INSERTION + ) class ProteinDeletionClassification(Classification, ProteinDeletion): """Define protein deletion classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_DELETION] = ( ClassificationType.PROTEIN_DELETION - ] = ClassificationType.PROTEIN_DELETION + ) class GenomicDeletionClassification(Classification, Deletion): """Define genomic deletion classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_DELETION] = ( ClassificationType.GENOMIC_DELETION - ] = ClassificationType.GENOMIC_DELETION + ) class CdnaDeletionClassification(Classification, Deletion): """Define cdna classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.CDNA_DELETION] = ( ClassificationType.CDNA_DELETION - ] = ClassificationType.CDNA_DELETION + ) class ProteinDelInsClassification(Classification, ProteinDelIns): """Define protein delins classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.PROTEIN_DELINS] = ( ClassificationType.PROTEIN_DELINS - ] = ClassificationType.PROTEIN_DELINS + ) class CdnaDelInsClassification(Classification, DelIns): """Define cdna delins classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.CDNA_DELINS] = ( ClassificationType.CDNA_DELINS - ] = ClassificationType.CDNA_DELINS + ) class GenomicDelInsClassification(Classification, DelIns): """Define genomic delins classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_DELINS] = ( ClassificationType.GENOMIC_DELINS - ] = ClassificationType.GENOMIC_DELINS + ) class GenomicDuplicationClassification(Classification, Duplication): """Define genomic duplication classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_DUPLICATION] = ( ClassificationType.GENOMIC_DUPLICATION - ] = ClassificationType.GENOMIC_DUPLICATION + ) class AmbiguousType(str, Enum): @@ -215,24 +216,24 @@ class AmbiguousType(str, Enum): class GenomicDuplicationAmbiguousClassification(Classification, DupDelAmbiguous): """Define genomic duplication ambiguous classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_DUPLICATION_AMBIGUOUS] = ( ClassificationType.GENOMIC_DUPLICATION_AMBIGUOUS - ] = ClassificationType.GENOMIC_DUPLICATION_AMBIGUOUS + ) ambiguous_type: AmbiguousType class GenomicDeletionAmbiguousClassification(Classification, DupDelAmbiguous): """Define genomic deletion ambiguous classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.GENOMIC_DELETION_AMBIGUOUS] = ( ClassificationType.GENOMIC_DELETION_AMBIGUOUS - ] = ClassificationType.GENOMIC_DELETION_AMBIGUOUS + ) ambiguous_type: AmbiguousType class AmplificationClassification(Classification): """Define amplification classification""" - classification_type: Literal[ + classification_type: Literal[ClassificationType.AMPLIFICATION] = ( ClassificationType.AMPLIFICATION - ] = ClassificationType.AMPLIFICATION + ) diff --git a/src/variation/schemas/copy_number_schema.py b/src/variation/schemas/copy_number_schema.py index cf53717f..f464bf79 100644 --- a/src/variation/schemas/copy_number_schema.py +++ b/src/variation/schemas/copy_number_schema.py @@ -1,4 +1,5 @@ """Module containing schemas for services""" + import re from enum import Enum from typing import Dict, Optional @@ -44,7 +45,7 @@ class ClinVarAssembly(str, Enum): HG18 = "hg18" -def validate_parsed_fields(cls, v: Dict) -> Dict: +def validate_parsed_fields(cls, v: Dict) -> Dict: # noqa: ARG001 """Validate base copy number query fields - `accession` or both `assembly` and `chromosome` must be provided - `start1` is required when `start_pos_type` is a definite diff --git a/src/variation/schemas/gnomad_vcf_to_protein_schema.py b/src/variation/schemas/gnomad_vcf_to_protein_schema.py index 2eb7dc6f..2467e407 100644 --- a/src/variation/schemas/gnomad_vcf_to_protein_schema.py +++ b/src/variation/schemas/gnomad_vcf_to_protein_schema.py @@ -1,4 +1,5 @@ """Module for gnomad vcf to protein response schema""" + from typing import Optional from ga4gh.core import core_models diff --git a/src/variation/schemas/hgvs_to_copy_number_schema.py b/src/variation/schemas/hgvs_to_copy_number_schema.py index 9ea9f60d..24098b8c 100644 --- a/src/variation/schemas/hgvs_to_copy_number_schema.py +++ b/src/variation/schemas/hgvs_to_copy_number_schema.py @@ -1,4 +1,5 @@ """Module containing schemas used in HGVS To Copy Number endpoints""" + from typing import Optional from ga4gh.vrs import models diff --git a/src/variation/schemas/normalize_response_schema.py b/src/variation/schemas/normalize_response_schema.py index 3bdec411..7e210d1b 100644 --- a/src/variation/schemas/normalize_response_schema.py +++ b/src/variation/schemas/normalize_response_schema.py @@ -1,4 +1,5 @@ """Module for normalize endpoint response schema.""" + from datetime import datetime from enum import Enum from typing import List, Literal, Optional, Union @@ -26,9 +27,9 @@ class ServiceMeta(BaseModel): name: Literal["variation-normalizer"] = "variation-normalizer" version: StrictStr response_datetime: datetime - url: Literal[ + url: Literal["https://github.com/cancervariants/variation-normalization"] = ( "https://github.com/cancervariants/variation-normalization" - ] = "https://github.com/cancervariants/variation-normalization" + ) model_config = ConfigDict( json_schema_extra={ diff --git a/src/variation/schemas/service_schema.py b/src/variation/schemas/service_schema.py index acc1466d..595596ae 100644 --- a/src/variation/schemas/service_schema.py +++ b/src/variation/schemas/service_schema.py @@ -1,4 +1,5 @@ """Module containing schemas for services""" + from enum import Enum from cool_seq_tool.schemas import ToCdnaService as ToCdna diff --git a/src/variation/schemas/to_vrs_response_schema.py b/src/variation/schemas/to_vrs_response_schema.py index f5dcafd3..ab2cd7e0 100644 --- a/src/variation/schemas/to_vrs_response_schema.py +++ b/src/variation/schemas/to_vrs_response_schema.py @@ -1,4 +1,5 @@ """Module for to_vrs endpoint response schema.""" + from typing import List, Union from ga4gh.vrs import models diff --git a/src/variation/schemas/token_response_schema.py b/src/variation/schemas/token_response_schema.py index e7b84db6..455892b4 100644 --- a/src/variation/schemas/token_response_schema.py +++ b/src/variation/schemas/token_response_schema.py @@ -1,4 +1,5 @@ """Module for schemas related to tokenization.""" + from enum import Enum from typing import Literal, Optional @@ -131,9 +132,9 @@ class ProteinStopGainToken(Token, StopGain): class ProteinReferenceAgreeToken(Token, ProteinReferenceAgree): """Token for reference agree on protein reference sequence""" - token_type: Literal[ + token_type: Literal[TokenType.PROTEIN_REFERENCE_AGREE] = ( TokenType.PROTEIN_REFERENCE_AGREE - ] = TokenType.PROTEIN_REFERENCE_AGREE + ) coordinate_type: Literal[AnnotationLayer.PROTEIN] = AnnotationLayer.PROTEIN @@ -148,9 +149,9 @@ class GenomicReferenceAgreeToken(Token, ReferenceAgree): """Token for reference agree on genomic reference sequence""" coordinate_type: Literal[AnnotationLayer.GENOMIC] = AnnotationLayer.GENOMIC - token_type: Literal[ + token_type: Literal[TokenType.GENOMIC_REFERENCE_AGREE] = ( TokenType.GENOMIC_REFERENCE_AGREE - ] = TokenType.GENOMIC_REFERENCE_AGREE + ) class ProteinDeletionToken(Token, ProteinDeletion): @@ -177,9 +178,9 @@ class GenomicDeletionToken(Token, Deletion): class GenomicDeletionAmbiguousToken(Token, DupDelAmbiguous): """Token for ambiguous deletion on genomic reference sequence""" - token_type: Literal[ + token_type: Literal[TokenType.GENOMIC_DELETION_AMBIGUOUS] = ( TokenType.GENOMIC_DELETION_AMBIGUOUS - ] = TokenType.GENOMIC_DELETION_AMBIGUOUS + ) coordinate_type: Literal[AnnotationLayer.GENOMIC] = AnnotationLayer.GENOMIC ambiguous_regex_type: AmbiguousRegexType @@ -236,9 +237,9 @@ class GenomicDuplicationToken(Token, Duplication): class GenomicDuplicationAmbiguousToken(Token, DupDelAmbiguous): """Ambiguous duplication on genomic reference sequence""" - token_type: Literal[ + token_type: Literal[TokenType.GENOMIC_DUPLICATION_AMBIGUOUS] = ( TokenType.GENOMIC_DUPLICATION_AMBIGUOUS - ] = TokenType.GENOMIC_DUPLICATION_AMBIGUOUS + ) coordinate_type: Literal[AnnotationLayer.GENOMIC] = AnnotationLayer.GENOMIC ambiguous_regex_type: AmbiguousRegexType diff --git a/src/variation/schemas/translation_response_schema.py b/src/variation/schemas/translation_response_schema.py index 73ab363f..2abf9235 100644 --- a/src/variation/schemas/translation_response_schema.py +++ b/src/variation/schemas/translation_response_schema.py @@ -1,4 +1,5 @@ """Module for Translation Response Schema.""" + from enum import Enum from typing import Dict, Optional diff --git a/src/variation/schemas/validation_response_schema.py b/src/variation/schemas/validation_response_schema.py index 00e8eb2e..2bef797a 100644 --- a/src/variation/schemas/validation_response_schema.py +++ b/src/variation/schemas/validation_response_schema.py @@ -1,4 +1,5 @@ """Module for Validation Response Schema.""" + from typing import List, Optional from pydantic import BaseModel, StrictBool, StrictInt, StrictStr diff --git a/src/variation/schemas/variation_schema.py b/src/variation/schemas/variation_schema.py index b384df72..3f0916e1 100644 --- a/src/variation/schemas/variation_schema.py +++ b/src/variation/schemas/variation_schema.py @@ -1,4 +1,5 @@ """Define supported variation types""" + from typing import Literal, Optional, Union from pydantic import BaseModel, StrictInt, StrictStr diff --git a/src/variation/schemas/vrs_python_translator_schema.py b/src/variation/schemas/vrs_python_translator_schema.py index 844f4b6c..667a8cbe 100644 --- a/src/variation/schemas/vrs_python_translator_schema.py +++ b/src/variation/schemas/vrs_python_translator_schema.py @@ -1,4 +1,5 @@ """Module for vrs-python translator endpoint response schema""" + from enum import Enum from typing import List, Literal, Optional, Union @@ -13,9 +14,9 @@ class VrsPythonMeta(BaseModel): name: Literal["vrs-python"] = "vrs-python" version: StrictStr - url: Literal[ + url: Literal["https://github.com/ga4gh/vrs-python"] = ( "https://github.com/ga4gh/vrs-python" - ] = "https://github.com/ga4gh/vrs-python" + ) class TranslateFromFormat(str, Enum): diff --git a/src/variation/to_copy_number_variation.py b/src/variation/to_copy_number_variation.py index 60745779..eb92c3e6 100644 --- a/src/variation/to_copy_number_variation.py +++ b/src/variation/to_copy_number_variation.py @@ -1,4 +1,5 @@ """Module for to copy number variation translation""" + import datetime from typing import Dict, List, NamedTuple, Optional, Tuple, Union from urllib.parse import unquote diff --git a/src/variation/to_vrs.py b/src/variation/to_vrs.py index eca7b347..3d80e030 100644 --- a/src/variation/to_vrs.py +++ b/src/variation/to_vrs.py @@ -1,4 +1,5 @@ """Module for to_vrs endpoint.""" + import datetime from typing import List, Optional, Tuple from urllib.parse import unquote diff --git a/src/variation/tokenize.py b/src/variation/tokenize.py index 26d2f494..0acfa999 100644 --- a/src/variation/tokenize.py +++ b/src/variation/tokenize.py @@ -1,4 +1,5 @@ """A module for tokenization.""" + from typing import List from variation.schemas.token_response_schema import Token, TokenType diff --git a/src/variation/tokenizers/__init__.py b/src/variation/tokenizers/__init__.py index 992e698c..7962d8d3 100644 --- a/src/variation/tokenizers/__init__.py +++ b/src/variation/tokenizers/__init__.py @@ -1,4 +1,5 @@ """Module to load and init namespace at package level.""" + from .cdna_and_genomic_reference_agree import CdnaGenomicReferenceAgree from .cdna_deletion import CdnaDeletion from .cdna_delins import CdnaDelIns diff --git a/src/variation/tokenizers/cdna_and_genomic_reference_agree.py b/src/variation/tokenizers/cdna_and_genomic_reference_agree.py index ab69d65c..645c633f 100644 --- a/src/variation/tokenizers/cdna_and_genomic_reference_agree.py +++ b/src/variation/tokenizers/cdna_and_genomic_reference_agree.py @@ -1,4 +1,5 @@ """A module for Reference Agree Tokenization on cDNA and genomic reference sequence.""" + from typing import Optional, Union from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/cdna_deletion.py b/src/variation/tokenizers/cdna_deletion.py index 9b949201..d146e819 100644 --- a/src/variation/tokenizers/cdna_deletion.py +++ b/src/variation/tokenizers/cdna_deletion.py @@ -1,4 +1,5 @@ """A module for Cdna Deletion Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/cdna_delins.py b/src/variation/tokenizers/cdna_delins.py index beda5786..2c7305f9 100644 --- a/src/variation/tokenizers/cdna_delins.py +++ b/src/variation/tokenizers/cdna_delins.py @@ -1,4 +1,5 @@ """A module for Cdna Deletion Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/cdna_insertion.py b/src/variation/tokenizers/cdna_insertion.py index 2a0d5417..5b75645e 100644 --- a/src/variation/tokenizers/cdna_insertion.py +++ b/src/variation/tokenizers/cdna_insertion.py @@ -1,4 +1,5 @@ """A module for Cdna Insertion Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/cdna_substitution.py b/src/variation/tokenizers/cdna_substitution.py index 59f36158..74c6d510 100644 --- a/src/variation/tokenizers/cdna_substitution.py +++ b/src/variation/tokenizers/cdna_substitution.py @@ -1,4 +1,5 @@ """A module for Cdna Substitution Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/free_text_categorical.py b/src/variation/tokenizers/free_text_categorical.py index 7edec067..d05e9b8e 100644 --- a/src/variation/tokenizers/free_text_categorical.py +++ b/src/variation/tokenizers/free_text_categorical.py @@ -1,4 +1,5 @@ """A module for free text categorical variation tokenization""" + from typing import Optional from variation.schemas.token_response_schema import AmplificationToken diff --git a/src/variation/tokenizers/gene_symbol.py b/src/variation/tokenizers/gene_symbol.py index 04e98c02..77957644 100644 --- a/src/variation/tokenizers/gene_symbol.py +++ b/src/variation/tokenizers/gene_symbol.py @@ -1,4 +1,5 @@ """Module for Gene Symbol tokenization.""" + from typing import Optional from gene.query import QueryHandler as GeneQueryHandler diff --git a/src/variation/tokenizers/genomic_deletion.py b/src/variation/tokenizers/genomic_deletion.py index 8d9c1630..fd1d2faa 100644 --- a/src/variation/tokenizers/genomic_deletion.py +++ b/src/variation/tokenizers/genomic_deletion.py @@ -1,4 +1,5 @@ """A module for Genomic Deletion Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/genomic_delins.py b/src/variation/tokenizers/genomic_delins.py index 888d3145..bf5d1f6e 100644 --- a/src/variation/tokenizers/genomic_delins.py +++ b/src/variation/tokenizers/genomic_delins.py @@ -1,4 +1,5 @@ """A module for Genomic DelIns Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/genomic_duplication.py b/src/variation/tokenizers/genomic_duplication.py index a20e1f6d..3e9360d5 100644 --- a/src/variation/tokenizers/genomic_duplication.py +++ b/src/variation/tokenizers/genomic_duplication.py @@ -1,4 +1,5 @@ """A module for Genomic Duplication Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/genomic_insertion.py b/src/variation/tokenizers/genomic_insertion.py index 3319fd50..5fea9272 100644 --- a/src/variation/tokenizers/genomic_insertion.py +++ b/src/variation/tokenizers/genomic_insertion.py @@ -1,4 +1,5 @@ """A module for Genomic Insertion Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/genomic_substitution.py b/src/variation/tokenizers/genomic_substitution.py index 3cafed25..d95fa7ec 100644 --- a/src/variation/tokenizers/genomic_substitution.py +++ b/src/variation/tokenizers/genomic_substitution.py @@ -1,4 +1,5 @@ """A module for Genomic Substitution Tokenization.""" + from typing import Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/tokenizers/gnomad_vcf.py b/src/variation/tokenizers/gnomad_vcf.py index 6cf309b0..3852671c 100644 --- a/src/variation/tokenizers/gnomad_vcf.py +++ b/src/variation/tokenizers/gnomad_vcf.py @@ -1,4 +1,5 @@ """A module for gnomad VCF tokenization""" + import re from typing import Optional diff --git a/src/variation/tokenizers/hgvs.py b/src/variation/tokenizers/hgvs.py index c98e33a9..bb161025 100644 --- a/src/variation/tokenizers/hgvs.py +++ b/src/variation/tokenizers/hgvs.py @@ -1,4 +1,5 @@ """Module for HGVS tokenization.""" + import re from typing import Optional diff --git a/src/variation/tokenizers/protein_deletion.py b/src/variation/tokenizers/protein_deletion.py index eb459a8b..20338ca7 100644 --- a/src/variation/tokenizers/protein_deletion.py +++ b/src/variation/tokenizers/protein_deletion.py @@ -1,4 +1,5 @@ """A module for tokenizing Protein Deletions.""" + import re from typing import Optional diff --git a/src/variation/tokenizers/protein_delins.py b/src/variation/tokenizers/protein_delins.py index 5bfe086e..527be4fa 100644 --- a/src/variation/tokenizers/protein_delins.py +++ b/src/variation/tokenizers/protein_delins.py @@ -1,4 +1,5 @@ """A module for Protein DelIns Tokenization Class.""" + from typing import Optional from bioutils.sequences import aa1_to_aa3, aa3_to_aa1 diff --git a/src/variation/tokenizers/protein_insertion.py b/src/variation/tokenizers/protein_insertion.py index 6b482eeb..fa2c38a3 100644 --- a/src/variation/tokenizers/protein_insertion.py +++ b/src/variation/tokenizers/protein_insertion.py @@ -1,4 +1,5 @@ """A module for Protein Insertion Tokenization Class.""" + from typing import Optional from bioutils.sequences import aa1_to_aa3, aa3_to_aa1 diff --git a/src/variation/tokenizers/protein_reference_agree.py b/src/variation/tokenizers/protein_reference_agree.py index 89b74e75..5d9ec8be 100644 --- a/src/variation/tokenizers/protein_reference_agree.py +++ b/src/variation/tokenizers/protein_reference_agree.py @@ -1,4 +1,5 @@ """A module for Reference Agree Tokenization.""" + import contextlib from typing import Optional diff --git a/src/variation/tokenizers/protein_substitution.py b/src/variation/tokenizers/protein_substitution.py index dcc0fccd..d780c33c 100644 --- a/src/variation/tokenizers/protein_substitution.py +++ b/src/variation/tokenizers/protein_substitution.py @@ -1,4 +1,5 @@ """A module for Protein Substitution Tokenization.""" + from typing import Optional, Union from bioutils.sequences import aa1_to_aa3, aa3_to_aa1 diff --git a/src/variation/tokenizers/tokenizer.py b/src/variation/tokenizers/tokenizer.py index 3175d4d2..32f63fde 100644 --- a/src/variation/tokenizers/tokenizer.py +++ b/src/variation/tokenizers/tokenizer.py @@ -1,4 +1,5 @@ """Module for Tokenization.""" + from abc import ABC, abstractmethod from typing import ClassVar, Dict, Optional, Tuple diff --git a/src/variation/translate.py b/src/variation/translate.py index 789d6f37..c95afd32 100644 --- a/src/variation/translate.py +++ b/src/variation/translate.py @@ -1,4 +1,5 @@ """Module for translation.""" + from typing import List, Optional from cool_seq_tool.handlers import SeqRepoAccess diff --git a/src/variation/translators/__init__.py b/src/variation/translators/__init__.py index 703976cc..00dd1c78 100644 --- a/src/variation/translators/__init__.py +++ b/src/variation/translators/__init__.py @@ -1,4 +1,5 @@ """Translator package import.""" + from .amplification import Amplification from .cdna_deletion import CdnaDeletion from .cdna_delins import CdnaDelIns diff --git a/src/variation/translators/ambiguous_translator_base.py b/src/variation/translators/ambiguous_translator_base.py index f287f5c2..72b5bac6 100644 --- a/src/variation/translators/ambiguous_translator_base.py +++ b/src/variation/translators/ambiguous_translator_base.py @@ -1,4 +1,5 @@ """Module for translating genomic ambiguous deletions and duplications""" + from typing import Dict, List, Literal, NamedTuple, Optional, Union from ga4gh.vrs import models diff --git a/src/variation/translators/amplification.py b/src/variation/translators/amplification.py index cbd4034a..7c4e4d08 100644 --- a/src/variation/translators/amplification.py +++ b/src/variation/translators/amplification.py @@ -1,4 +1,5 @@ """Module for Amplification Translation.""" + from typing import List, Optional from ga4gh.core import ga4gh_identify diff --git a/src/variation/translators/cdna_deletion.py b/src/variation/translators/cdna_deletion.py index 96fdb5a9..1a06b831 100644 --- a/src/variation/translators/cdna_deletion.py +++ b/src/variation/translators/cdna_deletion.py @@ -1,4 +1,5 @@ """Module for cDNA Deletion Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/cdna_delins.py b/src/variation/translators/cdna_delins.py index 1498b93c..2ada6653 100644 --- a/src/variation/translators/cdna_delins.py +++ b/src/variation/translators/cdna_delins.py @@ -1,4 +1,5 @@ """Module for Cdna DelIns Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/cdna_insertion.py b/src/variation/translators/cdna_insertion.py index f0d5d029..3f8ff186 100644 --- a/src/variation/translators/cdna_insertion.py +++ b/src/variation/translators/cdna_insertion.py @@ -1,4 +1,5 @@ """Module for Cdna insertion Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/cdna_reference_agree.py b/src/variation/translators/cdna_reference_agree.py index 92fe1a09..f3d35516 100644 --- a/src/variation/translators/cdna_reference_agree.py +++ b/src/variation/translators/cdna_reference_agree.py @@ -1,4 +1,5 @@ """Module for Cdna Reference Agree Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/cdna_substitution.py b/src/variation/translators/cdna_substitution.py index 755bdf0e..9f72d8a6 100644 --- a/src/variation/translators/cdna_substitution.py +++ b/src/variation/translators/cdna_substitution.py @@ -1,4 +1,5 @@ """Module for cDNA Substitution Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/genomic_del_dup_base.py b/src/variation/translators/genomic_del_dup_base.py index 80c879de..f822b941 100644 --- a/src/variation/translators/genomic_del_dup_base.py +++ b/src/variation/translators/genomic_del_dup_base.py @@ -1,4 +1,5 @@ """Module for Genomic Deletion Translation.""" + from typing import List, NamedTuple, Optional, Union from cool_seq_tool.schemas import ResidueMode diff --git a/src/variation/translators/genomic_deletion.py b/src/variation/translators/genomic_deletion.py index 7960b8aa..8656a868 100644 --- a/src/variation/translators/genomic_deletion.py +++ b/src/variation/translators/genomic_deletion.py @@ -1,4 +1,5 @@ """Module for Genomic Deletion Translation.""" + from variation.schemas.classification_response_schema import ClassificationType from variation.translators.genomic_del_dup_base import GenomicDelDupTranslator diff --git a/src/variation/translators/genomic_deletion_ambiguous.py b/src/variation/translators/genomic_deletion_ambiguous.py index 666451e9..d501551d 100644 --- a/src/variation/translators/genomic_deletion_ambiguous.py +++ b/src/variation/translators/genomic_deletion_ambiguous.py @@ -1,4 +1,5 @@ """Module for Genomic Deletion Ambiguous Translation.""" + from variation.schemas.classification_response_schema import ClassificationType from variation.translators.ambiguous_translator_base import AmbiguousTranslator diff --git a/src/variation/translators/genomic_delins.py b/src/variation/translators/genomic_delins.py index 9a6d6dcc..a3ed738e 100644 --- a/src/variation/translators/genomic_delins.py +++ b/src/variation/translators/genomic_delins.py @@ -1,4 +1,5 @@ """Module for Genomic DelIns Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer, ResidueMode diff --git a/src/variation/translators/genomic_duplication.py b/src/variation/translators/genomic_duplication.py index 79a7daec..619ff942 100644 --- a/src/variation/translators/genomic_duplication.py +++ b/src/variation/translators/genomic_duplication.py @@ -1,4 +1,5 @@ """Module for Genomic Duplication Translation.""" + from variation.schemas.classification_response_schema import ClassificationType from variation.translators.genomic_del_dup_base import GenomicDelDupTranslator diff --git a/src/variation/translators/genomic_duplication_ambiguous.py b/src/variation/translators/genomic_duplication_ambiguous.py index 254712b4..4cfec940 100644 --- a/src/variation/translators/genomic_duplication_ambiguous.py +++ b/src/variation/translators/genomic_duplication_ambiguous.py @@ -1,4 +1,5 @@ """Module for Genomic Duplication Ambiguous Translation.""" + from variation.schemas.classification_response_schema import ClassificationType from variation.translators.ambiguous_translator_base import AmbiguousTranslator diff --git a/src/variation/translators/genomic_insertion.py b/src/variation/translators/genomic_insertion.py index 03d636bc..5ead2a29 100644 --- a/src/variation/translators/genomic_insertion.py +++ b/src/variation/translators/genomic_insertion.py @@ -1,4 +1,5 @@ """Module for Genomic Insertion Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer, ResidueMode diff --git a/src/variation/translators/genomic_reference_agree.py b/src/variation/translators/genomic_reference_agree.py index f1b7d4a9..cc586749 100644 --- a/src/variation/translators/genomic_reference_agree.py +++ b/src/variation/translators/genomic_reference_agree.py @@ -1,4 +1,5 @@ """Module for Genomic Reference Agree Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer, ResidueMode diff --git a/src/variation/translators/genomic_substitution.py b/src/variation/translators/genomic_substitution.py index 6b273337..cc824092 100644 --- a/src/variation/translators/genomic_substitution.py +++ b/src/variation/translators/genomic_substitution.py @@ -1,4 +1,5 @@ """Module for Genomic Substitution Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer, ResidueMode, Strand diff --git a/src/variation/translators/protein_deletion.py b/src/variation/translators/protein_deletion.py index 70910d44..1aaf9449 100644 --- a/src/variation/translators/protein_deletion.py +++ b/src/variation/translators/protein_deletion.py @@ -1,4 +1,5 @@ """Module for Protein Deletion Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/protein_delins.py b/src/variation/translators/protein_delins.py index 11f1d77f..423409f1 100644 --- a/src/variation/translators/protein_delins.py +++ b/src/variation/translators/protein_delins.py @@ -1,4 +1,5 @@ """Module for Protein DelIns Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/protein_insertion.py b/src/variation/translators/protein_insertion.py index 0dfb3983..b627e678 100644 --- a/src/variation/translators/protein_insertion.py +++ b/src/variation/translators/protein_insertion.py @@ -1,4 +1,5 @@ """Module for Protein Insertion Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/protein_reference_agree.py b/src/variation/translators/protein_reference_agree.py index 05e9f3d8..5e3a8933 100644 --- a/src/variation/translators/protein_reference_agree.py +++ b/src/variation/translators/protein_reference_agree.py @@ -1,4 +1,5 @@ """Module for Protein Reference Agree Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/protein_stop_gain.py b/src/variation/translators/protein_stop_gain.py index 88144412..2c472e57 100644 --- a/src/variation/translators/protein_stop_gain.py +++ b/src/variation/translators/protein_stop_gain.py @@ -1,4 +1,5 @@ """Module for Protein Stop Gain Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/protein_substitution.py b/src/variation/translators/protein_substitution.py index a1933090..b6d6da38 100644 --- a/src/variation/translators/protein_substitution.py +++ b/src/variation/translators/protein_substitution.py @@ -1,4 +1,5 @@ """Module for Protein Substitution Translation.""" + from typing import List, Optional from cool_seq_tool.schemas import AnnotationLayer diff --git a/src/variation/translators/translator.py b/src/variation/translators/translator.py index 9d8bb661..1dd496aa 100644 --- a/src/variation/translators/translator.py +++ b/src/variation/translators/translator.py @@ -1,4 +1,5 @@ """Module for translation.""" + from abc import ABC, abstractmethod from typing import List, Optional, Union diff --git a/src/variation/utils.py b/src/variation/utils.py index f76d44ab..ce80cb44 100644 --- a/src/variation/utils.py +++ b/src/variation/utils.py @@ -1,4 +1,5 @@ """Module for general functionality throughout the app""" + import contextlib import re from typing import Dict, List, Literal, Optional, Tuple, Union diff --git a/src/variation/validate.py b/src/variation/validate.py index 15781ea6..aeea8ea1 100644 --- a/src/variation/validate.py +++ b/src/variation/validate.py @@ -1,4 +1,5 @@ """Module for Validation.""" + from typing import List from cool_seq_tool.handlers import SeqRepoAccess diff --git a/src/variation/validators/__init__.py b/src/variation/validators/__init__.py index 33f8f2e1..70cd17ad 100644 --- a/src/variation/validators/__init__.py +++ b/src/variation/validators/__init__.py @@ -1,4 +1,5 @@ """Validator package level import.""" + from .amplification import Amplification from .cdna_deletion import CdnaDeletion from .cdna_delins import CdnaDelIns diff --git a/src/variation/validators/amplification.py b/src/variation/validators/amplification.py index 70cd7a39..615e0b3c 100644 --- a/src/variation/validators/amplification.py +++ b/src/variation/validators/amplification.py @@ -1,4 +1,5 @@ """Module for Amplification validation""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/cdna_deletion.py b/src/variation/validators/cdna_deletion.py index c93ed452..7a5f758a 100644 --- a/src/variation/validators/cdna_deletion.py +++ b/src/variation/validators/cdna_deletion.py @@ -1,4 +1,5 @@ """The module for cDNA Deletion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/cdna_delins.py b/src/variation/validators/cdna_delins.py index a939394f..f3ed35c7 100644 --- a/src/variation/validators/cdna_delins.py +++ b/src/variation/validators/cdna_delins.py @@ -1,4 +1,5 @@ """The module for Cdna DelIns Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/cdna_insertion.py b/src/variation/validators/cdna_insertion.py index d285d417..64b704aa 100644 --- a/src/variation/validators/cdna_insertion.py +++ b/src/variation/validators/cdna_insertion.py @@ -1,4 +1,5 @@ """The module for Cdna Insertion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/cdna_reference_agree.py b/src/variation/validators/cdna_reference_agree.py index 17d16572..c586922d 100644 --- a/src/variation/validators/cdna_reference_agree.py +++ b/src/variation/validators/cdna_reference_agree.py @@ -1,4 +1,5 @@ """The module for Cdna Substitution Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/cdna_substitution.py b/src/variation/validators/cdna_substitution.py index 5c887c4c..1dea8ba8 100644 --- a/src/variation/validators/cdna_substitution.py +++ b/src/variation/validators/cdna_substitution.py @@ -1,4 +1,5 @@ """The module for cDNA Substitution Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_base.py b/src/variation/validators/genomic_base.py index 95b5d615..b163b215 100644 --- a/src/variation/validators/genomic_base.py +++ b/src/variation/validators/genomic_base.py @@ -1,4 +1,5 @@ """Module for Genomic Validation methods.""" + import logging from typing import List, Optional diff --git a/src/variation/validators/genomic_deletion.py b/src/variation/validators/genomic_deletion.py index cb3c9c4f..facd16d6 100644 --- a/src/variation/validators/genomic_deletion.py +++ b/src/variation/validators/genomic_deletion.py @@ -1,4 +1,5 @@ """The module for Genomic Deletion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_deletion_ambiguous.py b/src/variation/validators/genomic_deletion_ambiguous.py index ab999e53..19852656 100644 --- a/src/variation/validators/genomic_deletion_ambiguous.py +++ b/src/variation/validators/genomic_deletion_ambiguous.py @@ -1,4 +1,5 @@ """The module for Genomic Deletion Ambiguous Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_delins.py b/src/variation/validators/genomic_delins.py index 1e8f9b36..ba1d2f69 100644 --- a/src/variation/validators/genomic_delins.py +++ b/src/variation/validators/genomic_delins.py @@ -1,4 +1,5 @@ """The module for Genomic DelIns Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_duplication.py b/src/variation/validators/genomic_duplication.py index 89d82250..565455a8 100644 --- a/src/variation/validators/genomic_duplication.py +++ b/src/variation/validators/genomic_duplication.py @@ -1,4 +1,5 @@ """The module for Genomic Duplication Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_duplication_ambiguous.py b/src/variation/validators/genomic_duplication_ambiguous.py index 9479d744..08a5285f 100644 --- a/src/variation/validators/genomic_duplication_ambiguous.py +++ b/src/variation/validators/genomic_duplication_ambiguous.py @@ -1,4 +1,5 @@ """The module for Genomic Duplication Ambiguous Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_insertion.py b/src/variation/validators/genomic_insertion.py index 262128ea..491c9522 100644 --- a/src/variation/validators/genomic_insertion.py +++ b/src/variation/validators/genomic_insertion.py @@ -1,4 +1,5 @@ """The module for Genomic Insertion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_reference_agree.py b/src/variation/validators/genomic_reference_agree.py index ec30c1da..65dbbd6e 100644 --- a/src/variation/validators/genomic_reference_agree.py +++ b/src/variation/validators/genomic_reference_agree.py @@ -1,4 +1,5 @@ """The module for Genomic Reference Agree Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/genomic_substitution.py b/src/variation/validators/genomic_substitution.py index 898750b1..938c66df 100644 --- a/src/variation/validators/genomic_substitution.py +++ b/src/variation/validators/genomic_substitution.py @@ -1,4 +1,5 @@ """The module for Genomic Substitution Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_deletion.py b/src/variation/validators/protein_deletion.py index c8fc9d0d..2523b210 100644 --- a/src/variation/validators/protein_deletion.py +++ b/src/variation/validators/protein_deletion.py @@ -1,4 +1,5 @@ """The module for Protein Deletion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_delins.py b/src/variation/validators/protein_delins.py index 3580185d..75d511be 100644 --- a/src/variation/validators/protein_delins.py +++ b/src/variation/validators/protein_delins.py @@ -1,4 +1,5 @@ """The module for Protein DelIns Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_insertion.py b/src/variation/validators/protein_insertion.py index 9a7087dd..934917ff 100644 --- a/src/variation/validators/protein_insertion.py +++ b/src/variation/validators/protein_insertion.py @@ -1,4 +1,5 @@ """The module for Protein Insertion Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_reference_agree.py b/src/variation/validators/protein_reference_agree.py index 23811143..e7c859a7 100644 --- a/src/variation/validators/protein_reference_agree.py +++ b/src/variation/validators/protein_reference_agree.py @@ -1,4 +1,5 @@ """The module for Protein Reference Agree Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_stop_gain.py b/src/variation/validators/protein_stop_gain.py index 67bd9120..f9184819 100644 --- a/src/variation/validators/protein_stop_gain.py +++ b/src/variation/validators/protein_stop_gain.py @@ -1,4 +1,5 @@ """The module for Protein Stop Gain Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/protein_substitution.py b/src/variation/validators/protein_substitution.py index ba4df8a9..eaa569c9 100644 --- a/src/variation/validators/protein_substitution.py +++ b/src/variation/validators/protein_substitution.py @@ -1,4 +1,5 @@ """The module for Protein Substitution Validation.""" + from typing import List from variation.schemas.classification_response_schema import ( diff --git a/src/variation/validators/validator.py b/src/variation/validators/validator.py index f7fb8b0d..356223ae 100644 --- a/src/variation/validators/validator.py +++ b/src/variation/validators/validator.py @@ -1,4 +1,5 @@ """Module for Validation.""" + from abc import ABC, abstractmethod from typing import List, Literal, Optional, Tuple, Union diff --git a/src/variation/version.py b/src/variation/version.py index 2f615d6c..fa0e5bc3 100644 --- a/src/variation/version.py +++ b/src/variation/version.py @@ -1,2 +1,3 @@ """Module for version of app""" + __version__ = "0.8.2" diff --git a/src/variation/vrs_representation.py b/src/variation/vrs_representation.py index 1d12c4b3..531acd8b 100644 --- a/src/variation/vrs_representation.py +++ b/src/variation/vrs_representation.py @@ -1,4 +1,5 @@ """Module for generating VRS objects""" + from typing import Dict, List, Optional, Tuple, Union from cool_seq_tool.handlers import SeqRepoAccess diff --git a/tests/__init__.py b/tests/__init__.py index dfe3a3f7..a17fdde4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,5 @@ """Test package.""" + from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/conftest.py b/tests/conftest.py index dd872a60..7c5eb206 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Create methods used throughout tests.""" + import asyncio import contextlib import logging diff --git a/tests/test_classifier.py b/tests/test_classifier.py index e0ca546f..46c9acd5 100644 --- a/tests/test_classifier.py +++ b/tests/test_classifier.py @@ -1,4 +1,5 @@ """Module for testing classifiers""" + from pathlib import Path import pytest diff --git a/tests/test_gnomad_vcf_to_protein.py b/tests/test_gnomad_vcf_to_protein.py index aadf9096..d7231c84 100644 --- a/tests/test_gnomad_vcf_to_protein.py +++ b/tests/test_gnomad_vcf_to_protein.py @@ -1,4 +1,5 @@ """Module for testing gnomad_vcf_to_protein works correctly""" + import pytest from ga4gh.vrs import models diff --git a/tests/test_hgvs_dup_del_mode.py b/tests/test_hgvs_dup_del_mode.py index 14a48927..97ebf1a4 100644 --- a/tests/test_hgvs_dup_del_mode.py +++ b/tests/test_hgvs_dup_del_mode.py @@ -1,4 +1,5 @@ """Module for testing HGVS Dup Del mode.""" + import pytest from ga4gh.vrs import models diff --git a/tests/test_normalize.py b/tests/test_normalize.py index 107bad6c..472c449d 100644 --- a/tests/test_normalize.py +++ b/tests/test_normalize.py @@ -1,4 +1,5 @@ """Module for testing the normalize endpoint.""" + from datetime import datetime import pytest @@ -507,7 +508,7 @@ def gnomad_vcf_genomic_delins5(): @pytest.mark.asyncio() -async def test_protein_substitution(test_handler, braf_v600e, dis3_p63a, tp53_g262c): +async def test_protein_substitution(test_handler, braf_v600e, dis3_p63a): """Test that protein substitutions normalize correctly.""" resp = await test_handler.normalize(" BRAF V600E ") assertion_checks(resp, braf_v600e, check_vrs_id=True) diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index bf3132e8..234dbb3a 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -1,4 +1,5 @@ """Module for testing tokenizers""" + from pathlib import Path import pytest diff --git a/tests/test_translator.py b/tests/test_translator.py index 1d6d0dcc..6beb743b 100644 --- a/tests/test_translator.py +++ b/tests/test_translator.py @@ -1,4 +1,5 @@ """Module for testing translators""" + from pathlib import Path import pytest diff --git a/tests/test_validator.py b/tests/test_validator.py index ee07e501..e2c227e9 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -1,4 +1,5 @@ """Module for testing validators""" + from pathlib import Path import pytest diff --git a/tests/to_copy_number_variation/test_amplification_to_cx_var.py b/tests/to_copy_number_variation/test_amplification_to_cx_var.py index e9e06e2b..e428b289 100644 --- a/tests/to_copy_number_variation/test_amplification_to_cx_var.py +++ b/tests/to_copy_number_variation/test_amplification_to_cx_var.py @@ -1,4 +1,5 @@ """Module for testing Amplification to Copy Number Change""" + import pytest from ga4gh.vrs import models from tests.conftest import cnv_assertion_checks diff --git a/tests/to_copy_number_variation/test_parsed_to_copy_number.py b/tests/to_copy_number_variation/test_parsed_to_copy_number.py index b4091475..7ce36c29 100644 --- a/tests/to_copy_number_variation/test_parsed_to_copy_number.py +++ b/tests/to_copy_number_variation/test_parsed_to_copy_number.py @@ -1,4 +1,5 @@ """Test that parsed_to_copy_number works correctly""" + from copy import deepcopy import pytest