pori-python 1.2.2__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.
Files changed (72) hide show
  1. {pori_python-1.2.2/pori_python.egg-info → pori_python-1.4.0}/PKG-INFO +11 -14
  2. {pori_python-1.2.2 → pori_python-1.4.0}/README.md +9 -8
  3. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/__init__.py +0 -1
  4. pori_python-1.4.0/pori_python/graphkb/constants.py +215 -0
  5. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/genes.py +135 -137
  6. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/match.py +145 -145
  7. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/statement.py +5 -5
  8. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/util.py +115 -111
  9. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/graphkb/vocab.py +35 -35
  10. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/annotate.py +75 -75
  11. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/connection.py +57 -58
  12. pori_python-1.4.0/pori_python/ipr/constants.py +41 -0
  13. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/content.spec.json +39 -0
  14. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/inputs.py +311 -267
  15. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/ipr.py +191 -164
  16. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/main.py +188 -164
  17. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/summary.py +137 -125
  18. pori_python-1.4.0/pori_python/ipr/therapeutic_options.py +83 -0
  19. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/util.py +86 -52
  20. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/types.py +2 -2
  21. {pori_python-1.2.2 → pori_python-1.4.0/pori_python.egg-info}/PKG-INFO +11 -14
  22. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python.egg-info/requires.txt +1 -5
  23. pori_python-1.4.0/pyproject.toml +7 -0
  24. {pori_python-1.2.2 → pori_python-1.4.0}/setup.cfg +2 -6
  25. pori_python-1.4.0/tests/test_graphkb/data.py +198 -0
  26. pori_python-1.4.0/tests/test_graphkb/test_genes.py +306 -0
  27. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_graphkb/test_graphkb.py +7 -7
  28. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_graphkb/test_match.py +202 -202
  29. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_graphkb/test_statement.py +37 -37
  30. pori_python-1.4.0/tests/test_graphkb/test_util.py +151 -0
  31. pori_python-1.4.0/tests/test_graphkb/test_vocab.py +85 -0
  32. pori_python-1.4.0/tests/test_ipr/constants.py +3 -0
  33. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_ipr/test_annotate.py +90 -90
  34. pori_python-1.4.0/tests/test_ipr/test_connection.py +97 -0
  35. pori_python-1.4.0/tests/test_ipr/test_inputs.py +560 -0
  36. pori_python-1.4.0/tests/test_ipr/test_ipr.py +858 -0
  37. pori_python-1.4.0/tests/test_ipr/test_main.py +178 -0
  38. pori_python-1.4.0/tests/test_ipr/test_probe.py +82 -0
  39. pori_python-1.4.0/tests/test_ipr/test_summary.py +383 -0
  40. pori_python-1.4.0/tests/test_ipr/test_upload.py +383 -0
  41. pori_python-1.4.0/tests/test_ipr/test_util.py +29 -0
  42. pori_python-1.2.2/pori_python/graphkb/constants.py +0 -220
  43. pori_python-1.2.2/pori_python/ipr/constants.py +0 -28
  44. pori_python-1.2.2/pori_python/ipr/therapeutic_options.py +0 -83
  45. pori_python-1.2.2/pyproject.toml +0 -1
  46. pori_python-1.2.2/tests/test_graphkb/data.py +0 -198
  47. pori_python-1.2.2/tests/test_graphkb/test_genes.py +0 -306
  48. pori_python-1.2.2/tests/test_graphkb/test_util.py +0 -151
  49. pori_python-1.2.2/tests/test_graphkb/test_vocab.py +0 -85
  50. pori_python-1.2.2/tests/test_ipr/constants.py +0 -3
  51. pori_python-1.2.2/tests/test_ipr/test_connection.py +0 -97
  52. pori_python-1.2.2/tests/test_ipr/test_inputs.py +0 -463
  53. pori_python-1.2.2/tests/test_ipr/test_ipr.py +0 -760
  54. pori_python-1.2.2/tests/test_ipr/test_main.py +0 -168
  55. pori_python-1.2.2/tests/test_ipr/test_probe.py +0 -82
  56. pori_python-1.2.2/tests/test_ipr/test_summary.py +0 -355
  57. pori_python-1.2.2/tests/test_ipr/test_upload.py +0 -357
  58. pori_python-1.2.2/tests/test_ipr/test_util.py +0 -29
  59. {pori_python-1.2.2 → pori_python-1.4.0}/LICENSE +0 -0
  60. {pori_python-1.2.2 → pori_python-1.4.0}/MANIFEST.in +0 -0
  61. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/__init__.py +0 -0
  62. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/ipr/__init__.py +0 -0
  63. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python/py.typed +0 -0
  64. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python.egg-info/SOURCES.txt +0 -0
  65. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python.egg-info/dependency_links.txt +0 -0
  66. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python.egg-info/entry_points.txt +0 -0
  67. {pori_python-1.2.2 → pori_python-1.4.0}/pori_python.egg-info/top_level.txt +0 -0
  68. {pori_python-1.2.2 → pori_python-1.4.0}/setup.py +0 -0
  69. {pori_python-1.2.2 → pori_python-1.4.0}/tests/__init__.py +0 -0
  70. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_graphkb/__init__.py +0 -0
  71. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_ipr/__init__.py +0 -0
  72. {pori_python-1.2.2 → pori_python-1.4.0}/tests/test_ipr/util.py +0 -0
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pori_python
3
- Version: 1.2.2
3
+ Version: 1.4.0
4
4
  Home-page: https://github.com/bcgsc/pori_python
