function chado_feature_update
2.x tripal_feature.chado_node.inc | chado_feature_update($node) |
3.x tripal_feature.chado_node.inc | chado_feature_update($node) |
1.x tripal_feature.module | chado_feature_update($node) |
Related topics
File
- tripal_feature/
tripal_feature.module, line 526 - @todo Add file header description
Code
function chado_feature_update($node) {
if ($node->revision) {
// there is no way to handle revisions in Chado but leave
// this here just to make not we've addressed it.
}
$residues = preg_replace("/[\n\r\s]/", "", $node->residues);
$obsolete = 'FALSE';
if ($node->is_obsolete) {
$obsolete = 'TRUE';
}
// get the feature type id
$values = array(
'cv_id' => array(
'name' => 'sequence'
),
'name' => $node->feature_type
);
$type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
$feature_id = chado_get_id_for_node('feature', $node);
if (sizeof($type) > 0) {
$match = array(
'feature_id' => $feature_id,
);
$values = array(
'organism_id' => $node->organism_id,
'name' => $node->fname,
'uniquename' => $node->uniquename,
'residues' => $residues,
'seqlen' => drupal_strlen($residues),
'is_obsolete' => $obsolete,
'type_id' => $type[0]->cvterm_id,
'md5checksum' => md5($residues)
);
$options = array('return_record' => TRUE);
$status = tripal_core_chado_update('feature', $match, $values, $options);
// add the genbank synonyms
chado_feature_add_synonyms($node->synonyms, $feature_id);
}
else {
drupal_set_message(t('Unable to update feature.'), 'warning');
watchdog('tripal_feature',
'Update feature: Unable to update feature where values: %values',
array('%values' => print_r($values, TRUE)),
WATCHDOG_WARNING
);
}
}