diff --git a/docs/conf.py b/docs/conf.py index 9e9569ed..063c35ad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,13 +16,17 @@ import sphinx_rtd_theme # this import must be kept to make sphinx_rtd_theme function import sphinx_autopackagesummary # this import must be kept to make autopackagesummary function +print("sphinx-rtd-theme:", sphinx_rtd_theme.__version__) +print("sphinx-autopackagesummary", sphinx_autopackagesummary.__version__) + os.environ['SIIBRA_LOG_LEVEL'] = "ERROR" sys.path.insert(0, os.path.abspath("..")) print("Path:", sys.path) + def is_allen_api_microarray_service_available(): import requests - + # see https://community.brain-map.org/t/human-brain-atlas-api/2876 microarray_test_url = "http://api.brain-map.org/api/v2/data/query.json?criteria= service::human_microarray_expression[probes$eq1023146,1023147][donors$eq15496][structures$eq9148]" try: @@ -31,6 +35,7 @@ def is_allen_api_microarray_service_available(): return False return response["success"] + # -- Project information ----------------------------------------------------- project = "siibra-python" diff --git a/examples/03_data_features/000_matchings.py b/examples/03_data_features/000_matchings.py index 5fcf3aef..7447d6ab 100644 --- a/examples/03_data_features/000_matchings.py +++ b/examples/03_data_features/000_matchings.py @@ -138,5 +138,12 @@ # For example, the gene expressions retrieved from the Allen atlas are linked by the coordinate # For example, the gene expressions retrieved from the Allen atlas are linked by the coordinate # of their tissue probes in MNI space. If a coordinate is inside the selected brain regions, it is an exact match. +# +# .. warning:: +# The service "web API of the Allen Brain Atlas for the human microarray expression" +# is not available at the moment, therefore siibra is not able to fetch +# gene expression features. This is a known issue which we are investigating: +# https://github.com/FZJ-INM1-BDA/siibra-python/issues/636. +# features = siibra.features.get(v1, siibra.features.molecular.GeneExpressions, gene="TAC1") print(features[0].last_match_description) diff --git a/examples/03_data_features/004_gene_expressions.py b/examples/03_data_features/004_gene_expressions.py index 897ff618..256b0808 100644 --- a/examples/03_data_features/004_gene_expressions.py +++ b/examples/03_data_features/004_gene_expressions.py @@ -17,6 +17,12 @@ Gene expressions ~~~~~~~~~~~~~~~~ +.. warning:: + The service "web API of the Allen Brain Atlas for the human microarray expression" + is not available at the moment, therefore siibra is not able to fetch + gene expression features. This is a known issue which we are investigating: + https://github.com/FZJ-INM1-BDA/siibra-python/issues/636. + ``siibra`` can query gene expression data from the Allen brain atlas. The gene expressions are linked to atlas regions by coordinates of their probes in MNI space. When querying feature by a region, ``siibra`` automatically builds a diff --git a/siibra/livequeries/allen.py b/siibra/livequeries/allen.py index bd4c11a7..abbfbbe0 100644 --- a/siibra/livequeries/allen.py +++ b/siibra/livequeries/allen.py @@ -35,6 +35,18 @@ LOCATION_PRECISION_MM = 2. # the assumed spatial precision of the probe locations in MNI space +def is_allen_api_microarray_service_available(): + import requests + + # see https://community.brain-map.org/t/human-brain-atlas-api/2876 + microarray_test_url = "http://api.brain-map.org/api/v2/data/query.json?criteria= service::human_microarray_expression[probes$eq1023146,1023147][donors$eq15496][structures$eq9148]" + try: + response = requests.get(microarray_test_url).json() + except requests.RequestException: + return False + return response["success"] + + class InvalidAllenAPIResponseException(Exception): pass @@ -124,6 +136,13 @@ def parse_gene(spec): self.genes = parse_gene(gene) def query(self, concept: structure.BrainStructure) -> List[GeneExpressions]: + if not is_allen_api_microarray_service_available(): + raise InvalidAllenAPIResponseException( + 'The service "web API of the Allen Brain Atlas for the human microarray expression" ' + 'is not available at the moment, therefore siibra is not able to fetch ' + 'gene expression features. This is a known issue which we are investigating: ' + 'https://github.com/FZJ-INM1-BDA/siibra-python/issues/636.' + ) mnispace = _space.Space.registry().get('mni152')