function tripal_feature_load_gff3_property
2.x tripal_feature.gff_loader.inc | tripal_feature_load_gff3_property($feature, $property, $value) |
1.x gff_loader.inc | tripal_feature_load_gff3_property($feature, $property, $value) |
Related topics
1 call to tripal_feature_load_gff3_property()
- tripal_feature_load_gff3 in tripal_feature/
includes/ gff_loader.inc
File
- tripal_feature/
includes/ gff_loader.inc, line 1737 - @todo Add file header description
Code
function tripal_feature_load_gff3_property($feature, $property, $value) {
// first make sure the cvterm exists. if not, then add it
$select = array(
'name' => $property,
'cv_id' => array(
'name' => 'feature_property',
),
);
$options = array('statement_name' => 'sel_cvterm_name_cvid');
$result = tripal_core_chado_select('cvterm', array('*'), $select, $options);
// if we don't have a property like this already, then add it otherwise, just return
if (count($result) == 0) {
$term = array(
'id' => "null:$property",
'name' => $property,
'namespace' => 'feature_property',
'is_obsolete' => 0,
);
$cvterm = (object) tripal_cv_add_cvterm($term, 'feature_property', 0, 0);
if (!$cvterm) {
watchdog("T_gff3_loader", "Cannot add cvterm, $property", array(), WATCHDOG_WARNING);
return 0;
}
}
else {
$cvterm = $result[0];
}
// check to see if the property already exists for this feature
// if it does but the value is unique then increment the rank and add it.
// if the value is not unique then don't add it.
$add = 1;
$rank = 0;
$select = array(
'feature_id' => $feature->feature_id,
'type_id' => $cvterm->cvterm_id,
);
$options = array(
'statement_name' => 'sel_featureprop_featureid_typeid',
'order_by' => array(
'rank' => 'ASC',
),
);
$results = tripal_core_chado_select('featureprop', array('*'), $select, $options);
foreach ($results as $prop) {
if (strcmp($prop->value, $value) == 0) {
$add = NULL; // don't add it, it already exists
}
$rank = $prop->rank + 1;
}
// add the property if we pass the check above
if ($add) {
$values = array(
'feature_id' => $feature->feature_id,
'type_id' => $cvterm->cvterm_id,
'value' => $value,
'rank' => $rank,
);
$options = array('statement_name' => 'ins_featureprop_all');
$result = tripal_core_chado_insert('featureprop', $values, $options);
if (!$result) {
watchdog("T_gff3_loader", "cannot add featureprop, $property", array(), WATCHDOG_WARNING);
}
}
}