pori-python 1.6.0__tar.gz → 1.7.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 (56) hide show
  1. {pori_python-1.6.0/pori_python.egg-info → pori_python-1.7.0}/PKG-INFO +2 -2
  2. {pori_python-1.6.0 → pori_python-1.7.0}/README.md +1 -1
  3. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/main.py +13 -0
  4. {pori_python-1.6.0 → pori_python-1.7.0/pori_python.egg-info}/PKG-INFO +2 -2
  5. {pori_python-1.6.0 → pori_python-1.7.0}/setup.cfg +1 -1
  6. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_main.py +142 -38
  7. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_upload.py +24 -18
  8. {pori_python-1.6.0 → pori_python-1.7.0}/LICENSE +0 -0
  9. {pori_python-1.6.0 → pori_python-1.7.0}/MANIFEST.in +0 -0
  10. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/__init__.py +0 -0
  11. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/__init__.py +0 -0
  12. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/constants.py +0 -0
  13. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/genes.py +0 -0
  14. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/match.py +0 -0
  15. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/statement.py +0 -0
  16. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/util.py +0 -0
  17. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/graphkb/vocab.py +0 -0
  18. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/__init__.py +0 -0
  19. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/annotate.py +0 -0
  20. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/connection.py +0 -0
  21. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/constants.py +0 -0
  22. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/content.spec.json +0 -0
  23. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/inputs.py +0 -0
  24. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/ipr.py +0 -0
  25. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/summary.py +0 -0
  26. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/therapeutic_options.py +0 -0
  27. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/ipr/util.py +0 -0
  28. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/py.typed +0 -0
  29. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python/types.py +0 -0
  30. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python.egg-info/SOURCES.txt +0 -0
  31. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python.egg-info/dependency_links.txt +0 -0
  32. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python.egg-info/entry_points.txt +0 -0
  33. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python.egg-info/requires.txt +0 -0
  34. {pori_python-1.6.0 → pori_python-1.7.0}/pori_python.egg-info/top_level.txt +0 -0
  35. {pori_python-1.6.0 → pori_python-1.7.0}/pyproject.toml +0 -0
  36. {pori_python-1.6.0 → pori_python-1.7.0}/setup.py +0 -0
  37. {pori_python-1.6.0 → pori_python-1.7.0}/tests/__init__.py +0 -0
  38. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/__init__.py +0 -0
  39. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/data.py +0 -0
  40. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_genes.py +0 -0
  41. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_graphkb.py +0 -0
  42. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_match.py +0 -0
  43. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_statement.py +0 -0
  44. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_util.py +0 -0
  45. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_graphkb/test_vocab.py +0 -0
  46. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/__init__.py +0 -0
  47. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/constants.py +0 -0
  48. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_annotate.py +0 -0
  49. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_connection.py +0 -0
  50. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_inputs.py +0 -0
  51. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_ipr.py +0 -0
  52. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_ipr_integration.py +0 -0
  53. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_probe.py +0 -0
  54. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_summary.py +0 -0
  55. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/test_util.py +0 -0
  56. {pori_python-1.6.0 → pori_python-1.7.0}/tests/test_ipr/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pori_python
3
- Version: 1.6.0
3
+ Version: 1.7.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
@@ -46,7 +46,7 @@ Dynamic: license-file
46
46
 
47
47
  # PORI Python Adaptor
48
48
 
49
- ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/master/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
49
+ ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/main/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
50
50
 
