tripal_analysis_go.module 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <?php
  2. //
  3. // Copyright 2009 Clemson University
  4. //
  5. function tripal_analysis_go_init(){
  6. // Add style sheet
  7. drupal_add_css(drupal_get_path('theme', 'tripal').
  8. '/css/tripal_analysis_go.css');
  9. drupal_add_js(drupal_get_path('theme', 'tripal').
  10. '/js/tripal_analysis_go.js');
  11. }
  12. /*******************************************************************************
  13. * Menu items are automatically added for the new node types created
  14. * by this module to the 'Create Content' Navigation menu item. This function
  15. * adds more menu items needed for this module.
  16. */
  17. function tripal_analysis_go_menu() {
  18. $items = array();
  19. $items['node/%/goterms'] = array(
  20. 'title' => t('GO Analysis'),
  21. 'page callback' => 'tripal_analysis_go_organism_goterms',
  22. 'page arguments' => array(1),
  23. 'access callback' => 'tripal_analysis_go_node_has_menu',
  24. 'access arguments' => array('access chado_analysis_go content',1),
  25. 'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM
  26. );
  27. $items['download_goterm_features'] = array(
  28. 'path' => 'download_goterm_features',
  29. 'title' => t('Get GO Term Features'),
  30. 'page callback' => 'tripal_analysis_go_get_goterm_features',
  31. 'page arguments' => array(1,2),
  32. 'access arguments' => array('access chado_analysis_go content'),
  33. 'type' => MENU_CALLBACK
  34. );
  35. $items['tripal_analysis_go_org_charts'] = array(
  36. 'path' => 'tripal_analysis_go_org_charts',
  37. 'title' => t('Analysis GO Charts'),
  38. 'page callback' => 'tripal_analysis_go_org_charts',
  39. 'page arguments' => array(1),
  40. 'access arguments' => array('access chado_analysis_go content'),
  41. 'type' => MENU_CALLBACK
  42. );
  43. return $items;
  44. }
  45. /*******************************************************************************
  46. * Set the permission types that the chado module uses. Essentially we
  47. * want permissionis that protect creation, editing and deleting of chado
  48. * data objects
  49. */
  50. function tripal_analysis_go_perm(){
  51. return array(
  52. 'access chado_analysis_go content',
  53. 'create chado_analysis_go content',
  54. 'delete chado_analysis_go content',
  55. 'edit chado_analysis_go content',
  56. );
  57. }
  58. /*******************************************************************************
  59. * The following function proves access control for users trying to
  60. * perform actions on data managed by this module
  61. */
  62. function chado_analysis_go_access($op, $node, $account){
  63. if ($op == 'create') {
  64. return user_access('create chado_analysis_go content', $account);
  65. }
  66. if ($op == 'update') {
  67. if (user_access('edit chado_analysis_go content', $account)) {
  68. return TRUE;
  69. }
  70. }
  71. if ($op == 'delete') {
  72. if (user_access('delete chado_analysis_go content', $account)) {
  73. return TRUE;
  74. }
  75. }
  76. if ($op == 'view') {
  77. if (user_access('access chado_analysis_go content', $account)) {
  78. return TRUE;
  79. }
  80. }
  81. return FALSE;
  82. }
  83. /*******************************************************************************
  84. * Dynamic addition/removal of menu item
  85. */
  86. function tripal_analysis_go_node_has_menu($type,$vid){
  87. // check to see if this node is an organism node
  88. $sql = 'SELECT organism_id FROM {chado_organism} WHERE vid = %d';
  89. $result = db_query($sql, $vid);
  90. // menu status
  91. $box_status =variable_get("tripal_analysis_go-box-goterms","menu_off");
  92. // if this node is not an organism or a feature node then return false
  93. // we don't want the menu item to be shown, otherwise get the normal perms
  94. if($org_id = db_fetch_object($result)){
  95. if(strcmp($box_status,"menu_on")==0){
  96. return user_access($type);
  97. }
  98. } else {
  99. return FALSE;
  100. }
  101. }
  102. /*******************************************************************************
  103. * HOOK: Implementation of hook_nodeapi()
  104. * Display library information for associated features or organisms
  105. * This function also provides contents for indexing
  106. */
  107. function tripal_analysis_go_nodeapi(&$node, $op, $teaser, $page) {
  108. switch ($op) {
  109. // Note that this function only adds library view to an organism/feature
  110. // node. The view of a library node is controled by the theme *.tpl file
  111. case 'view':
  112. // Set the node types for showing library information
  113. $types_to_show = variable_get('tripal_analysis_go_setting',
  114. array('chado_feature','chado_organism'));
  115. // Abort if this node is not one of the types we should show.
  116. if (!in_array($node->type, $types_to_show, TRUE)) {
  117. // Turn the menu off if it's on
  118. $box_status = variable_get("tripal_analysis_go-box-goterms","menu_off");
  119. if (strcmp($box_status,"menu_on")==0 && $node->type =='chado_organism'){
  120. variable_set("tripal_analysis_go-box-goterms","menu_off");
  121. }
  122. break;
  123. }
  124. // Add library to the content item if it's not a teaser
  125. if (!$teaser) {
  126. // add the library to the organism/feature search indexing
  127. if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
  128. $node->content['tripal_analysis_go_search_index'] = array(
  129. '#value' => theme('tripal_analysis_go_search_index',$node),
  130. '#weight' => 5,
  131. );
  132. } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
  133. $node->content['tripal_analysis_go_search_result'] = array(
  134. '#value' => theme('tripal_analysis_go_search_result',$node),
  135. '#weight' => 5,
  136. );
  137. } else {
  138. // Show go terms if the organism/feature is not at teaser view
  139. $node->content['tripal_analysis_go_node_add'] = array(
  140. '#value' => theme('tripal_analysis_go_node_add', $node),
  141. '#weight' => 5
  142. );
  143. }
  144. }
  145. }
  146. }
  147. /************************************************************************
  148. * We need to let drupal know about our theme functions and their arguments.
  149. * We create theme functions to allow users of the module to customize the
  150. * look and feel of the output generated in this module
  151. */
  152. function tripal_analysis_go_theme () {
  153. return array(
  154. 'tripal_analysis_go_search_index' => array (
  155. 'arguments' => array('node'),
  156. ),
  157. 'tripal_analysis_go_search_result' => array (
  158. 'arguments' => array('node'),
  159. ),
  160. 'tripal_analysis_go_node_add' => array (
  161. 'arguments' => array('node'),
  162. )
  163. );
  164. }
  165. /************************************************************************
  166. */
  167. function theme_tripal_analysis_go_search_index($node){
  168. }
  169. /************************************************************************
  170. */
  171. function theme_tripal_analysis_go_search_result($node){
  172. }
  173. /************************************************************************
  174. */
  175. function theme_tripal_analysis_go_node_add($node){
  176. $content = '';
  177. if(strcmp($node->type,'chado_feature')==0){
  178. $content = tripal_analysis_go_feature_add($node);
  179. }
  180. if(strcmp($node->type,'chado_organism')==0){
  181. $box_status = variable_get("tripal_analysis_go-box-goterms","menu_off");
  182. if (strcmp($box_status,"menu_off")==0){
  183. $content = tripal_analysis_go_organism_add($node);
  184. }
  185. }
  186. return $content;
  187. }
  188. /************************************************************************
  189. */
  190. function tripal_analysis_go_organism_goterms($node) {
  191. $node = node_load($node);
  192. return tripal_analysis_go_organism_add($node);
  193. }
  194. /************************************************************************
  195. */
  196. function tripal_analysis_go_select_form(&$form_state = NULL,$node){
  197. $form = array();
  198. // find analyses that have GO terms
  199. $sql = "
  200. SELECT DISTINCT A.analysis_id, A.name, GCA.organism_id
  201. FROM {go_count_analysis} GCA
  202. INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
  203. WHERE organism_id = %d
  204. ORDER BY analysis_id DESC
  205. ";
  206. $previous_db = tripal_db_set_active('chado');
  207. $results = db_query($sql,$node->organism_id);
  208. tripal_db_set_active($previous_db);
  209. $analyses = array();
  210. $analyses[''] = '';
  211. while($analysis = db_fetch_object($results)){
  212. $analyses[$analysis->analysis_id."-".$analysis->organism_id] = "$analysis->name";
  213. }
  214. # create the select box
  215. $form['analysis_select'] = array(
  216. '#title' => t('Select a GO report to view'),
  217. '#description' => t('Any analysis with GO results related to this organism are available for viewing. For further information, see the analysis information page.'),
  218. '#type' => 'select',
  219. '#options' => $analyses,
  220. '#attributes' => array (
  221. 'onchange' => 'tripal_analysis_go_org_charts(this.options[this.selectedIndex].value)'
  222. ),
  223. );
  224. return $form;
  225. }
  226. /************************************************************************
  227. */
  228. function tripal_analysis_go_org_charts ($element) {
  229. $analysis_id = preg_replace("/^(\d+)-(\d+)$/","$1",$element);
  230. $organism_id = preg_replace("/^(\d+)-(\d+)$/","$2",$element);
  231. $content = '';
  232. if($analysis_id and $organism_id){
  233. $content = "
  234. <b>Biological Process</b>
  235. <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
  236. <div class=\"tripal_cv_tree\" id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_bp\"></div>
  237. <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_bp\" src=\"\" border=\"0\">
  238. <br><br><br><br>
  239. <b>Cellular Component</b>
  240. <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
  241. <div class=\"tripal_cv_tree\" id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_cc\"></div>
  242. <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_cc\" src=\"\" border=\"0\">
  243. <br><br><br><br>
  244. <b>Molecular Function</b>
  245. <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
  246. <div class=\"tripal_cv_tree\" id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_mf\"></div>
  247. <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_mf\" src=\"\" border=\"0\">
  248. ";
  249. }
  250. $opt = array($content);
  251. return drupal_json($opt);
  252. }
  253. /************************************************************************
  254. */
  255. function tripal_analysis_go_organism_add($node) {
  256. // Show GO information in a expandable box for a organism page.
  257. // Make sure we have $node->organism_id. In the case of creating a new
  258. // organism, the organism_id is not created until we save. This will cause
  259. // an error when users preview the creation without a $node->organism_id
  260. $box_status = variable_get("tripal_analysis_go-box-goterms","menu_off");
  261. if(strcmp($box_status,"menu_off")==0){
  262. $content .= "
  263. <div class=\"tripal_go_summary-info-box\">
  264. <div class=\"tripal_expandableBox\">
  265. <h3>Gene Ontology Summary</h3>
  266. </div>
  267. <div class=\"tripal_expandableBoxContent\">
  268. ";
  269. }
  270. // check to see if we have any analyses
  271. $sql = "
  272. SELECT DISTINCT A.analysis_id, A.name, GCA.organism_id
  273. FROM {go_count_analysis} GCA
  274. INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
  275. WHERE organism_id = %d
  276. ORDER BY analysis_id DESC
  277. ";
  278. $previous_db = tripal_db_set_active('chado');
  279. $results = db_fetch_object(db_query($sql,$node->organism_id));
  280. tripal_db_set_active($previous_db);
  281. if($results){
  282. $select_analysis = drupal_get_form('tripal_analysis_go_select_form',$node);
  283. $url = url("sites/all/themes/theme_tripal/images/ajax-loader.gif");
  284. $content .= "
  285. $select_analysis
  286. <div id=\"tripal_cv_cvterm_info_box\">
  287. <a href=\"#\" onclick=\"$('#tripal_cv_cvterm_info_box').hide()\" style=\"float: right\">Close [X]</a>
  288. <h3>Term Information</h3>
  289. <div id=\"tripal_cv_cvterm_info\"></div>
  290. </div>
  291. <div id=\"tripal_ajaxLoading\" style=\"display:none\">
  292. <div id=\"loadingText\">Loading...</div>
  293. <img src=\"$url\"></div><div id=\"tripal_analysis_go_org_charts\"></div>
  294. ";
  295. } else {
  296. $content .= "There are currently no Gene Ontology (GO) reports for this organism\n";
  297. }
  298. if(user_access('access administrative pages')){
  299. $link = url("tripal_toggle_box_menu/tripal_analysis_go/goterms/$node->nid");
  300. if(strcmp($box_status,"menu_off")==0){
  301. $content .= "<br><a href=\"$link\">Show on menu</a>";
  302. } else {
  303. $content .= "<br><a href=\"$link\">Remove from menu</a>";
  304. }
  305. }
  306. if(strcmp($box_status,"menu_off")==0){
  307. $content .= "</div></div>";
  308. }
  309. return $content;
  310. }
  311. /************************************************************************
  312. *
  313. */
  314. function tripal_analysis_go_cv_chart($chart_id){
  315. // The CV module will create the JSON array necessary for buillding a
  316. // pie chart using jgChart and Google Charts. We have to pass to it
  317. // a table that contains count information, tell it which column
  318. // contains the cvterm_id and provide a filter for getting the
  319. // results we want from the table.
  320. $organism_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$chart_id);
  321. $analysis_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$chart_id);
  322. $type = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$chart_id);
  323. $sql = "SELECT * FROM {Analysis} WHERE analysis_id = %d";
  324. $previous_db = tripal_db_set_active('chado'); // use chado database
  325. $analysis = db_fetch_object(db_query($sql,$analysis_id));
  326. tripal_db_set_active($previous_db); // now use drupal database
  327. if(strcmp($type,'mf')==0){
  328. $class = 'molecular_function';
  329. $title = "Number of Molecular Function Terms From $analysis->name Analysis";
  330. }
  331. if(strcmp($type,'cc')==0){
  332. $class = 'cellular_component';
  333. $title = "Number of Cellular Component Terms From $analysis->name Analysis";
  334. }
  335. if(strcmp($type,'bp')==0){
  336. $class = 'biological_process';
  337. $title = "Number of Biological Process Terms From $analysis->name Analysis";
  338. }
  339. $options = array(
  340. count_mview => 'go_count_analysis',
  341. cvterm_id_column => 'cvterm_id',
  342. count_column => 'feature_count',
  343. filter => "
  344. CNT.organism_id = $organism_id AND
  345. CNT.analysis_id = $analysis_id AND
  346. CNT.cvterm_id IN (
  347. SELECT CVTR.subject_id
  348. FROM {CVTerm_relationship} CVTR
  349. INNER JOIN CVTerm CVT on CVTR.object_id = CVT.cvterm_id
  350. INNER JOIN CV on CVT.cv_id = CV.cv_id
  351. WHERE CVT.name = '$class' AND
  352. CV.name = '$class'
  353. )
  354. ",
  355. type => 'p',
  356. size => '680x230',
  357. title => $title,
  358. );
  359. return $options;
  360. }
  361. /************************************************************************
  362. *
  363. */
  364. function tripal_analysis_go_cv_tree($tree_id){
  365. $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
  366. $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
  367. $type = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$tree_id);
  368. if(strcmp($type,'mf')==0){
  369. $class = 'molecular_function';
  370. }
  371. if(strcmp($type,'cc')==0){
  372. $class = 'cellular_component';
  373. }
  374. if(strcmp($type,'bp')==0){
  375. $class = 'biological_process';
  376. }
  377. $options = array(
  378. cv_id => tripal_cv_get_cv_id($class),
  379. count_mview => 'go_count_analysis',
  380. cvterm_id_column => 'cvterm_id',
  381. count_column => 'feature_count',
  382. filter => "CNT.organism_id = $organism_id AND CNT.analysis_id = $analysis_id",
  383. label => 'Features',
  384. );
  385. return $options;
  386. }
  387. /************************************************************************
  388. */
  389. function tripal_analysis_go_cvterm_add($cvterm_id,$tree_id){
  390. $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
  391. $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
  392. $sql = "
  393. SELECT DBX.accession
  394. FROM {cvterm} CVT
  395. INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
  396. WHERE cvterm_id = %d
  397. ";
  398. $previous_db = tripal_db_set_active('chado');
  399. $xref = db_fetch_object(db_query($sql,$cvterm_id));
  400. tripal_db_set_active($previous_db);
  401. $link = url("download_goterm_features/$cvterm_id/$tree_id");
  402. $options = array(
  403. 'Download sequences' => "<a href=\"$link\">GO_".$xref->accession.".fasta</a>",
  404. );
  405. return $options;
  406. }
  407. /************************************************************************
  408. */
  409. function tripal_analysis_go_get_goterm_features($cvterm_id,$tree_id){
  410. // get hte accession number for this cvterm and use it in naming the download
  411. $sql = "
  412. SELECT DBX.accession
  413. FROM {cvterm} CVT
  414. INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
  415. WHERE cvterm_id = %d
  416. ";
  417. $previous_db = tripal_db_set_active('chado');
  418. $xref = db_fetch_object(db_query($sql,$cvterm_id));
  419. tripal_db_set_active($previous_db);
  420. drupal_set_header('Content-Type: text');
  421. drupal_set_header('Content-Disposition: attachment; filename="GO_'.$xref->accession.'.fasta"');
  422. $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
  423. $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
  424. $sql = "
  425. SELECT DISTINCT F.name,F.residues,F.feature_id
  426. FROM {cvtermpath} CVTP
  427. INNER JOIN CVTerm CVT1 on CVTP.subject_id = CVT1.cvterm_id
  428. INNER JOIN CVTerm CVT2 on CVTP.object_id = CVT2.cvterm_id
  429. INNER JOIN AnalysisFeatureProp AFP on AFP.type_id = CVTP.subject_id
  430. INNER JOIN AnalysisFeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
  431. INNER JOIN Feature F on AF.feature_id = F.feature_id
  432. WHERE CVTP.object_id = %d and F.organism_id = %d and AF.analysis_id = %d
  433. ORDER BY F.name
  434. ";
  435. $previous_db = tripal_db_set_active('chado');
  436. $results = db_query($sql,$cvterm_id,$organism_id,$analysis_id);
  437. tripal_db_set_active($previous_db);
  438. while($feature = db_fetch_object($results)){
  439. // get the go term information for each sequence
  440. $sql = "
  441. SELECT CVT.name,DBX.accession
  442. FROM {Feature_CVTerm} FCVT
  443. INNER JOIN CVTerm CVT on FCVT.cvterm_id = CVT.cvterm_id
  444. INNER JOIN DBXref DBX on CVT.dbxref_id = DBX.dbxref_id
  445. WHERE FCVT.feature_id = %d
  446. ";
  447. $previous_db = tripal_db_set_active('chado');
  448. $terms = db_query($sql,$feature->feature_id);
  449. tripal_db_set_active($previous_db);
  450. $desc = '[';
  451. while($term = db_fetch_object($terms)){
  452. $desc .= "GO:$term->accession $term->name; ";
  453. }
  454. $desc = chop($desc);
  455. $desc = chop($desc,';');
  456. $desc .= ']';
  457. print tripal_feature_return_fasta($feature, $desc);
  458. }
  459. return;
  460. }
  461. /************************************************************************
  462. */
  463. function tripal_analysis_go_feature_add($node) {
  464. $content = "";
  465. $sql = "
  466. SELECT DISTINCT FCVT.feature_id,DBX.accession,CVT.name as goterm,
  467. CVT.cvterm_id as go_id, CV.name as cvname
  468. FROM {Feature_Cvterm} FCVT
  469. INNER JOIN Cvterm CVT ON CVT.cvterm_ID = FCVT.cvterm_ID
  470. INNER JOIN CV ON CV.cv_id = CVT.cv_id
  471. INNER JOIN dbxref DBX ON DBX.dbxref_id = CVT.dbxref_id
  472. WHERE
  473. (CV.name = 'biological_process' OR
  474. CV.name = 'cellular_component' OR
  475. CV.name = 'molecular_function') AND
  476. FCVT.feature_id = %d
  477. ORDER BY CV.name, CVT.name
  478. ";
  479. $previous_db = tripal_db_set_active('chado');
  480. $results = db_query($sql,$node->feature->feature_id);
  481. tripal_db_set_active($previous_db);
  482. $term = db_fetch_object($results); // retrive the first result
  483. if ($term) {
  484. $content .= "<div id=\"tripal_go_box\" class=\"tripal_go-info-box\">";
  485. $content .= "<div class=\"tripal_expandableBox\">".
  486. "<h3>GO terms assigned to this feature</h3>".
  487. "</div>";
  488. $content .= "<div class=\"tripal_expandableBoxContent\">";
  489. $content .= "<table class=\"feature-go-terms\">";
  490. $content .= " <tr>";
  491. $content .= " <th class=\"dbfieldname\">Accession</th>";
  492. $content .= " <th class=\"dbfieldname\">Category</th>";
  493. $content .= " <th class=\"dbfieldname\">Term</th>";
  494. $content .= " </tr>";
  495. do {
  496. $content .= "<tr>";
  497. $content .= " <td>GO:$term->accession</td>";
  498. $content .= " <td>$term->cvname</td>";
  499. $content .= " <td>$term->goterm</td>";
  500. $content .= "</tr>";
  501. } while($term = db_fetch_object($results));
  502. $content .= "</table>";
  503. $content .= "</div></div>";
  504. }
  505. return $content;
  506. }
  507. /*******************************************************************************
  508. * Tripal GO administrative setting form. This function is called by
  509. * tripal_analysis module which asks for an admin form to show on the page
  510. */
  511. function tripal_analysis_go_get_settings() {
  512. // Get an array of node types with internal names as keys
  513. $options = node_get_types('names');
  514. // Add 'chado_feature' to allowed content types for showing unigene results
  515. $allowedoptions ['chado_feature'] = "Show GO terms on feature pages";
  516. $allowedoptions ['chado_organism'] = "Show GO analysis on organism pages";
  517. $form['description'] = array(
  518. '#type' => 'item',
  519. '#value' => t("This option allows user to display the Gene Ontology (GO) ".
  520. "information. For features, this would include all GO terms assigned to a feature ".
  521. "and for organisms this would be statistical pie charts of GO terms for a organism. Check the box to ".
  522. "enable the display of GO information. Uncheck to disable."),
  523. '#weight' => 0,
  524. );
  525. $form['tripal_analysis_go_setting'] = array(
  526. '#type' => 'checkboxes',
  527. '#options' => $allowedoptions,
  528. '#default_value'=>variable_get('tripal_analysis_go_setting',array('chado_feature', 'chado_organism')),
  529. );
  530. $settings->form = $form;
  531. $settings->title = "Tripal GO";
  532. return $settings;
  533. }