Skip to content

Commit

Permalink
#805 - rename VARIANT_CLASSIFICATION_ to CLASSIFICATION_
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Sep 26, 2023
1 parent 31f7dfa commit e27a159
Show file tree
Hide file tree
Showing 30 changed files with 170 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def get_evidence_fields_from_preferred_transcript(
data[SpecialEKeys.P_HGVS] = clingen_allele.get_p_hgvs(transcript_version.accession, match_version=False)

# If we have a synonymous protein change, but a molecular consequence of splicing, change the "=" into "?"
if settings.VARIANT_CLASSIFICATION_AUTO_POPULATE_P_HGVS_SYNONYMOUS_SPLICE_CHANGE_TO_UNKNOWN:
if settings.CLASSIFICATION_AUTO_POPULATE_P_HGVS_SYNONYMOUS_SPLICE_CHANGE_TO_UNKNOWN:
p_hgvs = data[SpecialEKeys.P_HGVS]
if p_hgvs and "=" in p_hgvs and "splice" in transcript_data.get("consequence", ""):
prefix, allele = p_hgvs.split(":", 1)
Expand Down
2 changes: 1 addition & 1 deletion classification/classification_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_classification_counts_allele(qs: QuerySet[ClassificationModification], f
def get_visible_classifications_qs(user: User) -> QuerySet[ClassificationModification]:
# now excludes external labs (don't want to report on Shariant only data within SA Path for example)

shared = settings.VARIANT_CLASSIFICATION_STATS_USE_SHARED
shared = settings.CLASSIFICATION_STATS_USE_SHARED
kwargs = {"classification__lab__external": False}
if shared:
kwargs["clinical_significance__isnull"] = False
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.2.2 on 2023-09-26 05:13
import logging

from django.conf import settings
from django.db import migrations

from manual.operations.manual_operations import ManualOperation

def _check_settings_for_variant_classification(apps):
has_old_settings = False
for x in dir(settings):
if x.startswith("VARIANT_CLASSIFICATION"):
if not has_old_settings: # Only show 1st time
logging.warning("Your developer settings has obsolete settings. Please rename:")
has_old_settings = True
old_setting = x
new_setting = x[len("VARIANT_"):]
logging.warning("settings.%s -> %s", old_setting, new_setting)
return has_old_settings


class Migration(migrations.Migration):

dependencies = [
('classification', '0111_alter_resolvedvariantinfo_options'),
]

operations = [
ManualOperation.operation_other([
"Rename settings from VARIANT_CLASSIFICATION_X to CLASSIFICATION_X"
], test=_check_settings_for_variant_classification),
]

14 changes: 7 additions & 7 deletions classification/models/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ class Meta:

@staticmethod
def can_create_via_web_form(user: User):
can_create = settings.VARIANT_CLASSIFICATION_WEB_FORM_CREATE
return can_create and (user.is_superuser or settings.VARIANT_CLASSIFICATION_WEB_FORM_CREATE_BY_NON_ADMIN)
can_create = settings.CLASSIFICATION_WEB_FORM_CREATE
return can_create and (user.is_superuser or settings.CLASSIFICATION_WEB_FORM_CREATE_BY_NON_ADMIN)

@staticmethod
def dashboard_report_new_classifications(since) -> int:
Expand Down Expand Up @@ -691,7 +691,7 @@ def id_str(self):

@property
def cr_lab_id(self):
if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX:
if settings.CLASSIFICATION_ID_OVERRIDE_PREFIX:
return f"CR_{self.id}"
return self.lab_record_id

Expand Down Expand Up @@ -1033,7 +1033,7 @@ def process_option_values(cell: VCDataCell, values: List[Any]) -> Optional[List[
matched_option = Classification.match_option(options, check_value)
if matched_option:
results.append(matched_option.get('key'))
if settings.VARIANT_CLASSIFICATION_REQUIRE_OVERWRITE_NOTE and \
if settings.CLASSIFICATION_REQUIRE_OVERWRITE_NOTE and \
matched_option.get('override') and cell.note is None and cell.explain is None:
cell.add_validation(
code=ValidationCode.REQUIRES_NOTE,
Expand Down Expand Up @@ -1246,7 +1246,7 @@ def process_entry(self, cell: VCDataCell, source: str):
message='Transcript should include version e.g. NM_001256799.1')

elif e_key.key == SpecialEKeys.AGE:
if settings.VARIANT_CLASSIFICATION_AUTOFUZZ_AGE:
if settings.CLASSIFICATION_AUTOFUZZ_AGE:
cell.value = patch_fuzzy_age(value)

# ensure we have one non None value before returning the structure
Expand Down Expand Up @@ -2200,7 +2200,7 @@ def __str__(self) -> str:

@staticmethod
def check_can_create_no_classification_via_web_form(_user: User):
if not settings.VARIANT_CLASSIFICATION_WEB_FORM_CREATE_ALLOW_NO_VARIANT:
if not settings.CLASSIFICATION_WEB_FORM_CREATE_ALLOW_NO_VARIANT:
raise CreateNoClassificationForbidden()


Expand Down Expand Up @@ -2289,7 +2289,7 @@ def id_str(self) -> str:

@property
def cr_lab_id(self) -> str:
if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX:
if settings.CLASSIFICATION_ID_OVERRIDE_PREFIX:
return f"CR_{self.classification.id_str}"
return self.classification.lab_record_id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def validate_variant_fields(sender, **kwargs) -> Optional[ValidationMerger]: #
"""
vm = ValidationMerger()

if not settings.VARIANT_CLASSIFICATION_MATCH_VARIANTS:
if not settings.CLASSIFICATION_MATCH_VARIANTS:
# while this technically isn't about matching a variant, much of the work in get_variant_tuple -> pyhgvs
# requires
return vm
Expand Down
4 changes: 2 additions & 2 deletions classification/models/classification_variant_info_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def set_variant_and_save(self, variant: Variant) -> 'ResolvedVariantInfo':
c_hgvs = hgvs_variant.format()
c_hgvs_obj = CHGVS(c_hgvs)
self.c_hgvs = c_hgvs
self.c_hgvs_full = hgvs_variant.format(max_ref_length=settings.VARIANT_CLASSIFICATION_MAX_REFERENCE_LENGTH)
self.c_hgvs_full = hgvs_variant.format(max_ref_length=settings.CLASSIFICATION_MAX_REFERENCE_LENGTH)
self.transcript_version = c_hgvs_obj.transcript_version_model(genome_build=genome_build)
self.gene_symbol = GeneSymbol.objects.filter(symbol=c_hgvs_obj.gene_symbol).first()
except Exception as exception:
Expand Down Expand Up @@ -586,7 +586,7 @@ def issue_icon(self) -> Optional[IconWithTooltip]:
def is_supported_transcript(transcript_or_hgvs: str):
if not transcript_or_hgvs:
return False
for transcript_type in settings.VARIANT_CLASSIFICATION_SUPPORTED_TRANSCRIPTS:
for transcript_type in settings.CLASSIFICATION_SUPPORTED_TRANSCRIPTS:
if transcript_or_hgvs.startswith(transcript_type):
return True
return False
Expand Down
2 changes: 1 addition & 1 deletion classification/models/evidence_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def loaded_citations(self) -> CitationFetchResponse:

@property
def is_likely_acmg(self) -> bool:
if non_standard_res := settings.VARIANT_CLASSIFICATION_NON_ACMG_ASSERTION_METHOD:
if non_standard_res := settings.CLASSIFICATION_NON_ACMG_ASSERTION_METHOD:
if assertion_method := self.get(SpecialEKeys.ASSERTION_METHOD):
for non_standard_re in non_standard_res:
if non_standard_re.match(assertion_method):
Expand Down
2 changes: 1 addition & 1 deletion classification/models/variant_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _classification_import_from(self, genome_build: GenomeBuild):

def queue_resolve(self, imported_allele_info: ImportedAlleleInfo) -> bool:
actually_queued = False
if settings.VARIANT_CLASSIFICATION_MATCH_VARIANTS:
if settings.CLASSIFICATION_MATCH_VARIANTS:
if imported_allele_info.status == ImportedAlleleInfoStatus.PROCESSING and imported_allele_info.classification_import is None:
if genome_build_version := imported_allele_info.imported_genome_build_patch_version:
self.all_count += 1
Expand Down
2 changes: 1 addition & 1 deletion classification/signals/classification_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
search_type=Classification,
example=SearchExample(
note="The lab record ID",
examples=["CR_1545" if settings.VARIANT_CLASSIFICATION_ID_OVERRIDE_PREFIX else "vc1545"]
examples=["CR_1545" if settings.CLASSIFICATION_ID_OVERRIDE_PREFIX else "vc1545"]
)
)
def classification_search(search_input: SearchInputInstance):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ClassificationImportMapInsertTask(Task):

@property
def data_dir(self) -> Path:
if data_dir_str := settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_DATA_DIR:
if data_dir_str := settings.CLASSIFICATION_OMNI_IMPORTER_DATA_DIR:
data_dir = pathlib.Path(data_dir_str)
data_dir.mkdir(parents=True, exist_ok=True)
if not data_dir.exists():
Expand All @@ -35,15 +35,15 @@ def data_dir(self) -> Path:

@property
def omni_importer_dir(self) -> Path:
if omni_importer_dir_str := settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_APP_DIR:
if omni_importer_dir_str := settings.CLASSIFICATION_OMNI_IMPORTER_APP_DIR:
omni_importer_dir = pathlib.Path(omni_importer_dir_str)
if not omni_importer_dir.exists():
raise ValueError(f"{omni_importer_dir_str} does not exist")
if not (omni_importer_dir / "main.py").exists():
raise ValueError(f"main.py doesn't exist inside OMNI IMPORTER DIR {settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_APP_DIR}")
raise ValueError(f"main.py doesn't exist inside OMNI IMPORTER DIR {settings.CLASSIFICATION_OMNI_IMPORTER_APP_DIR}")
return omni_importer_dir
else:
raise ValueError("Require settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_APP_DIR to be set to do automated imports")
raise ValueError("Require settings.CLASSIFICATION_OMNI_IMPORTER_APP_DIR to be set to do automated imports")

@staticmethod
def update_status(upload_file: UploadedClassificationsUnmapped, status: UploadedClassificationsUnmappedStatus):
Expand Down Expand Up @@ -99,8 +99,8 @@ def run(self, upload_classifications_unmapped_id: int, import_records: bool = Tr
# and import it
# --file data/path_west/sharmvl_grch38molecular_variants20220326_060243.json --publish logged_in_users --org path_west --lab unit_1 --env prod

publish = settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_PUBLISH_LEVEL
include_source = settings.VARIANT_CLASSIFICATION_OMNI_IMPORTER_INCLUDE_SOURCE
publish = settings.CLASSIFICATION_OMNI_IMPORTER_PUBLISH_LEVEL
include_source = settings.CLASSIFICATION_OMNI_IMPORTER_INCLUDE_SOURCE

args: List[str] = [
settings.PYTHON_COMMAND, "main.py",
Expand Down
20 changes: 10 additions & 10 deletions classification/templates/classification/classifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@
</script>
{% endblock %}
{% block content %}
{% settings_value 'VARIANT_CLASSIFICATION_GRID_SHOW_USERNAME' as VARIANT_CLASSIFICATION_GRID_SHOW_USERNAME %}
{% settings_value 'VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN' as VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN %}
{% settings_value 'VARIANT_CLASSIFICATION_ID_FILTER' as VARIANT_CLASSIFICATION_ID_FILTER %}
{% settings_value 'VARIANT_CLASSIFICATION_REDCAP_EXPORT' as VARIANT_CLASSIFICATION_REDCAP_EXPORT %}
{% settings_value 'CLASSIFICATION_GRID_SHOW_USERNAME' as CLASSIFICATION_GRID_SHOW_USERNAME %}
{% settings_value 'CLASSIFICATION_GRID_SHOW_ORIGIN' as CLASSIFICATION_GRID_SHOW_ORIGIN %}
{% settings_value 'CLASSIFICATION_ID_FILTER' as CLASSIFICATION_ID_FILTER %}
{% settings_value 'CLASSIFICATION_REDCAP_EXPORT' as CLASSIFICATION_REDCAP_EXPORT %}

<div class="container">
{% if labs.count > 0 and can_create_classification %}
Expand All @@ -177,10 +177,10 @@
</p>
{% endif %}
<p>
Export the grid below by clicking the CSV {% if VARIANT_CLASSIFICATION_REDCAP_EXPORT %} or Redcap {% endif %}buttons on the bottom left of the grid.<br/>
Export the grid below by clicking the CSV {% if CLASSIFICATION_REDCAP_EXPORT %} or Redcap {% endif %}buttons on the bottom left of the grid.<br/>
The export will be using your default genome build.<br/>
</p>
{% if VARIANT_CLASSIFICATION_REDCAP_EXPORT %}
{% if CLASSIFICATION_REDCAP_EXPORT %}
<p>
You can import into REDCap using this <a href="/classification/redcap_data_dictionary.csv">data definition</a>.<br/>
Records will only be included in REDCap downloads if they have a value for <b>redcap_record_id</b>.
Expand All @@ -200,19 +200,19 @@
{% endif %}
{% crispy lab_form form_helper.horizontal_no_labels %}
</div>
{% if VARIANT_CLASSIFICATION_GRID_SHOW_USERNAME %}
{% if CLASSIFICATION_GRID_SHOW_USERNAME %}
<div class="col-md-4 col-lg-2">
<a class="hover-link" onclick="filterDefaultUser()">Filter : My Classifications</a>
{% crispy user_form form_helper.horizontal_no_labels %}
</div>
{% endif %}
{% if VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN %}
{% if CLASSIFICATION_GRID_SHOW_ORIGIN %}
<div class="col-md-4 col-lg-2">
<br />
{% crispy allele_origin_form form_helper.horizontal_no_labels %}
</div>
{% endif %}
{% if VARIANT_CLASSIFICATION_ID_FILTER %}
{% if CLASSIFICATION_ID_FILTER %}
<div class="col-md-4 col-lg-2">
<br/>
<input type="text" id="id_filter" placeholder="IDs filter" class="form-control" title="Filters on various ID evidence fields" />
Expand Down Expand Up @@ -241,7 +241,7 @@
<div>
Download as
<a class='hover-link download-link' href="javascript:downloadAs('csv')">CSV</a>
{% if VARIANT_CLASSIFICATION_REDCAP_EXPORT %},
{% if CLASSIFICATION_REDCAP_EXPORT %},
<a class='hover-link download-link' href="javascript:downloadAs('redcap')">REDCap</a>
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{% block title %}Variant Classification{% endblock %}
{% block head %}
{% settings_value 'VARIANT_CLASSIFICATION_WEB_FORM_CREATE_INITIALLY_REQUIRE_SAMPLE' as initially_require_sample %}
{% settings_value 'CLASSIFICATION_WEB_FORM_CREATE_INITIALLY_REQUIRE_SAMPLE' as initially_require_sample %}

<style>
.pill {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{% load js_tags %}
{% load settings_tags %}

{% settings_value 'VARIANT_CLASSIFICATION_GRID_SHOW_USERNAME' as show_username %}
{% settings_value 'VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN' as show_allele_origin %}
{% settings_value 'VARIANT_CLASSIFICATION_SHOW_SPECIMEN_ID' as show_specimen_id %}
{% settings_value 'CLASSIFICATION_GRID_SHOW_USERNAME' as show_username %}
{% settings_value 'CLASSIFICATION_GRID_SHOW_ORIGIN' as show_allele_origin %}
{% settings_value 'CLASSIFICATION_SHOW_SPECIMEN_ID' as show_specimen_id %}


<tr class="{{ row_class }}" style="{% if group.clinical_grouping == "not-shared" %}opacity:0.5;{% endif %}{% if group.is_withdrawn %}text-decoration:line-through;{% endif %}cursor:pointer">
Expand Down
10 changes: 5 additions & 5 deletions classification/templatetags/classification_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def classification_groups(
"user": context.request.user,
"genome_build": groups.genome_build,
"table_id": str(uuid.uuid4()).replace("-", "_"),
"show_allele_origin": settings.VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN,
"show_allele_origin": settings.CLASSIFICATION_GRID_SHOW_ORIGIN,
"sort_order_index": sort_order_index
}
ordered_classifications = list(groups.modifications)
Expand Down Expand Up @@ -338,7 +338,7 @@ def classification_modification_sort_score(vcm: ClassificationModification):
"show_variant_link": show_variant_link,
"show_clinical_context": show_clinical_context,
"edit_clinical_groupings": edit_clinical_groupings,
"show_allele_origin": settings.VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN,
"show_allele_origin": settings.CLASSIFICATION_GRID_SHOW_ORIGIN,
"user": user,
"discordance_enabled": settings.DISCORDANCE_ENABLED
}
Expand Down Expand Up @@ -410,7 +410,7 @@ def classification_row(

c_hgvs = vc.c_hgvs_best(preferred_genome_build=genome_build)
p_hgvs = None
if settings.VARIANT_CLASSIFICATION_GRID_SHOW_PHGVS:
if settings.CLASSIFICATION_GRID_SHOW_PHGVS:
p_hgvs = record.get(SpecialEKeys.P_HGVS)
if p_hgvs:
p_dot = p_hgvs.find('p.')
Expand All @@ -431,8 +431,8 @@ def classification_row(
"show_variant_link": show_variant_link,
"show_clinical_context": show_clinical_context,
"edit_clinical_context": edit_clinical_context,
"show_allele_origin": settings.VARIANT_CLASSIFICATION_GRID_SHOW_ORIGIN,
"show_specimen_id": settings.VARIANT_CLASSIFICATION_SHOW_SPECIMEN_ID
"show_allele_origin": settings.CLASSIFICATION_GRID_SHOW_ORIGIN,
"show_specimen_id": settings.CLASSIFICATION_SHOW_SPECIMEN_ID
}


Expand Down
6 changes: 3 additions & 3 deletions classification/tests/models/test_classification_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setUp(self):
def tearDown(self):
ClassificationTestUtils.tearDown()

@override_settings(VARIANT_CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=False)
@override_settings(CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=False)
def test_override_note_disabled(self):
lab, user = ClassificationTestUtils.lab_and_user()
vc = Classification.create(
Expand All @@ -30,7 +30,7 @@ def test_override_note_disabled(self):
bp2 = vc.evidence.get('bp2')
self.assertEqual(bp2, {'value': 'BA'})

@override_settings(VARIANT_CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=True)
@override_settings(CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=True)
def test_override_note_enabled(self):
lab, user = ClassificationTestUtils.lab_and_user()
vc = Classification.create(
Expand All @@ -53,7 +53,7 @@ def test_override_note_enabled(self):
}]
})

@override_settings(VARIANT_CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=True)
@override_settings(CLASSIFICATION_REQUIRE_OVERWRITE_NOTE=True)
def test_external(self):
lab, user = ClassificationTestUtils.external_lab_and_user()
vc = Classification.create(
Expand Down
2 changes: 1 addition & 1 deletion classification/tests/utils/test_clinvar_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def mock_send_data(
class TestClinVarExport(TestCase):

@mock.patch('classification.models.clinvar_export_sync.ClinVarExportSync._send_data', side_effect=mock_send_data)
@override_settings(VARIANT_CLASSIFICATION_MATCH_VARIANTS=False, CLINVAR_EXPORT={"enabled": True, "mode": "prod", "api_key": "ABC123"})
@override_settings(CLASSIFICATION_MATCH_VARIANTS=False, CLINVAR_EXPORT={"enabled": True, "mode": "prod", "api_key": "ABC123"})
def test_clinvar_setup(self, mocked_send_data):

grch37 = GenomeBuild.get_name_or_alias("GRCh37")
Expand Down
8 changes: 4 additions & 4 deletions classification/tests/views/test_classification_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def request_post(self, data):
request.data = data
return ClassificationView().post(request=request)

@override_settings(VARIANT_CLASSIFICATION_MATCH_VARIANTS=False)
@override_settings(CLASSIFICATION_MATCH_VARIANTS=False)
def test_return_data(self):
lab, _user = ClassificationTestUtils.lab_and_user()
response = self.request_post({
Expand Down Expand Up @@ -158,7 +158,7 @@ def test_return_data(self):
self.maxDiff = None
self.assertEqual(response, expected)

@override_settings(VARIANT_CLASSIFICATION_MATCH_VARIANTS=False)
@override_settings(CLASSIFICATION_MATCH_VARIANTS=False)
def test_test_mode(self):

lab, _user = ClassificationTestUtils.lab_and_user()
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_test_mode(self):
diffs = DeepDiff(t1=expected, t2=response_json)
self.assertFalse(diffs)

@override_settings(VARIANT_CLASSIFICATION_MATCH_VARIANTS=False)
@override_settings(CLASSIFICATION_MATCH_VARIANTS=False)
def test_bulk(self):
lab, _user = ClassificationTestUtils.lab_and_user()
response = self.request_post({"records": [{
Expand All @@ -229,7 +229,7 @@ def test_bulk(self):
self.assertEqual(results[0]['lab_record_id'], "test_1")
self.assertEqual(results[1]['lab_record_id'], "test_2")

@override_settings(VARIANT_CLASSIFICATION_MATCH_VARIANTS=False)
@override_settings(CLASSIFICATION_MATCH_VARIANTS=False)
def test_basic_update(self):
lab, _user = ClassificationTestUtils.lab_and_user()
# all test that aliases work re foo BAAA -> bar
Expand Down
Loading

0 comments on commit e27a159

Please sign in to comment.