scout-browser 4.102.0__py3-none-any.whl → 4.103.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. scout/adapter/mongo/case.py +26 -122
  2. scout/adapter/mongo/clinvar.py +91 -25
  3. scout/adapter/mongo/event.py +0 -47
  4. scout/adapter/mongo/variant_loader.py +7 -3
  5. scout/build/variant/variant.py +1 -0
  6. scout/commands/load/variants.py +1 -1
  7. scout/commands/update/user.py +87 -49
  8. scout/constants/__init__.py +3 -0
  9. scout/constants/clinvar.py +10 -0
  10. scout/constants/variant_tags.py +18 -0
  11. scout/demo/NIST.trgt.stranger.vcf.gz +0 -0
  12. scout/demo/NIST.trgt.stranger.vcf.gz.tbi +0 -0
  13. scout/demo/__init__.py +1 -0
  14. scout/models/clinvar.py +86 -0
  15. scout/parse/variant/coordinates.py +5 -1
  16. scout/parse/variant/gene.py +5 -9
  17. scout/parse/variant/genotype.py +66 -42
  18. scout/parse/variant/variant.py +2 -0
  19. scout/server/app.py +71 -2
  20. scout/server/blueprints/alignviewers/templates/alignviewers/igv_viewer.html +2 -0
  21. scout/server/blueprints/cases/controllers.py +1 -1
  22. scout/server/blueprints/cases/templates/cases/case_report.html +19 -2
  23. scout/server/blueprints/cases/templates/cases/utils.html +8 -29
  24. scout/server/blueprints/clinvar/controllers.py +233 -53
  25. scout/server/blueprints/clinvar/form.py +38 -1
  26. scout/server/blueprints/clinvar/static/form_style.css +8 -1
  27. scout/server/blueprints/clinvar/templates/clinvar/clinvar_onc_submissions.html +200 -0
  28. scout/server/blueprints/clinvar/templates/clinvar/clinvar_submissions.html +3 -2
  29. scout/server/blueprints/clinvar/templates/clinvar/components.html +198 -0
  30. scout/server/blueprints/clinvar/templates/clinvar/multistep_add_onc_variant.html +187 -0
  31. scout/server/blueprints/clinvar/templates/clinvar/multistep_add_variant.html +9 -348
  32. scout/server/blueprints/clinvar/templates/clinvar/scripts.html +193 -0
  33. scout/server/blueprints/clinvar/views.py +90 -13
  34. scout/server/blueprints/institutes/controllers.py +44 -5
  35. scout/server/blueprints/institutes/forms.py +1 -0
  36. scout/server/blueprints/institutes/templates/overview/gene_variants.html +15 -6
  37. scout/server/blueprints/institutes/templates/overview/institute_sidebar.html +28 -2
  38. scout/server/blueprints/institutes/templates/overview/utils.html +1 -1
  39. scout/server/blueprints/institutes/views.py +17 -4
  40. scout/server/blueprints/mme/templates/mme/mme_submissions.html +2 -2
  41. scout/server/blueprints/omics_variants/templates/omics_variants/outliers.html +2 -2
  42. scout/server/blueprints/variant/controllers.py +1 -1
  43. scout/server/blueprints/variant/templates/variant/cancer-variant.html +2 -1
  44. scout/server/blueprints/variant/templates/variant/components.html +0 -1
  45. scout/server/blueprints/variant/templates/variant/sv-variant.html +2 -1
  46. scout/server/blueprints/variant/templates/variant/variant.html +2 -2
  47. scout/server/blueprints/variant/templates/variant/variant_details.html +32 -24
  48. scout/server/blueprints/variants/templates/variants/cancer-variants.html +5 -3
  49. scout/server/blueprints/variants/templates/variants/str-variants.html +4 -1
  50. scout/server/blueprints/variants/templates/variants/sv-variants.html +3 -3
  51. scout/server/blueprints/variants/templates/variants/utils.html +4 -0
  52. scout/server/blueprints/variants/templates/variants/variants.html +4 -4
  53. scout/server/extensions/clinvar_extension.py +2 -2
  54. scout/server/templates/layout.html +1 -1
  55. {scout_browser-4.102.0.dist-info → scout_browser-4.103.0.dist-info}/METADATA +1 -1
  56. {scout_browser-4.102.0.dist-info → scout_browser-4.103.0.dist-info}/RECORD +59 -53
  57. {scout_browser-4.102.0.dist-info → scout_browser-4.103.0.dist-info}/WHEEL +0 -0
  58. {scout_browser-4.102.0.dist-info → scout_browser-4.103.0.dist-info}/entry_points.txt +0 -0
  59. {scout_browser-4.102.0.dist-info → scout_browser-4.103.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,9 @@
1
1
  {% extends "bootstrap_global.html" %}
2
+ {% from "clinvar/components.html" import condition_identifiers, hgvs_choices, observations %}
2
3
 
3
4
  {% block css %}
4
5
  {{ super() }}
5
- <link rel="stylesheet" href="{{ url_for('clinvar.static', filename='form_style.css') }}"></link>
6
+ <link rel="stylesheet" href="{{ url_for('clinvar.static', filename='form_style.css') }}"/>
6
7
  <link href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" rel="stylesheet" integrity="sha512-nMNlpuaDPrqlEls3IX/Q56H36qvBASwb3ipuo3MxeWbsQB1881ox0cRv7UPTgBlriqoynt35KjEwgGUeUXIPnw==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
7
8
  <link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.2.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />
8
9
  {% endblock %}
@@ -23,14 +24,14 @@
23
24
  <div class="col-md-10">
24
25
  <form id="clinVarAdd" method="POST" action="{{ url_for('clinvar.clinvar_save', institute_id=institute._id, case_name=case.display_name) }}" id="{{variant_data.var_id}}_form">
25
26
  <!-- progressbar -->
26
- <ul id="progressbar">
27
+ <ul id="progressbar" class="steps-7">
27
28
  <li class="active">Start</li>
28
29
  <li>Assertion Criteria</li>
29
30
  <li>Variant Details</li>
30
31
  <li>Inheritance Model</li>
31
32
  <li>Germline Classification</li>
32
33
  <li>Associated conditions</li>
33
- <li>Observation Data</li>
34
+ <li>Observation Data</li>
34
35
  </ul>
35
36
  <!-- fieldsets -->
36
37
  <fieldset data-step="1">
@@ -91,69 +92,7 @@
91
92
  <br>
92
93
  {% if var_category == 'snv' %}
93
94
  <br><br>
94
- <!-- Transcripts & HGVS:(optional) -->
95
- {{ variant_data.var_form.tx_hgvs.label(class="fw-bold, text-dark") }}
96
-
97
- <span class="text-danger" data-bs-toggle='tooltip' title="If you do not provide any HGVS expression, chromosome coordinates will be used to describe this variant instead (automatic). HGVS expressions were validated using VariantValidator"><strong>?</strong></span>
98
- <span class="badge bg-primary float-end"><a class="text-white" href="https://variantvalidator.org/service/validate/" target="_blank" rel="noopener">VariantValidator</a></span>
99
- <br><br>
100
-
101
- {% with messages = get_flashed_messages() %}
102
- {% if messages %}
103
- {% for message in messages %}
104
- <span class="ml-3">{{ message }}</span><br>
105
- {% endfor %}
106
- <br><br>
107
- {% endif %}
108
- {% endwith %}
109
-
110
- <table style="width:100%; table-layout: auto; border-collapse: collapse;">
111
- <caption></caption>
112
- <tr><th></th></tr>
113
- {% for item_row in variant_data.var_form.tx_hgvs | batch(3) %}
114
- <tr>
115
- {% for item in item_row %}
116
- {% set ns = namespace(label='', validated=false, mane_select=false, mane_plus_clinical=false) %}
117
- {% if "_validated_" in item.label.text %}
118
- {% set ns.validated = true %}
119
- {% endif %}
120
- {% if "_mane-select_" in item.label.text %}
121
- {% set ns.mane_select = true %}
122
- {% endif %}
123
- {% if "_mane-plus-clinical_" in item.label.text %}
124
- {% set ns.mane_plus_clinical = true %}
125
- {% endif %}
126
-
127
- {% set ns.label = item.label.text | replace("_validated_", "") | replace("_mane-select_", "") %}
128
-
129
- <td style="width: 3%; text-align: right; vertical-align: baseline;">
130
- <input type="radio" name="tx_hgvs" value="{{ ns.label }}"
131
- {% if ns.mane_select %}checked{% endif %}>
132
- </td>
133
-
134
- <td style="width: 30%; text-align: left; ">
135
- <p class="text-dark"
136
- {% if ns.label|length > 50 %}
137
- data-bs-toggle="tooltip" title="{{ns.label}}">{{ ns.label|truncate(25,true,'..') }}
138
- {% else %}
139
- >{{ ns.label }}
140
- {% endif %}
141
- {% if ns.mane_select %}
142
- <span class='badge bg-dark'>MANE SELECT</span>
143
- {% endif %}
144
- {% if ns.mane_plus_clinical %}
145
- <span class='badge bg-dark'>MANE PLUS CLINICAL</span>
146
- {% endif %}
147
- {% if ns.validated %}
148
- <em class="fa fa-check text-success" aria-hidden="true" data-bs-toggle="tooltip" title="Verified by VariantValidator"></em>
149
- {% endif %}
150
- </p>
151
- </td>
152
- {% endfor %}
153
- </tr>
154
- {% endfor %}
155
- </table>
156
-
95
+ {{hgvs_choices(variant_data.var_form.tx_hgvs)}}
157
96
  <br><br>
158
97
  <!-- dbSNP identifier -->
159
98
  {{variant_data.var_form.variations_ids.label(class="fw-bold, text-dark")}}
@@ -255,75 +194,7 @@
255
194
  <legend class="text-dark">Associated Conditions</legend>
256
195
  <h3 class="fs-subtitle">The condition for which the variant is interpreted. Examples available at <a href="https://www.ncbi.nlm.nih.gov/clinvar/docs/spreadsheet/#condition" target="_blank" rel="noopener">ClinVar</a></h3>
257
196
 
258
- <div class="row">
259
- <div class="col-6" id="clinvar_condition_container">
260
- {{variant_data.var_form.condition_type.label(class="fw-bold, text-dark")}}<span class="text-danger" data-bs-toggle='tooltip' title="Required field."><strong>*</strong></span>
261
-
262
- <select class="form-control, btn-secondary" name="condition_type" id="condition_type">
263
- {% for dbtype, _ in variant_data.var_form.condition_type.choices %}
264
- <option value="{{dbtype}}">{{dbtype}}</option>
265
- {% endfor %}
266
- </select>
267
-
268
- <br><br>
269
- {{variant_data.var_form.conditions.label(class="fw-bold, text-dark")}} <span class="text-danger" data-bs-toggle='tooltip' title="Required field. Include data from ONE DATABASE TYPE ONLY (i.e. only OMIM terms, only HPO terms etc). If multiple conditions are submitted for a variant, this indicates that the variant was interpreted for the combination of conditions in the same individual(s). i.e. this variant causes both condition A and condition B in the same individual. This scenario is most common for a new disease or syndrome that does not yet have a name and is described by several clinical features. If you want to indicate that the variant has been interpreted for more than one condition, please submit these as separate records."><strong>*?</strong></span>
270
- <select class="select2" id="condition_tags" name="conditions" multiple="true" style="width:100%;">
271
- {% if variant_data.var_form.omim_terms.choices %}
272
- {% for term, _ in variant_data.var_form.omim_terms.choices %}
273
- <option value="{{term}}" selected>{{term}}</option>
274
- {% endfor %}
275
- {% elif variant_data.var_form.orpha_terms.choices %}
276
- {% for term, _ in variant_data.var_form.orpha_terms.choices %}
277
- <option value="{{term}}" selected>{{term}}</option>
278
- {% endfor %}
279
- {% elif variant_data.var_form.hpo_terms.choices %}
280
- {% for term, _ in variant_data.var_form.hpo_terms.choices %}
281
- <option value="{{term}}" selected>{{term}}</option>
282
- {% endfor %}
283
- {% endif %}
284
- </select>
285
-
286
- <div class="mt-3">
287
- {{variant_data.var_form.multiple_condition_explanation.label(class="fw-bold, text-dark")}} <span class="text-danger" data-bs-toggle='tooltip' title="Required if you provide more than one condition ID."><strong>?</strong></span>
288
- <select name="multiple_condition_explanation" id="multiple_condition_explanation" class="form-control, btn-secondary">
289
- <option selected value>-</option>
290
- {% for choice, _ in variant_data.var_form.multiple_condition_explanation.choices %}
291
- <option value="{{choice}}">{{choice}}</option>
292
- {% endfor %}
293
- </select>
294
- </div>
295
-
296
-
297
- </div>
298
- <div class="col-6">
299
- {{ variant_data.var_form.omim_terms.label(class="fw-bold, text-dark" )}}<br>
300
- <ul class="list-group">
301
- {% for term in variant_data.var_form.omim_terms %}
302
- <li class="list-group-item">{{ term.label }}</li>
303
- {% else %}
304
- <span class="text-dark">N/A</span>
305
- {% endfor %}
306
- </ul>
307
- <br><br>
308
- {{variant_data.var_form.orpha_terms.label(class="fw-bold, text-dark")}}<br>
309
- <ul class="list-group">
310
- {% for term in variant_data.var_form.orpha_terms %}
311
- <li class="list-group-item">{{ term.label }}</li>
312
- {% else %}
313
- <span class="text-dark">N/A</span>
314
- {% endfor %}
315
- </ul>
316
- <br><br>
317
- {{variant_data.var_form.hpo_terms.label(class="fw-bold, text-dark")}}<br>
318
- <ul class="list-group">
319
- {% for term in variant_data.var_form.hpo_terms %}
320
- <li class="list-group-item">{{ term.label }}</li>
321
- {% else %}
322
- N/A
323
- </ul>
324
- {% endfor %}
325
- </div>
326
- </div>
197
+ {{ condition_identifiers(variant_data.var_form) }}
327
198
 
328
199
  <input type="button" name="previous" class="previous action-button-previous" value="Previous"/>
329
200
  <input type="button" name="next" class="next action-button" value="Next"/>
@@ -333,35 +204,7 @@
333
204
  <legend class="text-dark">Observation Data</legend>
334
205
  <h3 class="fs-subtitle">Information provided by filling in these fields will be used to create the CaseData.csv file. Observations from at least one individuals are required.</h3>
335
206
 
336
- <ul class="list-group">
337
- {% for cdata in variant_data.cdata_forms %}
338
- {{cdata.linking_id(class="fw-bold, text-dark")}} <!-- hidden field -->
339
- <li class="list-group-item bg-white">
340
- <div class="row">
341
- <div class="col-2">
342
- {{ cdata.include_ind.label(class="fw-bold, text-dark") }}
343
- {{ cdata.include_ind() }}
344
- </div>
345
- <div class="col-2">
346
- {{ cdata.individual_id.label(class="fw-bold, text-dark") }}
347
- {{ cdata.individual_id(class="form-control, bg-white", readonly=true) }}
348
- </div>
349
- <div class="col-2">
350
- {{ cdata.affected_status.label(class="fw-bold, text-dark") }}
351
- {{ cdata.affected_status(class="form-control, btn-secondary") }}
352
- </div>
353
- <div class="col-2">
354
- {{ cdata.allele_of_origin.label(class="fw-bold, text-dark") }}
355
- {{ cdata.allele_of_origin(class="form-control, btn-secondary") }}
356
- </div>
357
- <div class="col-2">
358
- {{ cdata.collection_method.label(class="fw-bold, text-dark") }}
359
- {{ cdata.collection_method(class="form-control, btn-secondary") }}
360
- </div>
361
- </div>
362
- </li>
363
- {% endfor %}
364
- </ul>
207
+ {{ observations(variant_data.cdata_forms) }}
365
208
 
366
209
  <input type="button" name="previous" class="previous action-button-previous" value="Previous"/>
367
210
  <input type="submit" name="submit" class="submit action-button" value="Add to submission"/>
@@ -379,135 +222,9 @@
379
222
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js" integrity="sha512-0QbL0ph8Tc8g5bLhfVzSqxe9GERORsKhIn1IrpxDAgUsbBGz/V7iSav2zzW325XGd1OMLdL4UiqRJj702IeqnQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
380
223
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta3/js/bootstrap-select.min.js" integrity="sha512-yrOmjPdp8qH8hgLfWpSFhC/+R9Cj9USL8uJxYIveJZGAiedxyIxwNw4RsLDlcjNlIRR4kkHaDHSmNHAkxFTmgg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
381
224
  <script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js" integrity="sha512-2ImtlRlf2VVmiGZsjm9bEyhjGW4dU7B6TNwh/hx/iSByxNENtj3WVE6o/9Lj4TJeVXPi4bnOIMXFIJJAeufa0A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
382
- <script>
383
-
384
- // Enable tooltips
385
- var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
386
- var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
387
- return new bootstrap.Tooltip(tooltipTriggerEl)
388
- })
389
-
390
- // Validates fields for conditions associated to a variant
391
- function validateConditions(){
392
-
393
- if ($("#condition_tags option:selected").length == 0) {
394
- alert("Please provide at least one condition ID");
395
- return false;
396
- }
225
+ {% include "clinvar/scripts.html" %}
397
226
 
398
- if ($("#condition_tags option:selected").length > 1 && $("#multiple_condition_explanation option:selected").text() === "-") {
399
- alert("When multiple condition IDs are provided then an option for 'Explanation for multiple conditions' must be provided");
400
- return false;
401
- }
402
-
403
- if ($("#condition_tags option:selected").length == 1 && $("#multiple_condition_explanation option:selected").text() !== "-") {
404
- alert("Please deselect the selected option in 'Explanation for multiple conditions' since only one condition ID was provided.");
405
- return false;
406
- }
407
-
408
- // Make sure that provided conditions are numbers, except when condition type is MeSH or MedGen
409
- var selectedConditionsValues = $('#condition_tags').val();
410
- for (let i = 0; i < selectedConditionsValues.length; i++) {
411
- if (isNaN(selectedConditionsValues[i]) && !['Mesh', 'MedGen'].includes($('#condition_type').val())){
412
- alert(`Condition ID "${selectedConditionsValues[i]}" has an invalid format.`);
413
- return false;
414
- }
415
- }
416
-
417
- return true;
418
- }
419
-
420
- var current_fs, next_fs, previous_fs; //fieldsets
421
- var left, opacity, scale; //fieldset properties which we will animate
422
- var animating; //flag to prevent quick multi-click glitches
423
-
424
- $(".next").click(function(){
425
- if(animating) return false;
426
- animating = true;
427
-
428
- current_fs = $(this).parent();
429
-
430
- // run the validations on the input for the current step
431
- var validationPassed = true;
432
-
433
- if(current_fs.data('step') == 6){
434
- validationPassed = validateConditions();
435
- }
436
-
437
- // check to see if the validator for the specific step we are on passed or not.
438
- if(validationPassed == false){
439
- // do not proceed
440
- animating = false;
441
- return;
442
- }
443
-
444
- next_fs = $(this).parent().next();
445
-
446
- //activate next step on progressbar using the index of next_fs
447
- $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
448
-
449
- //show the next fieldset
450
- next_fs.show();
451
- //hide the current fieldset with style
452
- current_fs.animate({opacity: 0}, {
453
- step: function(now, mx) {
454
- //as the opacity of current_fs reduces to 0 - stored in "now"
455
- //1. scale current_fs down to 80%
456
- scale = 1 - (1 - now) * 0.2;
457
- //2. bring next_fs from the right(50%)
458
- left = (now * 50)+"%";
459
- //3. increase opacity of next_fs to 1 as it moves in
460
- opacity = 1 - now;
461
- current_fs.css({
462
- 'transform': 'scale('+scale+')',
463
- 'position': 'absolute'
464
- });
465
- next_fs.css({'left': left, 'opacity': opacity});
466
- },
467
- duration: 800,
468
- complete: function(){
469
- current_fs.hide();
470
- animating = false;
471
- },
472
- //this comes from the custom easing plugin
473
- easing: 'easeInOutBack'
474
- });
475
- });
476
-
477
- $(".previous").click(function(){
478
- if(animating) return false;
479
- animating = true;
480
-
481
- current_fs = $(this).parent();
482
- previous_fs = $(this).parent().prev();
483
-
484
- //de-activate current step on progressbar
485
- $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
486
-
487
- //show the previous fieldset
488
- previous_fs.show();
489
- //hide the current fieldset with style
490
- current_fs.animate({opacity: 0}, {
491
- step: function(now, mx) {
492
- //as the opacity of current_fs reduces to 0 - stored in "now"
493
- //1. scale previous_fs from 80% to 100%
494
- scale = 0.8 + (1 - now) * 0.2;
495
- //2. take current_fs to the right(50%) - from 0%
496
- left = ((1-now) * 50)+"%";
497
- //3. increase opacity of previous_fs to 1 as it moves in
498
- opacity = 1 - now;
499
- current_fs.css({'left': left});
500
- previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
501
- },
502
- duration: 800,
503
- complete: function(){
504
- current_fs.hide();
505
- animating = false;
506
- },
507
- //this comes from the custom easing plugin
508
- easing: 'easeInOutBack'
509
- });
510
- });
227
+ <script>
511
228
 
