tripal_analysis_go.module 23 KB

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