|
1 | | -from abc import abstractmethod |
2 | 1 | from typing import Any, Dict, Mapping, Optional, Tuple, Sequence |
3 | 2 |
|
4 | 3 | import allel # type: ignore |
@@ -180,15 +179,29 @@ def __init__( |
180 | 179 | surveillance_use_only=surveillance_use_only, |
181 | 180 | ) |
182 | 181 |
|
183 | | - @property |
184 | | - @abstractmethod |
185 | | - def _xpehh_gwss_cache_name(self): |
186 | | - raise NotImplementedError("Must override _xpehh_gwss_cache_name") |
187 | | - |
188 | | - @property |
189 | | - @abstractmethod |
190 | | - def _ihs_gwss_cache_name(self): |
191 | | - raise NotImplementedError("Must override _ihs_gwss_cache_name") |
| 182 | + def _get_xpehh_gwss_cache_name(self): |
| 183 | + """Safe resolver for xpehh gwss cache name. |
| 184 | +
|
| 185 | + Subclasses should define _xpehh_gwss_cache_name as a class attribute. |
| 186 | + This method safely retrieves it or returns a default if unavailable. |
| 187 | + """ |
| 188 | + cache_name = getattr(self.__class__, "_xpehh_gwss_cache_name", None) |
| 189 | + if cache_name is None: |
| 190 | + # Fallback to a generic cache name if subclass hasn't defined one |
| 191 | + cache_name = "xpehh_gwss_v1" |
| 192 | + return cache_name |
| 193 | + |
| 194 | + def _get_ihs_gwss_cache_name(self): |
| 195 | + """Safe resolver for ihs gwss cache name. |
| 196 | +
|
| 197 | + Subclasses should define _ihs_gwss_cache_name as a class attribute. |
| 198 | + This method safely retrieves it or returns a default if unavailable. |
| 199 | + """ |
| 200 | + cache_name = getattr(self.__class__, "_ihs_gwss_cache_name", None) |
| 201 | + if cache_name is None: |
| 202 | + # Fallback to a generic cache name if subclass hasn't defined one |
| 203 | + cache_name = "ihs_gwss_v1" |
| 204 | + return cache_name |
192 | 205 |
|
193 | 206 | @staticmethod |
194 | 207 | def _make_gene_cnv_label(gene_id, gene_name, cnv_type): |
@@ -725,7 +738,7 @@ def ihs_gwss( |
725 | 738 | ) -> Tuple[np.ndarray, np.ndarray]: |
726 | 739 | # change this name if you ever change the behaviour of this function, to |
727 | 740 | # invalidate any previously cached data |
728 | | - name = self._ihs_gwss_cache_name |
| 741 | + name = self._get_ihs_gwss_cache_name() |
729 | 742 |
|
730 | 743 | params = dict( |
731 | 744 | contig=contig, |
@@ -1249,7 +1262,7 @@ def xpehh_gwss( |
1249 | 1262 | ) -> Tuple[np.ndarray, np.ndarray]: |
1250 | 1263 | # change this name if you ever change the behaviour of this function, to |
1251 | 1264 | # invalidate any previously cached data |
1252 | | - name = self._xpehh_gwss_cache_name |
| 1265 | + name = self._get_xpehh_gwss_cache_name() |
1253 | 1266 |
|
1254 | 1267 | params = dict( |
1255 | 1268 | contig=contig, |
|
0 commit comments