5
5
  Author-email: dat@bcgsc.ca
6
6
  Maintainer-email: dat@bcgsc.ca
7
7
  Requires-Python: >=3.9
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
- Requires-Dist: biopython
11
10
  Requires-Dist: jsonschema
12
11
  Requires-Dist: pandas>=1.1.0
13
12
  Requires-Dist: requests
@@ -37,10 +36,7 @@ Requires-Dist: mkdocs; extra == "dev"
37
36
  Requires-Dist: mkdocs-material; extra == "dev"
38
37
  Requires-Dist: mkdocs-redirects; extra == "dev"
39
38
  Requires-Dist: markdown-refdocs; extra == "dev"
40
- Requires-Dist: flake8; extra == "dev"
41
- Requires-Dist: black; extra == "dev"
42
- Requires-Dist: flake8-annotations; extra == "dev"
43
- Requires-Dist: isort; extra == "dev"
39
+ Requires-Dist: ruff; extra == "dev"
44
40
  Requires-Dist: mypy; extra == "dev"
45
41
  Dynamic: license-file
46
42
 
@@ -92,11 +88,9 @@ pip install -e .[dev]
92
88
 
93
89
  Run the tests:
94
90
 
95
- Export usernames, passwords, and set test options.
91
+ Export usernames, passwords, and test options.
96
92
 
97
- Note that IPR tests will try to use the BCGSC production GraphKB API by default.
98
- If you want to test interaction with a different instance, you will need to
99
- set the GraphKB variables.
93
+ IPR_URL and GRAPHKB_URL values must also be set.
100
94
 
101
95
  Set EXCLUDE vars to 1 if you don't want to run these tests.
102
96
  ONCOKB and BCGSC tests are enabled by default.
@@ -113,11 +107,12 @@ export EXCLUDE_ONCOKB_TESTS=1
113
107
  ```
114
108
 
115
109
  If you want to run tests that upload reports to a live IPR instance,
116
- specify the url of the IPR API you want to use and set the test var to 1.
110
+ specify the url of the IPR API you want to use and set the test var
111
+ INCLUDE_UPLOAD_TESTS to 1.
117
112
  These tests are disabled by default.
118
113
 
119
114
  The created reports are deleted by default. If you want to keep them,
120
- set DELETE_UPLOAD_TEST_REPORTS to 0 in the env.
115
+ set DELETE_UPLOAD_TEST_REPORTS to 0.
121
116
 
122
117
  ```bash
123
118
  export IPR_TEST_URL='http://localhost:8081/api'
@@ -130,14 +125,16 @@ pytest tests
130
125
  ```
131
126
 
132
127
  ### JSON Validate and Upload to IPR
128
+ An IPR_URL must be provided either as an environment variable or an arg.
129
+
133
130
  If you only want to validate the json content, use
134
131
  ```bash
