function tripal_feature_load_gff3_derives_from
2.x tripal_feature.gff_loader.inc | tripal_feature_load_gff3_derives_from($feature, |
1.x gff_loader.inc | tripal_feature_load_gff3_derives_from($feature, $subject, $organism) |
Related topics
1 call to tripal_feature_load_gff3_derives_from()
- tripal_feature_load_gff3 in tripal_feature/
includes/ gff_loader.inc
File
- tripal_feature/
includes/ gff_loader.inc, line 931 - @todo Add file header description
Code
function tripal_feature_load_gff3_derives_from($feature, $subject, $organism) {
// get the subject type
$values = array(
'organism_id' => $organism->organism_id,
'uniquename' => $subject,
);
$options = array('statement_name' => 'sel_tripalgfftemp_orun');
$result = tripal_core_chado_select('tripal_gff_temp', array('type_name'), $values, $options);
if (count($result) == 0) {
watchdog("T_gff3_loader", "Cannot find subject type for feature in 'derives_from' relationship: %subject", array('%subject' => $subject), WATCHDOG_WARNING);
return '';
}
$subject_type = $result[0]->type_name;
// get the subject feature
$match = array(
'organism_id' => $organism->organism_id,
'uniquename' => $subject,
'type_id' => array(
'name' => $subject_type,
'cv_id' => array(
'name' => 'sequence'
),
),
);
$options = array('statement_name' => 'sel_feature_orunty');
$sfeature = tripal_core_chado_select('feature', array('feature_id'), $match, $options);
if (count($sfeature) == 0) {
watchdog('T_gff3_loader', "Could not add 'Derives_from' relationship " .
"for %uniquename and %subject. Subject feature, '%subject', " .
"cannot be found", array('%uniquename' => $feature->uniquename, '%subject' => $subject), WATCHDOG_ERROR);
return;
}
// now check to see if the relationship already exists
$values = array(
'object_id' => $sfeature[0]->feature_id,
'subject_id' => $feature->feature_id,
'type_id' => array(
'cv_id' => array(
'name' => 'relationship'
),
'name' => 'derives_from',
),
'rank' => 0
);
$options = array('statement_name' => 'sel_featurerelationship_objectid_subjectid_typeid_rank');
$rel = tripal_core_chado_select('feature_relationship', array('*'), $values, $options);
if (count($rel) > 0) {
return;
}
// finally insert the relationship if it doesn't exist
$options = array('statement_name' => 'ins_featurerelationship_objectid_subjectid_typeid_rank');
$ret = tripal_core_chado_insert('feature_relationship', $values, $options);
if (!$ret) {
watchdog("T_gff3_loader", "Could not add 'Derives_from' relationship for $feature->uniquename and $subject",
array(), WATCHDOG_WARNING);
}
}