diff --git a/src/autobigs/engine/analysis/bigsdb.py b/src/autobigs/engine/analysis/bigsdb.py index 99776a2..9900bba 100644 --- a/src/autobigs/engine/analysis/bigsdb.py +++ b/src/autobigs/engine/analysis/bigsdb.py @@ -15,7 +15,7 @@ from autobigs.engine.reading import read_fasta from autobigs.engine.structures.alignment import PairwiseAlignment from autobigs.engine.structures.genomics import NamedString from autobigs.engine.structures.mlst import Allele, NamedMLSTProfile, AlignmentStats, MLSTProfile -from autobigs.engine.exceptions.database import NoBIGSdbExactMatchesException, NoBIGSdbMatchesException, NoSuchBIGSdbDatabaseException +from autobigs.engine.exceptions.database import BIGSdbResponseNotOkay, NoBIGSdbExactMatchesException, NoBIGSdbMatchesException, NoSuchBIGSdbDatabaseException from Bio.Align import PairwiseAligner @@ -99,7 +99,10 @@ class RemoteBIGSdbMLSTProfiler(BIGSdbMLSTProfiler): ) yield result_allele if isinstance(sequence_string, str) else (sequence_string.name, result_allele) else: - raise NoBIGSdbMatchesException(self._database_name, self._scheme_id, sequence_string.name if isinstance(sequence_string, NamedString) else None) + if response.status == 200: + raise NoBIGSdbMatchesException(self._database_name, self._scheme_id, sequence_string.name if isinstance(sequence_string, NamedString) else None) + else: + raise BIGSdbResponseNotOkay(sequence_response) except (ConnectionError, ServerDisconnectedError, ClientOSError) as e: # Errors we will retry last_error = e success = False diff --git a/src/autobigs/engine/exceptions/database.py b/src/autobigs/engine/exceptions/database.py index 15d61f0..7289b8c 100644 --- a/src/autobigs/engine/exceptions/database.py +++ b/src/autobigs/engine/exceptions/database.py @@ -3,6 +3,8 @@ from typing import Union class BIGSDbDatabaseAPIException(Exception): pass +class BIGSdbResponseNotOkay(BIGSDbDatabaseAPIException): + pass class NoBIGSdbMatchesException(BIGSDbDatabaseAPIException): def __init__(self, database_name: str, database_scheme_id: int, query_name: Union[None, str], *args):