scout-browser 4.90.1__py3-none-any.whl → 4.91__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 (62) hide show
  1. scout/__version__.py +1 -1
  2. scout/adapter/mongo/case.py +27 -38
  3. scout/commands/export/variant.py +14 -4
  4. scout/commands/load/panel.py +2 -1
  5. scout/commands/update/panelapp.py +11 -3
  6. scout/commands/view/case.py +2 -2
  7. scout/constants/__init__.py +1 -2
  8. scout/constants/acmg.py +15 -15
  9. scout/constants/case_tags.py +0 -46
  10. scout/constants/clnsig.py +2 -1
  11. scout/constants/gene_tags.py +0 -6
  12. scout/constants/panels.py +16 -0
  13. scout/constants/variants_export.py +2 -0
  14. scout/demo/__init__.py +4 -1
  15. scout/demo/panelapp_panel.json +463 -0
  16. scout/demo/panelapp_panels_reduced.json +37 -0
  17. scout/load/panel.py +3 -142
  18. scout/load/panelapp.py +138 -0
  19. scout/models/case/case_loading_models.py +5 -4
  20. scout/parse/panel.py +3 -117
  21. scout/parse/panelapp.py +112 -0
  22. scout/parse/variant/clnsig.py +26 -21
  23. scout/parse/variant/genotype.py +6 -5
  24. scout/server/blueprints/alignviewers/controllers.py +7 -5
  25. scout/server/blueprints/alignviewers/templates/alignviewers/utils.html +1 -1
  26. scout/server/blueprints/cases/templates/cases/case_sma.html +49 -42
  27. scout/server/blueprints/cases/templates/cases/collapsible_actionbar.html +27 -12
  28. scout/server/blueprints/cases/views.py +18 -7
  29. scout/server/blueprints/clinvar/templates/clinvar/clinvar_submissions.html +7 -7
  30. scout/server/blueprints/clinvar/templates/clinvar/multistep_add_variant.html +2 -2
  31. scout/server/blueprints/dashboard/controllers.py +128 -165
  32. scout/server/blueprints/dashboard/forms.py +3 -13
  33. scout/server/blueprints/dashboard/templates/dashboard/dashboard_general.html +17 -22
  34. scout/server/blueprints/institutes/forms.py +1 -2
  35. scout/server/blueprints/institutes/templates/overview/cases.html +2 -133
  36. scout/server/blueprints/institutes/templates/overview/utils.html +135 -0
  37. scout/server/blueprints/omics_variants/templates/omics_variants/outliers.html +5 -0
  38. scout/server/blueprints/panels/templates/panels/panel.html +5 -1
  39. scout/server/blueprints/panels/templates/panels/panel_pdf_simple.html +5 -1
  40. scout/server/blueprints/variant/controllers.py +6 -1
  41. scout/server/blueprints/variant/templates/variant/buttons.html +11 -10
  42. scout/server/blueprints/variant/templates/variant/components.html +63 -44
  43. scout/server/blueprints/variant/templates/variant/str-variant-reviewer.html +1 -1
  44. scout/server/blueprints/variant/templates/variant/utils.html +38 -10
  45. scout/server/blueprints/variant/templates/variant/variant.html +1 -1
  46. scout/server/blueprints/variants/controllers.py +9 -4
  47. scout/server/blueprints/variants/templates/variants/cancer-sv-variants.html +9 -5
  48. scout/server/blueprints/variants/templates/variants/cancer-variants.html +6 -17
  49. scout/server/blueprints/variants/templates/variants/str-variants.html +2 -2
  50. scout/server/blueprints/variants/templates/variants/sv-variants.html +8 -1
  51. scout/server/blueprints/variants/templates/variants/utils.html +14 -0
  52. scout/server/extensions/__init__.py +2 -0
  53. scout/server/extensions/panelapp_extension.py +75 -0
  54. scout/server/links.py +19 -1
  55. scout/server/utils.py +25 -33
  56. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/METADATA +1 -1
  57. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/RECORD +61 -57
  58. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/WHEEL +1 -1
  59. scout/demo/panelapp_test_panel.json +0 -79
  60. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/LICENSE +0 -0
  61. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/entry_points.txt +0 -0
  62. {scout_browser-4.90.1.dist-info → scout_browser-4.91.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,463 @@
1
+ {
2
+ "id": 522,
3
+ "hash_id": null,
4
+ "name": "Familial melanoma",
5
+ "disease_group": "",
6
+ "disease_sub_group": "",
7
+ "status": "public",
8
+ "version": "2.4",
9
+ "version_created": "2024-01-09T11:31:08.965539Z",
10
+ "relevant_disorders": [
11
+ "R254"
12
+ ],
13
+ "stats": {
14
+ "number_of_genes": 8,
15
+ "number_of_strs": 0,
16
+ "number_of_regions": 0
17
+ },
18
+ "types": [
19
+ {
20
+ "name": "GMS Rare Disease",
21
+ "slug": "gms-rare-disease",
22
+ "description": "This panel type is used for GMS panels that are not virtual (i.e. could be a wet lab test)"
23
+ },
24
+ {
25
+ "name": "GMS signed-off",
26
+ "slug": "gms-signed-off",
27
+ "description": "This panel has undergone review by a NHSE GMS disease specialist group and processes to be signed-off for use within the GMS."
28
+ }
29
+ ],
30
+ "genes": [
31
+ {
32
+ "gene_data": {
33
+ "alias": [
34
+ "hucep-6",
35
+ "KIAA0272",
36
+ "UCHL2"
37
+ ],
38
+ "biotype": "protein_coding",
39
+ "hgnc_id": "HGNC:950",
40
+ "gene_name": "BRCA1 associated protein 1",
41
+ "omim_gene": [
42
+ "603089"
43
+ ],
44
+ "alias_name": [
45
+ "ubiquitin carboxy-terminal hydrolase"
46
+ ],
47
+ "gene_symbol": "BAP1",
48
+ "hgnc_symbol": "BAP1",
49
+ "hgnc_release": "2017-11-03",
50
+ "ensembl_genes": {
51
+ "GRch37": {
52
+ "82": {
53
+ "location": "3:52435029-52444366",
54
+ "ensembl_id": "ENSG00000163930"
55
+ }
56
+ },
57
+ "GRch38": {
58
+ "90": {
59
+ "location": "3:52401013-52410350",
60
+ "ensembl_id": "ENSG00000163930"
61
+ }
62
+ }
63
+ },
64
+ "hgnc_date_symbol_changed": "1998-09-17"
65
+ },
66
+ "entity_type": "gene",
67
+ "entity_name": "BAP1",
68
+ "confidence_level": "3",
69
+ "penetrance": null,
70
+ "mode_of_pathogenicity": "",
71
+ "publications": [],
72
+ "evidence": [
73
+ "Expert Review Green",
74
+ "NHS GMS",
75
+ "Expert List"
76
+ ],
77
+ "phenotypes": [
78
+ "Tumor predisposition syndrome 1, OMIM:614327",
79
+ "{Uveal melanoma, susceptibility to, 2}, OMIM:606661"
80
+ ],
81
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
82
+ "tags": [],
83
+ "transcript": null
84
+ },
85
+ {
86
+ "gene_data": {
87
+ "alias": [
88
+ "PSK-J3"
89
+ ],
90
+ "biotype": "protein_coding",
91
+ "hgnc_id": "HGNC:1773",
92
+ "gene_name": "cyclin dependent kinase 4",
93
+ "omim_gene": [
94
+ "123829"
95
+ ],
96
+ "alias_name": null,
97
+ "gene_symbol": "CDK4",
98
+ "hgnc_symbol": "CDK4",
99
+ "hgnc_release": "2017-11-03",
100
+ "ensembl_genes": {
101
+ "GRch37": {
102
+ "82": {
103
+ "location": "12:58141510-58149796",
104
+ "ensembl_id": "ENSG00000135446"
105
+ }
106
+ },
107
+ "GRch38": {
108
+ "90": {
109
+ "location": "12:57747727-57756013",
110
+ "ensembl_id": "ENSG00000135446"
111
+ }
112
+ }
113
+ },
114
+ "hgnc_date_symbol_changed": "1993-07-28"
115
+ },
116
+ "entity_type": "gene",
117
+ "entity_name": "CDK4",
118
+ "confidence_level": "3",
119
+ "penetrance": null,
120
+ "mode_of_pathogenicity": "",
121
+ "publications": [],
122
+ "evidence": [
123
+ "Expert Review Green",
124
+ "NHS GMS",
125
+ "Expert List"
126
+ ],
127
+ "phenotypes": [],
128
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
129
+ "tags": [],
130
+ "transcript": null
131
+ },
132
+ {
133
+ "gene_data": {
134
+ "alias": [
135
+ "CDK4I",
136
+ "p16",
137
+ "INK4a",
138
+ "MTS1",
139
+ "CMM2",
140
+ "ARF",
141
+ "p19",
142
+ "p14",
143
+ "INK4",
144
+ "p16INK4a",
145
+ "p19Arf",
146
+ "p14ARF"
147
+ ],
148
+ "biotype": "protein_coding",
149
+ "hgnc_id": "HGNC:1787",
150
+ "gene_name": "cyclin dependent kinase inhibitor 2A",
151
+ "omim_gene": [
152
+ "600160"
153
+ ],
154
+ "alias_name": null,
155
+ "gene_symbol": "CDKN2A",
156
+ "hgnc_symbol": "CDKN2A",
157
+ "hgnc_release": "2017-11-03",
158
+ "ensembl_genes": {
159
+ "GRch37": {
160
+ "82": {
161
+ "location": "9:21967751-21995300",
162
+ "ensembl_id": "ENSG00000147889"
163
+ }
164
+ },
165
+ "GRch38": {
166
+ "90": {
167
+ "location": "9:21967753-21995301",
168
+ "ensembl_id": "ENSG00000147889"
169
+ }
170
+ }
171
+ },
172
+ "hgnc_date_symbol_changed": "1994-05-19"
173
+ },
174
+ "entity_type": "gene",
175
+ "entity_name": "CDKN2A",
176
+ "confidence_level": "3",
177
+ "penetrance": null,
178
+ "mode_of_pathogenicity": "",
179
+ "publications": [],
180
+ "evidence": [
181
+ "Expert Review Green",
182
+ "NHS GMS",
183
+ "Expert List"
184
+ ],
185
+ "phenotypes": [
186
+ "{Melanoma, cutaneous malignant, 2}, OMIM:155601",
187
+ "{Melanoma and neural system tumor syndrome}, OMIM:155755",
188
+ "{Melanoma-pancreatic cancer syndrome}, OMIM:606719"
189
+ ],
190
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
191
+ "tags": [],
192
+ "transcript": null
193
+ },
194
+ {
195
+ "gene_data": {
196
+ "alias": [
197
+ "hPot1",
198
+ "DKFZp586D211"
199
+ ],
200
+ "biotype": "protein_coding",
201
+ "hgnc_id": "HGNC:17284",
202
+ "gene_name": "protection of telomeres 1",
203
+ "omim_gene": [
204
+ "606478"
205
+ ],
206
+ "alias_name": null,
207
+ "gene_symbol": "POT1",
208
+ "hgnc_symbol": "POT1",
209
+ "hgnc_release": "2017-11-03",
210
+ "ensembl_genes": {
211
+ "GRch37": {
212
+ "82": {
213
+ "location": "7:124462440-124570037",
214
+ "ensembl_id": "ENSG00000128513"
215
+ }
216
+ },
217
+ "GRch38": {
218
+ "90": {
219
+ "location": "7:124822386-124929983",
220
+ "ensembl_id": "ENSG00000128513"
221
+ }
222
+ }
223
+ },
224
+ "hgnc_date_symbol_changed": "2004-08-20"
225
+ },
226
+ "entity_type": "gene",
227
+ "entity_name": "POT1",
228
+ "confidence_level": "3",
229
+ "penetrance": null,
230
+ "mode_of_pathogenicity": "",
231
+ "publications": [
232
+ "24686849",
233
+ "24686846",
234
+ "29523635",
235
+ "30451293",
236
+ "30586141",
237
+ "32325837",
238
+ "32907878"
239
+ ],
240
+ "evidence": [
241
+ "Expert Review Green",
242
+ "NHS GMS",
243
+ "Expert List"
244
+ ],
245
+ "phenotypes": [
246
+ "Melanoma, cutaneous malignant, susceptibility to, 10, OMIM:615848"
247
+ ],
248
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
249
+ "tags": [],
250
+ "transcript": null
251
+ },
252
+ {
253
+ "gene_data": {
254
+ "alias": [
255
+ "Ptop",
256
+ "Pip1",
257
+ "Tpp1",
258
+ "Tint1"
259
+ ],
260
+ "biotype": "protein_coding",
261
+ "hgnc_id": "HGNC:25070",
262
+ "gene_name": "ACD, shelterin complex subunit and telomerase recruitment factor",
263
+ "omim_gene": [
264
+ "609377"
265
+ ],
266
+ "alias_name": [
267
+ "TIN2 interacting protein 1",
268
+ "POT1 and TIN2 organizing protein"
269
+ ],
270
+ "gene_symbol": "ACD",
271
+ "hgnc_symbol": "ACD",
272
+ "hgnc_release": "2017-11-03",
273
+ "ensembl_genes": {
274
+ "GRch37": {
275
+ "82": {
276
+ "location": "16:67691415-67694713",
277
+ "ensembl_id": "ENSG00000102977"
278
+ }
279
+ },
280
+ "GRch38": {
281
+ "90": {
282
+ "location": "16:67657512-67660815",
283
+ "ensembl_id": "ENSG00000102977"
284
+ }
285
+ }
286
+ },
287
+ "hgnc_date_symbol_changed": "2005-01-04"
288
+ },
289
+ "entity_type": "gene",
290
+ "entity_name": "ACD",
291
+ "confidence_level": "2",
292
+ "penetrance": null,
293
+ "mode_of_pathogenicity": "",
294
+ "publications": [],
295
+ "evidence": [
296
+ "Expert Review Amber",
297
+ "NHS GMS"
298
+ ],
299
+ "phenotypes": [],
300
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
301
+ "tags": [],
302
+ "transcript": null
303
+ },
304
+ {
305
+ "gene_data": {
306
+ "alias": [
307
+ "FAD",
308
+ "FAD1",
309
+ "BRCC2",
310
+ "XRCC11"
311
+ ],
312
+ "biotype": "protein_coding",
313
+ "hgnc_id": "HGNC:1101",
314
+ "gene_name": "BRCA2, DNA repair associated",
315
+ "omim_gene": [
316
+ "600185"
317
+ ],
318
+ "alias_name": [
319
+ "BRCA1/BRCA2-containing complex, subunit 2"
320
+ ],
321
+ "gene_symbol": "BRCA2",
322
+ "hgnc_symbol": "BRCA2",
323
+ "hgnc_release": "2017-11-03",
324
+ "ensembl_genes": {
325
+ "GRch37": {
326
+ "82": {
327
+ "location": "13:32889611-32973805",
328
+ "ensembl_id": "ENSG00000139618"
329
+ }
330
+ },
331
+ "GRch38": {
332
+ "90": {
333
+ "location": "13:32315474-32400266",
334
+ "ensembl_id": "ENSG00000139618"
335
+ }
336
+ }
337
+ },
338
+ "hgnc_date_symbol_changed": "1994-10-17"
339
+ },
340
+ "entity_type": "gene",
341
+ "entity_name": "BRCA2",
342
+ "confidence_level": "2",
343
+ "penetrance": null,
344
+ "mode_of_pathogenicity": "",
345
+ "publications": [],
346
+ "evidence": [
347
+ "Expert Review Amber",
348
+ "NHS GMS"
349
+ ],
350
+ "phenotypes": [],
351
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
352
+ "tags": [],
353
+ "transcript": null
354
+ },
355
+ {
356
+ "gene_data": {
357
+ "alias": [
358
+ "RAP1"
359
+ ],
360
+ "biotype": "protein_coding",
361
+ "hgnc_id": "HGNC:19246",
362
+ "gene_name": "TERF2 interacting protein",
363
+ "omim_gene": [
364
+ "605061"
365
+ ],
366
+ "alias_name": null,
367
+ "gene_symbol": "TERF2IP",
368
+ "hgnc_symbol": "TERF2IP",
369
+ "hgnc_release": "2017-11-03",
370
+ "ensembl_genes": {
371
+ "GRch37": {
372
+ "82": {
373
+ "location": "16:75681684-75795770",
374
+ "ensembl_id": "ENSG00000166848"
375
+ }
376
+ },
377
+ "GRch38": {
378
+ "90": {
379
+ "location": "16:75647786-75761872",
380
+ "ensembl_id": "ENSG00000166848"
381
+ }
382
+ }
383
+ },
384
+ "hgnc_date_symbol_changed": "2002-09-18"
385
+ },
386
+ "entity_type": "gene",
387
+ "entity_name": "TERF2IP",
388
+ "confidence_level": "2",
389
+ "penetrance": null,
390
+ "mode_of_pathogenicity": "",
391
+ "publications": [],
392
+ "evidence": [
393
+ "Expert Review Amber",
394
+ "NHS GMS"
395
+ ],
396
+ "phenotypes": [],
397
+ "mode_of_inheritance": "",
398
+ "tags": [],
399
+ "transcript": null
400
+ },
401
+ {
402
+ "gene_data": {
403
+ "alias": [
404
+ "TRT",
405
+ "TP2",
406
+ "TCS1",
407
+ "hEST2",
408
+ "EST2"
409
+ ],
410
+ "biotype": "protein_coding",
411
+ "hgnc_id": "HGNC:11730",
412
+ "gene_name": "telomerase reverse transcriptase",
413
+ "omim_gene": [
414
+ "187270"
415
+ ],
416
+ "alias_name": null,
417
+ "gene_symbol": "TERT",
418
+ "hgnc_symbol": "TERT",
419
+ "hgnc_release": "2017-11-03",
420
+ "ensembl_genes": {
421
+ "GRch37": {
422
+ "82": {
423
+ "location": "5:1253262-1295184",
424
+ "ensembl_id": "ENSG00000164362"
425
+ }
426
+ },
427
+ "GRch38": {
428
+ "90": {
429
+ "location": "5:1253147-1295069",
430
+ "ensembl_id": "ENSG00000164362"
431
+ }
432
+ }
433
+ },
434
+ "hgnc_date_symbol_changed": "1998-01-21"
435
+ },
436
+ "entity_type": "gene",
437
+ "entity_name": "TERT",
438
+ "confidence_level": "2",
439
+ "penetrance": null,
440
+ "mode_of_pathogenicity": "",
441
+ "publications": [
442
+ "23348503",
443
+ "23348506",
444
+ "35912549"
445
+ ],
446
+ "evidence": [
447
+ "Expert Review Amber",
448
+ "NHS GMS",
449
+ "Expert List"
450
+ ],
451
+ "phenotypes": [
452
+ "{Melanoma, cutaneous malignant, 9}, OMIM:615134"
453
+ ],
454
+ "mode_of_inheritance": "MONOALLELIC, autosomal or pseudoautosomal, imprinted status unknown",
455
+ "tags": [
456
+ "watchlist"
457
+ ],
458
+ "transcript": null
459
+ }
460
+ ],
461
+ "strs": [],
462
+ "regions": []
463
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "count": 1,
3
+ "next": null,
4
+ "previous": null,
5
+ "results": [
6
+ {
7
+ "id": 522,
8
+ "hash_id": null,
9
+ "name": "Familial melanoma",
10
+ "disease_group": "",
11
+ "disease_sub_group": "",
12
+ "status": "public",
13
+ "version": "2.4",
14
+ "version_created": "2024-01-09T11:31:08.965539Z",
15
+ "relevant_disorders": [
16
+ "R254"
17
+ ],
18
+ "stats": {
19
+ "number_of_genes": 8,
20
+ "number_of_strs": 0,
21
+ "number_of_regions": 0
22
+ },
23
+ "types": [
24
+ {
25
+ "name": "GMS Rare Disease",
26
+ "slug": "gms-rare-disease",
27
+ "description": "This panel type is used for GMS panels that are not virtual (i.e. could be a wet lab test)"
28
+ },
29
+ {
30
+ "name": "GMS signed-off",
31
+ "slug": "gms-signed-off",
32
+ "description": "This panel has undergone review by a NHSE GMS disease specialist group and processes to be signed-off for use within the GMS."
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
scout/load/panel.py CHANGED
@@ -5,20 +5,15 @@ functions to load panels into the database
5
5
  """
6
6
 
7
7
  import logging
8
- import math
9
- from datetime import datetime
10
- from typing import Dict, List
11
8
 
12
- from click import Abort
9
+ from click import Abort, progressbar
13
10
  from flask.cli import current_app
14
11
 
15
- from scout.parse.panel import get_panel_info, parse_gene_panel, parse_panel_app_panel
12
+ from scout.parse.panel import get_panel_info, parse_gene_panel
16
13
  from scout.utils.handle import get_file_handle
17
- from scout.utils.scout_requests import fetch_mim_files, fetch_resource
14
+ from scout.utils.scout_requests import fetch_mim_files
18
15
 
19
16
  LOG = logging.getLogger(__name__)
20
- PANELAPP_BASE_URL = "https://panelapp.genomicsengland.co.uk/WebServices/{0}/"
21
- PANEL_NAME = "PANELAPP-GREEN"
22
17
 
23
18
 
24
19
  def load_panel(panel_path, adapter, **kwargs):
@@ -111,140 +106,6 @@ def load_panel(panel_path, adapter, **kwargs):
111
106
  raise err
112
107
 
113
108
 
114
- def _panelapp_panel_ids() -> List[str]:
115
- """Fetch all PanelApp panel IDs"""
116
- json_lines = fetch_resource(PANELAPP_BASE_URL.format("list_panels"), json=True)
117
- return [panel_info["Panel_Id"] for panel_info in json_lines.get("result", [])]
118
-
119
-
120
- def _parse_panelapp_panel(
121
- panel_id: str,
122
- institute: str,
123
- confidence: str,
124
- ensembl_id_to_hgnc_id_map: Dict[str, int],
125
- hgnc_symbol_to_ensembl_id_map: Dict[str, str],
126
- ):
127
- """fetch and parse lines from a PanelApp panel, given its ID
128
-
129
- Args:
130
- adapter(scout.adapter.MongoAdapter)
131
- panel_id(str): The panel app panel id
132
- confidence(str enum green|amber|red): traffic light-style PanelApp level of confidence
133
- ensembl_to_hgnc_map: dict[str, int]
134
- hgnc_to_ensembl_map: [int, str]
135
-
136
-
137
- Returns:
138
- parsed_panel(dict). Example:
139
- {'version': 3.3, 'date': datetime.datetime(2023, 1, 31, 16, 43, 37, 521719), 'display_name': 'Diabetes - neonatal onset - [GREEN]', 'institute': 'cust000', 'panel_type': 'clinical', 'genes': [list of genes], 'panel_id': '55a9041e22c1fc6711b0c6c0'}
140
-
141
- """
142
- json_lines = fetch_resource(PANELAPP_BASE_URL.format("get_panel") + panel_id, json=True)
143
- parsed_panel = parse_panel_app_panel(
144
- panel_info=json_lines["result"],
145
- ensembl_gene_hgnc_id_map=ensembl_id_to_hgnc_id_map,
146
- hgnc_symbol_ensembl_gene_map=hgnc_symbol_to_ensembl_id_map,
147
- institute=institute,
148
- confidence=confidence,
149
- )
150
- if confidence != "green":
151
- parsed_panel["panel_id"] = "_".join([panel_id, confidence])
152
- else: # This way the old green panels will be overwritten, instead of creating 2 sets of green panels, old and new
153
- parsed_panel["panel_id"] = panel_id
154
-
155
- return parsed_panel
156
-
157
-
158
- def load_panelapp_panel(adapter, panel_id=None, institute="cust000", confidence="green"):
159
- """Load PanelApp panels into scout database
160
-
161
- If no panel_id load all PanelApp panels
162
-
163
- Args:
164
- adapter(scout.adapter.MongoAdapter)
165
- panel_id(str): The panel app panel id
166
- institute(str): _id of an institute
167
- confidence(str enum green|amber|red): traffic light-style PanelApp level of confidence
168
- """
169
- panel_ids = [panel_id]
170
-
171
- if not panel_id:
172
- LOG.info("Fetching all panel app panels")
173
- panel_ids: List[str] = _panelapp_panel_ids()
174
-
175
- ensembl_id_to_hgnc_id_map: Dict[str, int] = adapter.ensembl_to_hgnc_id_mapping()
176
- hgnc_symbol_to_ensembl_id_map: Dict[int, str] = adapter.hgnc_symbol_ensembl_id_mapping()
177
-
178
- for _ in panel_ids:
179
- parsed_panel = _parse_panelapp_panel(
180
- panel_id=_,
181
- institute=institute,
182
- confidence=confidence,
183
- ensembl_id_to_hgnc_id_map=ensembl_id_to_hgnc_id_map,
184
- hgnc_symbol_to_ensembl_id_map=hgnc_symbol_to_ensembl_id_map,
185
- )
186
-
187
- if len(parsed_panel["genes"]) == 0:
188
- LOG.warning("Panel %s is missing genes. Skipping.", parsed_panel["display_name"])
189
- continue
190
-
191
- try:
192
- adapter.load_panel(parsed_panel=parsed_panel, replace=True)
193
- except Exception as err:
194
- raise err
195
-
196
-
197
- def load_panelapp_green_panel(adapter, institute, force):
198
- """Load/Update the panel containing all Panelapp Green genes
199
-
200
- Args:
201
- adapter(scout.adapter.MongoAdapter)
202
- institute(str): _id of an institute
203
- force(bool): force update panel even if it has fewer genes than previous version
204
- """
205
- LOG.info("Fetching all panel app panels")
206
- panel_ids = _panelapp_panel_ids()
207
-
208
- # check and set panel version
209
- old_panel = adapter.gene_panel(panel_id=PANEL_NAME)
210
- green_panel = {
211
- "panel_name": PANEL_NAME,
212
- "display_name": "PanelApp Green Genes",
213
- "institute": institute,
214
- "version": float(math.floor(old_panel["version"]) + 1) if old_panel else 1.0,
215
- "date": datetime.now(),
216
- }
217
- genes = set() # avoid duplicate genes from different panels
218
- # Loop over all PanelApp panels
219
-
220
- ensembl_id_to_hgnc_id_map: Dict[str, int] = adapter.ensembl_to_hgnc_id_mapping()
221
- hgnc_symbol_to_ensembl_id_map: Dict[int, str] = adapter.hgnc_symbol_ensembl_id_mapping()
222
-
223
- for _ in panel_ids:
224
- # And collect their green genes
225
- parsed_panel = _parse_panelapp_panel(
226
- panel_id=_,
227
- institute=institute,
228
- confidence="green",
229
- ensembl_id_to_hgnc_id_map=ensembl_id_to_hgnc_id_map,
230
- hgnc_symbol_to_ensembl_id_map=hgnc_symbol_to_ensembl_id_map,
231
- )
232
- genes.update({(gene["hgnc_id"], gene["hgnc_symbol"]) for gene in parsed_panel.get("genes")})
233
-
234
- green_panel["genes"] = [{"hgnc_id": tup[0], "hgnc_symbol": tup[1]} for tup in genes]
235
-
236
- # Do not update panel if new version contains less genes and force flag is False
237
- if old_panel and len(old_panel.get("genes", [])) > len(green_panel["genes"]):
238
- LOG.warning(
239
- f"This new version of PANELAPP-GREEN contains less genes (n={len(green_panel['genes'])}) than the previous one (n={len(old_panel['genes'])})"
240
- )
241
- if force is False:
242
- LOG.error("Aborting. Please use the force flag -f to update the panel anyway")
243
- return
244
-
245
- adapter.load_panel(parsed_panel=green_panel, replace=True)
246
-
247
-
248
109
  def load_omim_panel(adapter, genemap2, mim2genes, api_key, institute):
249
110
  """Add OMIM panel to the database.
250
111
  Args: