function tripal_cv_obo_load_typedefs
2.x tripal_cv.obo_loader.inc | tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) |
1.x obo_loader.inc | tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) |
OBO files are divided into a typedefs terms section and vocabulary 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
$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.
$jobid: The job_id of the job from the Tripal jobs management system.
Related topics
1 call to tripal_cv_obo_load_typedefs()
- 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 627 - Functions to aid in loading ontologies into the chado cv module
Code
function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
$sql = "SELECT * FROM {tripal_obo_temp} WHERE type = 'Typedef' ";
$typedefs = chado_query($sql);
$sql = "
SELECT count(*) as num_terms
FROM {tripal_obo_temp}
WHERE type = 'Typedef'
";
$result = chado_query($sql)->fetchObject();
$count = $result->num_terms;
// calculate the interval for updates
$interval = intval($count * 0.0001);
if ($interval < 1) {
$interval = 1;
}
$i = 0;
foreach ($typedefs as $typedef) {
$term = unserialize(base64_decode($typedef->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 + 33.33333333));
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
}
tripal_cv_obo_process_term($term, $defaultcv->name, 1, $newcvs, $default_db);
$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 + 33.33333333));
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
}
return 1;
}