Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Notmet and Met prediction statuses #208

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,46 @@ ci-docs-deps:

.PHONY: format
format: \
format-black \
format-ruff \
format-isort

.PHONY: format-ruff
format-ruff:
pipenv run ruff format --line-length 100 $(DIRS_PYTHON)

.PHONY: format-isort
format-isort:
pipenv run isort --profile=black --line-length 100 $(DIRS_PYTHON)

.PHONY: format-black
format-black:
pipenv run black --line-length 100 $(DIRS_PYTHON)
# .PHONY: format-black
# format-black:
# pipenv run black --line-length 100 $(DIRS_PYTHON)

# .PHONY: format-autoflake
# format-autoflake:
# pipenv run autoflake --remove-all-unused-imports -i -r $(DIRS_PYTHON)

.PHONY: lint
lint: \
lint-black \
lint-ruff \
lint-isort \
lint-flake8 \
lint-mypy

.PHONY: lint-ruff
lint-ruff:
pipenv run ruff check --line-length 100 $(DIRS_PYTHON)

.PHONY: lint-isort
lint-isort:
pipenv run isort --profile=black --line-length 100 --check-only --diff $(DIRS_PYTHON)

.PHONY: lint-black
lint-black:
pipenv run black --check --line-length 100 --diff $(DIRS_PYTHON)
# .PHONY: lint-black
# lint-black:
# pipenv run black --check --line-length 100 --diff $(DIRS_PYTHON)

.PHONY: lint-flake8
flake8:
pipenv run flake8 --max-line-length 100 $(DIRS_PYTHON)
# .PHONY: lint-flake8
# flake8:
# pipenv run flake8 --max-line-length 100 $(DIRS_PYTHON)

.PHONY: lint-mypy
lint-mypy:
Expand Down
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ typing-extensions = "*"
datamodel-code-generator = "*"
debugpy = "*"
isort = "*"
flake8 = "*"
black = "*"
ruff = "*"
pytest = "*"
sphinx = "*"
sphinxcontrib-bibtex = "*"
Expand Down
2,131 changes: 1,092 additions & 1,039 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/annonars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Annonars API client."""

from typing import List, Optional, Union
from typing import Optional, Union

import httpx
from loguru import logger
Expand Down
14 changes: 3 additions & 11 deletions src/auto_acmg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Implementations of the PVS1 algorithm."""

from typing import Dict, Optional, Type, Union
from typing import Optional, Type, Union

from loguru import logger

Expand All @@ -13,14 +13,6 @@
from src.defs.mehari import CdsPos, ProteinPos, TxPos
from src.defs.seqvar import SeqVar, SeqVarResolver
from src.defs.strucvar import StrucVar, StrucVarResolver
from src.seqvar.auto_bp7 import AutoBP7
from src.seqvar.auto_pm1 import AutoPM1
from src.seqvar.auto_pm2_ba1_bs1_bs2 import AutoPM2BA1BS1BS2
from src.seqvar.auto_pm4_bp3 import AutoPM4BP3
from src.seqvar.auto_pp2_bp1 import AutoPP2BP1
from src.seqvar.auto_pp3_bp4 import AutoPP3BP4
from src.seqvar.auto_ps1_pm5 import AutoPS1PM5
from src.seqvar.auto_pvs1 import AutoPVS1
from src.seqvar.default_predictor import DefaultSeqVarPredictor
from src.strucvar.default_predictor import DefaultStrucVarPredictor
from src.utils import SeqVarTranscriptsHelper, StrucVarTranscriptsHelper
Expand Down Expand Up @@ -86,7 +78,7 @@
"HGNC:129": CongenitalMyopathiesPredictor, # ACTA1
"HGNC:2974": CongenitalMyopathiesPredictor, # DNM2
"HGNC:7448": CongenitalMyopathiesPredictor, # MTM1
"HGNC:10483": CongenitalMyopathiesPredictor, # RYR1
# "HGNC:10483": CongenitalMyopathiesPredictor, # RYR1
"HGNC:17098": DICER1Predictor, # DICER1
"HGNC:1100": ENIGMAPredictor, # BRCA1
"HGNC:1101": ENIGMAPredictor, # BRCA2
Expand Down Expand Up @@ -287,7 +279,7 @@ def resolve_variant(self) -> Union[SeqVar, StrucVar, None]:
self.variant_name, self.genome_release
)
return strucvar
except ParseError as e:
except ParseError:
logger.debug("Failed to resolve the structure variant")
return None
except AutoAcmgBaseException as e:
Expand Down
6 changes: 5 additions & 1 deletion src/bench/comparison_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)

