diff --git a/src/dcd_mapping/annotate.py b/src/dcd_mapping/annotate.py index 47cf38c..b8f7342 100644 --- a/src/dcd_mapping/annotate.py +++ b/src/dcd_mapping/annotate.py @@ -306,22 +306,20 @@ def _annotate_haplotype_mapping( for allele in pre_mapped.members: allele.extensions = [_get_vrs_ref_allele_seq(allele, metadata, tx_results)] - # Determine reference sequence - if mapped_score.annotation_layer == AnnotationLayer.GENOMIC: - sequence_id = ( - f"ga4gh:{post_mapped.members[0].location.sequenceReference.refgetAccession}" - ) - accession = get_chromosome_identifier_from_vrs_id(sequence_id) - if accession is None: - raise ValueError - if accession.startswith("refseq:"): - accession = accession[7:] - else: - if tx_results is None: - raise ValueError # impossible by definition - accession = tx_results.np - if post_mapped: + # Determine reference sequence + if mapped_score.annotation_layer == AnnotationLayer.GENOMIC: + sequence_id = f"ga4gh:{post_mapped.members[0].location.sequenceReference.refgetAccession}" + accession = get_chromosome_identifier_from_vrs_id(sequence_id) + if accession is None: + raise ValueError + if accession.startswith("refseq:"): + accession = accession[7:] + else: + if tx_results is None: + raise ValueError # impossible by definition + accession = tx_results.np + sr = get_seqrepo() for allele in post_mapped.members: loc = allele.location diff --git a/src/dcd_mapping/mavedb_data.py b/src/dcd_mapping/mavedb_data.py index 831804b..3654eb6 100644 --- a/src/dcd_mapping/mavedb_data.py +++ b/src/dcd_mapping/mavedb_data.py @@ -14,6 +14,7 @@ from typing import Any import requests +from fastapi import HTTPException from pydantic import ValidationError from dcd_mapping.resource_utils import ( @@ -283,8 +284,17 @@ async def wrapper(*args, **kwargs) -> ScoresetMapping: # noqa: ANN002 # Set up metadata and scores for the current run. Now they will be accessible by these functions # without the need to download the data again. temp_dir_as_path = Path(temp_dir) - get_scoreset_metadata(urn, temp_dir_as_path) - get_scoreset_records(urn, silent, temp_dir_as_path) + try: + get_scoreset_metadata(urn, temp_dir_as_path) + get_scoreset_records(urn, silent, temp_dir_as_path) + except ScoresetNotSupportedError as e: + return ScoresetMapping( + metadata=None, + error_message=str(e).strip("'"), + ) + except ResourceAcquisitionError as e: + msg = f"Unable to acquire resource from MaveDB: {e}" + raise HTTPException(status_code=500, detail=msg) from e # Pass the storage path of the temp directory to the wrapped function as a kwarg. kwargs["store_path"] = temp_dir_as_path diff --git a/src/dcd_mapping/version.py b/src/dcd_mapping/version.py index 8e200fa..e095212 100644 --- a/src/dcd_mapping/version.py +++ b/src/dcd_mapping/version.py @@ -1,3 +1,3 @@ """Provide dcd mapping version""" -dcd_mapping_version = "2024.1.2" +dcd_mapping_version = "2024.1.3"