NOTE see the comments about the two styles of wrappers on the API wrappers page. This page only describes the “thick” wrapper.
OTI
oti indexes the values in the study nexson files managed by the phylesystem-api. This enables fast searching for text in different fields of the file. In v2 of the Open Tree API, it provides the [domains]/studies/*
methods.
Usage
The code examples below assume that you have created a wrapper via some action like:
from peyotl.api import APIWrapper
oti = APIWrapper().oti
Attributes
oti.study_search_term_set
is a read-only property that gives the set of terms that can be use to search for studiesoti.tree_search_term_set
is a read-only property that gives the set of terms that can be use to search for treesoti.find_trees(query_dict, exact=<bool>, verbose=<bool>)
searches for a set of trees matching a query where the key in thequery_dict
is the name of the property to be searched and the value in the dict is the value that the property must have in order for the tree to match. For example:oti.find_trees({'ot:ottTaxonName': 'Aponogeton ulvaceus'})
would return a record for every tree that has a taxon mapped to the ott taxon with the name “Aponogeton ulvaceus”.oti.find_trees(prop=val, exact=<bool>, verbose=<bool>)
is a shorthand for searching for property"ot:<prop>"
with valueval
. The preceding example would be:oti.find_trees(ottTaxonName='Aponogeton ulvaceus'})
Note that the python rules for argument names mean that theot:
prefix must be removed from the property when you use this shorthand. It is added by the wrapper, so only ‘ot:’ properties can be searched with this trickoti.find_studies(...)
supports the same two styles of invocation that asfind_trees
oti.find_all_studies(verbose=<bool>)
returns a record for every study.
TODO
- the wrapper calls should migrate to using the v2 API.
- Some output specifier (like the PhyloSchema could be used to obviate the need for
verbose
in the queries while providing more flexibility. - Chaining these calls to the phylesytem-api’s GET could be more convenient.
- Some sort of query language would allow for richer queries (intersections, unions…)