print(f"Number of variants: {len(variants)}")
Expand Down
6 changes: 5 additions & 1 deletion src/bench/comparison_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)

print(f"Number of variants: {len(variants)}")
Expand Down
6 changes: 5 additions & 1 deletion src/bench/comparison_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)
print(f"Number of variants: {len(variants)}")
# ========================================
Expand Down
6 changes: 5 additions & 1 deletion src/bench/comparison_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)
print(f"Number of variants: {len(variants)}")
# ========================================
Expand Down
8 changes: 6 additions & 2 deletions src/bench/comparison_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)
print(f"Number of variants: {len(variants)}")
# ========================================
Expand Down Expand Up @@ -154,7 +158,7 @@ def eval_autoacmg(pred: Optional[AutoACMGSeqVarResult], expected: List[str]):
return [], [], expected, []
crit_met: List[str] = []
for crit in pred.criteria:
if crit[1].prediction == AutoACMGPrediction.Met:
if crit[1].prediction == AutoACMGPrediction.Applicable:
crit_met.append(crit[1].name)
tp = list(set(expected) & set(crit_met))
fn = list(set(expected) - set(crit_met))
Expand Down
15 changes: 12 additions & 3 deletions src/bench/genebe.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@
if record["variant"].startswith("#"):
continue
variants.append(
(record["variant"], record["expected_criteria"].split(";"), record["comment"])
(
record["variant"],
record["expected_criteria"].split(";"),
record["comment"],
)
)
print(f"Number of variants: {len(variants)}")
# ========================================

# =========== Run the benchmark ===========
list_of_variants = gnb.parse_hgvs(
[variant[0] for variant in variants], username=genebe_username, api_key=genebe_api_key
[variant[0] for variant in variants],
username=genebe_username,
api_key=genebe_api_key,
)
df = gnb.annotate_variants_list_to_dataframe(
list_of_variants, flatten_consequences=True, username=genebe_username, api_key=genebe_api_key
list_of_variants,
flatten_consequences=True,
username=genebe_username,
api_key=genebe_api_key,
)

# Export the dataframe to a csv file
Expand Down
14 changes: 6 additions & 8 deletions src/bench/preprocess_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
],
"source": [
"import os\n",
"import sys\n",
"import pandas as pd\n",
"from src.core.config import settings"
]
Expand All @@ -36,7 +35,7 @@
"file_path = os.path.join(path_to_root, \"src\", \"bench\", \"clingen.txt\")\n",
"\n",
"# Load the data into a pandas DataFrame\n",
"data = pd.read_csv(file_path, sep='\\t')\n",
"data = pd.read_csv(file_path, sep=\"\\t\")\n",
"\n",
"# Display the first few rows of the DataFrame to understand its structure\n",
"data.head()"
Expand All @@ -49,20 +48,19 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"# Extract the required fields: Variant name, Mode of Inheritance, and add Guideline to Comment\n",
"data['Variant'] = data['Variation']\n",
"data['Mode of Inheritance'] = data['Mode of Inheritance']\n",
"data['Comment'] = data['Guideline']\n",
"data[\"Variant\"] = data[\"Variation\"]\n",
"data[\"Mode of Inheritance\"] = data[\"Mode of Inheritance\"]\n",
"data[\"Comment\"] = data[\"Guideline\"]\n",
"\n",
"# Select only the required columns\n",
"result = data[['Variant', 'Mode of Inheritance', 'Comment']]\n",
"result = data[[\"Variant\", \"Mode of Inheritance\", \"Comment\"]]\n",
"\n",
"# Display the processed DataFrame\n",
"result.head()\n",
"\n",
"# Save the result to a new CSV file\n",
"output_file_path = '/path/to/your/outputfile.csv'\n",
"output_file_path = \"/path/to/your/outputfile.csv\"\n",
"result.to_csv(output_file_path, index=False)\n",
"\n",
"# Print a message to indicate the process is complete\n",
Expand Down
Loading
Loading