51
51
  This repository is part of the [Platform for Oncogenomic Reporting and Interpretation (PORI)](https://bcgsc.github.io/pori/).
52
52
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  # PORI Python Adaptor
3
3
 
4
- ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/master/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
4
+ ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/main/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
5
5
 
6
6
  This repository is part of the [Platform for Oncogenomic Reporting and Interpretation (PORI)](https://bcgsc.github.io/pori/).
7
7
 
@@ -188,6 +188,12 @@ def command_interface() -> None:
188
188
  type=file_path,
189
189
  help='TSV without header, with two columns: transcripts and flags (comma-separated list of flags eg "MANE"). If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477).',
190
190
  )
191
+ parser.add_argument(
192
+ '--state',
193
+ required=False,
194
+ choices=['ready', 'nonproduction'],
195
+ help="Status to create the report with if not default (ready). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content.",
196
+ )
191
197
  args = parser.parse_args()
192
198
 
193
199
  with open(args.content, 'r') as fh:
@@ -213,6 +219,7 @@ def command_interface() -> None:
213
219
  validate_json=args.validate_json,
214
220
  ignore_extra_fields=args.ignore_extra_fields,
215
221
  transcript_flags=args.transcript_flags,
222
+ state=args.state,
216
223
  )
217
224
 
218
225
 
@@ -350,6 +357,7 @@ def ipr_report(
350
357
  ignore_extra_fields: bool = False,
351
358
  tmb_high: float = TMB_SIGNATURE_HIGH_THRESHOLD,
352
359
  transcript_flags: str = '',
360
+ state: str | None = None,
353
361
  ) -> dict:
354
362
  """Run the matching and create the report JSON for upload to IPR.
355
363
 
@@ -380,6 +388,7 @@ def ipr_report(
380
388
  allow_partial_matches: allow matches to statements where not all conditions are satisfied
381
389
  tmb_high: mutation burden threshold/cutoff to qualify as 'high'
382
390
  transcript_flags: path to a tsv file with two columns (no header) of transcript identifiers and flags to be added to any observed variants with matching transcript in the report upload. If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477).
391
+ state: optional report state override ('ready' or 'nonproduction'). When supplied, overrides the state in content, including when uploading precreated report JSON. When omitted, preserves any state in content; if neither supplies a state, the server default ('ready') applies.
383
392
  Returns:
384
393
  ipr_conn.upload_report return dictionary
385
394
  """
