function tripal_feature_load_organism_feature_browser
1.x tripal_feature.module | tripal_feature_load_organism_feature_browser($organism) |
Related topics
1 call to tripal_feature_load_organism_feature_browser()
File
- tripal_feature/
tripal_feature.module, line 1501 - @todo Add file header description
Code
function tripal_feature_load_organism_feature_browser($organism) {
if (!$organism) {
return array();
}
// don't show the browser if the settings in the admin page is turned off
// instead return the array indicating the status of the browser
$show_browser = variable_get('tripal_feature_browse_setting', 'show_feature_browser');
if (strcmp($show_browser, 'show_feature_browser') != 0) {
return array('enabled' => FALSE);
}
// get the list of available sequence ontology terms for which
// we will build drupal pages from features in chado. If a feature
// is not one of the specified typse we won't build a node for it.
$allowed_types = variable_get('chado_browser_feature_types', 'EST contig');
$allowed_types = preg_replace("/[\s\n\r]+/", " ", $allowed_types);
$so_terms = split(' ', $allowed_types);
// perform the query
$values = array(
'organism_id' => $organism->organism_id,
'type_id' => array(
'name' => $so_terms
),
);
$columns = array('feature_id', 'name', 'uniquename', 'type_id');
$options = array(
'pager' => array('limit' => 10, 'element' => 0),
'order_by' => array('name' => 'ASC'),
);
$features = tripal_core_chado_select('feature', $columns, $values, $options);
$pager = theme('pager');
// add the node ids and types
$nsql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
$tsql = "SELECT name FROM {cvterm} WHERE cvterm_id = %d";
foreach ($features as $feature) {
$node = db_fetch_object(db_query($nsql, $feature->feature_id));
$type = db_fetch_object(chado_query($tsql, $feature->type_id));
$feature->nid = $node->nid;
$feature->type_name = $type->name;
}
return array('features' => $features, 'pager' => $pager, 'enabled' => TRUE);
}