Help on class OntologiesApi in module allensdk.api.queries.ontologies_api:
class OntologiesApi(allensdk.api.queries.rma_template.RmaTemplate)
| See: `Atlas Drawings and Ontologies
| <http://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies>`_
|
| Method resolution order:
| OntologiesApi
| allensdk.api.queries.rma_template.RmaTemplate
| allensdk.api.queries.rma_api.RmaApi
| allensdk.api.api.Api
| __builtin__.object
|
| Methods defined here:
|
| __init__(self, base_uri=None)
|
| get_atlases(self)
|
| get_atlases_table(self, atlas_ids=None, brief=True)
| 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 <http://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies>`_.
| See also: `Class: Atlas <http://api.brain-map.org/doc/Atlas.html>`_
|
| get_structure_graphs(self)
|
| get_structure_sets(self)
|
| 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)
| 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.
|
| unpack_structure_set_ancestors(self, structure_dataframe)
| 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.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| rma_templates = {'ontology_queries': [{'count': False, 'criteria': '[g...
|
| ----------------------------------------------------------------------
| Methods inherited from allensdk.api.queries.rma_template.RmaTemplate:
|
| template_query(self, template_name, entry_name, **kwargs)
|
| to_filter_rhs(self, rhs)
|
| ----------------------------------------------------------------------
| Methods inherited from allensdk.api.queries.rma_api.RmaApi:
|
| build_query_url(self, stage_clauses, fmt='json')
| Combine one or more RMA query stages into a single RMA query.
|
| Parameters
| ----------
| stage_clauses : list of strings
| subqueries
| fmt : string, optional
| json (default), xml, or csv
|
| Returns
| -------
| string
| complete RMA url
|
| build_schema_query(self, clazz=None, fmt='json')
| Build the URL that will fetch the data schema.
|
| Parameters
| ----------
| clazz : string, optional
| Name of a specific class or None (default).
| fmt : string, optional
| json (default) or xml
|
| Returns
| -------
| url : string
| The constructed URL
|
| Notes
| -----
| If a class is specified, only the schema information for that class
| will be requested, otherwise the url requests the entire schema.
|
| debug_clause(self, debug_value=None)
| Construct a debug clause for use in an rma::options clause.
| Parameters
| ----------
| debug_value : string or boolean
| True, False, None (default) or 'preview'
|
| Returns
| -------
| clause : string
| The query clause for inclusion in an RMA query URL.
|
| Notes
| -----
| True will request debugging information in the response.
| False will request no debugging information.
| None will return an empty clause.
| 'preview' will request debugging information without the query being run.
|
| filter(self, key, value)
| serialize a single RMA query filter clause.
|
| Parameters
| ----------
| key : string
| keys for narrowing a query.
| value : string
| value for narrowing a query.
|
| Returns
| -------
| string
| a single filter clause for an RMA query string.
|
| filters(self, filters)
| serialize RMA query filter clauses.
|
| Parameters
| ----------
| filters : dict
| keys and values for narrowing a query.
|
| Returns
| -------
| string
| filter clause for an RMA query string.
|
| get_schema(self, clazz=None)
| Retrieve schema information.
|
| model_query(self, *args, **kwargs)
| Construct and execute a model stage of an RMA query string.
|
| Parameters
| ----------
| model : string
| The top level data type
| filters : dict
| key, value comparisons applied to the top-level model to narrow the results.
| criteria : string
| raw RMA criteria clause to choose what object are returned
| include : string
| raw RMA include clause to return associated objects
| only : list of strings, optional
| to be joined into an rma::options only filter to limit what data is returned
| except : list of strings, optional
| to be joined into an rma::options except filter to limit what data is returned
| tabular : list of string, optional
| return columns as a tabular data structure rather than a nested tree.
| count : boolean, optional
| False to skip the extra database count query.
| debug : string, optional
| 'true', 'false' or 'preview'
| num_rows : int or string, optional
| how many database rows are returned (may not correspond directly to JSON tree structure)
| start_row : int or string, optional
| which database row is start of returned data (may not correspond directly to JSON tree structure)
|
|
| Notes
| -----
| See `RMA Path Syntax <http://help.brain-map.org/display/api/RMA+Path+Syntax#RMAPathSyntax-DoubleColonforAxis>`_
| for a brief overview of the normalized RMA syntax.
| Normalized RMA syntax differs from the legacy syntax
| used in much of the RMA documentation.
| Using the &debug=true option with an RMA URL will include debugging information in the
| response, including the normalized query.
|
| model_stage(self, model, **kwargs)
| Construct a model stage of an RMA query string.
|
| Parameters
| ----------
| model : string
| The top level data type
| filters : dict
| key, value comparisons applied to the top-level model to narrow the results.
| criteria : string
| raw RMA criteria clause to choose what object are returned
| include : string
| raw RMA include clause to return associated objects
| only : list of strings, optional
| to be joined into an rma::options only filter to limit what data is returned
| except : list of strings, optional
| to be joined into an rma::options except filter to limit what data is returned
| tabular : list of string, optional
| return columns as a tabular data structure rather than a nested tree.
| count : boolean, optional
| False to skip the extra database count query.
| debug : string, optional
| 'true', 'false' or 'preview'
| num_rows : int or string, optional
| how many database rows are returned (may not correspond directly to JSON tree structure)
| start_row : int or string, optional
| which database row is start of returned data (may not correspond directly to JSON tree structure)
|
|
| Notes
| -----
| See `RMA Path Syntax <http://help.brain-map.org/display/api/RMA+Path+Syntax#RMAPathSyntax-DoubleColonforAxis>`_
| for a brief overview of the normalized RMA syntax.
| Normalized RMA syntax differs from the legacy syntax
| used in much of the RMA documentation.
| Using the &debug=true option with an RMA URL will include debugging information in the
| response, including the normalized query.
|
| only_except_tabular_clause(self, filter_type, attribute_list)
| Construct a clause to filter which attributes are returned
| for use in an rma::options clause.
|
| Parameters
| ----------
| filter_type : string
| 'only', 'except', or 'tabular'
| attribute_list : list of strings
| for example ['acronym', 'products.name', 'structure.id']
|
| Returns
| -------
| clause : string
| The query clause for inclusion in an RMA query URL.
|
| Notes
| -----
| The title of tabular columns can be set by adding '+as+<title>'
| to the attribute.
| The tabular filter type requests a response that is row-oriented
| rather than a nested structure.
| Because of this, the tabular option can mask the lazy query behavior
| of an rma::include clause.
| The tabular option does not mask the inner-join behavior of an rma::include
| clause.
| The tabular filter is required for .csv format RMA requests.
|
| options_clause(self, **kwargs)
| build rma:: options clause.
|
| Parameters
| ----------
| only : list of strings, optional
| except : list of strings, optional
| tabular : list of string, optional
| count : boolean, optional
| debug : string, optional
| 'true', 'false' or 'preview'
| num_rows : int or string, optional
| start_row : int or string, optional
|
| order_clause(self, order_list=None)
| Construct a debug clause for use in an rma::options clause.
|
| Parameters
| ----------
| order_list : list of strings
| for example ['acronym', 'products.name+asc', 'structure.id+desc']
|
| Returns
| -------
| clause : string
| The query clause for inclusion in an RMA query URL.
|
| Notes
| -----
| Optionally adding '+asc' (default) or '+desc' after an attribute
| will change the sort order.
|
| pipe_stage(self, pipe_name, parameters)
| Connect model and service stages via their JSON responses.
|
| Notes
| -----
| See: `Service Pipelines <http://help.brain-map.org/display/api/Service+Pipelines>`_
| and
| `Connected Services and Pipes <http://help.brain-map.org/display/api/Connected+Services+and+Pipes>`_
|
| quote_string(self, the_string)
| Wrap a clause in single quotes.
|
| Parameters
| ----------
| the_string : string
| a clause to be included in an rma query that needs to be quoted
|
| Returns
| -------
| string
| input wrapped in single quotes
|
| service_query(self, *args, **kwargs)
| Construct and Execute a single-stage RMA query
| to send a request to a connected service.
|
| Parameters
| ----------
| service_name : string
| Name of a documented connected service.
| parameters : dict
| key-value pairs as in the online documentation.
|
| Notes
| -----
| See: `Service Pipelines <http://help.brain-map.org/display/api/Service+Pipelines>`_
| and
| `Connected Services and Pipes <http://help.brain-map.org/display/api/Connected+Services+and+Pipes>`_
|
| service_stage(self, service_name, parameters=None)
| Construct an RMA query fragment to send a request to a connected service.
|
| Parameters
| ----------
| service_name : string
| Name of a documented connected service.
| parameters : dict
| key-value pairs as in the online documentation.
|
| Notes
| -----
| See: `Service Pipelines <http://help.brain-map.org/display/api/Service+Pipelines>`_
| and
| `Connected Services and Pipes <http://help.brain-map.org/display/api/Connected+Services+and+Pipes>`_
|
| tuple_filters(self, filters)
| Construct an RMA filter clause.
|
| Notes
| -----
|
| See `RMA Path Syntax - Square Brackets for Filters <http://help.brain-map.org/display/api/RMA+Path+Syntax#RMAPathSyntax-SquareBracketsforFilters>`_ for additional documentation.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from allensdk.api.queries.rma_api.RmaApi:
|
| ALL = 'all'
|
| COUNT = 'count'
|
| CRITERIA = 'rma::criteria'
|
| DEBUG = 'debug'
|
| EQ = '$eq'
|
| EXCEPT = 'except'
|
| FALSE = 'false'
|
| INCLUDE = 'rma::include'
|
| IS = '$is'
|
| MODEL = 'model::'
|
| NUM_ROWS = 'num_rows'
|
| ONLY = 'only'
|
| OPTIONS = 'rma::options'
|
| ORDER = 'order'
|
| PIPE = 'pipe::'
|
| PREVIEW = 'preview'
|
| SERVICE = 'service::'
|
| START_ROW = 'start_row'
|
| TABULAR = 'tabular'
|
| TRUE = 'true'
|
| ----------------------------------------------------------------------
| Methods inherited from allensdk.api.api.Api:
|
| construct_well_known_file_download_url(self, well_known_file_id)
| Join data api endpoint and id.
|
| Parameters
| ----------
| well_known_file_id : integer or string representing an integer
| well known file id
|
| Returns
| -------
| string
| the well-known-file download url for the current api api server
|
| See Also
| --------
| retrieve_file_over_http: Can be used to retrieve the file from the url.
|
| do_query(self, url_builder_fn, json_traversal_fn, *args, **kwargs)
| Bundle an query url construction function
| with a corresponding response json traversal function.
|
| Parameters
| ----------
| url_builder_fn : function
| A function that takes parameters and returns an rma url.
| json_traversal_fn : function
| A function that takes a json-parsed python data structure and returns data from it.
| post : boolean, optional kwarg
| True does an HTTP POST, False (default) does a GET
| args : arguments
| Arguments to be passed to the url builder function.
| kwargs : keyword arguments
| Keyword arguments to be passed to the rma builder function.
|
| Returnsurllib_re
| -------
| any type
| The data extracted from the json response.
|
| Examples
| --------
| `A simple Api subclass example
| <data_api_client.html#creating-new-api-query-classes>`_.
|
| do_rma_query(self, rma_builder_fn, json_traversal_fn, *args, **kwargs)
| Bundle an RMA query url construction function
| with a corresponding response json traversal function.
|
| ..note:: Deprecated in AllenSDK 0.9.2
| `do_rma_query` will be removed in AllenSDK 1.0, it is replaced by
| `do_query` because the latter is more general.
|
| Parameters
| ----------
| rma_builder_fn : function
| A function that takes parameters and returns an rma url.
| json_traversal_fn : function
| A function that takes a json-parsed python data structure and returns data from it.
| args : arguments
| Arguments to be passed to the rma builder function.
| kwargs : keyword arguments
| Keyword arguments to be passed to the rma builder function.
|
| Returns
| -------
| any type
| The data extracted from the json response.
|
| Examples
| --------
| `A simple Api subclass example
| <data_api_client.html#creating-new-api-query-classes>`_.
|
| json_msg_query(self, url, dataframe=False)
| Common case where the url is fully constructed
| and the response data is stored in the 'msg' field.
|
| Parameters
| ----------
| url : string
| Where to get the data in json form
| dataframe : boolean
| True converts to a pandas dataframe, False (default) doesn't
|
| Returns
| -------
| dict or DataFrame
| returned data; type depends on dataframe option
|
| load_api_schema(self)
| Download the RMA schema from the current RMA endpoint
|
| Returns
| -------
| dict
| the parsed json schema message
|
| Notes
| -----
| This information and other
| `Allen Brain Atlas Data Portal Data Model <http://help.brain-map.org/display/api/Data+Model>`_
| documentation is also available as a
| `Class Hierarchy <http://api.brain-map.org/class_hierarchy>`_
| and `Class List <http://api.brain-map.org/class_hierarchy>`_.
|
| read_data(self, parsed_json)
| Return the message data from the parsed query.
|
| Parameters
| ----------
| parsed_json : dict
| A python structure corresponding to the JSON data returned from the API.
|
| Notes
| -----
| See `API Response Formats - Response Envelope <http://help.brain-map.org/display/api/API+Response+Formats#APIResponseFormats-ResponseEnvelope>`_
| for additional documentation.
|
| retrieve_file_over_http(self, url, file_path)
| Get a file from the data api and save it.
|
| Parameters
| ----------
| url : string
| Url[1]_ from which to get the file.
| file_path : string
| Absolute path including the file name to save.
|
| See Also
| --------
| construct_well_known_file_download_url: Can be used to construct the url.
|
| References
| ----------
| .. [1] Allen Brain Atlas Data Portal: `Downloading a WellKnownFile <http://help.brain-map.org/display/api/Downloading+a+WellKnownFile>`_.
|
| retrieve_parsed_json_over_http(self, url, post=False)
| Get the document and put it in a Python data structure
|
| Parameters
| ----------
| url : string
| Full API query url.
| post : boolean
| True does an HTTP POST, False (default) encodes the URL and does a GET
|
| Returns
| -------
| dict
| Result document as parsed by the JSON library.
|
| retrieve_xml_over_http(self, url)
| Get the document and put it in a Python data structure
|
| Parameters
| ----------
| url : string
| Full API query url.
|
| Returns
| -------
| string
| Unparsed xml string.
|
| set_api_urls(self, api_base_url_string)
| Set the internal RMA and well known file download endpoint urls
| based on a api server endpoint.
|
| Parameters
| ----------
| api_base_url_string : string
| url of the api to point to
|
| set_default_working_directory(self, working_directory)
| Set the working directory where files will be saved.
|
| Parameters
| ----------
| working_directory : string
| the absolute path string of the working directory.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from allensdk.api.api.Api:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from allensdk.api.api.Api:
|
| default_api_url = 'http://api.brain-map.org'
|
| download_url = 'http://download.alleninstitute.org'