|
1 | 1 | from collections import OrderedDict |
| 2 | + |
2 | 3 | from flask import abort, jsonify |
3 | | -from app import common |
4 | | -from app import utilities_endpoints |
| 4 | + |
| 5 | +from app import common, utilities_endpoints |
5 | 6 |
|
6 | 7 |
|
7 | 8 | def find_subject_variants( |
@@ -180,11 +181,7 @@ def find_subject_specific_variants( |
180 | 181 | subject = subject.strip() |
181 | 182 | common.validate_subject(subject) |
182 | 183 |
|
183 | | - try: |
184 | | - variants = list(map(common.get_variant, variants)) |
185 | | - except Exception as err: |
186 | | - print(f"Unexpected {err=}, {type(err)=}") |
187 | | - abort(422, 'Failed LiftOver') |
| 184 | + variants = list(map(common.get_variant, variants)) |
188 | 185 |
|
189 | 186 | # Query |
190 | 187 | query = {} |
@@ -836,22 +833,13 @@ def find_subject_tx_implications( |
836 | 833 | ranges = list(map(common.get_range, ranges)) |
837 | 834 | common.get_lift_over_range(ranges) |
838 | 835 |
|
839 | | - try: |
840 | | - variants = common.get_variants(ranges, query) |
841 | | - except Exception as err: |
842 | | - print(f"Unexpected {err=}, {type(err)=}") |
843 | | - abort(422, 'Failed LiftOver') |
844 | | - |
| 836 | + variants = common.get_variants(ranges, query) |
845 | 837 | if not variants: |
846 | 838 | return jsonify({"resourceType": "Parameters"}) |
847 | 839 | normalized_variants = [{variant["BUILD"]: variant["SPDI"]} for variant in variants] |
848 | 840 |
|
849 | 841 | if variants and not ranges: |
850 | | - try: |
851 | | - normalized_variants = list(map(common.get_variant, variants)) |
852 | | - except Exception as err: |
853 | | - print(f"Unexpected {err=}, {type(err)=}") |
854 | | - abort(422, 'Failed LiftOver') |
| 842 | + normalized_variants = list(map(common.get_variant, variants)) |
855 | 843 |
|
856 | 844 | # Result Object |
857 | 845 | result = OrderedDict() |
@@ -1110,22 +1098,13 @@ def find_subject_dx_implications( |
1110 | 1098 | ranges = list(map(common.get_range, ranges)) |
1111 | 1099 | common.get_lift_over_range(ranges) |
1112 | 1100 |
|
1113 | | - try: |
1114 | | - variants = common.get_variants(ranges, query) |
1115 | | - except Exception as err: |
1116 | | - print(f"Unexpected {err=}, {type(err)=}") |
1117 | | - abort(422, 'Failed LiftOver') |
1118 | | - |
| 1101 | + variants = common.get_variants(ranges, query) |
1119 | 1102 | if not variants: |
1120 | 1103 | return jsonify({"resourceType": "Parameters"}) |
1121 | 1104 | normalized_variants = [{variant["BUILD"]: variant["SPDI"]} for variant in variants] |
1122 | 1105 |
|
1123 | 1106 | if variants and not ranges: |
1124 | | - try: |
1125 | | - normalized_variants = list(map(common.get_variant, variants)) |
1126 | | - except Exception as err: |
1127 | | - print(f"Unexpected {err=}, {type(err)=}") |
1128 | | - abort(422, 'Failed LiftOver') |
| 1107 | + normalized_variants = list(map(common.get_variant, variants)) |
1129 | 1108 |
|
1130 | 1109 | # Result Object |
1131 | 1110 | result = OrderedDict() |
@@ -1488,11 +1467,7 @@ def find_population_specific_variants( |
1488 | 1467 | # Parameters |
1489 | 1468 | variants = list(map(lambda x: x.strip().split(","), variants)) |
1490 | 1469 | for i in range(len(variants)): |
1491 | | - try: |
1492 | | - variants[i] = list(map(common.get_variant, variants[i])) |
1493 | | - except Exception as err: |
1494 | | - print(f"Unexpected {err=}, {type(err)=}") |
1495 | | - abort(422, 'Failed LiftOver') |
| 1470 | + variants[i] = list(map(common.get_variant, variants[i])) |
1496 | 1471 |
|
1497 | 1472 | # Query |
1498 | 1473 | query = {} |
@@ -2001,11 +1976,7 @@ def find_population_tx_implications( |
2001 | 1976 | return jsonify({"resourceType": "Parameters"}) |
2002 | 1977 |
|
2003 | 1978 | if variants: |
2004 | | - try: |
2005 | | - variants = list(map(common.get_variant, variants)) |
2006 | | - except Exception as err: |
2007 | | - print(f"Unexpected {err=}, {type(err)=}") |
2008 | | - abort(422, 'Failed LiftOver') |
| 1979 | + variants = list(map(common.get_variant, variants)) |
2009 | 1980 |
|
2010 | 1981 | condition_code_list = [] |
2011 | 1982 | if conditions: |
@@ -2217,11 +2188,7 @@ def find_population_dx_implications( |
2217 | 2188 | return jsonify({"resourceType": "Parameters"}) |
2218 | 2189 |
|
2219 | 2190 | if variants: |
2220 | | - try: |
2221 | | - variants = list(map(common.get_variant, variants)) |
2222 | | - except Exception as err: |
2223 | | - print(f"Unexpected {err=}, {type(err)=}") |
2224 | | - abort(422, 'Failed LiftOver') |
| 2191 | + variants = list(map(common.get_variant, variants)) |
2225 | 2192 |
|
2226 | 2193 | condition_code_list = [] |
2227 | 2194 | if conditions: |
|
0 commit comments