Skip to content

Commit e233a8a

Browse files
committed
Raise if allen api human microarray services down
1 parent 645cbfe commit e233a8a

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

docs/conf.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
import sphinx_rtd_theme # this import must be kept to make sphinx_rtd_theme function
1717
import sphinx_autopackagesummary # this import must be kept to make autopackagesummary function
1818

19+
print("sphinx-rtd-theme:", sphinx_rtd_theme.__version__)
20+
print("sphinx-autopackagesummary", sphinx_autopackagesummary.__version__)
21+
1922
os.environ['SIIBRA_LOG_LEVEL'] = "ERROR"
2023
sys.path.insert(0, os.path.abspath(".."))
2124
print("Path:", sys.path)
2225

26+
2327
def is_allen_api_microarray_service_available():
2428
import requests
25-
29+
2630
# see https://community.brain-map.org/t/human-brain-atlas-api/2876
2731
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]"
2832
try:
@@ -31,6 +35,7 @@ def is_allen_api_microarray_service_available():
3135
return False
3236
return response["success"]
3337

38+
3439
# -- Project information -----------------------------------------------------
3540

3641
project = "siibra-python"

examples/03_data_features/000_matchings.py

+7
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,12 @@
138138
# For example, the gene expressions retrieved from the Allen atlas are linked by the coordinate
139139
# For example, the gene expressions retrieved from the Allen atlas are linked by the coordinate
140140
# of their tissue probes in MNI space. If a coordinate is inside the selected brain regions, it is an exact match.
141+
#
142+
# .. warning::
143+
# The service "web API of the Allen Brain Atlas for the human microarray expression"
144+
# is not available at the moment, therefore siibra is not able to fetch
145+
# gene expression features. This is a known issue which we are investigating:
146+
# https://github.com/FZJ-INM1-BDA/siibra-python/issues/636.
147+
#
141148
features = siibra.features.get(v1, siibra.features.molecular.GeneExpressions, gene="TAC1")
142149
print(features[0].last_match_description)

examples/03_data_features/004_gene_expressions.py

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
Gene expressions
1818
~~~~~~~~~~~~~~~~
1919
20+
.. warning::
21+
The service "web API of the Allen Brain Atlas for the human microarray expression"
22+
is not available at the moment, therefore siibra is not able to fetch
23+
gene expression features. This is a known issue which we are investigating:
24+
https://github.com/FZJ-INM1-BDA/siibra-python/issues/636.
25+
2026
``siibra`` can query gene expression data from the Allen brain atlas. The gene
2127
expressions are linked to atlas regions by coordinates of their probes in MNI
2228
space. When querying feature by a region, ``siibra`` automatically builds a

siibra/livequeries/allen.py

+19
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
LOCATION_PRECISION_MM = 2. # the assumed spatial precision of the probe locations in MNI space
3636

3737

38+
def is_allen_api_microarray_service_available():
39+
import requests
40+
41+
# see https://community.brain-map.org/t/human-brain-atlas-api/2876
42+
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]"
43+
try:
44+
response = requests.get(microarray_test_url).json()
45+
except requests.RequestException:
46+
return False
47+
return response["success"]
48+
49+
3850
class InvalidAllenAPIResponseException(Exception):
3951
pass
4052

@@ -124,6 +136,13 @@ def parse_gene(spec):
124136
self.genes = parse_gene(gene)
125137

126138
def query(self, concept: structure.BrainStructure) -> List[GeneExpressions]:
139+
if not is_allen_api_microarray_service_available():
140+
raise InvalidAllenAPIResponseException(
141+
'The service "web API of the Allen Brain Atlas for the human microarray expression" '
142+
'is not available at the moment, therefore siibra is not able to fetch '
143+
'gene expression features. This is a known issue which we are investigating: '
144+
'https://github.com/FZJ-INM1-BDA/siibra-python/issues/636.'
145+
)
127146

128147
mnispace = _space.Space.registry().get('mni152')
129148

0 commit comments

Comments
 (0)