diff --git a/CHANGELOG.md b/CHANGELOG.md index 285957a..2ab5482 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - LLM evaluation logic - Integrated Alembic for managing chat history migrations - Tool implementations without langchain or langgraph dependencies +- Unit tests for the migrated tools - CRUDs. - BlueNaas CRUD tools - Cell types, resolving and utils tests diff --git a/swarm_copy/tools/get_morpho_tool.py b/swarm_copy/tools/get_morpho_tool.py index 45c72bb..f7e2aa6 100644 --- a/swarm_copy/tools/get_morpho_tool.py +++ b/swarm_copy/tools/get_morpho_tool.py @@ -1,6 +1,7 @@ """Get Morpho tool.""" import logging +from pathlib import Path from typing import Any, ClassVar from pydantic import BaseModel, Field @@ -30,8 +31,8 @@ class GetMorphoMetadata(BaseMetadata): knowledge_graph_url: str token: str morpho_search_size: int - brainregion_path: str - celltypes_path: str + brainregion_path: str | Path + celltypes_path: str | Path class KnowledgeGraphOutput(BaseModel): diff --git a/swarm_copy/tools/kg_morpho_features_tool.py b/swarm_copy/tools/kg_morpho_features_tool.py index 7298636..31023b8 100644 --- a/swarm_copy/tools/kg_morpho_features_tool.py +++ b/swarm_copy/tools/kg_morpho_features_tool.py @@ -1,6 +1,7 @@ """KG Morpho Feature tool.""" import logging +from pathlib import Path from typing import Any, ClassVar, Literal from pydantic import BaseModel, Field, model_validator @@ -151,7 +152,7 @@ class KGMorphoFeatureMetadata(BaseMetadata): knowledge_graph_url: str token: str kg_morpho_feature_search_size: int - brainregion_path: str + brainregion_path: str | Path class KGMorphoFeatureOutput(BaseModel): diff --git a/swarm_copy_tests/data/99111002.nwb b/swarm_copy_tests/data/99111002.nwb new file mode 100644 index 0000000..ce6791d Binary files /dev/null and b/swarm_copy_tests/data/99111002.nwb differ diff --git a/swarm_copy_tests/data/get_traces.json b/swarm_copy_tests/data/get_traces.json new file mode 100644 index 0000000..1dc0011 --- /dev/null +++ b/swarm_copy_tests/data/get_traces.json @@ -0,0 +1,201 @@ +{ + "hits": { + "hits": [ + { + "_id": "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751", + "_index": "nexus_search_d067e019-1398-4eb8-9e28-3af8a717dcd7_41b1545a-cb2e-4848-8c74-195ec79f7bd3_18", + "_score": 6.0860696, + "_source": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751", + "@type": [ + "https://neuroshapes.org/Trace", + "https://bbp.epfl.ch/ontologies/core/bmo/ExperimentalTrace" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/382", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/382|Field CA1", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/382", + "label": "Field CA1" + }, + "contributors": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311", + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311|Zsolt Kohus", + "label": "Zsolt Kohus" + } + ], + "createdAt": "2024-04-09T21:47:08.569Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/budd", + "deprecated": false, + "derivation": [ + { + "@type": [ + "http://www.w3.org/ns/prov#Entity", + "https://neuroshapes.org/PatchedCell" + ], + "identifier": "https://bbp.epfl.ch/data/data/demo/morpho-demo/7173ea54-8e59-478d-85f3-ff86246ef22b", + "label": "s160106_0201" + } + ], + "distribution": [ + { + "contentSize": 4919928, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F01dffb7b-1122-4e1a-9acf-837e683da4ba", + "encodingFormat": "application/nwb", + "label": "s160106_02.nwb" + } + ], + "generation": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/d857ff82-b558-4117-b643-74d44dbda5e6", + "endedAt": "2016-01-06T23:59:00.000Z", + "startedAt": "2016-01-06T00:00:00.000Z" + }, + "image": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2Fc1ef69e4-0073-481d-9446-fcfd7b5b5f7a", + "about": "https://neuroshapes.org/StimulationTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2Fc1ef69e4-0073-481d-9446-fcfd7b5b5f7a", + "repetition": 0, + "stimulusType": "square" + }, + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F6fd03e92-b2ae-4ab8-8c9e-f0ff52d20a0d", + "about": "https://neuroshapes.org/ResponseTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F6fd03e92-b2ae-4ab8-8c9e-f0ff52d20a0d", + "repetition": 0, + "stimulusType": "square" + } + ], + "name": "s160106_02", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "label": "demo/morpho-demo" + }, + "subjectAge": { + "label": "59 days Post-natal", + "period": "Post-natal", + "unit": "days", + "value": 59 + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-10T08:40:23.039Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/cgonzale", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/demo/morpho-demo/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2F1761e604-03fc-452b-9bf2-2214782bb751" + } + }, + { + "_id": "https://bbp.epfl.ch/data/demo/morpho-demo/5f710291-9aac-45d0-94ff-d3d318c6ba2f", + "_index": "nexus_search_d067e019-1398-4eb8-9e28-3af8a717dcd7_41b1545a-cb2e-4848-8c74-195ec79f7bd3_18", + "_score": 6.0860696, + "_source": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/5f710291-9aac-45d0-94ff-d3d318c6ba2f", + "@type": [ + "https://neuroshapes.org/Trace", + "https://bbp.epfl.ch/ontologies/core/bmo/ExperimentalTrace" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/382", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/382|Field CA1", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/382", + "label": "Field CA1" + }, + "contributors": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311", + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311|Zsolt Kohus", + "label": "Zsolt Kohus" + } + ], + "createdAt": "2024-04-10T13:58:37.803Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/budd", + "deprecated": false, + "derivation": [ + { + "@type": [ + "https://neuroshapes.org/PatchedCell", + "http://www.w3.org/ns/prov#Entity" + ], + "identifier": "https://bbp.epfl.ch/data/demo/morpho-demo/c5c68107-39e5-4124-8681-8a644ab0f8ce", + "label": "s160106_0201" + } + ], + "distribution": [ + { + "contentSize": 4919928, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2Ff759098b-3db5-4236-a577-eac23191e063", + "encodingFormat": "application/nwb", + "label": "s160106_02.nwb" + } + ], + "generation": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/d47968ad-7644-4153-9bf5-a68277f9e17e", + "endedAt": "2016-01-06T23:59:00.000Z", + "startedAt": "2016-01-06T00:00:00.000Z" + }, + "image": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2F835b1f06-c688-4771-9e45-c9c091666a8d", + "about": "https://neuroshapes.org/ResponseTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2F835b1f06-c688-4771-9e45-c9c091666a8d", + "repetition": 0, + "stimulusType": "square" + }, + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2Fde25efaf-6f6a-4245-a5a5-eeed4eddc83e", + "about": "https://neuroshapes.org/StimulationTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2Fde25efaf-6f6a-4245-a5a5-eeed4eddc83e", + "repetition": 0, + "stimulusType": "square" + } + ], + "name": "s160106_02", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "label": "demo/morpho-demo" + }, + "subjectAge": { + "label": "59 days Post-natal", + "period": "Post-natal", + "unit": "days", + "value": 59 + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-10T13:58:37.803Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/budd", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/demo/morpho-demo/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2F5f710291-9aac-45d0-94ff-d3d318c6ba2f" + } + } + ], + "max_score": 6.0860696, + "total": { + "relation": "eq", + "value": 1905 + } + }, + "timed_out": false, + "took": 65, + "_shards": { + "failed": 0, + "skipped": 664, + "successful": 742, + "total": 742 + } +} diff --git a/swarm_copy_tests/data/kg_me_model_output.json b/swarm_copy_tests/data/kg_me_model_output.json new file mode 100644 index 0000000..6db0acd --- /dev/null +++ b/swarm_copy_tests/data/kg_me_model_output.json @@ -0,0 +1,152 @@ +{ + "hits": { + "hits": [ + { + "sort": [ + 1716989796908 + ], + "_id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/eeeeac3c-6bf1-47ed-ab97-460668eba2d2", + "_index": "nexus_search_711d6b8f-1285-42db-9259-b277dd687435_711d6b8f-1285-42db-9259-b277dd687435_21", + "_source": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/eeeeac3c-6bf1-47ed-ab97-460668eba2d2", + "@type": "https://neuroshapes.org/MEModel", + "analysisSuitable": false, + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/322", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/322|Primary somatosensory area", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/322", + "label": "Primary somatosensory area" + }, + "createdAt": "2024-05-29T13:36:36.908Z", + "createdBy": "https://openbluebrain.com/api/nexus/v1/realms/bbp/users/antonel", + "deprecated": false, + "description": "My me-model", + "eType": { + "@id": "_:b0", + "identifier": "_:b0", + "label": "cNAC" + }, + "generation": {}, + "image": [ + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/2869d500-3c6e-4d15-bcae-b4ece55c5586", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/2869d500-3c6e-4d15-bcae-b4ece55c5586" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/aea6c71b-41a9-4268-96e7-d0f9265693e1", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/parameters_distribution", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/aea6c71b-41a9-4268-96e7-d0f9265693e1" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ea0b79b5-66bb-48bf-8933-9b43b56959d5", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/traces", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ea0b79b5-66bb-48bf-8933-9b43b56959d5" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ba3c8d1a-2839-4fdd-b13f-73950c84954a", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ba3c8d1a-2839-4fdd-b13f-73950c84954a" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/af301c80-0c51-4726-95b7-dc65e5e180fd", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/scores", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/af301c80-0c51-4726-95b7-dc65e5e180fd" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/798bab6a-4caa-460b-bac7-a6f08672f11b", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/798bab6a-4caa-460b-bac7-a6f08672f11b" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/489673cc-27c1-46bf-ad6a-510ea124a4cc", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/489673cc-27c1-46bf-ad6a-510ea124a4cc" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/3cb119a2-6a3a-4e75-99c5-53f2405d3e91", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/3cb119a2-6a3a-4e75-99c5-53f2405d3e91" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/3819e25e-ace3-4809-9a96-964d5d9fb932", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/3819e25e-ace3-4809-9a96-964d5d9fb932" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/33bcf9d3-b6db-4d2c-b3c6-3ea8a5932202", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/33bcf9d3-b6db-4d2c-b3c6-3ea8a5932202" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/29dc72cb-bb9d-4966-bc3b-70e6ff65c6e3", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/currentscape", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/29dc72cb-bb9d-4966-bc3b-70e6ff65c6e3" + }, + { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/e5e20e7a-87b5-47a2-abda-2d7212ab00e1", + "about": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/thumbnail", + "identifier": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/e5e20e7a-87b5-47a2-abda-2d7212ab00e1" + } + ], + "layer": [ + { + "@id": "http://purl.obolibrary.org/obo/UBERON_0005394", + "idLabel": "http://purl.obolibrary.org/obo/UBERON_0005394|layer 5", + "identifier": "http://purl.obolibrary.org/obo/UBERON_0005394", + "label": "layer 5" + } + ], + "mType": { + "@id": "_:b2", + "identifier": "_:b2", + "label": "L5_TPC:B" + }, + "memodel": { + "emodelResource": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/67acf101-12f6-4b7b-8a89-5237aadf94db", + "name": "EM__hipp_rat__CA1_int_cNAC_010710HP2_20190328163258__2" + }, + "neuronMorphology": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/255e007e-a6d1-4fc9-b984-1e0221e39ea3", + "name": "ch150801A1" + }, + "validated": true + }, + "name": "My me-model", + "objectOfStudy": { + "@id": "http://bbp.epfl.ch/neurosciencegraph/taxonomies/objectsofstudy/singlecells", + "identifier": "http://bbp.epfl.ch/neurosciencegraph/taxonomies/objectsofstudy/singlecells", + "label": "Single Cell" + }, + "project": { + "@id": "https://openbluebrain.com/api/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "identifier": "https://openbluebrain.com/api/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "label": "bbp/mmb-point-neuron-framework-model" + }, + "seed": 2, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10116", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10116", + "label": "Rattus norvegicus" + }, + "updatedAt": "2024-07-09T10:53:01.208Z", + "updatedBy": "https://openbluebrain.com/api/nexus/v1/realms/bbp/users/ajaquier", + "_self": "https://openbluebrain.com/api/nexus/v1/resources/bbp/mmb-point-neuron-framework-model/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2Feeeeac3c-6bf1-47ed-ab97-460668eba2d2" + } + } + ], + "total": { + "relation": "eq", + "value": 1 + } + }, + "timed_out": false, + "took": 14, + "_shards": { + "failed": 0, + "skipped": 4, + "successful": 15, + "total": 15 + } +} \ No newline at end of file diff --git a/swarm_copy_tests/data/kg_morpho_features_response.json b/swarm_copy_tests/data/kg_morpho_features_response.json new file mode 100644 index 0000000..70fd8de --- /dev/null +++ b/swarm_copy_tests/data/kg_morpho_features_response.json @@ -0,0 +1,412 @@ +{ + "hits": { + "hits": [ + { + "_id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/9ca1c32b-e9fd-470b-a759-bdaf37d81ec9", + "_index": "nexus_search_711d6b8f-1285-42db-9259-b277dd687435_2a84a9ee-75b2-43c4-90a0-1eb5624e8ca0_15", + "_score": 17.77101, + "_source": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/9ca1c32b-e9fd-470b-a759-bdaf37d81ec9", + "@type": [ + "https://neuroshapes.org/Annotation", + "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/718", + "idLabel": [ + "http://api.brain-map.org/api/v2/data/Structure/718|Ventral posterolateral nucleus of the thalamus" + ], + "identifier": [ + "http://api.brain-map.org/api/v2/data/Structure/718" + ], + "label": "Ventral posterolateral nucleus of the thalamus" + }, + "compartment": "BasalDendrite", + "contributors": [ + { + "@id": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi|Niccolo Ricardi" + ], + "label": "Niccolo Ricardi" + } + ], + "createdAt": "2024-03-20T14:30:24.472Z", + "createdBy": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "deprecated": false, + "featureSeries": [ + { + "compartment": "BasalDendrite", + "label": "Section Strahler Orders", + "statistic": "mean", + "unit": "dimensionless", + "value": 1.7364864864864864 + }, + { + "compartment": "BasalDendrite", + "label": "Section Areas", + "statistic": "median", + "unit": "μm²", + "value": 272.5912248893231 + }, + { + "compartment": "BasalDendrite", + "label": "Section Strahler Orders", + "statistic": "minimum", + "unit": "dimensionless", + "value": 1.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Volumes", + "statistic": "mean", + "unit": "μm³", + "value": 180.5787321010427 + }, + { + "compartment": "BasalDendrite", + "label": "Local Bifurcation Angles", + "statistic": "maximum", + "unit": "radian", + "value": 2.6143908349883835 + }, + { + "compartment": "BasalDendrite", + "label": "Number Of Leaves", + "statistic": "raw", + "unit": "dimensionless", + "value": 76.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Radial Distances", + "statistic": "minimum", + "unit": "μm", + "value": 5.518080711364746 + }, + { + "compartment": "BasalDendrite", + "label": "Local Bifurcation Angles", + "statistic": "mean", + "unit": "radian", + "value": 0.9031414351696362 + }, + { + "compartment": "BasalDendrite", + "label": "Section Tortuosity", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.08268018811941147 + }, + { + "compartment": "BasalDendrite", + "label": "Diameter Power Relations", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Strahler Orders", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.9106092887975676 + }, + { + "compartment": "BasalDendrite", + "label": "Section Bif Branch Orders", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 1.7145325641644276 + }, + { + "compartment": "BasalDendrite", + "label": "Section Bif Radial Distances", + "statistic": "standard deviation", + "unit": "μm", + "value": 35.042884826660156 + }, + { + "compartment": "BasalDendrite", + "label": "Terminal Path Lengths", + "statistic": "minimum", + "unit": "μm", + "value": 92.61423313617706 + }, + { + "compartment": "BasalDendrite", + "label": "Section Term Lengths", + "statistic": "median", + "unit": "μm", + "value": 92.60545349121094 + }, + { + "compartment": "BasalDendrite", + "label": "Section Path Distances", + "statistic": "standard deviation", + "unit": "μm", + "value": 71.30703565937296 + }, + { + "compartment": "BasalDendrite", + "label": "Section Bif Branch Orders", + "statistic": "mean", + "unit": "dimensionless", + "value": 3.3194444444444446 + }, + { + "compartment": "BasalDendrite", + "label": "Partition Asymmetry Length", + "statistic": "maximum", + "unit": "μm", + "value": 0.5928827095301132 + }, + { + "compartment": "BasalDendrite", + "label": "Sibling Ratios", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Path Distances", + "statistic": "maximum", + "unit": "μm", + "value": 343.71869564056396 + }, + { + "compartment": "BasalDendrite", + "label": "Section Lengths", + "statistic": "standard deviation", + "unit": "μm", + "value": 49.600032806396484 + }, + { + "compartment": "BasalDendrite", + "label": "Remote Bifurcation Angles", + "statistic": "maximum", + "unit": "radian", + "value": 2.2732763128975844 + }, + { + "compartment": "BasalDendrite", + "label": "Diameter Power Relations", + "statistic": "median", + "unit": "dimensionless", + "value": 2.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Term Branch Orders", + "statistic": "minimum", + "unit": "dimensionless", + "value": 1.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Strahler Orders", + "statistic": "median", + "unit": "dimensionless", + "value": 1.0 + }, + { + "compartment": "BasalDendrite", + "label": "Section Term Branch Orders", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 1.5169289394042875 + }, + { + "compartment": "BasalDendrite", + "label": "Section Tortuosity", + "statistic": "mean", + "unit": "dimensionless", + "value": 0.9999998807907104 + } + ], + "generation": { + "endedAt": "2024-03-20T14:24:16.000Z", + "startedAt": "2024-03-20T14:24:16.000Z" + }, + "name": "Neuron Morphology Feature Annotation", + "neuronMorphology": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/75e5f49f-4edf-474a-a3fd-47073a38ea38", + "name": "AA0322" + }, + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "label": "bbp/mmb-point-neuron-framework-model" + }, + "updatedAt": "2024-03-20T17:47:15.490Z", + "updatedBy": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "_self": "https://bbp.epfl.ch/nexus/v1/resources/bbp/mmb-point-neuron-framework-model/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2F9ca1c32b-e9fd-470b-a759-bdaf37d81ec9" + } + }, + { + "_id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/09704e7e-e773-4f2f-a6ab-0c30a73216fc", + "_index": "nexus_search_711d6b8f-1285-42db-9259-b277dd687435_2a84a9ee-75b2-43c4-90a0-1eb5624e8ca0_15", + "_score": 17.77101, + "_source": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/09704e7e-e773-4f2f-a6ab-0c30a73216fc", + "@type": [ + "https://neuroshapes.org/Annotation", + "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/718", + "idLabel": [ + "http://api.brain-map.org/api/v2/data/Structure/718|Ventral posterolateral nucleus of the thalamus" + ], + "identifier": [ + "http://api.brain-map.org/api/v2/data/Structure/718" + ], + "label": "Ventral posterolateral nucleus of the thalamus" + }, + "compartment": "Axon", + "contributors": [ + { + "@id": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi|Niccolo Ricardi" + ], + "label": "Niccolo Ricardi" + } + ], + "createdAt": "2024-03-20T14:30:24.463Z", + "createdBy": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "deprecated": false, + "featureSeries": [ + { + "compartment": "Axon", + "label": "Section Tortuosity", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.1429130584001541 + }, + { + "compartment": "Axon", + "label": "Section Tortuosity", + "statistic": "mean", + "unit": "dimensionless", + "value": 1.1262837648391724 + }, + { + "compartment": "Axon", + "label": "Terminal Path Lengths", + "statistic": "minimum", + "unit": "μm", + "value": 5599.079376220703 + }, + { + "compartment": "Axon", + "label": "Section Path Distances", + "statistic": "maximum", + "unit": "μm", + "value": 7780.849250793457 + }, + { + "compartment": "Axon", + "label": "Section Volumes", + "statistic": "mean", + "unit": "μm³", + "value": 136.01814291776782 + }, + { + "compartment": "Axon", + "label": "Diameter Power Relations", + "statistic": "maximum", + "unit": "dimensionless", + "value": 2.0 + }, + { + "compartment": "Axon", + "label": "Section Path Distances", + "statistic": "standard deviation", + "unit": "μm", + "value": 486.26185300130675 + }, + { + "compartment": "Axon", + "label": "Section Radial Distances", + "statistic": "median", + "unit": "μm", + "value": 3837.996337890625 + }, + { + "compartment": "Axon", + "label": "Section Strahler Orders", + "statistic": "median", + "unit": "dimensionless", + "value": 1.0 + }, + { + "compartment": "Axon", + "label": "Diameter Power Relations", + "statistic": "standard deviation", + "unit": "dimensionless", + "value": 0.0 + }, + { + "compartment": "Axon", + "label": "Section Lengths", + "statistic": "mean", + "unit": "μm", + "value": 233.14886474609375 + }, + { + "compartment": "Axon", + "label": "Section Path Distances", + "statistic": "minimum", + "unit": "μm", + "value": 4048.837158203125 + } + ], + "generation": { + "endedAt": "2024-03-20T14:24:16.000Z", + "startedAt": "2024-03-20T14:24:16.000Z" + }, + "name": "Neuron Morphology Feature Annotation", + "neuronMorphology": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/75e5f49f-4edf-474a-a3fd-47073a38ea38", + "name": "AA0322" + }, + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "label": "bbp/mmb-point-neuron-framework-model" + }, + "updatedAt": "2024-03-20T17:47:15.513Z", + "updatedBy": [ + "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi" + ], + "_self": "https://bbp.epfl.ch/nexus/v1/resources/bbp/mmb-point-neuron-framework-model/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2F09704e7e-e773-4f2f-a6ab-0c30a73216fc" + } + } + ], + "max_score": 17.77101, + "total": {"relation": "eq", "value": 1230} + }, + "timed_out": false, + "took": 342, + "_shards": {"failed": 0, "skipped": 0, "successful": 13, "total": 13} +} diff --git a/swarm_copy_tests/data/knowledge_graph.json b/swarm_copy_tests/data/knowledge_graph.json new file mode 100644 index 0000000..11b0579 --- /dev/null +++ b/swarm_copy_tests/data/knowledge_graph.json @@ -0,0 +1,182 @@ +{ + "hits": { + "hits": [ + { + "_id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ca1f0e5f-ff08-4476-9b5f-95f3c9d004fd", + "_index": "nexus_search_711d6b8f-1285-42db-9259-b277dd687435_2a84a9ee-75b2-43c4-90a0-1eb5624e8ca0_15", + "_score": 10.407086, + "_source": { + "@id": "https://bbp.epfl.ch/data/bbp/mmb-point-neuron-framework-model/ca1f0e5f-ff08-4476-9b5f-95f3c9d004fd", + "@type": [ + "https://neuroshapes.org/ReconstructedNeuronMorphology", + "https://neuroshapes.org/NeuronMorphology" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/629", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/629|Ventral anterior-lateral complex of the thalamus", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/629", + "label": "Ventral anterior-lateral complex of the thalamus" + }, + "contributors": [ + { + "@id": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ajaquier", + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ajaquier|Aurélien Tristan Jaquier", + "label": "Aurélien Tristan Jaquier" + } + ], + "createdAt": "2023-10-30T10:27:09.334Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ajaquier", + "curated": true, + "deprecated": false, + "description": "This is a morphology reconstruction of a mouse thalamus cell that was obtained from the Janelia Mouselight project http://ml-neuronbrowser.janelia.org/ . This morphology is positioned in the Mouselight custom 'CCFv2.5' reference space, instead of the Allen Institute CCFv3 reference space.", + "distribution": [ + { + "contentSize": 105248, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mmb-point-neuron-framework-model/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2F6ca97d5c-c61b-43d0-8f89-6c041d3e5173", + "encodingFormat": "application/h5", + "label": "AA0519.h5" + }, + { + "contentSize": 480929, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mmb-point-neuron-framework-model/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2Fad8ed9fe-9aef-4716-9326-6b15c3219a1b", + "encodingFormat": "application/asc", + "label": "AA0519.asc" + }, + { + "contentSize": 405464, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mmb-point-neuron-framework-model/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2F358624e3-3449-4a10-8e31-aa19017d8583", + "encodingFormat": "application/swc", + "label": "AA0519.swc" + } + ], + "mType": { + "@id": "http://uri.interlex.org/base/ilx_0738236", + "idLabel": "http://uri.interlex.org/base/ilx_0738236|VPL_TC", + "identifier": "http://uri.interlex.org/base/ilx_0738236", + "label": "VPL_TC" + }, + "name": "AA0519", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mmb-point-neuron-framework-model", + "label": "bbp/mmb-point-neuron-framework-model" + }, + "subjectAge": { + "label": "60 days Post-natal", + "period": "Post-natal", + "unit": "days", + "value": 60 + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-30T07:59:30.098Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ajaquier", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/bbp/mmb-point-neuron-framework-model/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fbbp%2Fmmb-point-neuron-framework-model%2Fca1f0e5f-ff08-4476-9b5f-95f3c9d004fd" + } + }, + { + "_id": "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9", + "_index": "nexus_search_b5db4c20-8200-47f9-98d9-0ca8fa3be422_d2505573-bdde-4df9-92f9-0652523b3fb2_15", + "_score": 7.05979, + "_source": { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9", + "@type": [ + "https://neuroshapes.org/ReconstructedNeuronMorphology", + "https://neuroshapes.org/NeuronMorphology" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/262", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/262|Reticular nucleus of the thalamus", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/262", + "label": "Reticular nucleus of the thalamus" + }, + "contributors": [ + { + "@id": "https://www.grid.ac/institutes/grid.443970.d", + "@type": [ + "http://schema.org/Organization", + "http://www.w3.org/ns/prov#Agent" + ], + "idLabel": "https://www.grid.ac/institutes/grid.443970.d|Janelia Research Campus", + "label": "Janelia Research Campus" + } + ], + "coordinatesInBrainAtlas": { + "valueX": "6413.2944", + "valueY": "4899.1997", + "valueZ": "4254.461" + }, + "createdAt": "2022-06-16T12:47:56.777Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/akkaufma", + "curated": true, + "deprecated": false, + "description": "Annotation Space: CCFv3.0 Axes> X: Anterior-Posterior; Y: Inferior-Superior; Z:Left-Right. Despite Mouselight metadata for CCFv2.5 and CCFv3 versions of this morphology indicating that this cell belongs to either the 'Ventral anterior-lateral complex of the thalamus' ('VAL') or 'Ventral medial nucleus of the thalamus' ('VM') region, it is almost certainly a reticular cell belonging to the 'Reticular nucleus of the thalamus' or 'RT' region. Reticular cells only exist in the RT region, and while most of the axons of this morphology exist in non-RT thalamus, viewing the morphology alongside the area of RT in the Mouselight browser here http://ml-neuronbrowser.janelia.org/ clearly shows the soma and dendrites existing in or near the RT region. Based on the location of its soma and dendrites, their general structure, and the projection pattern of its axons, this is almost certainly a reticular inhibitory cell from the RT region. In https://doi.org/10.1016/j.celrep.2023.112200 , this morphology was used as reticular inhibitory morphology belonging to the 'Rt_RC' M-type.", + "distribution": [ + { + "contentSize": 137320, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F2ad0380d-c9b2-496e-9855-ab3d173930dd", + "encodingFormat": "application/h5", + "label": "AA0718.h5" + }, + { + "contentSize": 633407, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F5ef4f830-d6ac-4a26-8a39-2c918d2d9fb0", + "encodingFormat": "application/asc", + "label": "AA0718.asc" + }, + { + "contentSize": 413625, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fad8fec6f-d59c-4998-beb4-274fa115add7", + "encodingFormat": "application/swc", + "label": "AA0718.swc" + } + ], + "license": { + "@id": "https://creativecommons.org/licenses/by-nc/4.0/", + "identifier": "https://creativecommons.org/licenses/by-nc/4.0/" + }, + "mType": { + "@id": "http://uri.interlex.org/base/ilx_0738229", + "idLabel": "http://uri.interlex.org/base/ilx_0738229|Rt_RC", + "identifier": "http://uri.interlex.org/base/ilx_0738229", + "label": "Rt_RC" + }, + "name": "AA0718", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mouselight", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mouselight", + "label": "bbp/mouselight" + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-10T11:34:30.456Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/bbp/mouselight/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fneuronmorphologies%2F046fb11c-8de8-42e8-9303-9d5a65ac04b9" + } + } + ], + "max_score": 10.407086, + "total": { + "relation": "eq", + "value": 160 + } + }, + "timed_out": false, + "took": 423, + "_shards": { + "failed": 0, + "skipped": 712, + "successful": 742, + "total": 742 + } +} diff --git a/swarm_copy_tests/data/morphology_id_metadata_response.json b/swarm_copy_tests/data/morphology_id_metadata_response.json new file mode 100644 index 0000000..904b6ad --- /dev/null +++ b/swarm_copy_tests/data/morphology_id_metadata_response.json @@ -0,0 +1,102 @@ +{ + "hits": { + "hits": [ + { + "_id": "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9", + "_index": "nexus_search_b5db4c20-8200-47f9-98d9-0ca8fa3be422_d2505573-bdde-4df9-92f9-0652523b3fb2_15", + "_score": 12.887569, + "_source": { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9", + "@type": [ + "https://neuroshapes.org/ReconstructedNeuronMorphology", + "https://neuroshapes.org/NeuronMorphology" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/262", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/262|Reticular nucleus of the thalamus", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/262", + "label": "Reticular nucleus of the thalamus" + }, + "contributors": [ + { + "@id": "https://www.grid.ac/institutes/grid.443970.d", + "@type": [ + "http://schema.org/Organization", + "http://www.w3.org/ns/prov#Agent" + ], + "idLabel": "https://www.grid.ac/institutes/grid.443970.d|Janelia Research Campus", + "label": "Janelia Research Campus" + } + ], + "coordinatesInBrainAtlas": { + "valueX": "6413.2944", + "valueY": "4899.1997", + "valueZ": "4254.461" + }, + "createdAt": "2022-06-16T12:47:56.777Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/akkaufma", + "curated": true, + "deprecated": false, + "description": "Annotation Space: CCFv3.0 Axes> X: Anterior-Posterior; Y: Inferior-Superior; Z:Left-Right. Despite Mouselight metadata for CCFv2.5 and CCFv3 versions of this morphology indicating that this cell belongs to either the 'Ventral anterior-lateral complex of the thalamus' ('VAL') or 'Ventral medial nucleus of the thalamus' ('VM') region, it is almost certainly a reticular cell belonging to the 'Reticular nucleus of the thalamus' or 'RT' region. Reticular cells only exist in the RT region, and while most of the axons of this morphology exist in non-RT thalamus, viewing the morphology alongside the area of RT in the Mouselight browser here http://ml-neuronbrowser.janelia.org/ clearly shows the soma and dendrites existing in or near the RT region. Based on the location of its soma and dendrites, their general structure, and the projection pattern of its axons, this is almost certainly a reticular inhibitory cell from the RT region. In https://doi.org/10.1016/j.celrep.2023.112200 , this morphology was used as reticular inhibitory morphology belonging to the 'Rt_RC' M-type.", + "distribution": [ + { + "contentSize": 137320, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F2ad0380d-c9b2-496e-9855-ab3d173930dd", + "encodingFormat": "application/h5", + "label": "AA0718.h5" + }, + { + "contentSize": 633407, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F5ef4f830-d6ac-4a26-8a39-2c918d2d9fb0", + "encodingFormat": "application/asc", + "label": "AA0718.asc" + }, + { + "contentSize": 413625, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fad8fec6f-d59c-4998-beb4-274fa115add7", + "encodingFormat": "application/swc", + "label": "AA0718.swc" + } + ], + "license": { + "@id": "https://creativecommons.org/licenses/by-nc/4.0/", + "identifier": "https://creativecommons.org/licenses/by-nc/4.0/" + }, + "mType": { + "@id": "http://uri.interlex.org/base/ilx_0738229", + "idLabel": "http://uri.interlex.org/base/ilx_0738229|Rt_RC", + "identifier": "http://uri.interlex.org/base/ilx_0738229", + "label": "Rt_RC" + }, + "name": "AA0718", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mouselight", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/bbp/mouselight", + "label": "bbp/mouselight" + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-10T11:34:30.456Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/ricardi", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/bbp/mouselight/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fneuronmorphologies%2F046fb11c-8de8-42e8-9303-9d5a65ac04b9" + } + } + ], + "max_score": 12.887569, + "total": { + "relation": "eq", + "value": 1 + } + }, + "timed_out": false, + "took": 53, + "_shards": { + "failed": 0, + "skipped": 664, + "successful": 742, + "total": 742 + } +} diff --git a/swarm_copy_tests/data/resolve_query.json b/swarm_copy_tests/data/resolve_query.json new file mode 100644 index 0000000..181dc08 --- /dev/null +++ b/swarm_copy_tests/data/resolve_query.json @@ -0,0 +1 @@ +[{"head": {"vars": ["subject", "predicate", "object", "context"]}, "results": {"bindings": [{"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "literal", "value": "Thalamus"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "literal", "value": "Thalamus"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "literal", "value": "TH"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/BrainRegion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#isDefinedBy"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "literal", "value": "TH"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "literal", "value": "549"}, "predicate": {"type": "uri", "value": "http://schema.org/identifier"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"datatype": "http://www.w3.org/2001/XMLSchema#boolean", "type": "literal", "value": "true"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/representedInAnnotation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/262"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/1129"}, "predicate": {"type": "uri", "value": "http://schema.org/isPartOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/321"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/483"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/549"}}]}}, {"head": {"vars": ["subject", "predicate", "object", "context"]}, "results": {"bindings": [{"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "An interneuron is a type of neuron that acts as a connector or messenger between other neurons within the brain and spinal cord, and is often connected using inhibitory synapses. Interneurons process messages between neurons, helping to coordinate and integrate information within the nervous system."}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#definition"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/Neuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Int"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/MType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologicalType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}]}}, {"head": {"vars": ["subject", "predicate", "object", "context"]}, "results": {"bindings": [{"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "literal", "value": "Field CA1"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "literal", "value": "Field CA1"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "literal", "value": "CA1"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/BrainRegion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#isDefinedBy"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "literal", "value": "CA1"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "literal", "value": "382"}, "predicate": {"type": "uri", "value": "http://schema.org/identifier"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"datatype": "http://www.w3.org/2001/XMLSchema#boolean", "type": "literal", "value": "true"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/representedInAnnotation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/391"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/375"}, "predicate": {"type": "uri", "value": "http://schema.org/isPartOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/399"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/407"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/415"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/614454396"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/382"}}, {"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "literal", "value": "Field CA2"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "literal", "value": "Field CA2"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "literal", "value": "CA2"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/BrainRegion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#isDefinedBy"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "literal", "value": "CA2"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "literal", "value": "423"}, "predicate": {"type": "uri", "value": "http://schema.org/identifier"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"datatype": "http://www.w3.org/2001/XMLSchema#boolean", "type": "literal", "value": "true"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/representedInAnnotation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/431"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/375"}, "predicate": {"type": "uri", "value": "http://schema.org/isPartOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/454"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/446"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/438"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/614454397"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/423"}}, {"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "literal", "value": "Field CA3"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "literal", "value": "Field CA3"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "literal", "value": "CA3"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/BrainRegion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#isDefinedBy"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "literal", "value": "CA3"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "literal", "value": "463"}, "predicate": {"type": "uri", "value": "http://schema.org/identifier"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"datatype": "http://www.w3.org/2001/XMLSchema#boolean", "type": "literal", "value": "true"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/representedInAnnotation"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/479"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/375"}, "predicate": {"type": "uri", "value": "http://schema.org/isPartOf"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/486"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/495"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/471"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/504"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}, {"object": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/614454398"}, "predicate": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/hasLeafRegionPart"}, "subject": {"type": "uri", "value": "http://api.brain-map.org/api/v2/data/Structure/463"}}]}}, {"head": {"vars": ["subject", "predicate", "object", "context"]}, "results": {"bindings": [{"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#prefLabel"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "An interneuron is a type of neuron that acts as a connector or messenger between other neurons within the brain and spinal cord, and is often connected using inhibitory synapses. Interneurons process messages between neurons, helping to coordinate and integrate information within the nervous system."}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#definition"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/Neuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "literal", "value": "Int"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#notation"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://neuroshapes.org/MType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologicalType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "https://neuroshapes.org/Interneuron"}}, {"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "literal", "value": "Hippocampus CA3 Oriens Interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "literal", "value": "CA3 SO interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "literal", "value": "The CA3 stratum oriens interneuron is a fast spiking interneuron in hippocampal area CA3 with a main dendrite arborization extending in the stratum oriens and a widespread axonal arborization in all strata (Kawaguchi et al., 1987). The vast majority of dendritic processes were confined to the same layers as the cell bodies (Kantona et al., 1999)."}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#definition"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/NewNeuronType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0105044"}}, {"object": {"type": "uri", "value": "http://www.w3.org/2002/07/owl#Class"}, "predicate": {"type": "uri", "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}, {"object": {"type": "literal", "value": "Spinal Cord Ventral Horn Interneuron IA"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}, {"object": {"type": "literal", "value": "Spinal Ia interneuron"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2004/02/skos/core#altLabel"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885"}, "predicate": {"type": "uri", "value": "https://neuroshapes.org/atlasRelease"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}, {"object": {"type": "uri", "value": "https://bbp.epfl.ch/ontologies/core/bmo/NewNeuronType"}, "predicate": {"type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, "subject": {"type": "uri", "value": "http://uri.interlex.org/base/ilx_0110929"}}]}}, {"hits": {"hits": [{"_id": "http://api.brain-map.org/api/v2/data/Structure/688", "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 15.918847, "_source": {"@id": "http://api.brain-map.org/api/v2/data/Structure/688", "@type": "Class", "altLabel": "CTX", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "atlas_id": 85, "color_hex_triplet": "B0FFB8", "delineates": ["http://purl.obolibrary.org/obo/UBERON_0000956"], "graph_order": 3, "hasHierarchyView": ["https://neuroshapes.org/BrainRegion"], "hasLeafRegionPart": ["http://api.brain-map.org/api/v2/data/Structure/614454511", "http://api.brain-map.org/api/v2/data/Structure/614454297", "http://api.brain-map.org/api/v2/data/Structure/589508447", "http://api.brain-map.org/api/v2/data/Structure/480149218", "http://api.brain-map.org/api/v2/data/Structure/614454726", "http://api.brain-map.org/api/v2/data/Structure/614454762"], "hasPart": ["http://api.brain-map.org/api/v2/data/Structure/695", "http://api.brain-map.org/api/v2/data/Structure/703"], "hemisphere_id": 3, "identifier": "688", "isDefinedBy": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion", "isPartOf": ["http://api.brain-map.org/api/v2/data/Structure/567"], "label": "Cerebral cortex", "notation": "CTX", "prefLabel": "Cerebral cortex", "regionVolume": {"unitCode": "cubic micrometer", "value": 221549640625.0}, "regionVolumeRatioToWholeBrain": {"unitCode": "cubic micrometer", "value": 0.4377993777515536}, "representedInAnnotation": true, "st_level": 3, "subClassOf": ["https://neuroshapes.org/BrainRegion"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2019-08-20T11:41:48.761Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/sy", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F688/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F688/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 82, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F688", "_tags": ["v1.13.5"], "_updatedAt": "2024-05-28T16:40:32.374948Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}, {"_id": "http://api.brain-map.org/api/v2/data/Structure/528", "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 15.918847, "_source": {"@id": "http://api.brain-map.org/api/v2/data/Structure/528", "@type": "Class", "altLabel": "CBX", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "atlas_id": 65, "color_hex_triplet": "F0F080", "delineates": ["http://purl.obolibrary.org/obo/UBERON_0002129"], "graph_order": 1015, "hasHierarchyView": ["https://neuroshapes.org/BrainRegion"], "hasLeafRegionPart": ["http://api.brain-map.org/api/v2/data/Structure/10730"], "hasPart": ["http://api.brain-map.org/api/v2/data/Structure/1145", "http://api.brain-map.org/api/v2/data/Structure/645"], "hemisphere_id": 3, "identifier": "528", "isDefinedBy": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion", "isPartOf": ["http://api.brain-map.org/api/v2/data/Structure/512"], "label": "Cerebellar cortex", "notation": "CBX", "prefLabel": "Cerebellar cortex", "regionVolume": {"unitCode": "cubic micrometer", "value": 51220765625.0}, "regionVolumeRatioToWholeBrain": {"unitCode": "cubic micrometer", "value": 0.10121622971413098}, "representedInAnnotation": true, "st_level": 5, "subClassOf": ["https://neuroshapes.org/BrainRegion"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2019-08-20T11:40:24.927Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/sy", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F528/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F528/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 81, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F528", "_tags": ["v1.12"], "_updatedAt": "2024-05-28T16:37:15.358248Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}, {"_id": "http://api.brain-map.org/api/v2/data/Structure/184", "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 13.0758095, "_source": {"@id": "http://api.brain-map.org/api/v2/data/Structure/184", "@type": "Class", "altLabel": "FRP", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "atlas_id": 871, "color_hex_triplet": "268F45", "delineates": ["http://purl.obolibrary.org/obo/UBERON_0002795"], "graph_order": 6, "hasHierarchyView": ["https://neuroshapes.org/BrainRegion"], "hasLeafRegionPart": ["http://api.brain-map.org/api/v2/data/Structure/68", "http://api.brain-map.org/api/v2/data/Structure/667"], "hemisphere_id": 3, "identifier": "184", "isDefinedBy": "http://bbp.epfl.ch/neurosciencegraph/ontologies/core/brainregion", "isPartOf": ["http://api.brain-map.org/api/v2/data/Structure/315"], "label": "Frontal pole, cerebral cortex", "notation": "FRP", "prefLabel": "Frontal pole, cerebral cortex", "regionVolume": {"unitCode": "cubic micrometer", "value": 972296875.0}, "regionVolumeRatioToWholeBrain": {"unitCode": "cubic micrometer", "value": 0.0019213344948967013}, "representedInAnnotation": true, "st_level": 8, "subClassOf": ["https://neuroshapes.org/BrainRegion"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2019-08-20T11:37:19.466Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/sy", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F184/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F184/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 80, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Fapi.brain-map.org%2Fapi%2Fv2%2Fdata%2FStructure%2F184", "_tags": ["v1.14.0"], "_updatedAt": "2024-05-28T16:30:18.357142Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}], "max_score": 15.918847, "total": {"relation": "eq", "value": 48}}, "timed_out": false, "took": 8, "_shards": {"failed": 0, "skipped": 0, "successful": 1, "total": 1}}, {"hits": {"hits": [{"_id": "http://uri.interlex.org/base/ilx_0112352", "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 13.711583, "_source": {"@id": "http://uri.interlex.org/base/ilx_0112352", "@type": "Class", "altLabel": "Ventral tegmental area DA cell", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "definition": "Principal neuron of the ventral tegmental area", "label": "Ventral Tegmental Area Dopamine Neuron", "subClassOf": ["https://bbp.epfl.ch/ontologies/core/bmo/NewNeuronType", "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2022-11-01T10:43:54.694Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0112352/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0112352/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 73, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0112352", "_tags": ["v1.11.2"], "_updatedAt": "2024-05-28T16:48:32.797241Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}, {"_id": "http://uri.interlex.org/base/ilx_0110943", "_ignored": ["definition.keyword"], "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 11.970262, "_source": {"@id": "http://uri.interlex.org/base/ilx_0110943", "@type": "Class", "altLabel": "fusimotor neuron", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "definition": "Motor neurons which activate the contractile regions of intrafusal muscle fibers, thus adjusting the sensitivity of the muscle spindles to stretch. Gamma motor neurons may be static or dynamic according to which aspect of responsiveness (or which fiber types) they regulate. The alpha and gamma motor neurons are often activated together (alpha gamma coactivation) which allows the spindles to contribute to the control of movement trajectories despite changes in muscle length (MSH).", "label": "Spinal Cord Ventral Horn Motor Neuron Gamma", "subClassOf": ["https://bbp.epfl.ch/ontologies/core/bmo/NewNeuronType", "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2022-11-01T10:43:51.808Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0110943/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0110943/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 73, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0110943", "_tags": ["v1.11.4"], "_updatedAt": "2024-05-28T16:48:26.214141Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}, {"_id": "http://uri.interlex.org/base/ilx_0105169", "_index": "nexus_61cab3d6-56e5-4d32-b538-a08c90aca76c_3", "_score": 9.032584, "_source": {"@id": "http://uri.interlex.org/base/ilx_0105169", "@type": "Class", "altLabel": "hypoglossal motor neuron", "atlasRelease": {"@id": "https://bbp.epfl.ch/neurosciencegraph/data/4906ab85-694f-469d-962f-c0174e901885", "@type": "BrainAtlasRelease", "_rev": 8}, "definition": "Motor neuron whose soma lies in the hypoglossal nucleus", "label": "Hypoglossal Nucleus Motor Neuron", "subClassOf": ["https://bbp.epfl.ch/ontologies/core/bmo/NewNeuronType", "https://bbp.epfl.ch/ontologies/core/bmo/BrainCellType"], "_constrainedBy": "https://neuroshapes.org/dash/ontologyentity", "_createdAt": "2022-11-01T10:43:40.761Z", "_createdBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd", "_deprecated": false, "_incoming": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0105169/incoming", "_outgoing": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0105169/outgoing", "_project": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_rev": 73, "_schemaProject": "https://bbp.epfl.ch/nexus/v1/projects/neurosciencegraph/datamodels", "_self": "https://bbp.epfl.ch/nexus/v1/resources/neurosciencegraph/datamodels/_/http:%2F%2Furi.interlex.org%2Fbase%2Filx_0105169", "_tags": ["v1.12.2"], "_updatedAt": "2024-05-28T16:48:06.526340Z", "_updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/serviceaccounts/users/service-account-brain-modeling-ontology-ci-cd"}}], "max_score": 13.711583, "total": {"relation": "eq", "value": 48}}, "timed_out": false, "took": 15, "_shards": {"failed": 0, "skipped": 0, "successful": 1, "total": 1}}] diff --git a/swarm_copy_tests/data/simple.swc b/swarm_copy_tests/data/simple.swc new file mode 100644 index 0000000..ebba216 --- /dev/null +++ b/swarm_copy_tests/data/simple.swc @@ -0,0 +1,31 @@ +# SWC structure: +# index, type, x, y, z, radius, parent +# +# (0, 5) +# (-5, 5)----- ------ (6, 5) +# | +# | +# | +# | Type = 3 +# | +# o origin +# | +# | Type = 2 +# | +# | +#(-5, -4)----- ------ (6, -4) +# (0, -4) +# +# all radii are 1, except for end points, which are 0 +# section types: soma=1, axon=2, basal=3, apical=4 + + + 1 1 0 0 0 1. -1 + 2 3 0 0 0 1. 1 + 3 3 0 5 0 1. 2 + 4 3 -5 5 0 0. 3 + 5 3 6 5 0 0. 3 + 6 2 0 0 0 1. 1 + 7 2 0 -4 0 1. 6 + 8 2 6 -4 0 0. 7 + 9 2 -5 -4 0 0. 7 diff --git a/swarm_copy_tests/data/tool_calls.json b/swarm_copy_tests/data/tool_calls.json new file mode 100644 index 0000000..c8d9066 --- /dev/null +++ b/swarm_copy_tests/data/tool_calls.json @@ -0,0 +1,102 @@ +[ + { + "prompt": "What are the morphological features of neurons in the thalamus?", + "expected_tool_calls": [ + { + "tool_name": "resolve-entities-tool", + "arguments": {"brain_region": "thalamus"} + }, + { + "tool_name": "get-morpho-tool", + "arguments": {"brain_region_id":"http://api.brain-map.org/api/v2/data/Structure/549"} + } + ] + }, + { + "prompt": "Find me articles about the role of the hippocampus in memory formation.", + "expected_tool_calls": [ + { + "tool_name": "literature-search-tool", + "arguments": { + "query": "hippocampus memory formation" + } + } + ] + }, + { + "prompt": "Retrieve electrophysiological features of cortical neurons.", + "expected_tool_calls": [ + { + "tool_name": "resolve-entities-tool", + "arguments": { + "brain_region": "cortex" + } + }, + { + "tool_name": "get-traces-tool", + "arguments": { + "brain_region_id": "http://api.brain-map.org/api/v2/data/Structure/134" + } + }, + { + "tool_name": "electrophys-feature-tool", + "arguments": { + "brain_region": "cortex" + } + } + ] + }, + { + "prompt": "Get traces for neurons in the hippocampus.", + "expected_tool_calls": [ + { + "tool_name": "resolve-entities-tool", + "arguments": { + "brain_region": "hippocampus"} + }, + { + "tool_name": "get-traces-tool", + "arguments": { + "brain_region_id": "http://api.brain-map.org/api/v2/data/Structure/134" + } + }, + { + "tool_name": "electrophys-features-tool" + } + ] + }, + { + "prompt": "Search for literature on synaptic plasticity.", + "expected_tool_calls": [ + { + "tool_name": "literature-search-tool", + "arguments": { + "query": "synaptic plasticity" + } + } + ] + }, + { + "prompt": "Run 1000 ms of simulation of a me model from somatosensory cortex with 34 degree temperature, current clamp stimulation mode with step current for fire pattern detection. use 1 number of step and 0.05 nA current stimulation. Record from soma.", + "expected_tool_calls": [ + { + "tool_name": "resolve-entities-tool", + "arguments": { + "brain_region": "somatosensory area" + } + }, + { + "tool_name": "literature-search-tool" + }, + { + "tool_name": "get-me-model-tool", + "arguments": { + "brain_region_id" : "http://api.brain-map.org/api/v2/data/Structure/322" + } + }, + { + "tool_name": "bluenaas-tool" + } + ] +} +] \ No newline at end of file diff --git a/swarm_copy_tests/data/trace_id_metadata.json b/swarm_copy_tests/data/trace_id_metadata.json new file mode 100644 index 0000000..388651c --- /dev/null +++ b/swarm_copy_tests/data/trace_id_metadata.json @@ -0,0 +1,110 @@ +{ + "hits": { + "hits": [ + { + "_id": "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751", + "_index": "nexus_search_d067e019-1398-4eb8-9e28-3af8a717dcd7_41b1545a-cb2e-4848-8c74-195ec79f7bd3_18", + "_score": 8.232272, + "_source": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751", + "@type": [ + "https://neuroshapes.org/Trace", + "https://bbp.epfl.ch/ontologies/core/bmo/ExperimentalTrace" + ], + "brainRegion": { + "@id": "http://api.brain-map.org/api/v2/data/Structure/382", + "idLabel": "http://api.brain-map.org/api/v2/data/Structure/382|Field CA1", + "identifier": "http://api.brain-map.org/api/v2/data/Structure/382", + "label": "Field CA1" + }, + "contributors": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311", + "@type": [ + "http://www.w3.org/ns/prov#Agent", + "http://schema.org/Person" + ], + "idLabel": "https://bbp.epfl.ch/neurosciencegraph/data/859a20a2-9eea-4ab5-9504-d080c3c79311|Zsolt Kohus", + "label": "Zsolt Kohus" + } + ], + "createdAt": "2024-04-09T21:47:08.569Z", + "createdBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/budd", + "deprecated": false, + "derivation": [ + { + "@type": [ + "http://www.w3.org/ns/prov#Entity", + "https://neuroshapes.org/PatchedCell" + ], + "identifier": "https://bbp.epfl.ch/data/data/demo/morpho-demo/7173ea54-8e59-478d-85f3-ff86246ef22b", + "label": "s160106_0201" + } + ], + "distribution": [ + { + "contentSize": 4919928, + "contentUrl": "https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F01dffb7b-1122-4e1a-9acf-837e683da4ba", + "encodingFormat": "application/nwb", + "label": "s160106_02.nwb" + } + ], + "generation": { + "@id": "https://bbp.epfl.ch/data/demo/morpho-demo/d857ff82-b558-4117-b643-74d44dbda5e6", + "endedAt": "2016-01-06T23:59:00.000Z", + "startedAt": "2016-01-06T00:00:00.000Z" + }, + "image": [ + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2Fc1ef69e4-0073-481d-9446-fcfd7b5b5f7a", + "about": "https://neuroshapes.org/StimulationTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2Fc1ef69e4-0073-481d-9446-fcfd7b5b5f7a", + "repetition": 0, + "stimulusType": "square" + }, + { + "@id": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F6fd03e92-b2ae-4ab8-8c9e-f0ff52d20a0d", + "about": "https://neuroshapes.org/ResponseTrace", + "identifier": "https://bbp.epfl.ch/neurosciencegraph/data/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F6fd03e92-b2ae-4ab8-8c9e-f0ff52d20a0d", + "repetition": 0, + "stimulusType": "square" + } + ], + "name": "s160106_02", + "project": { + "@id": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "identifier": "https://bbp.epfl.ch/nexus/v1/projects/demo/morpho-demo", + "label": "demo/morpho-demo" + }, + "subjectAge": { + "label": "59 days Post-natal", + "period": "Post-natal", + "unit": "days", + "value": 59 + }, + "subjectSpecies": { + "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "identifier": "http://purl.obolibrary.org/obo/NCBITaxon_10090", + "label": "Mus musculus" + }, + "updatedAt": "2024-04-10T08:40:23.039Z", + "updatedBy": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/cgonzale", + "_self": "https://bbp.epfl.ch/nexus/v1/resources/demo/morpho-demo/_/https:%2F%2Fbbp.epfl.ch%2Fdata%2Fdemo%2Fmorpho-demo%2F1761e604-03fc-452b-9bf2-2214782bb751" + } + } + ], + "max_score": 8.232272, + "total": { + "relation": "eq", + "value": 1 + } + }, + "timed_out": false, + "took": 284, + "_shards": { + "failed": 0, + "skipped": 664, + "successful": 742, + "total": 742 + } +} diff --git a/swarm_copy_tests/tools/__init__.py b/swarm_copy_tests/tools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/swarm_copy_tests/tools/test_base_tool.py b/swarm_copy_tests/tools/test_base_tool.py new file mode 100644 index 0000000..e69de29 diff --git a/swarm_copy_tests/tools/test_electrophys_tool.py b/swarm_copy_tests/tools/test_electrophys_tool.py new file mode 100644 index 0000000..5706ec9 --- /dev/null +++ b/swarm_copy_tests/tools/test_electrophys_tool.py @@ -0,0 +1,206 @@ +"""Tests Electrophys tool.""" + +import json +from pathlib import Path + +import httpx +import pytest + +from swarm_copy.tools import ElectrophysFeatureTool +from swarm_copy.tools.electrophys_tool import ( + CALCULATED_FEATURES, + AmplitudeInput, + ElectrophysInput, + ElectrophysMetadata, +) + + +class TestElectrophysTool: + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) + @pytest.mark.asyncio + async def test_arun(self, httpx_mock): + url = "http://fake_url" + json_path = ( + Path(__file__).resolve().parent.parent / "data" / "trace_id_metadata.json" + ) + with open(json_path) as f: + electrophys_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=electrophys_response, + ) + + trace_path = Path(__file__).resolve().parent.parent / "data" / "99111002.nwb" + with open(trace_path, "rb") as f: + trace_content = f.read() + + httpx_mock.add_response( + url="https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F01dffb7b-1122-4e1a-9acf-837e683da4ba", + content=trace_content, + ) + + trace_id = "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751" + + tool = ElectrophysFeatureTool( + input_schema=ElectrophysInput( + trace_id=trace_id, + stimuli_types=[ + "step", + ], + calculated_feature=[ + "mean_frequency", + ], + amplitude=None, + ), + metadata=ElectrophysMetadata( + knowledge_graph_url=url, + search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + ) + response = await tool.arun() + assert isinstance(response, dict) + assert len(response["feature_dict"].keys()) == 1 + assert ( + len(response["feature_dict"]["step_0"].keys()) + == 2 # mean_frequency + 1 for stimulus current added manually + ) + + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) + @pytest.mark.asyncio + async def test_arun_with_amplitude(self, httpx_mock): + url = "http://fake_url" + json_path = ( + Path(__file__).resolve().parent.parent / "data" / "trace_id_metadata.json" + ) + with open(json_path) as f: + electrophys_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=electrophys_response, + ) + + trace_path = Path(__file__).resolve().parent.parent / "data" / "99111002.nwb" + with open(trace_path, "rb") as f: + trace_content = f.read() + + httpx_mock.add_response( + url="https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F01dffb7b-1122-4e1a-9acf-837e683da4ba", + content=trace_content, + ) + + trace_id = "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751" + + tool = ElectrophysFeatureTool( + input_schema=ElectrophysInput( + trace_id=trace_id, + stimuli_types=[ + "step", + ], + calculated_feature=[ + "mean_frequency", + ], + amplitude=AmplitudeInput(min_value=-0.5, max_value=1), + ), + metadata=ElectrophysMetadata( + knowledge_graph_url=url, + search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + ) + response = await tool.arun() + assert isinstance(response, dict) + assert len(response["feature_dict"].keys()) == 1 + assert ( + len(response["feature_dict"]["step_0.25"].keys()) + == 2 # mean_frequency + 1 for stimulus current added manually + ) + + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) + @pytest.mark.asyncio + async def test_arun_without_stimuli_types(self, httpx_mock): + url = "http://fake_url" + json_path = ( + Path(__file__).resolve().parent.parent / "data" / "trace_id_metadata.json" + ) + with open(json_path) as f: + electrophys_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=electrophys_response, + ) + + trace_path = Path(__file__).resolve().parent.parent / "data" / "99111002.nwb" + with open(trace_path, "rb") as f: + trace_content = f.read() + + httpx_mock.add_response( + url="https://bbp.epfl.ch/nexus/v1/files/demo/morpho-demo/https%3A%2F%2Fbbp.epfl.ch%2Fdata%2Fdata%2Fdemo%2Fmorpho-demo%2F01dffb7b-1122-4e1a-9acf-837e683da4ba", + content=trace_content, + ) + + trace_id = "https://bbp.epfl.ch/data/demo/morpho-demo/1761e604-03fc-452b-9bf2-2214782bb751" + + tool = ElectrophysFeatureTool( + input_schema=ElectrophysInput( + trace_id=trace_id, + stimuli_types=[ + "step", + ], + calculated_feature=[], + amplitude=None, + ), + metadata=ElectrophysMetadata( + knowledge_graph_url=url, + search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + ) + + # Without stimuli types and calculated features + response = await tool.arun() + assert isinstance(response, dict) + assert len(response["feature_dict"].keys()) == 1 + assert ( + len(response["feature_dict"]["step_0"].keys()) + == len(list(CALCULATED_FEATURES.__args__[0].__args__)) + + 1 # 1 for stimulus current added manually + ) + + @pytest.mark.asyncio + async def test_arun_errors(self): + # Do not receive trace content back + url = "http://fake_url" + + tool = ElectrophysFeatureTool( + input_schema=ElectrophysInput( + trace_id="wrong-trace-id", + stimuli_types=[ + "idrest", + ], + calculated_feature=[ + "mean_frequency", + ], + amplitude=None, + ), + metadata=ElectrophysMetadata( + knowledge_graph_url=url, + search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + ) + + with pytest.raises(ValueError) as tool_exception: + await tool.arun() + + assert ( + tool_exception.value.args[0] + == "The provided ID (wrong-trace-id) is not valid." + ) diff --git a/swarm_copy_tests/tools/test_get_morpho_tool.py b/swarm_copy_tests/tools/test_get_morpho_tool.py new file mode 100644 index 0000000..d316d49 --- /dev/null +++ b/swarm_copy_tests/tools/test_get_morpho_tool.py @@ -0,0 +1,175 @@ +"""Tests Get Morpho tool.""" + +import json +from pathlib import Path + +import httpx +import pytest + +from swarm_copy.tools import GetMorphoTool +from swarm_copy.tools.get_morpho_tool import GetMorphoInput, GetMorphoMetadata + + +class TestGetMorphoTool: + @pytest.mark.asyncio + async def test_arun(self, httpx_mock, brain_region_json_path, tmp_path): + url = "http://fake_url" + json_path = ( + Path(__file__).resolve().parent.parent / "data" / "knowledge_graph.json" + ) + with open(json_path) as f: + knowledge_graph_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=knowledge_graph_response, + ) + tool = GetMorphoTool( + input_schema=GetMorphoInput( + brain_region_id="brain_region_id_link/549", + mtype_id="brain_region_id_link/549", + ), + metadata=GetMorphoMetadata( + knowledge_graph_url=url, + morpho_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + celltypes_path=tmp_path, + ), + ) + response = await tool.arun() + assert isinstance(response, list) + assert len(response) == 2 + assert isinstance(response[0], dict) + + @pytest.mark.asyncio + async def test_arun_errors(self, httpx_mock, brain_region_json_path, tmp_path): + url = "http://fake_url" + httpx_mock.add_response( + url=url, + json={}, + ) + + tool = GetMorphoTool( + input_schema=GetMorphoInput( + brain_region_id="brain_region_id_link/bad", + mtype_id="brain_region_id_link/superbad", + ), + metadata=GetMorphoMetadata( + knowledge_graph_url=url, + morpho_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + celltypes_path=tmp_path, + ), + ) + with pytest.raises(KeyError) as tool_exception: + await tool.arun() + + assert tool_exception.value.args[0] == "hits" + + +def test_create_query(brain_region_json_path, tmp_path): + url = "http://fake_url" + + tool = GetMorphoTool( + input_schema=GetMorphoInput( + brain_region_id="not_needed", + mtype_id="not_needed", + ), + metadata=GetMorphoMetadata( + knowledge_graph_url=url, + morpho_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + celltypes_path=tmp_path, + ), + ) + + # This should be a set, but passing a list here ensures that the test doesn;t rely on order. + brain_regions_ids = ["brain-region-id/68", "brain-region-id/131"] + mtype_id = "mtype-id/1234" + + entire_query = tool.create_query( + brain_regions_ids=brain_regions_ids, mtype_ids={mtype_id} + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": "brain-region-id/68" + } + }, + { + "term": { + "brainRegion.@id.keyword": "brain-region-id/131" + } + }, + ] + } + }, + {"bool": {"should": [{"term": {"mType.@id.keyword": mtype_id}}]}}, + { + "term": { + "@type.keyword": ( + "https://neuroshapes.org/ReconstructedNeuronMorphology" + ) + } + }, + {"term": {"deprecated": False}}, + {"term": {"curated": True}}, + ] + } + }, + } + assert isinstance(entire_query, dict) + assert entire_query == expected_query + + # Case 2 with no mtype + entire_query1 = tool.create_query(brain_regions_ids=brain_regions_ids) + expected_query1 = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": "brain-region-id/68" + } + }, + { + "term": { + "brainRegion.@id.keyword": "brain-region-id/131" + } + }, + ] + } + }, + { + "term": { + "@type.keyword": ( + "https://neuroshapes.org/ReconstructedNeuronMorphology" + ) + } + }, + {"term": {"deprecated": False}}, + {"term": {"curated": True}}, + ] + } + }, + } + assert entire_query1 == expected_query1 diff --git a/swarm_copy_tests/tools/test_kg_morpho_features_tool.py b/swarm_copy_tests/tools/test_kg_morpho_features_tool.py new file mode 100644 index 0000000..2436acf --- /dev/null +++ b/swarm_copy_tests/tools/test_kg_morpho_features_tool.py @@ -0,0 +1,453 @@ +"""Tests KG Morpho Features tool.""" + +import json +from pathlib import Path + +import httpx +import pytest + +from swarm_copy.tools import KGMorphoFeatureTool +from swarm_copy.tools.kg_morpho_features_tool import ( + KGFeatRangeInput, + KGFeatureInput, + KGMorphoFeatureInput, + KGMorphoFeatureMetadata, +) + + +class TestKGMorphoFeaturesTool: + @pytest.mark.asyncio + async def test_arun(self, httpx_mock, brain_region_json_path): + url = "http://fake_url" + json_path = ( + Path(__file__).resolve().parent.parent + / "data" + / "kg_morpho_features_response.json" + ) + with open(json_path) as f: + kg_morpho_features_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=kg_morpho_features_response, + ) + + feature_input = KGFeatureInput( + label="Section Tortuosity", + ) + + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="brain_region_id_link/549", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + response = await tool.arun() + assert isinstance(response, list) + assert len(response) == 2 + assert isinstance(response[0], dict) + + @pytest.mark.asyncio + async def test_arun_errors(self, httpx_mock, brain_region_json_path): + url = "http://fake_url" + + # Mock issue (resolve query without results) + httpx_mock.add_response( + url=url, + json={}, + ) + + feature_input = KGFeatureInput( + label="Section Tortuosity", + ) + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="brain_region_id_link/549", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + + with pytest.raises(KeyError) as tool_exception: + await tool.arun() + assert tool_exception.value.args[0] == "hits" + + def test_create_query(self, brain_region_json_path): + url = "http://fake_url" + + feature_input = KGFeatureInput( + label="Soma Radius", + compartment="NeuronMorphology", + ) + + brain_regions_ids = {"brain-region-id/68"} + + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + + entire_query = tool.create_query( + brain_regions_ids=brain_regions_ids, features=feature_input + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": ( + "brain-region-id/68" + ) + } + } + ] + } + }, + { + "nested": { + "path": "featureSeries", + "query": { + "bool": { + "must": [ + { + "term": { + "featureSeries.label.keyword": ( + "Soma Radius" + ) + } + }, + { + "term": { + "featureSeries.compartment.keyword": ( + "NeuronMorphology" + ) + } + }, + ] + } + }, + } + }, + { + "term": { + "@type.keyword": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + } + }, + {"term": {"deprecated": False}}, + ] + } + }, + } + assert isinstance(entire_query, dict) + assert entire_query == expected_query + + def test_create_query_with_max_value(self, brain_region_json_path): + url = "http://fake_url" + + feature_input = KGFeatureInput( + label="Soma Radius", + compartment="NeuronMorphology", + feat_range=KGFeatRangeInput(max_value=5), + ) + + brain_regions_ids = {"brain-region-id/68"} + + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + + entire_query = tool.create_query( + brain_regions_ids=brain_regions_ids, features=feature_input + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": ( + "brain-region-id/68" + ) + } + } + ] + } + }, + { + "nested": { + "path": "featureSeries", + "query": { + "bool": { + "must": [ + { + "term": { + "featureSeries.label.keyword": ( + "Soma Radius" + ) + } + }, + { + "term": { + "featureSeries.compartment.keyword": ( + "NeuronMorphology" + ) + } + }, + { + "term": { + "featureSeries.statistic.keyword": ( + "raw" + ) + } + }, + { + "range": { + "featureSeries.value": {"lte": 5.0} + } + }, + ] + } + }, + } + }, + { + "term": { + "@type.keyword": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + } + }, + {"term": {"deprecated": False}}, + ] + } + }, + } + assert entire_query == expected_query + + def test_create_query_with_min_value(self, brain_region_json_path): + url = "http://fake_url" + + feature_input = KGFeatureInput( + label="Soma Radius", + compartment="NeuronMorphology", + feat_range=KGFeatRangeInput(min_value=2), + ) + + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + + brain_regions_ids = {"brain-region-id/68"} + entire_query = tool.create_query( + brain_regions_ids=brain_regions_ids, features=feature_input + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": ( + "brain-region-id/68" + ) + } + } + ] + } + }, + { + "nested": { + "path": "featureSeries", + "query": { + "bool": { + "must": [ + { + "term": { + "featureSeries.label.keyword": ( + "Soma Radius" + ) + } + }, + { + "term": { + "featureSeries.compartment.keyword": ( + "NeuronMorphology" + ) + } + }, + { + "term": { + "featureSeries.statistic.keyword": ( + "raw" + ) + } + }, + { + "range": { + "featureSeries.value": {"gte": 2.0} + } + }, + ] + } + }, + } + }, + { + "term": { + "@type.keyword": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + } + }, + {"term": {"deprecated": False}}, + ] + } + }, + } + assert entire_query == expected_query + + def test_create_query_with_min_max_value(self, brain_region_json_path): + url = "http://fake_url" + + feature_input = KGFeatureInput( + label="Soma Radius", + compartment="NeuronMorphology", + feat_range=KGFeatRangeInput(min_value=2, max_value=5), + ) + + tool = KGMorphoFeatureTool( + input_schema=KGMorphoFeatureInput( + brain_region_id="", features=feature_input + ), + metadata=KGMorphoFeatureMetadata( + knowledge_graph_url=url, + kg_morpho_feature_search_size=2, + token="fake_token", + brainregion_path=brain_region_json_path, + httpx_client=httpx.AsyncClient(), + ), + ) + + brain_regions_ids = {"brain-region-id/68"} + entire_query = tool.create_query( + brain_regions_ids=brain_regions_ids, features=feature_input + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": ( + "brain-region-id/68" + ) + } + } + ] + } + }, + { + "nested": { + "path": "featureSeries", + "query": { + "bool": { + "must": [ + { + "term": { + "featureSeries.label.keyword": ( + "Soma Radius" + ) + } + }, + { + "term": { + "featureSeries.compartment.keyword": ( + "NeuronMorphology" + ) + } + }, + { + "term": { + "featureSeries.statistic.keyword": ( + "raw" + ) + } + }, + { + "range": { + "featureSeries.value": { + "gte": 2.0, + "lte": 5.0, + } + } + }, + ] + } + }, + } + }, + { + "term": { + "@type.keyword": "https://bbp.epfl.ch/ontologies/core/bmo/NeuronMorphologyFeatureAnnotation" + } + }, + {"term": {"deprecated": False}}, + ] + } + }, + } + assert entire_query == expected_query diff --git a/swarm_copy_tests/tools/test_literature_search_tool.py b/swarm_copy_tests/tools/test_literature_search_tool.py new file mode 100644 index 0000000..c57d8a1 --- /dev/null +++ b/swarm_copy_tests/tools/test_literature_search_tool.py @@ -0,0 +1,50 @@ +"""Tests Literature Search tool.""" + +import httpx +import pytest + +from swarm_copy.tools import LiteratureSearchTool +from swarm_copy.tools.literature_search_tool import ( + LiteratureSearchInput, + LiteratureSearchMetadata, +) + + +class TestLiteratureSearchTool: + @pytest.mark.asyncio + async def test_arun(self, httpx_mock): + url = "http://fake_url?query=covid+19&retriever_k=100&use_reranker=true&reranker_k=5" + reranker_k = 5 + + fake_response = [ + { + "article_title": "Article title", + "article_authors": ["Author1", "Author2"], + "paragraph": "This is the paragraph", + "section": "fake_section", + "article_doi": "fake_doi", + "journal_issn": "fake_journal_issn", + } + for _ in range(reranker_k) + ] + + httpx_mock.add_response( + url=url, + json=fake_response, + ) + + tool = LiteratureSearchTool( + input_schema=LiteratureSearchInput(query="covid 19"), + metadata=LiteratureSearchMetadata( + literature_search_url=url, + httpx_client=httpx.AsyncClient(), + token="fake_token", + retriever_k=100, + use_reranker=True, + reranker_k=reranker_k, + ), + ) + response = await tool.arun() + assert isinstance(response, list) + assert len(response) == reranker_k + assert isinstance(response[0], dict) diff --git a/swarm_copy_tests/tools/test_morphology_features_tool.py b/swarm_copy_tests/tools/test_morphology_features_tool.py new file mode 100644 index 0000000..197b634 --- /dev/null +++ b/swarm_copy_tests/tools/test_morphology_features_tool.py @@ -0,0 +1,114 @@ +"""Tests Morphology features tool.""" + +import json +from pathlib import Path + +import httpx +import pytest + +from swarm_copy.tools import MorphologyFeatureTool +from swarm_copy.tools.morphology_features_tool import ( + MorphologyFeatureInput, + MorphologyFeatureMetadata, +) + + +class TestMorphologyFeatureTool: + @pytest.mark.asyncio + async def test_arun(self, httpx_mock): + url = "http://fake_url" + morphology_id = "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9" + json_path = ( + Path(__file__).resolve().parent.parent + / "data" + / "morphology_id_metadata_response.json" + ) + with open(json_path) as f: + morphology_metadata_response = json.load(f) + + # Mock get morphology ids + httpx_mock.add_response( + url=url, + json=morphology_metadata_response, + ) + + morphology_path = Path(__file__).resolve().parent.parent / "data" / "simple.swc" + with open(morphology_path) as f: + morphology_content = f.read() + + # Mock get object id request + httpx_mock.add_response( + url="https://bbp.epfl.ch/nexus/v1/files/bbp/mouselight/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fad8fec6f-d59c-4998-beb4-274fa115add7", + content=morphology_content, + ) + + tool = MorphologyFeatureTool( + metadata=MorphologyFeatureMetadata( + knowledge_graph_url=url, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + input_schema=MorphologyFeatureInput(morphology_id=morphology_id), + ) + + response = await tool.arun() + assert isinstance(response[0], dict) + assert len(response[0]["feature_dict"]) == 23 + + @pytest.mark.asyncio + async def test_arun_errors_404(self, httpx_mock): + url = "http://fake_url" + morphology_id = "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9" + + tool = MorphologyFeatureTool( + metadata=MorphologyFeatureMetadata( + knowledge_graph_url=url, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + input_schema=MorphologyFeatureInput(morphology_id=morphology_id), + ) + + # test different failures + # Failure 1 + httpx_mock.add_response( + url=url, + status_code=404, + ) + with pytest.raises(ValueError) as tool_exception: + await tool.arun() + + assert ( + tool_exception.value.args[0] == "We did not find the object" + " https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9" + " you are asking" + ) + + @pytest.mark.asyncio + async def test_arun_wrong_id(self, httpx_mock): + url = "http://fake_url" + morphology_id = "https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9" + + tool = MorphologyFeatureTool( + metadata=MorphologyFeatureMetadata( + knowledge_graph_url=url, + httpx_client=httpx.AsyncClient(), + token="fake_token", + ), + input_schema=MorphologyFeatureInput(morphology_id=morphology_id), + ) + + # Failure 2 + fake_json = {"hits": {"hits": [{"_source": {"@id": "wrong_id"}}]}} + httpx_mock.add_response( + url=url, + json=fake_json, + ) + with pytest.raises(ValueError) as tool_exception: + await tool.arun() + + assert ( + tool_exception.value.args[0] == "We did not find the object" + " https://bbp.epfl.ch/neurosciencegraph/data/neuronmorphologies/046fb11c-8de8-42e8-9303-9d5a65ac04b9" + " you are asking" + ) diff --git a/swarm_copy_tests/tools/test_resolve_entities_tool.py b/swarm_copy_tests/tools/test_resolve_entities_tool.py new file mode 100644 index 0000000..01014ae --- /dev/null +++ b/swarm_copy_tests/tools/test_resolve_entities_tool.py @@ -0,0 +1,100 @@ +"""Test the revole_brain_region_tool.""" + +import pytest +from httpx import AsyncClient + +from swarm_copy.tools import ResolveEntitiesTool +from swarm_copy.tools.resolve_entities_tool import ( + BRResolveOutput, + EtypeResolveOutput, + MTypeResolveOutput, + ResolveBRMetadata, + ResolveBRInput +) + + +@pytest.mark.asyncio +async def test_arun(httpx_mock, get_resolve_query_output): + # Mock exact match to fail + httpx_mock.add_response( + url="http://fake_sparql_url.com/78", + json={ + "head": {"vars": ["subject", "predicate", "object", "context"]}, + "results": {"bindings": []}, + }, + ) + + # Hit fuzzy match + httpx_mock.add_response( + url="http://fake_sparql_url.com/78", + json=get_resolve_query_output[2], + ) + + # Hit ES match + httpx_mock.add_response( + url="http://fake_class_url.com/78", + json=get_resolve_query_output[4], + ) + + # Mock exact match to fail (mtype) + httpx_mock.add_response( + url="http://fake_sparql_url.com/78", + json={ + "head": {"vars": ["subject", "predicate", "object", "context"]}, + "results": {"bindings": []}, + }, + ) + + # Hit fuzzy match (mtype) + httpx_mock.add_response( + url="http://fake_sparql_url.com/78", + json=get_resolve_query_output[3], + ) + # Hit ES match (mtype). + httpx_mock.add_response( + url="http://fake_class_url.com/78", json=get_resolve_query_output[5] + ) + + tool = ResolveEntitiesTool( + metadata=ResolveBRMetadata( + token="greattokenpleasedontexpire", + httpx_client=AsyncClient(timeout=None), + kg_sparql_url="http://fake_sparql_url.com/78", + kg_class_view_url="http://fake_class_url.com/78", + ), + input_schema=ResolveBRInput( + brain_region="Field", + mtype="Interneu", + etype="bAC" + ) + ) + + response = await tool.arun() + assert response == [ + BRResolveOutput( + brain_region_name="Field CA1", + brain_region_id="http://api.brain-map.org/api/v2/data/Structure/382", + ).model_dump(), + BRResolveOutput( + brain_region_name="Field CA2", + brain_region_id="http://api.brain-map.org/api/v2/data/Structure/423", + ).model_dump(), + BRResolveOutput( + brain_region_name="Field CA3", + brain_region_id="http://api.brain-map.org/api/v2/data/Structure/463", + ).model_dump(), + MTypeResolveOutput( + mtype_name="Interneuron", mtype_id="https://neuroshapes.org/Interneuron" + ).model_dump(), + MTypeResolveOutput( + mtype_name="Hippocampus CA3 Oriens Interneuron", + mtype_id="http://uri.interlex.org/base/ilx_0105044", + ).model_dump(), + MTypeResolveOutput( + mtype_name="Spinal Cord Ventral Horn Interneuron IA", + mtype_id="http://uri.interlex.org/base/ilx_0110929", + ).model_dump(), + EtypeResolveOutput( + etype_name="bAC", etype_id="http://uri.interlex.org/base/ilx_0738199" + ).model_dump(), + ] diff --git a/swarm_copy_tests/tools/test_traces_tool.py b/swarm_copy_tests/tools/test_traces_tool.py new file mode 100644 index 0000000..03bba53 --- /dev/null +++ b/swarm_copy_tests/tools/test_traces_tool.py @@ -0,0 +1,150 @@ +"""Tests Traces tool.""" + +import json +from pathlib import Path + +import httpx +import pytest + +from swarm_copy.tools import GetTracesTool +from swarm_copy.tools.traces_tool import GetTracesInput, GetTracesMetadata + + +class TestTracesTool: + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) + @pytest.mark.asyncio + async def test_arun(self, httpx_mock, brain_region_json_path): + url = "http://fake_url" + json_path = Path(__file__).resolve().parent.parent / "data" / "get_traces.json" + with open(json_path) as f: + get_traces_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=get_traces_response, + ) + + tool = GetTracesTool( + metadata=GetTracesMetadata( + knowledge_graph_url=url, + trace_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + ), + input_schema=GetTracesInput(brain_region_id="brain_region_id_link/549"), + ) + + response = await tool.arun() + assert isinstance(response, list) + assert len(response) == 2 + assert isinstance(response[0], dict) + assert isinstance(response[0], dict) + + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) + @pytest.mark.asyncio + async def test_arun_with_etype(self, httpx_mock, brain_region_json_path): + url = "http://fake_url" + json_path = Path(__file__).resolve().parent.parent / "data" / "get_traces.json" + with open(json_path) as f: + get_traces_response = json.load(f) + + httpx_mock.add_response( + url=url, + json=get_traces_response, + ) + + tool = GetTracesTool( + metadata=GetTracesMetadata( + knowledge_graph_url=url, + trace_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + ), + input_schema=GetTracesInput( + brain_region_id="brain_region_id_link/549", etype_id="bAC_id/123" + ), + ) + response = await tool.arun() + assert isinstance(response, list) + assert len(response) == 2 + assert isinstance(response[0], dict) + + @pytest.mark.asyncio + async def test_arun_errors(self, httpx_mock, brain_region_json_path): + url = "http://fake_url" + + # Mocking an issue + httpx_mock.add_response( + url=url, + json={}, + ) + + tool = GetTracesTool( + metadata=GetTracesMetadata( + knowledge_graph_url=url, + trace_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + ), + input_schema=GetTracesInput(brain_region_id="brain_region_id_link/549"), + ) + with pytest.raises(KeyError) as tool_exception: + await tool.arun() + + assert tool_exception.value.args[0] == "hits" + + def test_create_query(self, brain_region_json_path): + brain_region_ids = {"brain_region_id1"} + etype_id = "bAC_id/123" + url = "http://fake_url" + + tool = GetTracesTool( + metadata=GetTracesMetadata( + knowledge_graph_url=url, + trace_search_size=2, + httpx_client=httpx.AsyncClient(), + token="fake_token", + brainregion_path=brain_region_json_path, + ), + input_schema=GetTracesInput( + brain_region_id="brain_region_id1", etype_id=etype_id + ), + ) + entire_query = tool.create_query( + brain_region_ids=brain_region_ids, etype_id=etype_id + ) + expected_query = { + "size": 2, + "track_total_hits": True, + "query": { + "bool": { + "must": [ + { + "bool": { + "should": [ + { + "term": { + "brainRegion.@id.keyword": ( + "brain_region_id1" + ) + } + }, + ] + } + }, + {"term": {"eType.@id.keyword": ("bAC_id/123")}}, + { + "term": { + "@type.keyword": "https://bbp.epfl.ch/ontologies/core/bmo/ExperimentalTrace" + } + }, + {"term": {"curated": True}}, + {"term": {"deprecated": False}}, + ] + } + }, + } + assert entire_query == expected_query