pori-python 1.3.0__tar.gz → 1.4.0__tar.gz
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.
- {pori_python-1.3.0/pori_python.egg-info → pori_python-1.4.0}/PKG-INFO +1 -1
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/constants.py +1 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/content.spec.json +26 -1
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/inputs.py +32 -2
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/ipr.py +0 -1
- {pori_python-1.3.0 → pori_python-1.4.0/pori_python.egg-info}/PKG-INFO +1 -1
- {pori_python-1.3.0 → pori_python-1.4.0}/setup.cfg +1 -1
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_inputs.py +77 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_upload.py +26 -10
- {pori_python-1.3.0 → pori_python-1.4.0}/LICENSE +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/MANIFEST.in +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/README.md +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/constants.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/genes.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/match.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/statement.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/util.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/graphkb/vocab.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/annotate.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/connection.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/main.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/summary.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/therapeutic_options.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/ipr/util.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/py.typed +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python/types.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python.egg-info/SOURCES.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python.egg-info/dependency_links.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python.egg-info/entry_points.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python.egg-info/requires.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pori_python.egg-info/top_level.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/pyproject.toml +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/setup.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/data.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_genes.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_graphkb.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_match.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_statement.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_util.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_graphkb/test_vocab.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/constants.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_annotate.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_connection.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_ipr.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_main.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_probe.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_summary.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/test_util.py +0 -0
- {pori_python-1.3.0 → pori_python-1.4.0}/tests/test_ipr/util.py +0 -0
|
@@ -548,12 +548,37 @@
|
|
|
548
548
|
},
|
|
549
549
|
"score": {
|
|
550
550
|
"type": "number"
|
|
551
|
+
},
|
|
552
|
+
"cutoff": {
|
|
553
|
+
"type": "number"
|
|
551
554
|
}
|
|
552
555
|
},
|
|
556
|
+
"type": "object",
|
|
553
557
|
"required": [
|
|
554
558
|
"score"
|
|
555
559
|
],
|
|
556
|
-
"
|
|
560
|
+
"oneOf": [
|
|
561
|
+
{
|
|
562
|
+
"required": [
|
|
563
|
+
"kbCategory"
|
|
564
|
+
],
|
|
565
|
+
"not": {
|
|
566
|
+
"required": [
|
|
567
|
+
"cutoff"
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"required": [
|
|
573
|
+
"cutoff"
|
|
574
|
+
],
|
|
575
|
+
"not": {
|
|
576
|
+
"required": [
|
|
577
|
+
"kbCategory"
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
]
|
|
557
582
|
},
|
|
558
583
|
"images": {
|
|
559
584
|
"items": {
|
|
@@ -27,6 +27,7 @@ from .constants import (
|
|
|
27
27
|
HLA_SIGNATURE_VARIANT_TYPE,
|
|
28
28
|
MSI_MAPPING,
|
|
29
29
|
HRD_MAPPING,
|
|
30
|
+
HRD_SIGNATURE_OVER_CUTOFF,
|
|
30
31
|
TMB_SIGNATURE,
|
|
31
32
|
TMB_SIGNATURE_VARIANT_TYPE,
|
|
32
33
|
)
|
|
@@ -558,13 +559,42 @@ def preprocess_hrd(hrd: Any) -> Iterable[Dict]:
|
|
|
558
559
|
"""
|
|
559
560
|
Process hrd input into preformatted signature input.
|
|
560
561
|
HRD gets mapped to corresponding GraphKB Signature CategoryVariants.
|
|
562
|
+
|
|
563
|
+
Either a cutoff or a kbcategory is expected.
|
|
564
|
+
If a cutoff is provided, the score is compared to the cutoff
|
|
565
|
+
to determine whether to create the signature variant.
|
|
566
|
+
If a kbCategory is provided, the signature variant is created based on the category.
|
|
567
|
+
If neither are provided, a warning is logged and no signature variant is created.
|
|
561
568
|
"""
|
|
562
569
|
if hrd:
|
|
570
|
+
hrd_cutoff = hrd.get('cutoff', None)
|
|
563
571
|
hrd_cat = hrd.get('kbCategory', '')
|
|
572
|
+
hrd_score = hrd.get('score', None)
|
|
564
573
|
|
|
565
|
-
|
|
574
|
+
if hrd_cutoff and hrd_cat:
|
|
575
|
+
raise ValueError(
|
|
576
|
+
'In the HRD section, only one of cutoff and kbcategory should be provided.'
|
|
577
|
+
)
|
|
566
578
|
|
|
567
|
-
|
|
579
|
+
if not (hrd_cutoff or hrd_cat):
|
|
580
|
+
logger.warning(
|
|
581
|
+
'No hrd category or cutoff provided; score will be loaded with no variant matching.'
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
if hrd_cutoff:
|
|
585
|
+
if not hrd_score:
|
|
586
|
+
raise ValueError(
|
|
587
|
+
'In the HRD section, if cutoff is provided a score must also be provided.'
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
if hrd_score >= hrd_cutoff:
|
|
591
|
+
hrd_variant = HRD_SIGNATURE_OVER_CUTOFF
|
|
592
|
+
else:
|
|
593
|
+
return []
|
|
594
|
+
elif hrd_cat:
|
|
595
|
+
hrd_variant = HRD_MAPPING.get(hrd_cat, None)
|
|
596
|
+
|
|
597
|
+
# Signature CategoryVariant created for hrd
|
|
568
598
|
if hrd_variant:
|
|
569
599
|
return [hrd_variant]
|
|
570
600
|
|
|
@@ -292,6 +292,83 @@ class TestPreProcessSignatureVariants:
|
|
|
292
292
|
signatureNames = {r.get('signatureName', '') for r in self.hrd}
|
|
293
293
|
assert len(EXPECTED_HRD.symmetric_difference(signatureNames)) == 0
|
|
294
294
|
|
|
295
|
+
def test_preprocess_hrd_cutoff_above(self) -> None:
|
|
296
|
+
"""Test HRD with cutoff where score >= cutoff returns strong signature."""
|
|
297
|
+
hrd = preprocess_hrd(
|
|
298
|
+
{
|
|
299
|
+
'score': 75,
|
|
300
|
+
'cutoff': 50,
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
assert len(hrd) == 1
|
|
304
|
+
assert hrd[0]['signatureName'] == 'homologous recombination deficiency'
|
|
305
|
+
assert hrd[0]['variantTypeName'] == 'strong signature'
|
|
306
|
+
|
|
307
|
+
def test_preprocess_hrd_cutoff_below(self) -> None:
|
|
308
|
+
"""Test HRD with cutoff where score < cutoff does not return variant."""
|
|
309
|
+
hrd = preprocess_hrd(
|
|
310
|
+
{
|
|
311
|
+
'score': 25,
|
|
312
|
+
'cutoff': 50,
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
assert len(hrd) == 0
|
|
316
|
+
|
|
317
|
+
def test_preprocess_hrd_cutoff_equal(self) -> None:
|
|
318
|
+
"""Test HRD with cutoff where score == cutoff returns strong signature."""
|
|
319
|
+
hrd = preprocess_hrd(
|
|
320
|
+
{
|
|
321
|
+
'score': 50,
|
|
322
|
+
'cutoff': 50,
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
assert len(hrd) == 1
|
|
326
|
+
assert hrd[0]['signatureName'] == 'homologous recombination deficiency'
|
|
327
|
+
assert hrd[0]['variantTypeName'] == 'strong signature'
|
|
328
|
+
|
|
329
|
+
def test_preprocess_hrd_cutoff_missing_score(self) -> None:
|
|
330
|
+
"""Test HRD with cutoff but missing score raises ValueError."""
|
|
331
|
+
with pytest.raises(ValueError, match='if cutoff is provided a score must also be provided'):
|
|
332
|
+
preprocess_hrd(
|
|
333
|
+
{
|
|
334
|
+
'cutoff': 50,
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
def test_preprocess_hrd_cutoff_and_kbcategory(self) -> None:
|
|
339
|
+
"""Test HRD with both cutoff and kbCategory raises ValueError."""
|
|
340
|
+
with pytest.raises(
|
|
341
|
+
ValueError, match='only one of cutoff and kbcategory should be provided'
|
|
342
|
+
):
|
|
343
|
+
preprocess_hrd(
|
|
344
|
+
{
|
|
345
|
+
'score': 75,
|
|
346
|
+
'cutoff': 50,
|
|
347
|
+
'kbCategory': 'homologous recombination deficiency strong signature',
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
def test_preprocess_hrd_kbcategory_moderate(self) -> None:
|
|
352
|
+
"""Test HRD with kbCategory moderate signature."""
|
|
353
|
+
hrd = preprocess_hrd(
|
|
354
|
+
{
|
|
355
|
+
'kbCategory': 'homologous recombination deficiency moderate signature',
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
assert len(hrd) == 1
|
|
359
|
+
assert hrd[0]['signatureName'] == 'homologous recombination deficiency'
|
|
360
|
+
assert hrd[0]['variantTypeName'] == 'moderate signature'
|
|
361
|
+
|
|
362
|
+
def test_preprocess_hrd_empty(self) -> None:
|
|
363
|
+
"""Test HRD with empty input returns empty list."""
|
|
364
|
+
hrd = preprocess_hrd({})
|
|
365
|
+
assert hrd == []
|
|
366
|
+
|
|
367
|
+
def test_preprocess_hrd_none(self) -> None:
|
|
368
|
+
"""Test HRD with None input returns empty list."""
|
|
369
|
+
hrd = preprocess_hrd(None)
|
|
370
|
+
assert hrd == []
|
|
371
|
+
|
|
295
372
|
def test_preprocess_signature_variants(self) -> None:
|
|
296
373
|
records = preprocess_signature_variants(
|
|
297
374
|
[
|
|
@@ -74,7 +74,7 @@ def loaded_reports(tmp_path_factory) -> Generator:
|
|
|
74
74
|
],
|
|
75
75
|
'hrd': {
|
|
76
76
|
'score': 9999.0,
|
|
77
|
-
'
|
|
77
|
+
'cutoff': 5,
|
|
78
78
|
},
|
|
79
79
|
'expressionVariants': json.loads(
|
|
80
80
|
pd.read_csv(get_test_file('expression.short.tab'), sep='\t').to_json(orient='records')
|
|
@@ -106,6 +106,7 @@ def loaded_reports(tmp_path_factory) -> Generator:
|
|
|
106
106
|
'caption': 'Test adding a caption to an image',
|
|
107
107
|
}
|
|
108
108
|
],
|
|
109
|
+
'config': 'test config',
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
json_file.write_text(
|
|
@@ -254,15 +255,30 @@ class TestCreateReport:
|
|
|
254
255
|
async_equals_sync = stringify_sorted(section) == stringify_sorted(async_section)
|
|
255
256
|
assert async_equals_sync
|
|
256
257
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
def test_signature_variants_loaded(self, loaded_reports) -> None:
|
|
259
|
+
section = get_section(loaded_reports['sync'], 'signature-variants')
|
|
260
|
+
kbmatched = [item for item in section if item['kbMatches']]
|
|
261
|
+
# Check for COSMIC signatures
|
|
262
|
+
assert ('SBS2', 'high signature') in [
|
|
263
|
+
(item['signatureName'], item['variantTypeName']) for item in kbmatched
|
|
264
|
+
]
|
|
265
|
+
# Check for HRD signature (score 9999 > cutoff 5, so strong signature)
|
|
266
|
+
assert ('homologous recombination deficiency', 'strong signature') in [
|
|
267
|
+
(item['signatureName'], item['variantTypeName']) for item in kbmatched
|
|
268
|
+
]
|
|
269
|
+
# Check for MSI signature
|
|
270
|
+
assert ('microsatellite instability', 'high signature') in [
|
|
271
|
+
(item['signatureName'], item['variantTypeName']) for item in kbmatched
|
|
272
|
+
]
|
|
273
|
+
async_section = get_section(loaded_reports['async'], 'signature-variants')
|
|
274
|
+
async_equals_sync = stringify_sorted(section) == stringify_sorted(async_section)
|
|
275
|
+
assert async_equals_sync
|
|
276
|
+
|
|
277
|
+
def test_hrd_score_in_report(self, loaded_reports) -> None:
|
|
278
|
+
"""Test that HRD score is present in the loaded report."""
|
|
279
|
+
report = loaded_reports['sync'][1]['reports'][0]
|
|
280
|
+
assert 'hrdScore' in report
|
|
281
|
+
assert report['hrdScore'] == 9999.0
|
|
266
282
|
|
|
267
283
|
def test_kb_matches_loaded(self, loaded_reports) -> None:
|
|
268
284
|
section = get_section(loaded_reports['sync'], 'kb-matches')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|