Skip to content

Commit

Permalink
Merge pull request #78 from Clinical-Genomics/clinsig_ignorecase
Browse files Browse the repository at this point in the history
Clinsig fixcase
  • Loading branch information
northwestwitch authored Dec 21, 2022
2 parents 6497e92 + d584de7 commit 8824812
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [unreleased]
### Changed
- Fix uppercase/lowercase letters when parsing clinsig terms from files

## [2.2]
### Changed
- Provide the URL to the prod service running on the Clinical Genomics server instead of the stage one on README page
Expand Down
20 changes: 20 additions & 0 deletions preClinVar/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
DRY_RUN_SUBMISSION_URL = "https://submit.ncbi.nlm.nih.gov/api/v1/submissions/?dry-run=true"
VALIDATE_SUBMISSION_URL = "https://submit.ncbi.nlm.nih.gov/apitest/v1/submissions"

CLNSIG_TERMS = [
"Pathogenic",
"Likely pathogenic",
"Uncertain significance",
"Likely benign",
"Benign",
"Pathogenic, low penetrance",
"Uncertain risk allele",
"Likely pathogenic, low penetrance",
"Established risk allele",
"Likely risk allele",
"affects",
"association",
"drug response",
"confers sensitivity",
"protective",
"other",
"not provided",
]

CONDITIONS_MAP = {
"HPO": "HP",
"MedGen": "MedGen",
Expand Down
8 changes: 7 additions & 1 deletion preClinVar/file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from csv import DictReader
from tempfile import NamedTemporaryFile

from preClinVar.constants import CONDITIONS_MAP, SNV_COORDS, SV_COORDS
from preClinVar.constants import CLNSIG_TERMS, CONDITIONS_MAP, SNV_COORDS, SV_COORDS

LOG = logging.getLogger("uvicorn.access")

Expand Down Expand Up @@ -45,6 +45,12 @@ def set_item_clin_sig(item, variant_dict):
"""
# set first required params
clinsig = variant_dict.get("Clinical significance")
# Make sure clinsig term is compliant with API standards:
for term in CLNSIG_TERMS:
if clinsig.lower() == term.lower():
clinsig = term
break

clinsig_comment = variant_dict.get("Comment on clinical significance")
last_eval = variant_dict.get("Date last evaluated")
inherit_mode = variant_dict.get("Mode of inheritance")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_file_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from preClinVar.constants import CLNSIG_TERMS
from preClinVar.file_parser import set_item_clin_sig


def test_set_item_clin_sig_fix_case():
"""Test the function that collects clinsig from Variant file when clisnsig term has wrong uppercase/lowercase"""
# GIVEN a variant dictionary with a non-compliant slinsig value
item = {}
variant_dict = {"Clinical significance": "Likely Pathogenic"}

# WHEN clisig is collected from variant_dict
set_item_clin_sig(item, variant_dict)

# THEN it's converted into a compliant term
assert item["clinicalSignificance"]["clinicalSignificanceDescription"] in CLNSIG_TERMS

0 comments on commit 8824812

Please sign in to comment.