512
229
  //Function definition for keeping the tooltip updated for each Assertion method database option
513
230
  function updateTooltip(){
@@ -542,62 +259,6 @@ $(function () {
542
259
  })
543
260
  });
544
261
 
545
-
546
- var conditionsPlaceHolders = {"OMIM": "e.g. 100800, ..", "HPO": "e.g. 0002839, ..", "MedGen": "e.g. C0001080, ..", "MeSh": "e.g. D000130, ..", "MONDO": "e.g. 0007947, ..", "Orphanet": "e.g. 155, .."};
547
-
548
- // Populate condition list
549
- $('#condition_tags').select2({
550
- tags: true,
551
- theme: 'bootstrap-5',
552
- tokenSeparators: [','],
553
- allowClear: true,
554
- });
555
-
556
- // Set selected condition type on page load
557
- window.onload = function() {
558
- const selectedCondId = document.getElementById('condition_type');
559
- {% if variant_data.var_form.omim_terms.choices %}
560
- selectedCondId.options.selectedIndex = 4;
561
- {% elif variant_data.var_form.orpha_terms.choices %}
562
- selectedCondId.options.selectedIndex = 5;
563
- {% elif variant_data.var_form.hpo_terms.choices %}
564
- selectedCondId.options.selectedIndex = 0;
565
- {% endif %}
566
- };
567
-
568
- // reset and modify conditions field's placeholder when condition ID type changes
569
- $(function(){
570
- $("#condition_type").change(function(){
571
- $('#condition_tags')[0].options.length = 0; // reset conditions multiselect
572
-
573
- // Change placeholder
574
- selectedCondId = $("#condition_type option:selected").text();
575
- $('#condition_tags').select2({
576
- placeholder: conditionsPlaceHolders[selectedCondId],
577
- theme: 'bootstrap-5',
578
- tags: true,
579
- tokenSeparators: [','],
580
- allowClear: true,
581
- });
582
-
583
- // repopulate option values according to the selected condition ID
584
- choices = {};
585
- if ($('#condition_type').val() == 'OMIM'){
586
- choices = {{ variant_data.var_form.omim_terms.choices|tuple_list_to_dict(0,1)|safe}};
587
- }
588
- if ($('#condition_type').val() == 'Orphanet'){
589
- choices = {{ variant_data.var_form.orpha_terms.choices|tuple_list_to_dict(0,1)|safe }};
590
- }
591
- if ($('#condition_type').val() == 'HPO'){
592
- choices = {{ variant_data.var_form.hpo_terms.choices|tuple_list_to_dict(0,1)|safe }};
593
- }
594
- for (var key in choices) {
595
- var newOption = new Option(key, key, true, true);
596
- $('#condition_tags').append(newOption).trigger('change');
597
- }
598
- });
599
- });
600
-
601
262
  // Modify variant classification options based on selected assertion_method_cit (ACMG-based or not)
