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

#3090 removed hyperlinks and displaying co-occurring/uncertain in MVL export #906

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions classification/models/classification_groups.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's a very obscure edge case but:

Classifications can be put in the same group as long as the first resolved ontology term is shared

This means there could be a scenario where we have:
Condition A, Condition B, co-occurring
Condition A, Condition C, co-occurring

which would show up as
Condition A, Condition B, Condition C co-occurring.

To keep things safe, I'd suggest we only show the join term if the condition_resolution_obj for each condition is the same (not just if the joining term is the same).

Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,25 @@ def __lt__(self, other):
def conditions(self) -> List[ConditionResolved]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note this is a left over from my code that made things more complicated than they need to be)

It might be cleanest to change the signature of ClassificationGroup.conditions to return a single ConditionResolved, as it only returns multiple now because a single ConditionResolved doesn't properly handle the merging of resolved terms and plain text - but they wont be grouped together anyway.

That way we don't need to hack the join term so much either (as in we can just use the condition tag as it was)

all_terms = set()
all_plain_texts = set()
all_joins = set()
for cm in self.modifications:
c = cm.classification
if resolved := c.condition_resolution_obj:
for term in resolved.terms:
all_terms.add(term)
all_joins.add(resolved.join)
else:
if text := cm.get(SpecialEKeys.CONDITION):
all_plain_texts.add(text)
all_condition_resolved = []
shared_join = None
if len(all_joins) == 1: # if there's more than one join, we can't display it
shared_join = all_joins.pop()

for term in all_terms:
all_condition_resolved.append(ConditionResolved(terms=[term], join=None))
all_condition_resolved.append(ConditionResolved(terms=[term], join=shared_join))
for plain_text in all_plain_texts:
all_condition_resolved.append(ConditionResolved(terms=[], join=None, plain_text=plain_text))
all_condition_resolved.append(ConditionResolved(terms=[], join=shared_join, plain_text=plain_text))

all_condition_resolved.sort()
return all_condition_resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load classification_tags %}
<br/>
{% spaceless %}
<table style="max-width:1200px">
<thead>
<tr style='border-bottom:1px solid gray;border-top:1px solid gray'>
Expand All @@ -22,11 +23,16 @@
<del>{{ group.clinical_significance | ekey:'clinical_significance' }}</del><br/>{{ group.clinical_significance_pending | ekey:'clinical_significance' }} (PENDING)
{% else %}{{ group.clinical_significance | ekey:'clinical_significance' }}{% endif %}
</td>
<td style='padding:8px'>{% for condition in group.conditions %}<div>{% condition condition_obj=condition limit=None %}</div>{% empty %}-{% endfor %}</td>
<td style='padding:8px'>{% for condition in group.conditions %}<div>{% condition condition_obj=condition limit=None no_links=True %}</div>{% empty %}-{% endfor %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OntologyTerm has "show_link" which defaults to True, probably best to keep the convention (instead of "no_links" defaulting to False).

{% if group.conditions|length > 0 and group.conditions.0.join_text %}
<span class="font-italic">{{ group.conditions.0.join_text }}</span>
{% endif %}
</td>
<td style='padding:8px'>{{ group.zygosities | ekey:'zygosity' }}</td>
<td style='font-family:monospace;padding:8px'>{% for acmg in group.acmg_criteria %}{% if not forloop.first %}, {% endif %}{{ acmg }}{% empty %}-{% endfor %}</td>
<td style='font-family:monospace;padding:8px'><div style='white-space: nowrap'>{% with curated_date=group.most_recent_curated %}{% if curated_date.name %}{{ curated_date.name }} {% endif %}{{ curated_date.date | date:'Y-m-d' }}{% endwith %}</div></td>
</tr>
{% endfor %}
</tbody>
</table>
</table>
{% endspaceless %}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
{% empty %}
<div class="no-value">-</div>
{% endfor %}
{% if group.conditions|length > 0 and group.conditions.0.join_text %}
<span class="font-italic">{{ group.conditions.0.join_text }}</span>
{% endif %}
</td>
<td style="width:100px;">
{% if show_allele_origin %}
Expand Down
7 changes: 5 additions & 2 deletions classification/templates/classification/tags/condition.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
{% if condition.terms %}
{% for term in condition.terms %}
{% if not forloop.first %}<br/>{% endif %}
<span><a href="{% url 'ontology_term' term.url_safe_id %}" class="hover-link">{{ term.id }}</a> {{ term.name }}</span>
{% if no_links %}
<span> {{ term.id }} {{ term.name }}</span>
{% else %}
<span><a href="{% url 'ontology_term' term.url_safe_id %}" class="hover-link">{{ term.id }}</a> {{ term.name }}</span>
{% endif %}
{% endfor %}
{% if condition.join_text %}&#32;<span class="font-italic">{{ condition.join_text }}</span>{% endif %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change ClassificationGroup as per the above suggestion, then we can put this back in.

Especially since {% condition %} is used in other contexts where we would want to show off the join text

{% else %}{{ condition.plain_text | limit_length:limit }}{% endif %}
4 changes: 2 additions & 2 deletions classification/templatetags/classification_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ def db_ref(data: VCDbRefDict, css: Optional[str] = ''):


@register.inclusion_tag("classification/tags/condition.html")
def condition(condition_obj: ConditionResolved, limit: Optional[int] = 100):
return {"condition": condition_obj, "limit": limit}
def condition(condition_obj: ConditionResolved, limit: Optional[int] = 100, no_links: Optional[bool] = None):
return {"condition": condition_obj, "limit": limit, "no_links": no_links}


# look at removing this
Expand Down
Loading