allensdk.api.queries.ontologies_api module

class allensdk.api.queries.ontologies_api.OntologiesApi(base_uri=None)[source]

Bases: allensdk.api.queries.rma_template.RmaTemplate

See: Atlas Drawings and Ontologies

get_atlases(self)[source]
get_atlases_table(self, atlas_ids=None, brief=True)[source]

List Atlases available through the API with associated ontologies and structure graphs.

Parameters:
atlas_ids : integer or list of integers, optional

only select specific atlases

brief : boolean, optional

True (default) requests only name and id fields.

Returns:
dict : atlas metadata

Notes

This query is based on the table of available Atlases. See also: Class: Atlas

get_structure_graphs(self)[source]
get_structure_sets(self, structure_set_ids=None)[source]
get_structures(self, structure_graph_ids=None, structure_graph_names=None, structure_set_ids=None, structure_set_names=None, order=['structures.graph_order'], num_rows='all', count=False, **kwargs)[source]

Retrieve data about anatomical structures.

Parameters:
structure_graph_ids : int or list of ints, optional

database keys to get all structures in particular graphs

structure_graph_names : string or list of strings, optional

list of graph names to narrow the query

structure_set_ids : int or list of ints, optional

database keys to get all structures in a particular set

structure_set_names : string or list of strings, optional

list of set names to narrow the query.

order : list of strings

list of RMA order clauses for sorting

num_rows : int

how many records to retrieve

Returns:
dict

the parsed json response containing data from the API

Notes

Only one of the methods of limiting the query should be used at a time.

get_structures_with_sets(self, structure_graph_ids, order=['structures.graph_order'], num_rows='all', count=False, **kwargs)[source]

Download structures along with the sets to which they belong.

Parameters:
structure_graph_ids : int or list of int

Only fetch structure records from these graphs.

order : list of strings

list of RMA order clauses for sorting

num_rows : int

how many records to retrieve

Returns:
dict

the parsed json response containing data from the API

rma_templates = {'ontology_queries': [{'name': 'structures_by_graph_ids', 'description': 'see name', 'model': 'Structure', 'criteria': '[graph_id$in{{ graph_ids }}]', 'order': ['structures.graph_order'], 'num_rows': 'all', 'count': False, 'criteria_params': ['graph_ids']}, {'name': 'structures_by_graph_names', 'description': 'see name', 'model': 'Structure', 'criteria': 'graph[structure_graphs.name$in{{ graph_names }}]', 'order': ['structures.graph_order'], 'num_rows': 'all', 'count': False, 'criteria_params': ['graph_names']}, {'name': 'structures_by_set_ids', 'description': 'see name', 'model': 'Structure', 'criteria': '[structure_set_id$in{{ set_ids }}]', 'order': ['structures.graph_order'], 'num_rows': 'all', 'count': False, 'criteria_params': ['set_ids']}, {'name': 'structures_by_set_names', 'description': 'see name', 'model': 'Structure', 'criteria': 'structure_sets[name$in{{ set_names }}]', 'order': ['structures.graph_order'], 'num_rows': 'all', 'count': False, 'criteria_params': ['set_names']}, {'name': 'structure_graphs_list', 'description': 'see name', 'model': 'StructureGraph', 'num_rows': 'all', 'count': False}, {'name': 'structure_sets_list', 'description': 'see name', 'model': 'StructureSet', 'num_rows': 'all', 'count': False}, {'name': 'atlases_list', 'description': 'see name', 'model': 'Atlas', 'num_rows': 'all', 'count': False}, {'name': 'atlases_table', 'description': 'see name', 'model': 'Atlas', 'criteria': '{% if atlas_ids is defined %}[id$in{{ atlas_ids }}],{%endif%}structure_graph(ontology),graphic_group_labels', 'include': 'structure_graph(ontology),graphic_group_labels', 'only': ['atlases.id', 'atlases.name', 'atlases.image_type', 'ontologies.id', 'ontologies.name', 'structure_graphs.id', 'structure_graphs.name', 'graphic_group_labels.id', 'graphic_group_labels.name'], 'num_rows': 'all', 'count': False, 'criteria_params': ['atlas_ids']}, {'name': 'structures_with_sets', 'description': 'see name', 'model': 'Structure', 'include': 'structure_sets', 'criteria': '[graph_id$in{{ graph_ids }}]', 'order': ['structures.graph_order'], 'num_rows': 'all', 'count': False, 'criteria_params': ['graph_ids']}, {'name': 'structure_sets_by_id', 'description': 'see name', 'model': 'StructureSet', 'criteria': '[id$in{{ set_ids }}]', 'num_rows': 'all', 'count': False, 'criteria_params': ['set_ids']}]}
unpack_structure_set_ancestors(self, structure_dataframe)[source]

Convert a slash-separated structure_id_path field to a list.

Parameters:
structure_dataframe : DataFrame

structure data from the API

Returns:
None

A new column is added to the dataframe containing the ancestor list.