From 9b6a6b1a5af91e1dc503bce9d708370f345aee93 Mon Sep 17 00:00:00 2001 From: Daniel Danis Date: Wed, 13 Nov 2024 15:58:50 +0100 Subject: [PATCH] Raise an exception if unable to parse `ProteinMetadata` from Uniprot JSON. --- src/gpsea/model/_protein.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gpsea/model/_protein.py b/src/gpsea/model/_protein.py index 178c86e1b..6db36e09a 100644 --- a/src/gpsea/model/_protein.py +++ b/src/gpsea/model/_protein.py @@ -368,19 +368,16 @@ def from_uniprot_json( regions = list() for feature in data["features"]: - try: - region_name = feature["description"] - locus = feature["location"] - region_start = int(locus["start"]["value"]) - 1 # convert to 0-based coordinates - region_end = int(locus["end"]["value"]) - feature_type = FeatureType.from_string(feature["type"]) - finfo = FeatureInfo( - name=region_name, region=Region(start=region_start, end=region_end) - ) - pfeature = ProteinFeature.create(info=finfo, feature_type=feature_type) - regions.append(pfeature) - except Exception as feature_exception: - print(f"Could not parse feature: {str(feature_exception)} (skipping)") + region_name = feature["description"] + locus = feature["location"] + region_start = int(locus["start"]["value"]) - 1 # convert to 0-based coordinates + region_end = int(locus["end"]["value"]) + feature_type = FeatureType.from_string(feature["type"]) + finfo = FeatureInfo( + name=region_name, region=Region(start=region_start, end=region_end) + ) + pfeature = ProteinFeature.create(info=finfo, feature_type=feature_type) + regions.append(pfeature) return ProteinMetadata( protein_id=protein_id,