602
263
  $(function(){
603
264
  $("#assertion_method_cit_db, #assertion_method_cit_id").change(function(){
@@ -0,0 +1,193 @@
1
+ <script>
2
+
3
+ // Enable tooltips
4
+ var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
5
+ var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
6
+ return new bootstrap.Tooltip(tooltipTriggerEl)
7
+ })
8
+
9
+ var current_fs, next_fs, previous_fs; //fieldsets
10
+ var left, opacity, scale; //fieldset properties which we will animate
11
+ var animating; //flag to prevent quick multi-click glitches
12
+
13
+ $(".next").click(function(){
14
+ if(animating) return false;
15
+ animating = true;
16
+
17
+ current_fs = $(this).parent();
18
+
19
+ // run the validations on the input for the current step
20
+ var validationPassed = true;
21
+
22
+ {% if variant_data.var_obj.category == "snv" %}
23
+ if(current_fs.data('step') == 6){
24
+ validationPassed = validateConditions();
25
+ }
26
+ {% elif variant_data.var_obj.category == "cancer" %}
27
+ if(current_fs.data('step') == 4){
28
+ validationPassed = validateConditions();
29
+ }
30
+ {% endif %}
31
+
32
+ // check to see if the validator for the specific step we are on passed or not.
33
+ if(validationPassed == false){
34
+ // do not proceed
35
+ animating = false;
36
+ return;
37
+ }
38
+
39
+ next_fs = $(this).parent().next();
40
+
41
+ //activate next step on progressbar using the index of next_fs
42
+ $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
43
+
44
+ //show the next fieldset
45
+ next_fs.show();
46
+ //hide the current fieldset with style
47
+ current_fs.animate({opacity: 0}, {
48
+ step: function(now, mx) {
49
+ //as the opacity of current_fs reduces to 0 - stored in "now"
50
+ //1. scale current_fs down to 80%
51
+ scale = 1 - (1 - now) * 0.2;
52
+ //2. bring next_fs from the right(50%)
53
+ left = (now * 50)+"%";
54
+ //3. increase opacity of next_fs to 1 as it moves in
55
+ opacity = 1 - now;
56
+ current_fs.css({
57
+ 'transform': 'scale('+scale+')',
58
+ 'position': 'absolute'
59
+ });
60
+ next_fs.css({'left': left, 'opacity': opacity});
61
+ },
62
+ duration: 800,
63
+ complete: function(){
64
+ current_fs.hide();
65
+ animating = false;
66
+ },
67
+ //this comes from the custom easing plugin
68
+ easing: 'easeInOutBack'
69
+ });
70
+ });
71
+
72
+ $(".previous").click(function(){
73
+ if(animating) return false;
74
+ animating = true;
75
+
76
+ current_fs = $(this).parent();
77
+ previous_fs = $(this).parent().prev();
78
+
79
+ //de-activate current step on progressbar
80
+ $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
81
+
82
+ //show the previous fieldset
83
+ previous_fs.show();
84
+ //hide the current fieldset with style
85
+ current_fs.animate({opacity: 0}, {
86
+ step: function(now, mx) {
87
+ //as the opacity of current_fs reduces to 0 - stored in "now"
88
+ //1. scale previous_fs from 80% to 100%
89
+ scale = 0.8 + (1 - now) * 0.2;
90
+ //2. take current_fs to the right(50%) - from 0%
91
+ left = ((1-now) * 50)+"%";
92
+ //3. increase opacity of previous_fs to 1 as it moves in
93
+ opacity = 1 - now;
94
+ current_fs.css({'left': left});
95
+ previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
96
+ },
97
+ duration: 800,
98
+ complete: function(){
99
+ current_fs.hide();
100
+ animating = false;
101
+ },
102
+ //this comes from the custom easing plugin
103
+ easing: 'easeInOutBack'
104
+ });
105
+ });
106
+
107
+ // Conditions-asociated code
108
+
109
+ var conditionsPlaceHolders = {"OMIM": "e.g. 100800, ..", "HPO": "e.g. 0002839, ..", "HP": "e.g. 0002839, .." , "MedGen": "e.g. C0001080, ..", "MeSh": "e.g. D000130, ..", "MONDO": "e.g. 0007947, ..", "Orphanet": "e.g. 155, .."};
110
+
111
+ // Set selected condition type on page load
112
+ window.onload = function() {
113
+ const selectedCondId = document.getElementById('condition_type');
114
+ {% if variant_data.var_form.omim_terms.choices %}
115
+ selectedCondId.options.selectedIndex = 4;
116
+ {% elif variant_data.var_form.orpha_terms.choices %}
117
+ selectedCondId.options.selectedIndex = 5;
118
+ {% elif variant_data.var_form.hpo_terms.choices %}
119
+ selectedCondId.options.selectedIndex = 0;
120
+ {% endif %}
121
+ };
122
+
123
+ // Populate condition list
124
+ $('#condition_tags').select2({
125
+ tags: true,
126
+ theme: 'bootstrap-5',
127
+ tokenSeparators: [','],
128
+ allowClear: true,
129
+ });
130
+
131
+ // reset and modify conditions field's placeholder when condition ID type changes
132
+ $(function(){
133
+ $("#condition_type").change(function(){
134
+ $('#condition_tags')[0].options.length = 0; // reset conditions multiselect
135
+
136
+ // Change placeholder
137
+ selectedCondId = $("#condition_type option:selected").text();
138
+ $('#condition_tags').select2({
139
+ placeholder: conditionsPlaceHolders[selectedCondId],
140
+ theme: 'bootstrap-5',
141
+ tags: true,
142
+ tokenSeparators: [','],
143
+ allowClear: true,
144
+ });
145
+
146
+ // repopulate option values according to the selected condition ID
147
+ choices = {};
148
+ if ($('#condition_type').val() == 'OMIM'){
149
+ choices = {{ variant_data.var_form.omim_terms.choices|tuple_list_to_dict(0,1)|safe}};
150
+ }
151
+ if ($('#condition_type').val() == 'Orphanet'){
152
+ choices = {{ variant_data.var_form.orpha_terms.choices|tuple_list_to_dict(0,1)|safe }};
153
+ }
154
+ if ($('#condition_type').val() == 'HPO' || $('#condition_type').val() == 'HP'){
155
+ choices = {{ variant_data.var_form.hpo_terms.choices|tuple_list_to_dict(0,1)|safe }};
156
+ }
157
+ for (var key in choices) {
158
+ var newOption = new Option(key, key, true, true);
159
+ $('#condition_tags').append(newOption).trigger('change');
160
+ }
161
+ });
162
+ });
163
+
164
+ // Validates fields for conditions associated to a variant
165
+ function validateConditions(){
166
+
167
+ if ($("#condition_tags option:selected").length == 0) {
168
+ alert("Please provide at least one condition ID");
169
+ return false;
170
+ }
171
+
172
+ if ($("#condition_tags option:selected").length > 1 && $("#multiple_condition_explanation option:selected").text() === "-") {
173
+ alert("When multiple condition IDs are provided then an option for 'Explanation for multiple conditions' must be provided");
174
+ return false;
175
+ }
176
+
177
+ if ($("#condition_tags option:selected").length == 1 && $("#multiple_condition_explanation option:selected").text() !== "-") {
178
+ alert("Please deselect the selected option in 'Explanation for multiple conditions' since only one condition ID was provided.");
179
+ return false;
180
+ }
181
+
182
+ // Make sure that provided conditions are numbers, except when condition type is MeSH or MedGen
183
+ var selectedConditionsValues = $('#condition_tags').val();
184
+ for (let i = 0; i < selectedConditionsValues.length; i++) {
185
+ if (isNaN(selectedConditionsValues[i]) && !['Mesh', 'MedGen'].includes($('#condition_type').val())){
186
+ alert(`Condition ID "${selectedConditionsValues[i]}" has an invalid format.`);
187
+ return false;
188
+ }
189
+ }
190
+
191
+ return true;
192
+ }
193
+ </script>