pori-python 1.3.0__tar.gz → 1.5.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.5.0}/PKG-INFO +1 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/constants.py +4 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/genes.py +130 -12
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/util.py +68 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/vocab.py +2 -2
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/connection.py +45 -14
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/constants.py +1 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/content.spec.json +169 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/inputs.py +90 -3
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/ipr.py +80 -2
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/main.py +75 -5
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/util.py +5 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/types.py +2 -1
- {pori_python-1.3.0 → pori_python-1.5.0/pori_python.egg-info}/PKG-INFO +1 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/setup.cfg +1 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_genes.py +33 -8
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_util.py +42 -0
- pori_python-1.5.0/tests/test_ipr/test_connection.py +219 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_inputs.py +237 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_ipr.py +178 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_main.py +30 -1
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_probe.py +5 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_upload.py +96 -12
- pori_python-1.5.0/tests/test_ipr/test_util.py +48 -0
- pori_python-1.3.0/tests/test_ipr/test_connection.py +0 -97
- pori_python-1.3.0/tests/test_ipr/test_util.py +0 -29
- {pori_python-1.3.0 → pori_python-1.5.0}/LICENSE +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/MANIFEST.in +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/README.md +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/match.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/graphkb/statement.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/annotate.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/summary.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/ipr/therapeutic_options.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python/py.typed +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python.egg-info/SOURCES.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python.egg-info/dependency_links.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python.egg-info/entry_points.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python.egg-info/requires.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pori_python.egg-info/top_level.txt +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/pyproject.toml +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/setup.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/data.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_graphkb.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_match.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_statement.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_graphkb/test_vocab.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/__init__.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/constants.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_annotate.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/test_summary.py +0 -0
- {pori_python-1.3.0 → pori_python-1.5.0}/tests/test_ipr/util.py +0 -0
|
@@ -59,7 +59,10 @@ ONCOKB_SOURCE_NAME = 'oncokb'
|
|
|
59
59
|
TSO500_SOURCE_NAME = 'tso500'
|
|
60
60
|
ONCOGENE = 'oncogenic'
|
|
61
61
|
TUMOUR_SUPPRESSIVE = 'tumour suppressive'
|
|
62
|
-
CANCER_GENE =
|
|
62
|
+
CANCER_GENE = [
|
|
63
|
+
'cancer gene',
|
|
64
|
+
'tumourigenesis',
|
|
65
|
+
] # KBDEV-1532. tumourigenesis for backward compatibility
|
|
63
66
|
FUSION_NAMES = ['structural variant', 'fusion']
|
|
64
67
|
|
|
65
68
|
GSC_PHARMACOGENOMIC_SOURCE_EXCLUDE_LIST = ['cancer genome interpreter', 'civic']
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Dict, List, Sequence, Set, Tuple, cast
|
|
5
|
+
from typing import Any, Dict, List, Sequence, Set, Tuple, cast, Union
|
|
6
6
|
from typing_extensions import deprecated
|
|
7
7
|
|
|
8
8
|
from pori_python.types import IprGene, Ontology, Record, Statement, Variant
|
|
@@ -27,8 +27,117 @@ from .util import get_rid, logger, looks_like_rid
|
|
|
27
27
|
from .vocab import get_terms_set
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def get_cancer_gene_flags(
|
|
31
|
+
conn: GraphKBConnection,
|
|
32
|
+
flags: bool = False,
|
|
33
|
+
ignore_cache: bool = False,
|
|
34
|
+
) -> Union[List[Record], Dict[str, List[Record]]]:
|
|
35
|
+
"""
|
|
36
|
+
Return all cancer genes, optionally sorted by flags.
|
|
37
|
+
|
|
38
|
+
Flag definitions:
|
|
39
|
+
oncogenic: relevance 'oncogenic' from OncoKB
|
|
40
|
+
tumourSuppressive: relevance 'tumour suppressive' from OncoKB
|
|
41
|
+
cancerGene: relevance 'cancer gene' AND child terms ('oncogenic', 'tumour suppressive', 'other cancer gene'), from OncoKB AND TSO500
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
conn: the graphkb connection object
|
|
45
|
+
flags: if the results should be sorted by flags
|
|
46
|
+
ignore_cache: if cache should be ignored when querying GraphKB API
|
|
47
|
+
|
|
48
|
+
Returns (if flags=False; default): list of unique gene records
|
|
49
|
+
[ <record>, <record>, ... ]
|
|
50
|
+
|
|
51
|
+
Returns (if flags=True): dict of flags as keys, and list of gene records as value
|
|
52
|
+
{
|
|
53
|
+
'oncogenic': [ <record>, <record>, ... ],
|
|
54
|
+
'tumourSuppressive': [ <record>, <record>, ... ],
|
|
55
|
+
'cancerGene': [ <record>, <record>, ... ],
|
|
56
|
+
}
|
|
57
|
+
"""
|
|
58
|
+
# all cancer gene statements
|
|
59
|
+
cancer_genes = conn.get_related_terms(
|
|
60
|
+
terms=CANCER_GENE,
|
|
61
|
+
subgraphType='children',
|
|
62
|
+
)
|
|
63
|
+
statements = cast(
|
|
64
|
+
List[Statement],
|
|
65
|
+
conn.query(
|
|
66
|
+
{
|
|
67
|
+
'target': 'Statement',
|
|
68
|
+
'filters': {
|
|
69
|
+
'relevance': {'target': 'Vocabulary', 'filters': {'name': cancer_genes}}
|
|
70
|
+
},
|
|
71
|
+
'returnProperties': [
|
|
72
|
+
'source.name',
|
|
73
|
+
'relevance.name',
|
|
74
|
+
*[f'subject.{prop}' for prop in GENE_RETURN_PROPERTIES],
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
ignore_cache=ignore_cache,
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# post-query filtering (faster)
|
|
82
|
+
cancerGeneStms = list(
|
|
83
|
+
filter(
|
|
84
|
+
lambda r: (
|
|
85
|
+
r['subject']['@class'] == 'Feature'
|
|
86
|
+
and r['subject']['biotype'] == 'gene'
|
|
87
|
+
and r['source']['name'] in [ONCOKB_SOURCE_NAME, TSO500_SOURCE_NAME]
|
|
88
|
+
),
|
|
89
|
+
statements,
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
oncogenicStms = list(
|
|
93
|
+
filter(
|
|
94
|
+
lambda r: (
|
|
95
|
+
r['relevance']['name'] == ONCOGENE and r['source']['name'] == ONCOKB_SOURCE_NAME
|
|
96
|
+
),
|
|
97
|
+
cancerGeneStms,
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
tumourSuppressiveStms = list(
|
|
101
|
+
filter(
|
|
102
|
+
lambda r: (
|
|
103
|
+
r['relevance']['name'] == TUMOUR_SUPPRESSIVE
|
|
104
|
+
and r['source']['name'] == ONCOKB_SOURCE_NAME
|
|
105
|
+
),
|
|
106
|
+
cancerGeneStms,
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Returning a sorted list of unique gene records, based on iProbe requirements
|
|
111
|
+
# Unique by name, sorted by displayName
|
|
112
|
+
if not flags:
|
|
113
|
+
seen: set = set()
|
|
114
|
+
unique_genes: List[Record] = []
|
|
115
|
+
for r in cancerGeneStms:
|
|
116
|
+
name = r['subject']['name']
|
|
117
|
+
if name not in seen:
|
|
118
|
+
seen.add(name)
|
|
119
|
+
unique_genes.append(r['subject'])
|
|
120
|
+
|
|
121
|
+
return cast(
|
|
122
|
+
List[Record],
|
|
123
|
+
sorted(unique_genes, key=lambda gene: gene['displayName']),
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Returning a Dict of flags, with list of associated gene records
|
|
127
|
+
# Duplicates are ok
|
|
128
|
+
return {
|
|
129
|
+
'cancerGene': [r['subject'] for r in cancerGeneStms],
|
|
130
|
+
'oncogenic': [r['subject'] for r in oncogenicStms],
|
|
131
|
+
'tumourSuppressive': [r['subject'] for r in tumourSuppressiveStms],
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@deprecated('functionality replaced by get_cancer_gene_flags')
|
|
30
136
|
def _get_tumourigenesis_genes_list(
|
|
31
|
-
conn: GraphKBConnection,
|
|
137
|
+
conn: GraphKBConnection,
|
|
138
|
+
relevance: Union[str, List[str]],
|
|
139
|
+
sources: Union[str, List[str]],
|
|
140
|
+
ignore_cache: bool = False,
|
|
32
141
|
) -> List[Ontology]:
|
|
33
142
|
statements = cast(
|
|
34
143
|
List[Statement],
|
|
@@ -57,6 +166,7 @@ def _get_tumourigenesis_genes_list(
|
|
|
57
166
|
return [gene for gene in genes.values()]
|
|
58
167
|
|
|
59
168
|
|
|
169
|
+
@deprecated('functionality replaced by get_cancer_gene_flags')
|
|
60
170
|
def get_oncokb_oncogenes(conn: GraphKBConnection) -> List[Ontology]:
|
|
61
171
|
"""Get the list of oncogenes stored in GraphKB derived from OncoKB.
|
|
62
172
|
|
|
@@ -66,9 +176,10 @@ def get_oncokb_oncogenes(conn: GraphKBConnection) -> List[Ontology]:
|
|
|
66
176
|
Returns:
|
|
67
177
|
gene (Feature) records
|
|
68
178
|
"""
|
|
69
|
-
return _get_tumourigenesis_genes_list(conn, ONCOGENE,
|
|
179
|
+
return _get_tumourigenesis_genes_list(conn, ONCOGENE, ONCOKB_SOURCE_NAME)
|
|
70
180
|
|
|
71
181
|
|
|
182
|
+
@deprecated('functionality replaced by get_cancer_gene_flags')
|
|
72
183
|
def get_oncokb_tumour_supressors(conn: GraphKBConnection) -> List[Ontology]:
|
|
73
184
|
"""Get the list of tumour supressor genes stored in GraphKB derived from OncoKB.
|
|
74
185
|
|
|
@@ -78,11 +189,14 @@ def get_oncokb_tumour_supressors(conn: GraphKBConnection) -> List[Ontology]:
|
|
|
78
189
|
Returns:
|
|
79
190
|
gene (Feature) records
|
|
80
191
|
"""
|
|
81
|
-
return _get_tumourigenesis_genes_list(conn, TUMOUR_SUPPRESSIVE,
|
|
192
|
+
return _get_tumourigenesis_genes_list(conn, TUMOUR_SUPPRESSIVE, ONCOKB_SOURCE_NAME)
|
|
82
193
|
|
|
83
194
|
|
|
195
|
+
@deprecated('functionality replaced by get_cancer_gene_flags')
|
|
84
196
|
def get_cancer_genes(conn: GraphKBConnection) -> List[Ontology]:
|
|
85
|
-
"""
|
|
197
|
+
"""
|
|
198
|
+
Get the list of cancer genes stored in GraphKB derived from OncoKB & TSO500.
|
|
199
|
+
Cancer genes include oncogenes, tumour supressor genes and other cancer genes.
|
|
86
200
|
|
|
87
201
|
Args:
|
|
88
202
|
conn: the graphkb connection object
|
|
@@ -90,8 +204,12 @@ def get_cancer_genes(conn: GraphKBConnection) -> List[Ontology]:
|
|
|
90
204
|
Returns:
|
|
91
205
|
gene (Feature) records
|
|
92
206
|
"""
|
|
207
|
+
cancer_gene_terms = conn.get_related_terms(
|
|
208
|
+
terms=CANCER_GENE,
|
|
209
|
+
subgraphType='children',
|
|
210
|
+
)
|
|
93
211
|
return _get_tumourigenesis_genes_list(
|
|
94
|
-
conn,
|
|
212
|
+
conn, cancer_gene_terms, [ONCOKB_SOURCE_NAME, TSO500_SOURCE_NAME]
|
|
95
213
|
)
|
|
96
214
|
|
|
97
215
|
|
|
@@ -513,12 +631,12 @@ def get_gene_information(
|
|
|
513
631
|
# PositionalVariant without a reference2 implies a smallMutation type
|
|
514
632
|
gene_flags['knownSmallMutation'].add(condition['reference1']) # type: ignore
|
|
515
633
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
gene_flags['
|
|
520
|
-
|
|
521
|
-
gene_flags['cancerGeneListMatch'] = convert_to_rid_set(
|
|
634
|
+
# cancer gene flags
|
|
635
|
+
logger.info('fetching cancer genes')
|
|
636
|
+
cancer_gene_flags = get_cancer_gene_flags(graphkb_conn, flags=True)
|
|
637
|
+
gene_flags['oncogene'] = convert_to_rid_set(cancer_gene_flags['oncogenic'])
|
|
638
|
+
gene_flags['tumourSuppressor'] = convert_to_rid_set(cancer_gene_flags['tumourSuppressive'])
|
|
639
|
+
gene_flags['cancerGeneListMatch'] = convert_to_rid_set(cancer_gene_flags['cancerGene'])
|
|
522
640
|
|
|
523
641
|
logger.info('fetching therapeutic associated genes lists')
|
|
524
642
|
gene_flags['therapeuticAssociated'] = convert_to_rid_set(
|
|
@@ -354,6 +354,74 @@ class GraphKBConnection:
|
|
|
354
354
|
raise AssertionError(f'Unable to unqiuely identify source with name {name}')
|
|
355
355
|
return source[0]
|
|
356
356
|
|
|
357
|
+
@property
|
|
358
|
+
def version(self) -> Dict[str, str]:
|
|
359
|
+
"""
|
|
360
|
+
Retrieve GraphKB components version
|
|
361
|
+
|
|
362
|
+
Returns:
|
|
363
|
+
Dict[str, str]: component keys with version values
|
|
364
|
+
|
|
365
|
+
e.g. > {"api":"3.17.3","db":"production","parser":"2.1.0","schema":"4.1.1"}
|
|
366
|
+
"""
|
|
367
|
+
return self.request('version')
|
|
368
|
+
|
|
369
|
+
def get_related_records(
|
|
370
|
+
self,
|
|
371
|
+
base: Union[str, List[str]],
|
|
372
|
+
ontology: str,
|
|
373
|
+
subgraphType: str,
|
|
374
|
+
returnProperties: Optional[List[str]] = None,
|
|
375
|
+
) -> List[Record]:
|
|
376
|
+
"""
|
|
377
|
+
Given some base node RIDs, an ontology class and a subgraph type,
|
|
378
|
+
leverage the subgraphs route to return the list of related nodes.
|
|
379
|
+
|
|
380
|
+
Args:
|
|
381
|
+
base: the base node RIDs to start the graph traversal from
|
|
382
|
+
ontology: the ontology class to traverse
|
|
383
|
+
subgraphType: the type of traversal. See options in API specs
|
|
384
|
+
returnProperties: additional record properties to return
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
list of related node record(s) traversed
|
|
388
|
+
"""
|
|
389
|
+
related = self.post(
|
|
390
|
+
uri=f'/subgraphs/{ontology}',
|
|
391
|
+
data={
|
|
392
|
+
'base': base if isinstance(base, list) else [base],
|
|
393
|
+
'subgraphType': subgraphType,
|
|
394
|
+
'returnProperties': returnProperties or [],
|
|
395
|
+
},
|
|
396
|
+
)
|
|
397
|
+
return related['result']['g']['nodes']
|
|
398
|
+
|
|
399
|
+
def get_related_terms(
|
|
400
|
+
self,
|
|
401
|
+
terms: Union[str, List[str]],
|
|
402
|
+
ontology: str = 'Vocabulary',
|
|
403
|
+
subgraphType: str = 'similar',
|
|
404
|
+
) -> List[str]:
|
|
405
|
+
"""
|
|
406
|
+
Given some base term name(s), an ontology class and a subgraph type,
|
|
407
|
+
leverage the subgraphs route to return the list of related term name(s)
|
|
408
|
+
|
|
409
|
+
Args:
|
|
410
|
+
terms: the base term name(s) to start the graph traversal from
|
|
411
|
+
ontology: the ontology class to traverse
|
|
412
|
+
subgraphType: the type of traversal
|
|
413
|
+
|
|
414
|
+
Returns:
|
|
415
|
+
list of related term name(s)
|
|
416
|
+
"""
|
|
417
|
+
rids = convert_to_rid_list(self.query({'target': ontology, 'filters': {'name': terms}}))
|
|
418
|
+
nodes = self.get_related_records(
|
|
419
|
+
base=rids,
|
|
420
|
+
ontology=ontology,
|
|
421
|
+
subgraphType=subgraphType,
|
|
422
|
+
)
|
|
423
|
+
return [x['name'] for x in nodes.values()]
|
|
424
|
+
|
|
357
425
|
|
|
358
426
|
def get_rid(conn: GraphKBConnection, target: str, name: str) -> str:
|
|
359
427
|
"""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Callable, Dict, Iterable, List, Set, cast
|
|
1
|
+
from typing import Callable, Dict, Iterable, List, Set, cast, Union
|
|
2
2
|
|
|
3
3
|
from pori_python.types import Ontology
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ from . import GraphKBConnection
|
|
|
6
6
|
from .util import convert_to_rid_list
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def query_by_name(ontology_class: str, base_term_name: str) -> Dict:
|
|
9
|
+
def query_by_name(ontology_class: str, base_term_name: Union[str, list[str]]) -> Dict:
|
|
10
10
|
return {'target': ontology_class, 'filters': {'name': base_term_name}}
|
|
11
11
|
|
|
12
12
|
|
|
@@ -93,10 +93,54 @@ class IprConnection:
|
|
|
93
93
|
**kwargs,
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
+
def check_upload_permission(self, project_name: str) -> None:
|
|
97
|
+
"""Check that the current user has permission to upload to the given project.
|
|
98
|
+
|
|
99
|
+
Fetches all projects and the current user info (including groups and
|
|
100
|
+
projects) up front. Checks for admin, manager, create report access,
|
|
101
|
+
all projects access, and project membership.
|
|
102
|
+
"""
|
|
103
|
+
projects = self.get('project')
|
|
104
|
+
project_exists = any(p['name'] == project_name for p in projects)
|
|
105
|
+
if not project_exists:
|
|
106
|
+
raise Exception(
|
|
107
|
+
f'Project {project_name} does not exist or user does not have permission to view it'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
user = self.get('user/me')
|
|
111
|
+
user_groups = user.get('groups', []) if isinstance(user, dict) else []
|
|
112
|
+
group_names = {
|
|
113
|
+
group.get('name', '').strip().lower()
|
|
114
|
+
if isinstance(group, dict)
|
|
115
|
+
else group.strip().lower()
|
|
116
|
+
for group in user_groups
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
is_admin = 'admin' in group_names
|
|
120
|
+
is_manager = 'manager' in group_names
|
|
121
|
+
has_create_report_access = 'create report access' in group_names
|
|
122
|
+
has_all_projects_access = 'all projects access' in group_names
|
|
123
|
+
|
|
124
|
+
# admins and managers can always create reports
|
|
125
|
+
can_create_report = is_admin or is_manager or has_create_report_access
|
|
126
|
+
|
|
127
|
+
user_projects = user.get('projects', []) if isinstance(user, dict) else []
|
|
128
|
+
has_project_access = (
|
|
129
|
+
is_admin
|
|
130
|
+
or has_all_projects_access
|
|
131
|
+
or any(isinstance(p, dict) and p.get('name') == project_name for p in user_projects)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if not can_create_report:
|
|
135
|
+
raise Exception('User does not have report creation permission')
|
|
136
|
+
|
|
137
|
+
if not has_project_access:
|
|
138
|
+
raise Exception(f'User has no permission to create report in project {project_name}')
|
|
139
|
+
|
|
96
140
|
def upload_report(
|
|
97
141
|
self,
|
|
98
142
|
content: Dict,
|
|
99
|
-
mins_to_wait: int =
|
|
143
|
+
mins_to_wait: int = 10,
|
|
100
144
|
async_upload: bool = False,
|
|
101
145
|
ignore_extra_fields: bool = False,
|
|
102
146
|
) -> Dict:
|
|
@@ -105,19 +149,6 @@ class IprConnection:
|
|
|
105
149
|
# or 'report'. jobStatus is no longer available once the report is successfully
|
|
106
150
|
# uploaded.
|
|
107
151
|
|
|
108
|
-
projects = self.get('project')
|
|
109
|
-
project_names = [item['name'] for item in projects]
|
|
110
|
-
|
|
111
|
-
# if project is not exist, create one
|
|
112
|
-
if content['project'] not in project_names:
|
|
113
|
-
logger.info(
|
|
114
|
-
f'Project not found - attempting to create project {content["project"]}'
|
|
115
|
-
)
|
|
116
|
-
try:
|
|
117
|
-
self.post('project', {'name': content['project']})
|
|
118
|
-
except Exception as err:
|
|
119
|
-
raise Exception(f'Project creation failed due to {err}')
|
|
120
|
-
|
|
121
152
|
if ignore_extra_fields:
|
|
122
153
|
initial_result = self.post('reports-async?ignore_extra_fields=true', content)
|
|
123
154
|
else:
|
|
@@ -202,6 +202,16 @@
|
|
|
202
202
|
"number",
|
|
203
203
|
"null"
|
|
204
204
|
]
|
|
205
|
+
},
|
|
206
|
+
"flags": {
|
|
207
|
+
"description": "variant flags",
|
|
208
|
+
"items": {
|
|
209
|
+
"type": "string"
|
|
210
|
+
},
|
|
211
|
+
"type": [
|
|
212
|
+
"array",
|
|
213
|
+
"null"
|
|
214
|
+
]
|
|
205
215
|
}
|
|
206
216
|
},
|
|
207
217
|
"required": [
|
|
@@ -475,6 +485,16 @@
|
|
|
475
485
|
"null",
|
|
476
486
|
"string"
|
|
477
487
|
]
|
|
488
|
+
},
|
|
489
|
+
"flags": {
|
|
490
|
+
"description": "variant flags",
|
|
491
|
+
"items": {
|
|
492
|
+
"type": "string"
|
|
493
|
+
},
|
|
494
|
+
"type": [
|
|
495
|
+
"array",
|
|
496
|
+
"null"
|
|
497
|
+
]
|
|
478
498
|
}
|
|
479
499
|
},
|
|
480
500
|
"required": [
|
|
@@ -548,12 +568,37 @@
|
|
|
548
568
|
},
|
|
549
569
|
"score": {
|
|
550
570
|
"type": "number"
|
|
571
|
+
},
|
|
572
|
+
"cutoff": {
|
|
573
|
+
"type": "number"
|
|
551
574
|
}
|
|
552
575
|
},
|
|
576
|
+
"type": "object",
|
|
553
577
|
"required": [
|
|
554
578
|
"score"
|
|
555
579
|
],
|
|
556
|
-
"
|
|
580
|
+
"oneOf": [
|
|
581
|
+
{
|
|
582
|
+
"required": [
|
|
583
|
+
"kbCategory"
|
|
584
|
+
],
|
|
585
|
+
"not": {
|
|
586
|
+
"required": [
|
|
587
|
+
"cutoff"
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
"required": [
|
|
593
|
+
"cutoff"
|
|
594
|
+
],
|
|
595
|
+
"not": {
|
|
596
|
+
"required": [
|
|
597
|
+
"kbCategory"
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
]
|
|
557
602
|
},
|
|
558
603
|
"images": {
|
|
559
604
|
"items": {
|
|
@@ -867,6 +912,109 @@
|
|
|
867
912
|
"example": "POG",
|
|
868
913
|
"type": "string"
|
|
869
914
|
},
|
|
915
|
+
"seqQC": {
|
|
916
|
+
"default": [],
|
|
917
|
+
"type": "array",
|
|
918
|
+
"items": {
|
|
919
|
+
"type": "object",
|
|
920
|
+
"properties": {
|
|
921
|
+
"reads": {
|
|
922
|
+
"description": "Number of reads",
|
|
923
|
+
"example": "2534M",
|
|
924
|
+
"type": [
|
|
925
|
+
"string",
|
|
926
|
+
"null"
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
"bioQC": {
|
|
930
|
+
"description": "Biological QC status",
|
|
931
|
+
"example": "passed",
|
|
932
|
+
"type": [
|
|
933
|
+
"string",
|
|
934
|
+
"null"
|
|
935
|
+
]
|
|
936
|
+
},
|
|
937
|
+
"labQC": {
|
|
938
|
+
"description": "Lab QC status",
|
|
939
|
+
"example": "passed",
|
|
940
|
+
"type": [
|
|
941
|
+
"string",
|
|
942
|
+
"null"
|
|
943
|
+
]
|
|
944
|
+
},
|
|
945
|
+
"sample": {
|
|
946
|
+
"description": "Sample identifier, e.g. Tumour DNA, Constitutional DNA",
|
|
947
|
+
"example": "Tumour DNA",
|
|
948
|
+
"type": [
|
|
949
|
+
"string",
|
|
950
|
+
"null"
|
|
951
|
+
]
|
|
952
|
+
},
|
|
953
|
+
"library": {
|
|
954
|
+
"description": "Library identifier",
|
|
955
|
+
"example": "LIB0001",
|
|
956
|
+
"type": [
|
|
957
|
+
"string",
|
|
958
|
+
"null"
|
|
959
|
+
]
|
|
960
|
+
},
|
|
961
|
+
"coverage": {
|
|
962
|
+
"description": "Sequencing coverage",
|
|
963
|
+
"example": "80x",
|
|
964
|
+
"type": [
|
|
965
|
+
"string",
|
|
966
|
+
"null"
|
|
967
|
+
]
|
|
968
|
+
},
|
|
969
|
+
"inputNg": {
|
|
970
|
+
"description": "Input amount in nanograms",
|
|
971
|
+
"example": "500",
|
|
972
|
+
"type": [
|
|
973
|
+
"string",
|
|
974
|
+
"number",
|
|
975
|
+
"integer",
|
|
976
|
+
"null"
|
|
977
|
+
]
|
|
978
|
+
},
|
|
979
|
+
"inputUg": {
|
|
980
|
+
"description": "Input amount in micrograms",
|
|
981
|
+
"example": "0.5",
|
|
982
|
+
"type": [
|
|
983
|
+
"string",
|
|
984
|
+
"number",
|
|
985
|
+
"integer",
|
|
986
|
+
"null"
|
|
987
|
+
]
|
|
988
|
+
},
|
|
989
|
+
"protocol": {
|
|
990
|
+
"description": "Sequencing protocol",
|
|
991
|
+
"example": "WGS",
|
|
992
|
+
"type": [
|
|
993
|
+
"string",
|
|
994
|
+
"null"
|
|
995
|
+
]
|
|
996
|
+
},
|
|
997
|
+
"sampleName": {
|
|
998
|
+
"description": "Full sample name",
|
|
999
|
+
"example": "SAMPLE1-FF-1",
|
|
1000
|
+
"type": [
|
|
1001
|
+
"string",
|
|
1002
|
+
"null"
|
|
1003
|
+
]
|
|
1004
|
+
},
|
|
1005
|
+
"duplicateReadsPerc": {
|
|
1006
|
+
"description": "Percentage of duplicate reads",
|
|
1007
|
+
"example": "12.3",
|
|
1008
|
+
"type": [
|
|
1009
|
+
"string",
|
|
1010
|
+
"number",
|
|
1011
|
+
"integer",
|
|
1012
|
+
"null"
|
|
1013
|
+
]
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
870
1018
|
"smallMutations": {
|
|
871
1019
|
"default": [],
|
|
872
1020
|
"items": {
|
|
@@ -1081,6 +1229,16 @@
|
|
|
1081
1229
|
"string",
|
|
1082
1230
|
"null"
|
|
1083
1231
|
]
|
|
1232
|
+
},
|
|
1233
|
+
"flags": {
|
|
1234
|
+
"description": "variant flags",
|
|
1235
|
+
"items": {
|
|
1236
|
+
"type": "string"
|
|
1237
|
+
},
|
|
1238
|
+
"type": [
|
|
1239
|
+
"array",
|
|
1240
|
+
"null"
|
|
1241
|
+
]
|
|
1084
1242
|
}
|
|
1085
1243
|
},
|
|
1086
1244
|
"required": [
|
|
@@ -1265,6 +1423,16 @@
|
|
|
1265
1423
|
"integer",
|
|
1266
1424
|
"null"
|
|
1267
1425
|
]
|
|
1426
|
+
},
|
|
1427
|
+
"flags": {
|
|
1428
|
+
"description": "variant flags",
|
|
1429
|
+
"items": {
|
|
1430
|
+
"type": "string"
|
|
1431
|
+
},
|
|
1432
|
+
"type": [
|
|
1433
|
+
"array",
|
|
1434
|
+
"null"
|
|
1435
|
+
]
|
|
1268
1436
|
}
|
|
1269
1437
|
},
|
|
1270
1438
|
"required": [
|