diff --git a/annotation/regexes.py b/annotation/regexes.py index 9e66c90fe..7213e873e 100644 --- a/annotation/regexes.py +++ b/annotation/regexes.py @@ -76,7 +76,7 @@ class DbRegexes: NIHMS = DbRefRegex(db="NIHMS", prefixes="NIHMS", link="https://www.ncbi.nlm.nih.gov/pubmed/?term=NIHMS${1}") # smallest OMIM starts with a 1, so there's no 0 padding there, expect min length OMIM = DbRefRegex(db="OMIM", prefixes=["OMIM", "MIM"], link=OntologyService.URLS[OntologyService.OMIM], min_length=OntologyService.EXPECTED_LENGTHS[OntologyService.OMIM], expected_length=OntologyService.EXPECTED_LENGTHS[OntologyService.OMIM]) - ORPHA = DbRefRegex(db="Orphanet", prefixes=["ORPHANET", "ORPHA"], link=OntologyService.URLS[OntologyService.ORPHANET], expected_length=OntologyService.EXPECTED_LENGTHS[OntologyService.ORPHANET]) + ORPHA = DbRefRegex(db="ORPHA", prefixes=["ORPHANET", "ORPHA"], link=OntologyService.URLS[OntologyService.ORPHANET], expected_length=OntologyService.EXPECTED_LENGTHS[OntologyService.ORPHANET]) PUBMED_CENTRAL = DbRefRegex(db="PMCID", prefixes=["PMCID", "PubMedCentral", "PMC"], link="https://www.ncbi.nlm.nih.gov/pmc/articles/${1}", match_type=MatchType.OPT_ALPHA_MAN_NUMERIC) PUBMED = DbRefRegex(db="PMID", prefixes=["PubMed", "PMID"], link="https://www.ncbi.nlm.nih.gov/pubmed/${1}") SNP = DbRefRegex(db="SNP", prefixes="rs", link="https://www.ncbi.nlm.nih.gov/snp/${1}", match_type=MatchType.SIMPLE_NUMBERS) diff --git a/classification/management/commands/fix_orphanet_revalidation.py b/classification/management/commands/fix_orphanet_revalidation.py new file mode 100644 index 000000000..b9e2d26a7 --- /dev/null +++ b/classification/management/commands/fix_orphanet_revalidation.py @@ -0,0 +1,15 @@ +from django.core.management.base import BaseCommand +from classification.models import Classification +from library.guardian_utils import admin_bot + + +class Command(BaseCommand): + + def handle(self, *args, **options): + user = admin_bot() + search_term_orpha = "ORPHANET" + classifications = Classification.objects.filter(evidence__search_terms__icontains=search_term_orpha) + print(f"Found {classifications.count()} classifications with '{search_term_orpha}' in literature") + for classification in classifications: + classification.revalidate(user=user) + self.stdout.write(self.style.SUCCESS("Revalidation complete for Orphanet classifications.")) diff --git a/classification/migrations/0105_fix_orphanet_revalidation.py b/classification/migrations/0105_fix_orphanet_revalidation.py new file mode 100644 index 000000000..020537d77 --- /dev/null +++ b/classification/migrations/0105_fix_orphanet_revalidation.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.2 on 2023-08-14 23:42 +from django.db import migrations +from manual.operations.manual_operations import ManualOperation + + +def _test_fix_orphanet_revalidation(apps): + Classification = apps.get_model("classification", "Classification") + search_term_orpha = "ORPHANET" + return Classification.objects.filter(evidence__search_terms__icontains=search_term_orpha).exists() + +class Migration(migrations.Migration): + + dependencies = [ + ('classification', '0104_discordancereport_admin_note'), + ] + + operations = [ + ManualOperation(task_id=ManualOperation.task_id_manage(["fix_orphanet_revalidation"]), + test=_test_fix_orphanet_revalidation) + ] diff --git a/ontology/migrations/0026_alter_ontologyterm_ontology_service.py b/ontology/migrations/0026_alter_ontologyterm_ontology_service.py new file mode 100644 index 000000000..610ea60d9 --- /dev/null +++ b/ontology/migrations/0026_alter_ontologyterm_ontology_service.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2023-08-14 23:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ontology', '0025_alter_ontologyterm_ontology_service'), + ] + + operations = [ + migrations.AlterField( + model_name='ontologyterm', + name='ontology_service', + field=models.CharField(choices=[('MONDO', 'MONDO'), ('OMIM', 'OMIM'), ('HP', 'HP'), ('HGNC', 'HGNC'), ('DOID', 'DOID'), ('ORPHA', 'ORPHA'), ('MedGen', 'MedGen')], max_length=10), + ), + ] diff --git a/ontology/models/models_ontology.py b/ontology/models/models_ontology.py index 92836d839..697099438 100644 --- a/ontology/models/models_ontology.py +++ b/ontology/models/models_ontology.py @@ -45,7 +45,7 @@ class OntologyService(models.TextChoices): HGNC = "HGNC", "HGNC" DOID = "DOID", "DOID" - ORPHANET = "Orphanet", "Orphanet" + ORPHANET = "ORPHA", "ORPHA" MEDGEN = "MedGen", "MedGen" EXPECTED_LENGTHS: Dict[str, int] = Constant({ @@ -257,8 +257,8 @@ def normalize(dirty_id: str) -> 'OntologyIdNormalized': raise ValueError(f"Can not convert {dirty_id} to a proper id") prefix = parts[0].strip().upper() - if prefix == "ORPHANET": # Orphanet is the one ontology (so far) where the standard is sentance case - prefix = "Orphanet" + if prefix == "ORPHA": # Orphanet is the one ontology (so far) where the standard is sentance case + prefix = "ORPHA" elif prefix.upper() == "MIM": prefix = "OMIM" elif prefix.upper() == "MEDGEN": diff --git a/ontology/models/ontology_search.py b/ontology/models/ontology_search.py index 4f386b4f3..ca839e180 100644 --- a/ontology/models/ontology_search.py +++ b/ontology/models/ontology_search.py @@ -27,7 +27,7 @@ def validate_ontology(term: OntologyTerm, preview_proxy: Optional[PreviewProxyMo return SearchResult(preview, messages=messages) -ONTOLOGY_TERM_PATTERN = re.compile(r"^((MONDO|OMIM|MIM|HPO|HP|DOID|ORPHANET)\s*:\s*[0-9]+)|(MEDGEN\s*:\s*\w{0,2}[0-9]+)$", re.IGNORECASE) +ONTOLOGY_TERM_PATTERN = re.compile(r"^((MONDO|OMIM|MIM|HPO|HP|DOID|ORPHA)\s*:\s*[0-9]+)|(MEDGEN\s*:\s*\w{0,2}[0-9]+)$", re.IGNORECASE) @search_receiver( search_type=OntologyTerm,