function tripal_cv_get_cvterm_by_name
2.x tripal_cv.DEPRECATED.inc | tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal') |
3.x tripal_cv.DEPRECATED.inc | tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal') |
1.x tripal_cv.api.inc | tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal') |
Retrieve a chado cvterm object with a given name
Parameters
$name: the cvterm.name
$cv_id: the cv_id of the term you are looking for
$cv_name: the name of the CV
Return value
cvterm array or FALSE on error
Related topics
6 calls to tripal_cv_get_cvterm_by_name()
- chado_feature_validate in tripal_feature/
tripal_feature.module - tripal_contact_add_contact in tripal_contact/
api/ tripal_contact.api.inc - Adds a contact to the Chado contact table
- tripal_pub_add_publication in tripal_pub/
api/ tripal_pub.api.inc - Adds a new publication to the Chado, along with all properties and database cross-references. If the publication does not already exist in Chado then it is added. If it does exist nothing is done. If the $update parameter is TRUE then theā¦
- tripal_pub_PMID_parse_publication_type in tripal_pub/
includes/ importers/ PMID.inc - tripal_stock_add_ONE_property_form in tripal_stock/
includes/ tripal_stock-properties.inc
File
- tripal_cv/
api/ tripal_cv.api.inc, line 223 - Controlled Vocabulary API
Code
function tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal') {
if ($cv_id) {
$values = array(
'name' => $name,
'cv_id' => $cv_id,
);
$options = array(
'statement_name' => 'sel_cvterm_nacv',
'case_insensitive_columns' => array('name')
);
$r = tripal_core_chado_select('cvterm', array('*'), $values, $options);
}
elseif ($cv_name) {
$values = array(
'name' => $name,
'cv_id' => array(
'name' => $cv_name,
),
);
$options = array(
'statement_name' => 'sel_cvterm_nacv',
'case_insensitive_columns' => array('name')
);
$r = tripal_core_chado_select('cvterm', array('*'), $values, $options);
}
else {
$values = array(
'name' => $name,
);
$options = array(
'statement_name' => 'sel_cvterm_na',
'case_insensitive_columns' => array('name')
);
$r = tripal_core_chado_select('cvterm', array('*'), $values, $options);
}
if (!$r) {
return FALSE;
}
if (count($r) > 1) {
watchdog('tripal_cv', "Cannot find a unique term for the term '%name' in the vocabulary '%cv'. Multiple entries exist for this name",
array('%name' => $name, '%cv' => $cv_name ? $cv_name : $cv_id), WATCHDOG_ERROR);
return FALSE;
}
if (count($r) == 0) {
return FALSE;
}
return $r[0];
}