@@ -398,6 +407,10 @@ def ipr_report(
398
407
  else:
399
408
  logger.warning('No ipr_url given')
400
409
 
410
+ if state:
411
+ # copy so the caller's content is not mutated
412
+ content = {**content, 'state': state}
413
+
401
414
  # Verify upload permission before doing any expensive processing
402
415
  if ipr_upload and ipr_conn:
403
416
  ipr_conn.check_upload_permission(content['project'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pori_python
3
- Version: 1.6.0
3
+ Version: 1.7.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
@@ -46,7 +46,7 @@ Dynamic: license-file
46
46
 
47
47
  # PORI Python Adaptor
48
48
 
49
- ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/master/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
49
+ ![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/main/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python)
50
50
 
51
51
  This repository is part of the [Platform for Oncogenomic Reporting and Interpretation (PORI)](https://bcgsc.github.io/pori/).
52
52
 
@@ -17,7 +17,7 @@ known_standard_library = requests
17
17
 
18
18
  [metadata]
19
19
  name = pori_python
20
- version = 1.6.0
20
+ version = 1.7.0
21
21
  url = https://github.com/bcgsc/pori_python
22
22
  author_email = dat@bcgsc.ca
23
23
  maintainer_email = dat@bcgsc.ca
@@ -1,13 +1,18 @@
1
1
  import json
2
2
  import os
3
- import pandas as pd
4
- import pytest
5
3
  import sys
6
- from typing import Dict
7
4
  from unittest.mock import MagicMock, patch
8
5
 
6
+ import pandas as pd
7
+ import pytest
8
+
9
9
  from pori_python.ipr.connection import IprConnection
10
- from pori_python.ipr.main import command_interface, load_transcript_flags
10
+ from pori_python.ipr.main import (
11
+ command_interface,
12
+ create_report,
13
+ ipr_report,
14
+ load_transcript_flags,
15
+ )
11
16
  from pori_python.types import IprGene
12
17
 
13
18
  from .constants import EXCLUDE_INTEGRATION_TESTS
@@ -52,8 +57,99 @@ class TestLoadTranscriptFlags:
52
57
  ]
53
58
 
54
59
 
60
+ class TestStateArgument:
61
+ """Unit tests (no network) for the report state option"""
62
+
63
+ @staticmethod
64
+ def run_cli(tmp_path, extra_args: list[str]) -> MagicMock:
65
+ json_file = tmp_path / 'content.json'
66
+ json_file.write_text(json.dumps({'project': 'TEST'}))
67
+ argv = ['ipr', '--username', 'user', '--password', 'pass', '--content', str(json_file)]
68
+ with (
69
+ patch.object(sys, 'argv', [*argv, *extra_args]),
70
+ patch('pori_python.ipr.main.ipr_report') as mock_ipr_report,
71
+ ):
72
+ command_interface()
73
+ return mock_ipr_report
74
+
75
+ @staticmethod
76
+ def upload_content_for(report_function, input_content=None, **kwargs) -> dict:
77
+ """Run report_function up to the json upload step and return the uploaded content"""
78
+ with patch('pori_python.ipr.main.IprConnection') as mock_conn_class:
79
+ report_function(
80
+ username='user',
81
+ password='pass',
82
+ content=input_content if input_content is not None else {'project': 'TEST'},
83
+ ipr_url='http://fake.url.ca',
84
+ upload_json=True,
85
+ **kwargs,
86
+ )
87
+ mock_conn = mock_conn_class.return_value
88
+ assert mock_conn.upload_report.called
89
+ return mock_conn.upload_report.call_args[0][0]
90
+
91
+ def test_cli_passes_state_to_ipr_report(self, tmp_path) -> None:
92
+ mock_ipr_report = self.run_cli(tmp_path, ['--state', 'nonproduction'])
93
+
94
+ assert mock_ipr_report.call_args.kwargs['state'] == 'nonproduction'
95
+
96
+ def test_cli_state_not_set_by_default(self, tmp_path) -> None:
97
+ mock_ipr_report = self.run_cli(tmp_path, [])
98
+
99
+ assert mock_ipr_report.call_args.kwargs['state'] is None
100
+
101
+ def test_cli_rejects_invalid_state(self, tmp_path) -> None:
102
+ with pytest.raises(SystemExit):
103
+ self.run_cli(tmp_path, ['--state', 'bogus'])
104
+
105
+ @pytest.mark.parametrize('report_function', [ipr_report, create_report])
106
+ def test_state_arg_set_in_output_content(self, report_function) -> None:
107
+ content = self.upload_content_for(report_function, state='nonproduction')
108
+
109
+ assert content['state'] == 'nonproduction'
110
+
111
+ @pytest.mark.parametrize('report_function', [ipr_report, create_report])
112
+ def test_state_omitted_does_not_add_state(self, report_function) -> None:
113
+ content = self.upload_content_for(report_function)
114
+
115
+ assert 'state' not in content
116
+
117
+ @pytest.mark.parametrize('report_function', [ipr_report, create_report])
118
+ @pytest.mark.parametrize('input_state', ['ready', 'nonproduction'])
119
+ def test_state_omitted_preserves_input_state(self, report_function, input_state) -> None:
120
+ content = self.upload_content_for(
121
+ report_function, input_content={'project': 'TEST', 'state': input_state}
122
+ )
123
+
124
+ assert content['state'] == input_state
125
+
126
+ @pytest.mark.parametrize('report_function', [ipr_report, create_report])
127
+ def test_state_arg_overrides_input_state(self, report_function) -> None:
128
+ content = self.upload_content_for(
129
+ report_function,
130
+ input_content={'project': 'TEST', 'state': 'ready'},
131
+ state='nonproduction',
132
+ )
133
+
134
+ assert content['state'] == 'nonproduction'
135
+
136
+ def test_input_content_not_mutated(self) -> None:
137
+ original = {'project': 'TEST'}
138
+ with patch('pori_python.ipr.main.IprConnection'):
139
+ ipr_report(
140
+ username='user',
141
+ password='pass',
142
+ content=original,
143
+ ipr_url='http://fake.url.ca',
144
+ upload_json=True,
145
+ state='nonproduction',
146
+ )
147
+
148
+ assert 'state' not in original
149
+
150
+
55
151
  @pytest.fixture(scope='module')
56
- def report_upload_content(tmp_path_factory) -> Dict:
152
+ def report_upload_content(tmp_path_factory) -> dict:
57
153
  mock = MagicMock()
58
154
  json_file = tmp_path_factory.mktemp('inputs') / 'content.json'
59
155
  json_file.write_text(
@@ -118,32 +214,36 @@ def report_upload_content(tmp_path_factory) -> Dict:
118
214
  else:
119
215
  return []
120
216
 
121
- with patch.object(
122
- sys,
123
- 'argv',
124
- [
125
- 'ipr',
126
- '--username',
127
- os.environ.get('IPR_USER', os.environ['USER']),
128
- '--password',
129
- os.environ['IPR_PASS'],
130
- '--ipr_url',
131
- 'http://fake.url.ca',
132
- '--graphkb_username',
133
- os.environ.get('GRAPHKB_USER', os.environ['USER']),
134
- '--graphkb_password',
135
- os.environ.get('GRAPHKB_PASS', os.environ['IPR_PASS']),
136
- '--graphkb_url',
137
- os.environ.get('GRAPHKB_URL', False),
138
- '--content',
139
- str(json_file),
140
- '--therapeutics',
141
- ],
217
+ with (
218
+ patch.object(
219
+ sys,
220
+ 'argv',
221
+ [
222
+ 'ipr',
223
+ '--username',
224
+ os.environ.get('IPR_USER', os.environ['USER']),
225
+ '--password',
226
+ os.environ['IPR_PASS'],
227
+ '--ipr_url',
228
+ 'http://fake.url.ca',
229
+ '--graphkb_username',
230
+ os.environ.get('GRAPHKB_USER', os.environ['USER']),
231
+ '--graphkb_password',
232
+ os.environ.get('GRAPHKB_PASS', os.environ['IPR_PASS']),
233
+ '--graphkb_url',
234
+ os.environ.get('GRAPHKB_URL', False),
235
+ '--content',
236
+ str(json_file),
237
+ '--therapeutics',
238
+ '--state',
239
+ 'nonproduction',
240
+ ],
241
+ ),
242
+ patch.object(IprConnection, 'upload_report', new=mock),
142
243
  ):
143
- with patch.object(IprConnection, 'upload_report', new=mock):
144
- with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()):
145
- with patch.object(IprConnection, 'get', side_effect=side_effect_function):
146
- command_interface()
244
+ with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()):
245
+ with patch.object(IprConnection, 'get', side_effect=side_effect_function):
246
+ command_interface()
147
247
 
148
248
  assert mock.called
149
249
 
@@ -153,7 +253,7 @@ def report_upload_content(tmp_path_factory) -> Dict:
153
253
 
154
254
  @pytest.mark.skipif(EXCLUDE_INTEGRATION_TESTS, reason='excluding long running integration tests')
155
255
  class TestCreateReport:
156
- def test_main_sections_present(self, report_upload_content: Dict) -> None:
256
+ def test_main_sections_present(self, report_upload_content: dict) -> None:
157
257
  sections = set(report_upload_content.keys())
158
258
 
159
259
  for section in [
@@ -166,7 +266,11 @@ class TestCreateReport:
166
266
  ]:
167
267
  assert section in sections
168
268
 
169
- def test_kept_low_quality_fusion(self, report_upload_content: Dict) -> None:
269
+ def test_state_set(self, report_upload_content: dict) -> None:
270
+ # the fixture passes --state nonproduction on the command line
271
+ assert report_upload_content['state'] == 'nonproduction'
272
+
273
+ def test_kept_low_quality_fusion(self, report_upload_content: dict) -> None:
170
274
  fusions = [(sv['gene1'], sv['gene2']) for sv in report_upload_content['structuralVariants']]
171
275
  if (
172
276
  EXCLUDE_BCGSC_TESTS
@@ -175,32 +279,32 @@ class TestCreateReport:
175
279
  else:
176
280
  assert ('SARM1', 'SUZ12') in fusions
177
281
 
178
- def test_pass_through_content_added(self, report_upload_content: Dict) -> None:
282
+ def test_pass_through_content_added(self, report_upload_content: dict) -> None:
179
283
  # check the passthorough content was added
180
284
  assert 'blargh' in report_upload_content
181
285
 
182
- def test_found_fusion_partner_gene(self, report_upload_content: Dict) -> None:
286
+ def test_found_fusion_partner_gene(self, report_upload_content: dict) -> None:
183
287
  genes = report_upload_content['genes']
184
288
  # eg, A1BG
185
289
  assert any([g.get('knownFusionPartner', False) for g in genes])
186
290
 
187
291
  @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data')
188
- def test_found_oncogene(self, report_upload_content: Dict) -> None:
292
+ def test_found_oncogene(self, report_upload_content: dict) -> None:
189
293
  genes = report_upload_content['genes']
190
294
  # eg, ZBTB20
191
295
  assert any([g.get('oncogene', False) for g in genes])
192
296
 
193
297
  @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data)')
194
- def test_found_tumour_supressor(self, report_upload_content: Dict) -> None:
298
+ def test_found_tumour_supressor(self, report_upload_content: dict) -> None:
195
299
  genes = report_upload_content['genes']
196
300
  # eg, ZNRF3
197
301
  assert any([g.get('tumourSuppressor', False) for g in genes])
198
302
 
199
- def test_found_kb_statement_related_gene(self, report_upload_content: Dict) -> None:
303
+ def test_found_kb_statement_related_gene(self, report_upload_content: dict) -> None:
200
304
  genes = report_upload_content['genes']
201
305
  assert any([g.get('kbStatementRelated', False) for g in genes])
202
306
 
203
307
  @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data')
204
- def test_found_cancer_gene_list_match_gene(self, report_upload_content: Dict) -> None:
308
+ def test_found_cancer_gene_list_match_gene(self, report_upload_content: dict) -> None:
205
309
  genes = report_upload_content['genes']
206
310
  assert any([g.get('cancerGeneListMatch', False) for g in genes])
@@ -1,12 +1,13 @@
1
1
  import json
2
2
  import os
3
- import pandas as pd
4
- import pytest
5
3
  import sys
6
4
  import uuid
7
- from typing import Generator
5
+ from collections.abc import Generator
8
6
  from unittest.mock import patch
9
7
 
8
+ import pandas as pd
9
+ import pytest
10
+
10
11
  from pori_python.ipr.connection import IprConnection
11
12
  from pori_python.ipr.main import command_interface
12
13
  from pori_python.types import IprGene
@@ -57,8 +58,8 @@ def loaded_reports(tmp_path_factory) -> Generator:
57
58
  json_file = tmp_path_factory.mktemp('inputs') / 'content.json'
58
59
  async_json_file = tmp_path_factory.mktemp('inputs') / 'async_content.json'
59
60
  transcript_flags_file = tmp_path_factory.mktemp('inputs') / 'transcript_flags.tsv'
60
- patient_id = f'TEST_{str(uuid.uuid4())}'
61
- async_patient_id = f'TEST_ASYNC_{str(uuid.uuid4())}'
61
+ patient_id = f'TEST_{uuid.uuid4()!s}'
62
+ async_patient_id = f'TEST_ASYNC_{uuid.uuid4()!s}'
62
63
 
63
64
  json_contents = {
64
65
  'comparators': [
@@ -200,6 +201,7 @@ def loaded_reports(tmp_path_factory) -> Generator:
200
201
 
201
202
  sync_argslist = argslist.copy()
202
203
  sync_argslist.extend(['--content', str(json_file)])
204
+ sync_argslist.extend(['--state', 'nonproduction'])
203
205
  with patch.object(sys, 'argv', sync_argslist):
204
206
  with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()):
205
207
  command_interface()
@@ -252,9 +254,7 @@ def stringify_sorted(obj):
252
254
  obj.pop(key, None)
253
255
  keys = obj.keys()
254
256
  for key in keys:
255
- if isinstance(obj[key], list):
256
- obj[key] = stringify_sorted(obj[key])
257
- elif isinstance(obj[key], dict):
257
+ if isinstance(obj[key], list) or isinstance(obj[key], dict):
258
258
  obj[key] = stringify_sorted(obj[key])
259
259
  return str(obj)
260
260
  elif isinstance(obj, str):
@@ -365,12 +365,13 @@ class TestCreateReport:
365
365
  def test_genomic_alterations_identified_loaded(self, loaded_reports) -> None:
366
366
  section = get_section(loaded_reports['sync'], 'summary/genomic-alterations-identified')
367
367
  variants = set([item['geneVariant'] for item in section])
368
+ # we expect to see the observed variant name, as it appears in the test data input
368
369
  for variant in [
369
- 'FGFR2:p.R421C',
370
+ 'FGFR2:p.Arg421Cys',
370
371
  'PTP4A3 (high_percentile)',
371
372
  'ERBB2 (Amplification)',
372
373
  '(EWSR1,FLI1):fusion(e.7,e.4)',
373
- 'CDKN2A:p.T18M',
374
+ 'CDKN2A:p.Thr18Met',
374
375
  ]:
375
376
  assert variant in variants
376
377
  async_section = get_section(
@@ -388,15 +389,20 @@ class TestCreateReport:
388
389
 
389
390
  def test_seqqc_loaded(self, loaded_reports) -> None:
390
391
  """Test that seqQC data is present in the loaded report."""
391
- sync_report = loaded_reports['sync'][1]['reports'][0]
392
- assert 'seqQC' in sync_report
393
- assert len(sync_report['seqQC']) == 2
394
- samples = [item['sample'] for item in sync_report['seqQC']]
392
+ sync_section = get_section(loaded_reports['sync'], 'appendices')
393
+ async_section = get_section(loaded_reports['async'], 'appendices')
394
+
395
+ assert 'seqQC' in sync_section
396
+ assert len(sync_section['seqQC']) == 2
397
+ samples = [item['sample'] for item in sync_section['seqQC']]
395
398
  assert 'Tumour DNA' in samples
396
399
  assert 'Constitutional DNA' in samples
397
- async_report = loaded_reports['async'][1]['reports'][0]
398
- assert 'seqQC' in async_report
399
- assert len(async_report['seqQC']) == 2
400
+ assert 'seqQC' in async_section
401
+ assert len(async_section['seqQC']) == 2
402
+
403
+ def test_state_loaded(self, loaded_reports) -> None:
404
+ assert loaded_reports['sync'][1]['reports'][0]['state'] == 'nonproduction'
405
+ assert loaded_reports['async'][1]['reports'][0]['state'] == 'ready'
400
406
 
401
407
  def test_sample_info_loaded(self, loaded_reports) -> None:
402
408
  sync_section = get_section(loaded_reports['sync'], 'sample-info')
@@ -448,4 +454,4 @@ class TestCreateReport:
448
454
  # we expect the two observed variant sets to have one element in common
449
455
  # (the kras mutation)
450
456
  assert len(observedVariants1) == len(observedVariants2) == 2
451
- assert len((set(observedVariants1 + observedVariants2))) == 3
457
+ assert len(set(observedVariants1 + observedVariants2)) == 3
File without changes
File without changes
File without changes
File without changes