function tripal_cv_obo_add_relationship
2.x tripal_cv.obo_loader.inc | tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
$objname, $object_is_relationship = 0, $default_db = 'OBO_REL') |
1.x obo_loader.inc | tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
$objname, $object_is_relationship = 0, $default_db = 'OBO_REL') |
Adds a cvterm relationship
@object_is_relationship Set to 1 if this term is a relationship term @default_db The name of the default database.
Parameters
$cvterm: A database object for the cvterm
$rel: The relationship name
$objname: The relationship term name
$defaultcv: A database object containing a record from the cv table for the default controlled vocabulary
Related topics
1 call to tripal_cv_obo_add_relationship()
- tripal_cv_obo_process_term in tripal_cv/
includes/ tripal_cv.obo_loader.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_cv/
includes/ tripal_cv.obo_loader.inc, line 947 - Functions to aid in loading ontologies into the chado cv module
Code
function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
$objname, $object_is_relationship = 0, $default_db = 'OBO_REL') {
// make sure the relationship cvterm exists
$term = array(
'name' => $rel,
'id' => "$default_db:$rel",
'definition' => '',
'is_obsolete' => 0,
'cv_name' => $defaultcv,
'is_relationship' => TRUE,
'db_name' => $default_db
);
$relcvterm = tripal_insert_cvterm($term, array('update_existing' => FALSE));
if (!$relcvterm) {
tripal_cv_obo_quiterror("Cannot find the relationship term in the current ontology: $rel\n");
}
// get the object term
$oterm = tripal_cv_obo_get_term($objname);
if (!$oterm) {
tripal_cv_obo_quiterror("Could not find object term $objname\n");
}
$objterm = array();
$objterm['id'] = $oterm['id'][0];
$objterm['name'] = $oterm['name'][0];
if (array_key_exists('def', $oterm)) {
$objterm['definition'] = $oterm['def'][0];
}
if (array_key_exists('subset', $oterm)) {
$objterm['subset'] = $oterm['subset'][0];
}
if (array_key_exists('namespace', $oterm)) {
$objterm['namespace'] = $oterm['namespace'][0];
}
if (array_key_exists('is_obsolete', $oterm)) {
$objterm['is_obsolete'] = $oterm['is_obsolete'][0];
}
$objterm['cv_name'] = $defaultcv;
$objterm['is_relationship'] = $object_is_relationship;
$objterm['db_name'] = $default_db;
$objcvterm = tripal_insert_cvterm($objterm, array('update_existing' => TRUE));
if (!$objcvterm) {
tripal_cv_obo_quiterror("Cannot add cvterm " . $oterm['name'][0]);
}
// check to see if the cvterm_relationship already exists, if not add it
$values = array(
'type_id' => $relcvterm->cvterm_id,
'subject_id' => $cvterm->cvterm_id,
'object_id' => $objcvterm->cvterm_id
);
$result = chado_select_record('cvterm_relationship', array('*'), $values);
if (count($result) == 0) {
$options = array('return_record' => FALSE);
$success = chado_insert_record('cvterm_relationship', $values, $options);
if (!$success) {
tripal_cv_obo_quiterror("Cannot add term relationship: '$cvterm->name' $rel '$objcvterm->name'");
}
}
return TRUE;
}