function tripal_cv_load_obo_v1_2_url

2.x tripal_cv.obo_loader.inc tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = TRUE)
1.x obo_loader.inc tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = TRUE)

A wrapper function for importing the user specified OBO file into Chado by specifying the remote URL of the OBO. It requires that the file be in OBO v1.2 compatible format. This function is typically executed via the Tripal jobs management after a user submits a job via the Load Onotloies form.

Parameters

$obo_name: The name of the OBO (typially the ontology or controlled vocabulary name)

$url: The remote URL of the OBO file.

$job_id: The job_id of the job from the Tripal jobs management system.

$is_new: Set to TRUE if this is a new ontology that does not yet exist in the tripal_cv_obo table. If TRUE the OBO will be added to the table.

Related topics

1 call to tripal_cv_load_obo_v1_2_url()
tripal_cv_load_obo_v1_2_id in tripal_cv/includes/tripal_cv.obo_loader.inc
A wrapper function for importing the user specified OBO file into Chado by specifying the obo_id of the OBO. It requires that the file be in OBO v1.2 compatible format. This function is typically executed via the Tripal jobs management after a user…

File

tripal_cv/includes/tripal_cv.obo_loader.inc, line 437
Functions to aid in loading ontologies into the chado cv module

Code

function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = TRUE) {

  $newcvs = array();

  // first download the OBO
  $temp = tempnam(sys_get_temp_dir(), 'obo_');
  print "Downloading URL $url, saving to $temp\n";
  $url_fh = fopen($url, "r");
  $obo_fh = fopen($temp, "w");
  if (!$url_fh) {
    tripal_cv_obo_quiterror("Unable to download the remote OBO file at $url. Could a firewall be blocking outgoing connections? " .
    " if you are unable to download the file you may manually downlod the OBO file and use the web interface to " .
      " specify the location of the file on your server.");

  }
  while (!feof($url_fh)) {
    fwrite($obo_fh, fread($url_fh, 255), 255);
  }
  fclose($url_fh);
  fclose($obo_fh);

  if ($is_new) {
    tripal_insert_obo($obo_name, $url);
  }

  // second, parse the OBO
  $success = tripal_cv_load_obo_v1_2($temp, $jobid, $newcvs);
  if ($success) {

    // update the cvtermpath table
    tripal_cv_load_update_cvtermpath($newcvs, $jobid);
    print "Done\n";
  }
  // now remove the temp file
  unlink($temp);
}