'download_goterm_features',
'title' => t('Get GO Term Features'),
'page callback' => 'tripal_analysis_go_get_goterm_features',
'page arguments' => array(1,2),
'access arguments' => array('access chado_analysis_go content'),
'type' => MENU_CALLBACK
);
$items['tripal_analysis_go_org_charts'] = array(
'path' => 'tripal_analysis_go_org_charts',
'title' => t('Analysis GO Charts'),
'page callback' => 'tripal_analysis_go_org_charts',
'page arguments' => array(1),
'access arguments' => array('access chado_analysis_go content'),
'type' => MENU_CALLBACK
);
return $items;
}
/*******************************************************************************
* Set the permission types that the chado module uses. Essentially we
* want permissionis that protect creation, editing and deleting of chado
* data objects
*/
function tripal_analysis_go_perm(){
return array(
'access chado_analysis_go content',
'create chado_analysis_go content',
'delete chado_analysis_go content',
'edit chado_analysis_go content',
);
}
/*******************************************************************************
* The following function proves access control for users trying to
* perform actions on data managed by this module
*/
function chado_analysis_go_access($op, $node, $account){
if ($op == 'create') {
return user_access('create chado_analysis_go content', $account);
}
if ($op == 'update') {
if (user_access('edit chado_analysis_go content', $account)) {
return TRUE;
}
}
if ($op == 'delete') {
if (user_access('delete chado_analysis_go content', $account)) {
return TRUE;
}
}
if ($op == 'view') {
if (user_access('access chado_analysis_go content', $account)) {
return TRUE;
}
}
return FALSE;
}
/*******************************************************************************
*
*/
function tripal_analysis_go_block($op = 'list', $delta = 0, $edit=array()){
switch($op) {
case 'list':
$blocks['tago_org_sum']['info'] = t('Tripal Organism GO Analysis Report');
$blocks['tago_org_sum']['cache'] = BLOCK_NO_CACHE;
return $blocks;
case 'view':
if(user_access('access chado_analysis_go content') and arg(0) == 'node' and is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load($nid);
$block = array();
switch($delta){
case 'tago_org_sum':
$block['subject'] = t('GO Summary');
$block['content'] = theme('tripal_analysis_go_org_summary',$node);
break;
default :
}
return $block;
}
}
}
/*******************************************************************************
* HOOK: Implementation of hook_nodeapi()
* Display library information for associated features or organisms
* This function also provides contents for indexing
*/
function tripal_analysis_go_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
if ($teaser) {
return;
}
// add the library to the organism/feature search indexing
if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
$node->content['tripal_analysis_go_search_index'] = array(
'#value' => theme('tripal_analysis_go_search_index',$node),
'#weight' => 5,
);
} else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
$node->content['tripal_analysis_go_search_result'] = array(
'#value' => theme('tripal_analysis_go_search_result',$node),
'#weight' => 5,
);
} else {
// Show go terms if the organism/feature is not at teaser view
switch($node->type){
case 'chado_organism':
$node->content['tripal_organism_go_summary'] = array(
'#value' => theme('tripal_organism_go_summary',$node),
'#weight' => 5,
);
break;
case 'chado_feature':
$node->content['tripal_feature_go_terms'] = array(
'#value' => theme('tripal_feature_go_terms',$node),
'#weight' => 5,
);
break;
}
}
break;
}
}
/************************************************************************
* We need to let drupal know about our theme functions and their arguments.
* We create theme functions to allow users of the module to customize the
* look and feel of the output generated in this module
*/
function tripal_analysis_go_theme () {
return array(
'tripal_analysis_go_search_index' => array (
'arguments' => array('node'),
),
'tripal_analysis_go_search_result' => array (
'arguments' => array('node'),
),
'tripal_organism_go_summary' => array (
'arguments' => array('node'=> null),
'template' => 'tripal_organism_go_summary',
),
'tripal_feature_go_terms' => array (
'arguments' => array('node'=> null),
'template' => 'tripal_feature_go_terms',
)
);
}
/************************************************************************
*/
function theme_tripal_analysis_go_search_index($node){
}
/************************************************************************
*/
function theme_tripal_analysis_go_search_result($node){
}
/************************************************************************
*/
function tripal_analysis_go_preprocess_tripal_feature_go_terms(&$variables){
$feature = $variables['node']->feature;
$variables['tripal_analysis_go']['terms'] = tripal_analysis_go_load_feature_terms($feature);
}
/************************************************************************
*/
function tripal_analysis_go_preprocess_tripal_organism_go_summary(&$variables){
$node = $variables['node'];
$variables['tripal_analysis_go']['select_form'] = tripal_analysis_go_load_organism_go_summary($node);
}
/************************************************************************
*/
function tripal_analysis_go_select_form(&$form_state = NULL,$node){
$form = array();
// find analyses that have GO terms
$sql = "
SELECT DISTINCT A.analysis_id, A.name, GCA.organism_id
FROM {go_count_analysis} GCA
INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
WHERE organism_id = %d
ORDER BY analysis_id DESC
";
$previous_db = tripal_db_set_active('chado');
$results = db_query($sql,$node->organism->organism_id);
tripal_db_set_active($previous_db);
$analyses = array();
$analyses[''] = '';
while($analysis = db_fetch_object($results)){
$analyses[$analysis->analysis_id."-".$analysis->organism_id] = "$analysis->name";
}
# create the select box
$form['tripal_analysis_go_select'] = array(
'#title' => t('Select a GO report to view'),
'#description' => t('Any analysis with GO results related to this organism are available for viewing. For further information, see the analysis information page.'),
'#type' => 'select',
'#options' => $analyses,
'#attributes' => array (
'onchange' => 'tripal_analysis_go_org_charts(this.options[this.selectedIndex].value)'
),
);
return $form;
}
/************************************************************************
*/
function tripal_analysis_go_org_charts ($element) {
$analysis_id = preg_replace("/^(\d+)-(\d+)$/","$1",$element);
$organism_id = preg_replace("/^(\d+)-(\d+)$/","$2",$element);
$content = '';
if($analysis_id and $organism_id){
$content = "
Biological Process
Expand the tree to browse term counts. Click a term to view term details.