function tripal_feature_load_gff3_feature
2.x tripal_feature.gff_loader.inc | tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uniquename,
$name, $residues, $is_analysis = 'f', $is_obsolete = 'f', $add_only, $score) |
1.x gff_loader.inc | tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uniquename,
$name, $residues, $is_analysis = 'f', $is_obsolete = 'f', $add_only, $score) |
Create the feature record & link it to it's analysis
Parameters
$organism:
$analysis_id:
$cvterm:
$uniquename:
$name:
$residues:
$is_analysis:
$is_obsolete:
$add_only:
$score:
Related topics
1 call to tripal_feature_load_gff3_feature()
- 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 1704 - Provides gff3 loading functionality. Creates features based on their specification in a GFF3 file.
Code
function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uniquename,
$name, $residues, $is_analysis = 'f', $is_obsolete = 'f', $add_only, $score) {
// Check to see if the feature already exists.
$feature = NULL;
$fselect = array(
'organism_id' => $organism->organism_id,
'uniquename' => $uniquename,
'type_id' => $cvterm->cvterm_id
);
$columns = array('feature_id', 'name', 'uniquename', 'seqlen', 'organism_id', 'type_id');
$result = chado_select_record('feature', $columns, $fselect);
if (count($result) > 0) {
$feature = $result[0];
}
if (strcmp($is_obsolete, 'f') == 0 or $is_obsolete == 0) {
$is_obsolete = 'FALSE';
}
if (strcmp($is_obsolete, 't') == 0 or $is_obsolete == 1) {
$is_obsolete = 'TRUE';
}
if (strcmp($is_analysis, 'f') == 0 or $is_analysis == 0) {
$is_analysis = 'FALSE';
}
if (strcmp($is_analysis, 't') == 0 or $is_analysis == 1) {
$is_analysis = 'TRUE';
}
// Insert the feature if it does not exist otherwise perform an update.
if (!$feature) {
$values = array(
'organism_id' => $organism->organism_id,
'name' => $name,
'uniquename' => $uniquename,
'md5checksum' => md5($residues),
'type_id' => $cvterm->cvterm_id,
'is_analysis' => $is_analysis,
'is_obsolete' => $is_obsolete,
);
$feature = (object) chado_insert_record('feature', $values);
if (!$feature) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert feature '$uniquename' ($cvterm->name)", array());
return 0;
}
}
elseif (!$add_only) {
$values = array(
'name' => $name,
'md5checksum' => md5($residues),
'is_analysis' => $is_analysis,
'is_obsolete' => $is_obsolete,
);
$match = array(
'organism_id' => $organism->organism_id,
'uniquename' => $uniquename,
'type_id' => $cvterm->cvterm_id,
);
$result = chado_update_record('feature', $match, $values);
if (!$result) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to update feature '$uniquename' ($cvterm->name)", array());
return 0;
}
}
else {
// The feature exists and we don't want to update it so return
// a value of 0. This will stop all downstream property additions
return $feature;
}
// Add the analysisfeature entry to the analysisfeature table if
// it doesn't already exist.
$af_values = array(
'analysis_id' => $analysis_id,
'feature_id' => $feature->feature_id
);
$afeature = chado_select_record('analysisfeature', array('analysisfeature_id'), $af_values);
if (count($afeature) == 0) {
// if a score is available then set that to be the significance field
if (strcmp($score, '.') != 0) {
$af_values['significance'] = $score;
}
if (!chado_insert_record('analysisfeature', $af_values)) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not add analysisfeature record: $analysis_id, $feature->feature_id", array());
}
}
else {
// if a score is available then set that to be the significance field
$new_vals = array();
if (strcmp($score, '.') != 0) {
$new_vals['significance'] = $score;
}
else {
$new_vals['significance'] = '__NULL__';
}
if (!$add_only) {
$ret = chado_update_record('analysisfeature', $af_values, $new_vals);
if (!$ret) {
tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not update analysisfeature record: $analysis_id, $feature->feature_id", array());
}
}
}
return $feature;
}