Skip to content

Commit

Permalink
# Conflicts:
Browse files Browse the repository at this point in the history
#	annotation/models/models.py
#	annotation/vep_annotation.py
#	classification/migrations/0151_one_off_tier_1_2.py
#	snpdb/management/commands/one_off_fix_symbolic_variants.py
  • Loading branch information
TheMadBug committed Jul 31, 2024
1 parent da84b8b commit a169721
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classification/migrations/0151_one_off_tier_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def inject_tier_1_2(apps, schema_editor):
"key": "tier_1_or_2",
"tier": "1",
"index": 5,
"label": "Tier I or II",
"label": "Tier I / II",
"aliases": ["1 or 2"]
}
)
Expand Down
43 changes: 43 additions & 0 deletions classification/migrations/0152_allele_origin_confirmed_ekey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 4.2.11 on 2024-07-31 01:02

from django.db import migrations


def add_evidence_key(apps, schema_editor):
data = {
"key": "allele_origin_confirmation",
"order": 12,
"evidence_category": "V",
"value_type": "S",
"description": "Paired or follow up testing to confirm allele origin of variant.",
"options": [
{
"key": "confirmed",
"index": 1
},
{
"key": "unconfirmed",
"index": 2
}
],
"copy_consensus": False
}
EvidenceKey = apps.get_model('classification', 'EvidenceKey')
EvidenceKey.objects.get_or_create(key="allele_origin_confirmation", defaults=data)


def remove_evidence_key(apps, schema_editor):
EvidenceKey = apps.get_model('classification', 'EvidenceKey')
if ek := EvidenceKey.objects.filter(key="allele_origin_confirmation").first():
ek.delete()


class Migration(migrations.Migration):

dependencies = [
('classification', '0151_one_off_tier_1_2'),
]

operations = [
migrations.RunPython(add_evidence_key, remove_evidence_key)
]
11 changes: 10 additions & 1 deletion classification/views/classification_export_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.db.models import Count
from django.db.models.query import QuerySet

from classification.enums import CriteriaEvaluation
from classification.models.classification import ClassificationModification
from classification.models.evidence_key import EvidenceKeyMap, EvidenceKey
from genes.hgvs import CHGVS
Expand Down Expand Up @@ -47,7 +48,7 @@ def value_for(self, ekey: EvidenceKey, value, pretty: bool = False, cell_formatt
class UsedKey:

def __init__(self):
self.ekey = None
self.ekey: Optional[EvidenceKey] = None
self.has_value = False
self.has_note = False
self.has_explain = False
Expand Down Expand Up @@ -189,6 +190,14 @@ def row(self, classification_modification: ClassificationModification, formatter
cols.append(None)
else:
value = value_obj.get('value')

# prettyValue for a horak code will say Met: 2 Points
# we just want to say 2
if used_key.ekey.crit_uses_points:
points = CriteriaEvaluation.POINTS.get(value)
if points is not None:
value = str(points)

cols.append(self.key_value_formatter.value_for(used_key.ekey, value, pretty=self.pretty, cell_formatter=self.cell_formatter))
if used_key.has_note:
if not value_obj:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def resolved_condition(self):
return (self.vc.condition_resolution_dict or {}).get('display_text')

@export_column()
def acmg_criteria(self):
def criteria(self):
return self.cm.criteria_strength_summary(self.e_keys)

@export_column()
Expand Down
22 changes: 19 additions & 3 deletions library/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,13 @@ def slack_bot_username():
return f"{site_name} ({env_name})"


# message limit is actually 4000, but this gives us a lot of leway
SLACK_CHARACTER_LIMIT = 3500


def send_notification(
message: str,
blocks: Optional[list] = None,
blocks: Optional[list[NotificationBuilder.Block]] = None,
slack_webhook_url: Optional[str] = None):
"""
Sends a message to your notification service, currently Slack centric.
Expand All @@ -435,8 +439,20 @@ def send_notification(
"text": message,
"icon_emoji": emoji
}
if blocks:
data["blocks"] = blocks
character_count = 0
data_blocks = []
for block in blocks:
this_block = json.dumps(block)
character_count += len(this_block)
if character_count >= SLACK_CHARACTER_LIMIT:
data_blocks.append(
NotificationBuilder.MarkdownBlock("Message is too big for slack, check EventLog for the full message").as_slack()
)
break
data_blocks.append(block)

if data_blocks:
data["blocks"] = data_blocks

r = requests.post(
headers={"Content-Type": "application/json"},
Expand Down

0 comments on commit a169721

Please sign in to comment.