|
31 | 31 | preprocess_cosmic, |
32 | 32 | preprocess_expression_variants, |
33 | 33 | preprocess_hla, |
34 | | - preprocess_msi, |
35 | 34 | preprocess_hrd, |
| 35 | + preprocess_msi, |
36 | 36 | preprocess_signature_variants, |
37 | 37 | preprocess_small_mutations, |
38 | 38 | preprocess_structural_variants, |
@@ -294,7 +294,7 @@ def ipr_report( |
294 | 294 | username: str, |
295 | 295 | password: str, |
296 | 296 | content: Dict, |
297 | | - ipr_url: str, |
| 297 | + ipr_url: str = "", |
298 | 298 | log_level: str = "info", |
299 | 299 | output_json_path: str = "", |
300 | 300 | always_write_output_json: bool = False, |
@@ -324,7 +324,7 @@ def ipr_report( |
324 | 324 | Args: |
325 | 325 | username: the username for connecting to GraphKB and IPR |
326 | 326 | password: the password for connecting to GraphKB and IPR |
327 | | - ipr_url: base URL to use in connecting to IPR |
| 327 | + ipr_url: base URL to use in connecting to IPR (eg. https://ipr-api.bcgsc.ca/api) |
328 | 328 | log_level: the logging level |
329 | 329 | content: report content |
330 | 330 | output_json_path: path to a JSON file to output the report upload body. |
@@ -358,17 +358,24 @@ def ipr_report( |
358 | 358 | ) |
359 | 359 |
|
360 | 360 | # IPR CONNECTION |
361 | | - ipr_conn = IprConnection(username, password, ipr_url) |
| 361 | + ipr_conn = None |
| 362 | + if ipr_url: |
| 363 | + ipr_conn = IprConnection(username, password, ipr_url) |
| 364 | + else: |
| 365 | + logger.warning("No ipr_url given") |
362 | 366 |
|
363 | 367 | if validate_json: |
| 368 | + if not ipr_conn: |
| 369 | + raise ValueError("ipr_url required to validate_json") |
364 | 370 | ipr_result = ipr_conn.validate_json(content) |
365 | 371 | return ipr_result |
366 | 372 |
|
367 | 373 | if upload_json: |
| 374 | + if not ipr_conn: |
| 375 | + raise ValueError("ipr_url required to validate_json") |
368 | 376 | ipr_result = ipr_conn.upload_report( |
369 | 377 | content, mins_to_wait, async_upload, ignore_extra_fields |
370 | 378 | ) |
371 | | - return ipr_result |
372 | 379 |
|
373 | 380 | # validate the JSON content follows the specification |
374 | 381 | try: |
@@ -495,6 +502,8 @@ def ipr_report( |
495 | 502 | comments_list.append(graphkb_comments) |
496 | 503 |
|
497 | 504 | if include_ipr_variant_text: |
| 505 | + if not ipr_conn: |
| 506 | + raise ValueError("ipr_url required to include_ipr_variant_text") |
498 | 507 | ipr_comments = get_ipr_analyst_comments( |
499 | 508 | ipr_conn, |
500 | 509 | gkb_matches, |
@@ -550,18 +559,18 @@ def ipr_report( |
550 | 559 |
|
551 | 560 | # if input includes hrdScore field, that is ok to pass to db |
552 | 561 | # but prefer the 'hrd' field if it exists |
553 | | - if output.get('hrd'): |
554 | | - if output.get('hrd').get('score'): |
555 | | - output['hrdScore'] = output['hrd']['score'] |
556 | | - output.pop('hrd') # kbmatches have already been made |
| 562 | + if output.get("hrd"): |
| 563 | + if output.get("hrd").get("score"): |
| 564 | + output["hrdScore"] = output["hrd"]["score"] |
| 565 | + output.pop("hrd") # kbmatches have already been made |
557 | 566 |
|
558 | | - ipr_spec = ipr_conn.get_spec() |
559 | | - output = clean_unsupported_content(output, ipr_spec) |
560 | 567 | ipr_result = {} |
561 | 568 | upload_error = None |
562 | 569 |
|
563 | 570 | # UPLOAD TO IPR |
564 | 571 | if ipr_upload: |
| 572 | + ipr_spec = ipr_conn.get_spec() |
| 573 | + output = clean_unsupported_content(output, ipr_spec) |
565 | 574 | try: |
566 | 575 | logger.info(f"Uploading to IPR {ipr_conn.url}") |
567 | 576 | ipr_result = ipr_conn.upload_report( |
|
0 commit comments