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) |
Load a preoprty (featurepop) for the feature
Parameters
$feature:
$property:
$value:
Related topics
1 call to tripal_feature_load_gff3_property()
- tripal_feature_load_gff3 in tripal_feature/
includes/ tripal_feature.gff_loader.inc - Actually load a GFF3 file. This is the function called by tripal jobs
File
- tripal_feature/
includes/ tripal_feature.gff_loader.inc, line 2012 - Provides gff3 loading functionality. Creates features based on their specification in a GFF3 file.
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',
),
);
$result = chado_select_record('cvterm', array('*'), $select);
// 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,
'cv_name' => 'feature_property',
'is_relationship' => FALSE
);
$cvterm = (object) tripal_insert_cvterm($term, array('update_existing' => FALSE));
if (!$cvterm) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add cvterm, $property", array());
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(
'order_by' => array(
'rank' => 'ASC',
),
);
$results = chado_select_record('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,
);
$result = chado_insert_record('featureprop', $values);
if (!$result) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "cannot add featureprop, $property", array());
}
}
}