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) |
Load the derives from attribute for a gff3 feature
Parameters
$feature:
$subject:
$organism:
Related topics
1 call to tripal_feature_load_gff3_derives_from()
- 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 1161 - Provides gff3 loading functionality. Creates features based on their specification in a GFF3 file.
Code
function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
$organism, $fmin, $fmax) {
$type = $cvterm->name;
// First look for the object feature in the temp table to get it's type.
$values = array(
'organism_id' => $organism->organism_id,
'uniquename' => $object,
);
$result = chado_select_record('tripal_gff_temp', array('type_name'), $values);
$type_id = NULL;
if (count($result) > 0) {
$otype = tripal_get_cvterm(array(
'name' => $result[0]->type_name,
'cv_id' => array(
'name' => 'sequence'
)
));
if ($otype) {
$type_id = $otype->cvterm_id;
}
}
// If the object wasn't in the temp table then look for it in the
// feature table and get it's type.
if (!$type_id) {
$result = chado_select_record('feature', array('type_id'), $values);
if (count($result) > 1) {
watchdog("tripal_feature", "Cannot find feature type for, '%subject' , in 'derives_from' relationship. Multiple matching features exist with this uniquename.",
array('%subject' => $object), WATCHDOG_WARNING);
return '';
}
else if (count($result) == 0) {
watchdog("tripal_feature", "Cannot find feature type for, '%subject' , in 'derives_from' relationship.",
array('%subject' => $object), WATCHDOG_WARNING);
return '';
}
else {
$type_id = $result->type_id;
}
}
// Get the object feature.
$match = array(
'organism_id' => $organism->organism_id,
'uniquename' => $object,
'type_id' => $type_id,
);
$ofeature = chado_select_record('feature', array('feature_id'), $match);
if (count($ofeature) == 0) {
tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not add 'Derives_from' relationship " .
"for %uniquename and %subject. Subject feature, '%subject', " .
"cannot be found", array('%uniquename' => $feature->uniquename, '%subject' => $subject));
return;
}
// If this feature is a protein then add it to the tripal_gffprotein_temp.
if ($type == 'protein' or $type == 'polypeptide') {
$values = array(
'feature_id' => $feature->feature_id,
'parent_id' => $ofeature[0]->feature_id,
'fmin' => $fmin,
'fmax' => $fmax
);
$result = chado_insert_record('tripal_gffprotein_temp', $values);
if (!$result) {
tripal_report_error('tripal_feature', TRIPAL_ERROR, "Cound not save record in temporary protein table, Cannot continue.", array());
exit;
}
}
// Now check to see if the relationship already exists. If it does
// then just return.
$values = array(
'object_id' => $ofeature[0]->feature_id,
'subject_id' => $feature->feature_id,
'type_id' => array(
'cv_id' => array(
'name' => 'sequence'
),
'name' => 'derives_from',
),
'rank' => 0
);
$rel = chado_select_record('feature_relationship', array('*'), $values);
if (count($rel) > 0) {
return;
}
// finally insert the relationship if it doesn't exist
$ret = chado_insert_record('feature_relationship', $values);
if (!$ret) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not add 'Derives_from' relationship for $feature->uniquename and $subject",
array());
}
}