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) |
Implements hook_update().
Related topics
File
- tripal_feature/
includes/ tripal_feature.chado_node.inc, line 511 - Implementation of hooks to create a feature content type
Code
function chado_feature_update($node) {
$node->uniquename = trim($node->uniquename);
$node->fname = trim($node->fname);
$node->feature_type = trim($node->feature_type);
$node->residues = trim($node->residues);
$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 = chado_select_record('cvterm', array('cvterm_id'), $values);
$feature_id = chado_get_id_from_nid('feature', $node->nid);
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 = chado_update_record('feature', $match, $values, $options);
// add the genbank synonyms
chado_feature_add_synonyms($node->synonyms, $feature_id);
// * Properties Form *
$details = array(
'property_table' => 'featureprop', // the name of the prop table
'base_table' => 'feature', // the name of your chado base table
'foreignkey_name' => 'feature_id', // the name of the key in your base table
'foreignkey_value' => $feature_id // the value of the feature_id key
);
chado_update_node_form_properties($node, $details);
// * Additional DBxrefs Form *
$details = array(
'linking_table' => 'feature_dbxref', // the name of your _dbxref table
'foreignkey_name' => 'feature_id', // the name of the key in your base table
'foreignkey_value' => $feature_id // the value of the feature_id key
);
chado_update_node_form_dbxrefs($node, $details);
// * Relationships Form *
$details = array(
'relationship_table' => 'feature_relationship',
'foreignkey_value' => $feature_id
);
chado_update_node_form_relationships($node, $details);
}
else {
drupal_set_message(t('Unable to update feature.'), 'warning');
tripal_report_error('tripal_feature', TRIPAL_WARNING,
'Update feature: Unable to update feature where values: %values',
array('%values' => print_r($values, TRUE))
);
}
}