Skip to content

Commit

Permalink
When re-raising exception from sequencing fetching, including fetcher…
Browse files Browse the repository at this point in the history
… implementation and underlying exception message
  • Loading branch information
reece committed Feb 22, 2019
1 parent 2cb053d commit 42859e4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions hgvs/dataproviders/seqfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..exceptions import HGVSDataNotAvailableError

logger = logging.getLogger(__name__)
_logger = logging.getLogger(__name__)


class SeqFetcher(object):
Expand Down Expand Up @@ -41,18 +41,19 @@ def _fetch_seq_seqrepo(ac, start_i=None, end_i=None):
return sr.fetch(ac, start_i, end_i)

self.fetcher = _fetch_seq_seqrepo
self.source = "local (SeqRepo)"
logger.info("Using SeqRepo({}) sequence fetching".format(seqrepo_dir))
self.source = "SeqRepo ({})".format(seqrepo_dir)
else:
self.fetcher = bioutils.seqfetcher.fetch_seq
self.source = "remote (bioutils.seqfetcher)"
logger.info("Using remote sequence fetching")
self.source = "bioutils.seqfetcher"
_logger.info("Fetching sequences with " + self.source)

def fetch_seq(self, ac, start_i=None, end_i=None):
try:
return self.fetcher(ac, start_i, end_i)
except (RuntimeError, KeyError) as ex:
raise HGVSDataNotAvailableError("No sequence available for {ac} ({ex})".format(ac=ac, ex=ex))
except Exception as ex:
raise HGVSDataNotAvailableError("Failed to fetch {ac} from {self.source} ({ex})".format(
ac=ac, ex=ex, self=self))



# <LICENSE>
Expand Down

0 comments on commit 42859e4

Please sign in to comment.