135
- ipr --password $IPR_PASS -c 'path/to/content.json' --validate_json
132
+ ipr --password $IPR_PASS -c 'path/to/content.json' --validate_json --ipr_url $IPR_URL
136
133
  ```
137
134
 
138
135
  If you only want to upload the json directly to ipr and skip all the preprocessing, use
139
136
  ```bash
140
- ipr --password $IPR_PASS -c 'path/to/content.json' --upload_json
137
+ ipr --password $IPR_PASS -c 'path/to/content.json' --upload_json --ipr_url $IPR_URL
141
138
  ```
142
139
 
143
140
  ## Documentation
@@ -46,11 +46,9 @@ pip install -e .[dev]
46
46
 
47
47
  Run the tests:
48
48
 
49
- Export usernames, passwords, and set test options.
49
+ Export usernames, passwords, and test options.
50
50
 
51
- Note that IPR tests will try to use the BCGSC production GraphKB API by default.
52
- If you want to test interaction with a different instance, you will need to
53
- set the GraphKB variables.
51
+ IPR_URL and GRAPHKB_URL values must also be set.
54
52
 
55
53
  Set EXCLUDE vars to 1 if you don't want to run these tests.
56
54
  ONCOKB and BCGSC tests are enabled by default.
@@ -67,11 +65,12 @@ export EXCLUDE_ONCOKB_TESTS=1
67
65
  ```
68
66
 
69
67
  If you want to run tests that upload reports to a live IPR instance,
70
- specify the url of the IPR API you want to use and set the test var to 1.
68
+ specify the url of the IPR API you want to use and set the test var
69
+ INCLUDE_UPLOAD_TESTS to 1.
71
70
  These tests are disabled by default.
72
71
 
73
72
  The created reports are deleted by default. If you want to keep them,
74
- set DELETE_UPLOAD_TEST_REPORTS to 0 in the env.
73
+ set DELETE_UPLOAD_TEST_REPORTS to 0.
75
74
 
76
75
  ```bash
77
76
  export IPR_TEST_URL='http://localhost:8081/api'
@@ -84,14 +83,16 @@ pytest tests
84
83
  ```
85
84
 
86
85
  ### JSON Validate and Upload to IPR
86
+ An IPR_URL must be provided either as an environment variable or an arg.
87
+
87
88
  If you only want to validate the json content, use
88
89
  ```bash
89
- ipr --password $IPR_PASS -c 'path/to/content.json' --validate_json
90
+ ipr --password $IPR_PASS -c 'path/to/content.json' --validate_json --ipr_url $IPR_URL
90
91
  ```
91
92
 
92
93
  If you only want to upload the json directly to ipr and skip all the preprocessing, use
93
94
  ```bash
94
- ipr --password $IPR_PASS -c 'path/to/content.json' --upload_json
95
+ ipr --password $IPR_PASS -c 'path/to/content.json' --upload_json --ipr_url $IPR_URL
95
96
  ```
96
97
 
97
98
  ## Documentation
@@ -1,2 +1 @@
1
- from .constants import DEFAULT_URL # noqa: F401
2
1
  from .util import GraphKBConnection, logger # noqa: F401
