function tripal_cv_obo_process_terms
2.x tripal_cv.obo_loader.inc | tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) |
1.x obo_loader.inc | tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) |
OBO files are divided into a typedefs section and a terms section. This function loads the typedef terms from the OBO.
Parameters
$defaultcv: A database object containing a record from the cv table for the default controlled vocabulary
$jobid: The job_id of the job from the Tripal jobs management system.
$newcvs: An associative array of controlled vocabularies for this OBO. The key must be the name of the vocabulary and the value the cv_id from the cv table of chado.
$default_db: The name of the default database.
Related topics
1 call to tripal_cv_obo_process_terms()
- tripal_cv_load_obo_v1_2 in tripal_cv/
includes/ tripal_cv.obo_loader.inc - Imports a given OBO file into Chado. This function is usually called by one of three wrapper functions: tripal_cv_load_obo_v1_2_id, tripal_cv_load_obo_v1_2_file or tirpal_cv_load_obo_v1_2_url. But, it can be called directly if the full path to an…
File
- tripal_cv/
includes/ tripal_cv.obo_loader.inc, line 689 - Functions to aid in loading ontologies into the chado cv module
Code
function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) {
$i = 0;
// iterate through each term from the OBO file and add it
$sql = "
SELECT * FROM {tripal_obo_temp}
WHERE type = 'Term'
ORDER BY id
";
$terms = chado_query($sql);
$sql = "
SELECT count(*) as num_terms
FROM {tripal_obo_temp}
WHERE type = 'Term'
";
$result = chado_query($sql)->fetchObject();
$count = $result->num_terms;
// calculate the interval for updates
$interval = intval($count * 0.0001);
if ($interval < 1) {
$interval = 1;
}
foreach ($terms as $t) {
$term = unserialize(base64_decode($t->stanza));
// update the job status every interval
if ($jobid and $i % $interval == 0) {
$complete = ($i / $count) * 33.33333333;
tripal_set_job_progress($jobid, intval($complete + 66.666666));
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
}
// add/update this term
if (!tripal_cv_obo_process_term($term, $defaultcv->name, 0, $newcvs, $default_db)) {
tripal_cv_obo_quiterror("Failed to process terms from the ontology");
}
$i++;
}
// set the final status
if ($jobid) {
if ($count > 0) {
$complete = ($i / $count) * 33.33333333;
}
else {
$complete = 33.33333333;
}
tripal_set_job_progress($jobid, intval($complete + 66.666666));
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
}
return 1;
}