private function OBOImporter::oboEbiLookup

3.x OBOImporter.inc private OBOImporter::oboEbiLookup($accession, $type_of_search)

API call to Ontology Lookup Service provided by https://www.ebi.ac.uk/ols/docs/api#resources-terms

Parameters

accession: Accession term for query

type_of_search: Either ontology, term, query, or query-non-local

3 calls to OBOImporter::oboEbiLookup()
OBOImporter::addRelationship in tripal_chado/includes/TripalImporter/OBOImporter.inc
Adds a cvterm relationship
OBOImporter::loadOBO_v1_2 in tripal_chado/includes/TripalImporter/OBOImporter.inc
Imports a given OBO file into Chado. This function is usually called by one of three wrapper functions: loadOBO_v1_2_id, loadOBO_v1_2_file or tirpal_cv_load_obo_v1_2_url. But, it can be called directly if the full path to an OBO file is available on…
OBOImporter::processTerm in tripal_chado/includes/TripalImporter/OBOImporter.inc
Uses the provided term array to add/update information to Chado about the term including the term, dbxref, synonyms, properties, and relationships.

File

tripal_chado/includes/TripalImporter/OBOImporter.inc, line 1476

Class

OBOImporter

Code

private function oboEbiLookup($accession, $type_of_search) {
  //Grab just the ontology from the $accession.
  $parts = explode(':', $accession);
  $ontology = strtolower($parts[0]);
  $ontology = preg_replace('/\s+/', '', $ontology);
  if ($type_of_search == 'ontology') {
    $options = array();
    $full_url = 'http://www.ebi.ac.uk/ols/api/ontologies/' . $ontology;
    $response = drupal_http_request($full_url, $options);
    if (!empty($response)) {
      $response = drupal_json_decode($response->data);
    }
  }
  elseif ($type_of_search == 'term') {
    //The IRI of the terms, this value must be double URL encoded
    $iri = urlencode(urlencode("http://purl.obolibrary.org/obo/" . str_replace(':', '_', $accession)));
    $options = array();
    $full_url = 'http://www.ebi.ac.uk/ols/api/ontologies/' . $ontology . '/' . 'terms/' . $iri;
    $response = drupal_http_request($full_url, $options);
    if (!empty($response)) {
      $response = drupal_json_decode($response->data);
    }
  }
  elseif ($type_of_search == 'query') {
    $options = array();
    $full_url = 'http://www.ebi.ac.uk/ols/api/search?q=' . $accession . '&queryFields=obo_id&local=true';
    $response = drupal_http_request($full_url, $options);
    if (!empty($response)) {
      $response = drupal_json_decode($response->data);
    }
  }
  elseif ($type_of_search == 'query-non-local') {
    $options = array();
    $full_url = 'http://www.ebi.ac.uk/ols/api/search?q=' . $accession . '&queryFields=obo_id';
    $response = drupal_http_request($full_url, $options);
    if (!empty($response)) {
      $response = drupal_json_decode($response->data);
    }
  }
  return $response;
}