@@ -0,0 +1,215 @@
1
+ import argparse
2
+ from typing import Dict
3
+
4
+ from pori_python.types import CategoryBaseTermMapping
5
+
6
+ DEFAULT_LIMIT = 1000
7
+
8
+ PREFERRED_GENE_SOURCE_NAME = 'HGNC'
9
+
10
+ BASE_RETURN_PROPERTIES = ['@rid', '@class']
11
+
12
+ GENERIC_RETURN_PROPERTIES = [
13
+ 'name',
14
+ 'sourceId',
15
+ 'sourceIdVersion',
16
+ 'source.name',
17
+ 'source.@rid',
18
+ 'displayName',
19
+ 'deprecated',
20
+ ] + BASE_RETURN_PROPERTIES
21
+
22
+ GENE_RETURN_PROPERTIES = ['biotype'] + GENERIC_RETURN_PROPERTIES
23
+
24
+ VARIANT_RETURN_PROPERTIES = (
25
+ BASE_RETURN_PROPERTIES
26
+ + [f'type.{p}' for p in GENERIC_RETURN_PROPERTIES]
27
+ + [f'reference1.{p}' for p in GENE_RETURN_PROPERTIES]
28
+ + [f'reference2.{p}' for p in GENE_RETURN_PROPERTIES]
29
+ + ['zygosity', 'germline', 'displayName']
30
+ )
31
+
32
+ POS_VARIANT_RETURN_PROPERTIES = VARIANT_RETURN_PROPERTIES + [
33
+ 'break1Start',
34
+ 'break1End',
35
+ 'break2Start',
36
+ 'break2End',
37
+ 'break1Repr',
38
+ 'break2Repr',
39
+ 'refSeq',
40
+ 'untemplatedSeq',
41
+ 'untemplatedSeqSize',
42
+ 'truncation',
43
+ 'assembly',
44
+ ]
45
+
46
+ STATEMENT_RETURN_PROPERTIES = (
47
+ BASE_RETURN_PROPERTIES
48
+ + ['displayNameTemplate', 'sourceId', 'source.name', 'source.displayName']
49
+ + [f'conditions.{p}' for p in GENERIC_RETURN_PROPERTIES]
50
+ + [f'subject.{p}' for p in GENERIC_RETURN_PROPERTIES]
51
+ + [f'evidence.{p}' for p in GENERIC_RETURN_PROPERTIES]
52
+ + [f'relevance.{p}' for p in GENERIC_RETURN_PROPERTIES]
53
+ + [f'evidenceLevel.{p}' for p in GENERIC_RETURN_PROPERTIES]
54
+ + ['reviewStatus']
55
+ )
56
+
57
+
58
+ ONCOKB_SOURCE_NAME = 'oncokb'
59
+ TSO500_SOURCE_NAME = 'tso500'
60
+ ONCOGENE = 'oncogenic'
61
+ TUMOUR_SUPPRESSIVE = 'tumour suppressive'
62
+ CANCER_GENE = 'cancer gene'
63
+ FUSION_NAMES = ['structural variant', 'fusion']
64
+
65
+ GSC_PHARMACOGENOMIC_SOURCE_EXCLUDE_LIST = ['cancer genome interpreter', 'civic']
66
+ GSC_PHARMACOGENOMIC_SOURCE_DISPLAYNAME_EXCLUDE_LIST = ['CGI', 'CIViC']
67
+
68
+ BASE_THERAPEUTIC_TERMS = ['therapeutic efficacy', 'eligibility']
69
+ # the order here is the order these are applied, the first category matched is returned
70
+ RELEVANCE_BASE_TERMS: CategoryBaseTermMapping = [
71
+ ('therapeutic', BASE_THERAPEUTIC_TERMS),
72
+ ('diagnostic', ['diagnostic indicator']),
73
+ ('prognostic', ['prognostic indicator']),
74
+ ('pharmacogenomic', ['metabolism', 'toxicity', 'dosage']),
75
+ ('cancer predisposition', ['pathogenic']),
76
+ ('biological', ['functional effect', 'tumourigenesis', 'predisposing']),
77
+ ]
78
+ FAILED_REVIEW_STATUS = 'failed'
79
+
80
+ CHROMOSOMES_HG38 = [f'chr{i}' for i in range(1, 23)] + ['chrX', 'chrY', 'chrM']
81
+ CHROMOSOMES_HG19 = [str(i) for i in range(1, 23)] + ['x', 'y', 'mt']
82
+ CHROMOSOMES = CHROMOSOMES_HG38 + CHROMOSOMES_HG19
83
+
84
+ AMBIGUOUS_AA = ['x', '?', 'X']
85
+ AA_3to1_MAPPING = {
86
+ 'Ala': 'A',
87
+ 'Arg': 'R',
88
+ 'Asn': 'N',
89
+ 'Asp': 'D',
90
+ 'Asx': 'B',
91
+ 'Cys': 'C',
92
+ 'Glu': 'E',
93
+ 'Gln': 'Q',
94
+ 'Glx': 'Z',
95
+ 'Gly': 'G',
96
+ 'His': 'H',
97
+ 'Ile': 'I',
98
+ 'Leu': 'L',
99
+ 'Lys': 'K',
100
+ 'Met': 'M',
101
+ 'Phe': 'F',
102
+ 'Pro': 'P',
103
+ 'Ser': 'S',
104
+ 'Thr': 'T',
105
+ 'Trp': 'W',
106
+ 'Tyr': 'Y',
107
+ 'Val': 'V',
108
+ 'Ter': '*',
109
+ }
110
+
111
+
112
+ class IterableNamespace(argparse.Namespace):
113
+ def __init__(self, *pos, **kwargs):
114
+ argparse.Namespace.__init__(self, *pos, **kwargs)
115
+
116
+ def keys(self):
117
+ return self.__dict__.keys()
118
+
119
+ def items(self):
120
+ return self.__dict__.items()
121
+
122
+ def values(self):
123
+ return self.__dict__.values()
124
+
125
+ def __getitem__(self, key):
126
+ return getattr(self, key)
127
+
128
+
129
+ INPUT_COPY_CATEGORIES = IterableNamespace(
130
+ AMP='amplification',
131
+ ANY_GAIN='copy gain',
132
+ ANY_LOSS='copy loss',
133
+ DEEP='deep deletion',
134
+ GAIN='low level copy gain',
135
+ LOSS='shallow deletion',
136
+ )
137
+ INPUT_EXPRESSION_CATEGORIES = IterableNamespace(
138
+ UP='increased expression', DOWN='reduced expression'
139
+ )
140
+
141
+ # From: https://github.com/bcgsc/pori_graphkb_parser/blob/ae3738842a4c208ab30f58c08ae987594d632504/src/constants.ts#L33-L80
142
+ TYPES_TO_NOTATION: Dict[str, str] = {
143
+ 'acetylation': 'ac',
144
+ 'copy gain': 'copygain',
145
+ 'copy loss': 'copyloss',
146
+ 'deletion': 'del',
147
+ 'duplication': 'dup',
148
+ 'extension': 'ext',
149
+ 'frameshift': 'fs',
150
+ 'fusion': 'fusion',
151
+ 'indel': 'delins',
152
+ 'insertion': 'ins',
153
+ 'inversion': 'inv',
154
+ 'inverted translocation': 'itrans',
155
+ 'methylation': 'me',
156
+ 'missense mutation': 'mis',
157
+ 'mutation': 'mut',
158
+ 'nonsense mutation': '>',
159
+ 'phosphorylation': 'phos',
160
+ 'splice-site': 'spl',
161
+ 'substitution': '>',
162
+ 'translocation': 'trans',
163
+ 'truncating frameshift mutation': 'fs',
164
+ 'ubiquitination': 'ub',
165
+ # deprecated forms and aliases
166
+ 'frameshift mutation': 'fs',
167
+ 'frameshift truncation': 'fs',
168
+ 'missense variant': 'mis',
169
+ 'truncating frameshift': 'fs',
170
+ 'missense': 'mis',
171
+ 'mutations': 'mut',
172
+ 'nonsense': '>',
173
+ }
174
+
175
+ # For match.type_screening() [KBDEV-1056]
176
+ DEFAULT_NON_STRUCTURAL_VARIANT_TYPE = 'mutation'
177
+ STRUCTURAL_VARIANT_SIZE_THRESHOLD = 48 # bp
178
+ STRUCTURAL_VARIANT_TYPES = [
179
+ 'structural variant',
180
+ 'insertion',
181
+ 'in-frame insertion',
182
+ 'deletion',
183
+ 'deletion polymorphism',
184
+ 'in-frame deletion',
185
+ 'translocation',
186
+ 'inverted translocation',
187
+ 'inversion',
188
+ 'indel',
189
+ 'fusion',
190
+ 'out-of-frame fusion',
191
+ 'oncogenic fusion',
192
+ 'in-frame fusion',
193
+ 'disruptive fusion',
194
+ 'duplication',
195
+ 'internal duplication',
196
+ 'tandem duplication',
197
+ 'internal tandem duplication',
198
+ 'itd',
199
+ 'domain duplication',
200
+ 'kinase domain duplication',
201
+ 'copy variant',
202
+ 'copy number variation',
203
+ 'copy number variant',
204
+ 'copy loss',
205
+ 'copy number loss',
206
+ 'shallow deletion',
207
+ 'deep deletion',
208
+ 'gene deletion',
209
+ 'copy gain',
210
+ 'copy number gain',
211
+ 'low level copy gain',
212
+ 'amplification',
213
+ 'focal amplification',
214
+ 'rearrangement',
215
+ ]