tripal_analysis_interpro.module 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. require_once "parseInterpro.inc";
  3. /*******************************************************************************
  4. * Tripal Interpro lets users show/hide iprscan results associated with a tripal
  5. * feature
  6. ******************************************************************************/
  7. function tripal_analysis_interpro_init(){
  8. // Add javascript and style sheet
  9. drupal_add_css(drupal_get_path('theme', 'tripal').'/css/tripal_analysis_interpro.css');
  10. // Add javascript and style sheet
  11. drupal_add_js(drupal_get_path('theme', 'tripal').'/js/tripal_analysis_interpro.js');
  12. }
  13. /*******************************************************************************
  14. * Provide information to drupal about the node types that we're creating
  15. * in this module
  16. */
  17. function tripal_analysis_interpro_node_info() {
  18. $nodes = array();
  19. $nodes['chado_analysis_interpro'] = array(
  20. 'name' => t('Analysis: Interpro'),
  21. 'module' => 'chado_analysis_interpro',
  22. 'description' => t('An interpro analysis from the chado database'),
  23. 'has_title' => FALSE,
  24. 'title_label' => t('Analysis: Interpro'),
  25. 'has_body' => FALSE,
  26. 'body_label' => t('Interpro Analysis Description'),
  27. 'locked' => TRUE
  28. );
  29. return $nodes;
  30. }
  31. /*******************************************************************************
  32. *
  33. */
  34. function tripal_analysis_interpro_block($op = 'list', $delta = 0, $edit=array()){
  35. switch($op) {
  36. case 'list':
  37. $blocks['tai_results']['info'] = t('Tripal InterProScan Analysis Results');
  38. $blocks['tai_results']['cache'] = BLOCK_NO_CACHE;
  39. return $blocks;
  40. case 'view':
  41. if(user_access('access chado_analysis_interpro content') and arg(0) == 'node' and is_numeric(arg(1))) {
  42. $nid = arg(1);
  43. $node = node_load($nid);
  44. $block = array();
  45. switch($delta){
  46. case 'tai_results':
  47. $block['subject'] = t('InterProScan Results');
  48. $block['content'] = theme('tripal_analysis_interpro_results', $node);
  49. break;
  50. default :
  51. }
  52. return $block;
  53. }
  54. }
  55. }
  56. /*******************************************************************************
  57. * Provide a Interpro Analysis form
  58. */
  59. function chado_analysis_interpro_form ($node){
  60. // add in the default fields for the analysis
  61. $form = chado_analysis_form($node);
  62. $analysis = $node->analysis;
  63. $interprofile = $analysis->tripal_analysis_interpro->interprofile;
  64. $interproparameters = $analysis->tripal_analysis_interpro->interproparameters;
  65. $parsego = $analysis->tripal_analysis_interpro->parsego;
  66. $parseHTML = $analysis->tripal_analysis_interpro->parseHTML;
  67. $query_re = $analysis->tripal_analysis_interpro->query_re;
  68. $query_type = $analysis->tripal_analysis_interpro->query_type;
  69. $query_uniquename = $analysis->tripal_analysis_interpro->query_uniquename;
  70. $moreSettings ['interpro'] = 'Interpro Settings';
  71. $form['interpro'] = array(
  72. '#title' => t('Interpro Settings'),
  73. '#type' => 'fieldset',
  74. '#description' => t('Specific Settings for Interpro Analysis.'),
  75. '#collapsible' => TRUE,
  76. '#attributes' => array('id' => 'interpro-extra-settings'),
  77. '#weight' => 11
  78. );
  79. $form['interpro']['interprofile'] = array(
  80. '#title' => t('Interproscan Output File (in XML format)'),
  81. '#type' => 'textfield',
  82. '#description' => t('Please provide the full path to the XML output file generated by InterProScan.'),
  83. '#default_value' => $interprofile,
  84. );
  85. $form['interpro']['interprojob'] = array(
  86. '#type' => 'checkbox',
  87. '#title' => t('Submit a job to parse the InterProScan XML file'),
  88. '#description' => t('Note: features associated with the interpro results must '.
  89. 'exist in chado before parsing the file. Otherwise, interpro '.
  90. 'results that cannot be linked to a feature will be '.
  91. 'discarded.'),
  92. '#default_value' => $interprojob,
  93. '#attributes' => array(
  94. 'onclick' => 'return isSubmittingJob(this)'
  95. )
  96. );
  97. $form['interpro']['parseHTML'] = array(
  98. '#type' => 'checkbox',
  99. '#title' => t('The input file is in HTML format (deprecated, only provided for backwards compatibility)'),
  100. '#description' => t('Check the box to use the HTML parser. The feature name must be unique across all organisms and types.'),
  101. '#default_value' => $parseHTML
  102. );
  103. $form['interpro']['parsego'] = array(
  104. '#type' => 'checkbox',
  105. '#title' => t('Load GO terms to the database'),
  106. '#description' => t('Check the box to load GO terms to chado database'),
  107. '#default_value' => $parsego
  108. );
  109. $form['interpro']['interproparameters'] = array(
  110. '#title' => t('Parameters'),
  111. '#type' => 'textfield',
  112. '#description' => t('The parameters used when running the InterProScan analysis.'),
  113. '#default_value' => $interproparameters,
  114. );
  115. $form['interpro']['query_re'] = array(
  116. '#title' => t('Query Name RE'),
  117. '#type' => 'textfield',
  118. '#description' => t('Enter the regular expression that will extract the '.
  119. 'feature name from the query line in the interpro results. This should be '.
  120. 'the same as the definition line in the query FASTA file. This option is '.
  121. 'is only required when the query does not identically match a feature '.
  122. 'in the database.'),
  123. '#default_value' => $query_re,
  124. );
  125. $form['interpro']['query_type'] = array(
  126. '#title' => t('Query Type'),
  127. '#type' => 'textfield',
  128. '#description' => t('Please enter the Sequence Ontology term that describes '.
  129. 'the query sequences used for InterProScan. This is only necessary if two '.
  130. 'or more sequences have the same name.'),
  131. '#default_value' => $query_type,
  132. );
  133. $form['interpro']['query_uniquename'] = array(
  134. '#title' => t('Use Unique Name'),
  135. '#type' => 'checkbox',
  136. '#description' => t('Select this checboxk if the query name in the results file '.
  137. 'matches the uniquename of the feature. By default, the blast results will '.
  138. 'mapped to the "name" of the feature.'),
  139. '#default_value' => $query_uniquename,
  140. );
  141. return $form;
  142. }
  143. /**
  144. *
  145. *
  146. */
  147. function chado_analysis_interpro_load($node){
  148. // load the default set of analysis fields
  149. $additions = chado_analysis_load($node);
  150. // create some variables for easier lookup
  151. $analysis = $additions->analysis;
  152. $analysis_id = $analysis->analysis_id;
  153. $intepro_settings = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_settings');
  154. $interprofile = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interprofile');
  155. $interproparameters= tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interproparameters');
  156. $parsego = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parsego');
  157. $parseHTML = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parseHTML');
  158. $query_re = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_re');
  159. $query_type = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_type');
  160. $query_uniquename = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_uniquename');
  161. $analysis->tripal_analysis_interpro->interprofile = $interprofile->value;
  162. $analysis->tripal_analysis_interpro->interproparameters= $interproparameters->value;
  163. $analysis->tripal_analysis_interpro->parsego = $parsego->value;
  164. $analysis->tripal_analysis_interpro->parseHTML = $parseHTML->value;
  165. $analysis->tripal_analysis_interpro->query_re = $query_re->value;
  166. $analysis->tripal_analysis_interpro->query_type = $query_type->value;
  167. $analysis->tripal_analysis_interpro->query_uniquename = $query_uniquename->value;
  168. // if there is an old style 'interpro_settings' array, then break these out for
  169. // use in the new format
  170. if(count($interpro_settings)>0){
  171. $prop_values = explode ("|", $interpro_settings->value);
  172. $analysis->tripal_analysis_interpro->interprofile = $prop_values[0];
  173. $analysis->tripal_analysis_interpro->interproparameters = $prop_values[1];
  174. }
  175. return $additions;
  176. }
  177. /**
  178. *
  179. */
  180. function chado_analysis_interpro_insert($node){
  181. // insert the analysistripal_core_generate_chado_var
  182. chado_analysis_insert($node);
  183. // set the type for this analysis
  184. tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_interpro');
  185. // now add in the remaining settings as a single property but separated by bars
  186. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile);
  187. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters);
  188. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego);
  189. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML);
  190. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re);
  191. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type);
  192. tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename);
  193. // submit the parsing jobs
  194. chado_analysis_interpro_submit_job($node);
  195. }
  196. /**
  197. *
  198. */
  199. function chado_analysis_interpro_update($node){
  200. // insert the analysistripal_core_generate_chado_var
  201. chado_analysis_update($node);
  202. // set the type for this analysis
  203. tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_interpro',1);
  204. // now add in the remaining settings as a single property but separated by bars
  205. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile,1);
  206. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters,1);
  207. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego,1);
  208. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML,1);
  209. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re,1);
  210. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type,1);
  211. tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename,1);
  212. // if this analysis uses the old style settings cvterm then remove that term
  213. $old = tripal_analysis_get_property($node->analysis_id,'analysis_interpro_settings');
  214. if(count($old) > 0){
  215. tripal_analysis_delete_property($node->analysis_id,'analysis_interpro_settings');
  216. }
  217. // submit the parsing jobs
  218. chado_analysis_interpro_submit_job($node);
  219. }
  220. /*******************************************************************************
  221. * Delete interpro anlysis
  222. */
  223. function chado_analysis_interpro_delete($node){
  224. chado_analysis_delete($node);
  225. }
  226. /**
  227. *
  228. */
  229. function chado_analysis_interpro_submit_job($node){
  230. global $user;
  231. // Add a job if the user wants to parse the html output
  232. if($node->interprojob) {
  233. $job_args[0] = $node->analysis_id;
  234. $job_args[1] = $node->interprofile;
  235. if ($node->parsego) {
  236. $job_args[2] = 1;
  237. } else {
  238. $job_args[2] = 0;
  239. }
  240. if (is_readable($node->interprofile)) {
  241. $fname = preg_replace("/.*\/(.*)/", "$1", $node->interprofile);
  242. if($node->parseHTML){
  243. tripal_add_job("Parse HTML interpro: $fname",'tripal_analysis_interpro',
  244. 'tripal_analysis_interpro_parseHTMLFile', $job_args, $user->uid);
  245. } else {
  246. $job_args[3] = $node->query_re;
  247. $job_args[4] = $node->query_type;
  248. $job_args[5] = $node->query_uniquename;;
  249. tripal_add_job("Parse XML interpro: $fname",'tripal_analysis_interpro',
  250. 'tripal_analysis_interpro_parseXMLFile', $job_args, $user->uid);
  251. }
  252. } else {
  253. drupal_set_message("Can not open interpro output file. Job not scheduled.");
  254. }
  255. }
  256. }
  257. /*******************************************************************************
  258. * This function customizes the view of the chado_analysis node. It allows
  259. * us to generate the markup.
  260. */
  261. function chado_analysis_interpro_view ($node, $teaser = FALSE, $page = FALSE) {
  262. // use drupal's default node view:
  263. if (!$teaser) {
  264. $node = node_prepare($node, $teaser);
  265. // When previewing a node submitting form, it shows 'Array' instead of
  266. // correct date format. We need to format the date here
  267. $time = $node->timeexecuted;
  268. if(is_array($time)){
  269. $month = $time['month'];
  270. $day = $time['day'];
  271. $year = $time['year'];
  272. $timestamp = $year.'-'.$month.'-'.$day;
  273. $node->timeexecuted = $timestamp;
  274. }
  275. // When viewing a node, we need to reformat the analysisprop since we
  276. // separate each value with a bar |
  277. if (preg_match("/.*\|.*/",$node->interprofile)) {
  278. $prop_values = explode("|", $node->interprofile);
  279. $node->interprofile = $prop_values[0];
  280. $node->interproparameters = $prop_values[1];
  281. }
  282. }
  283. return $node;
  284. }
  285. /*******************************************************************************
  286. * tripal_analysis_interpro_nodeapi()
  287. * HOOK: Implementation of hook_nodeapi()
  288. * Display interpro results for allowed node types
  289. */
  290. function tripal_analysis_interpro_nodeapi(&$node, $op, $teaser, $page) {
  291. switch ($op) {
  292. case 'view':
  293. // Find out which node types for showing the interpro
  294. $types_to_show = variable_get('tripal_analysis_interpro_setting',
  295. array('chado_feature'));
  296. // Abort if this node is not one of the types we should show.
  297. if (!in_array($node->type, $types_to_show, TRUE)) {
  298. break;
  299. }
  300. // Add interpro to the content item if it's not a teaser
  301. if (!$teaser && $node->feature->feature_id) {
  302. if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
  303. $node->content['tripal_analysis_interpro_index_version'] = array(
  304. '#value' => theme('parse_EBI_Interpro_XML_index_version',$node),
  305. '#weight' => 7,
  306. );
  307. } else {
  308. // Show interpro result if not at teaser view
  309. $node->content['tripal_feature_interpro_results'] = array(
  310. '#value' => theme('tripal_feature_interpro_results', $node),
  311. '#weight' => 7
  312. );
  313. }
  314. }
  315. }
  316. }
  317. /************************************************************************
  318. * We need to let drupal know about our theme functions and their arguments.
  319. * We create theme functions to allow users of the module to customize the
  320. * look and feel of the output generated in this module
  321. */
  322. function tripal_analysis_interpro_theme () {
  323. return array(
  324. 'parse_EBI_Interpro_XML_index_version' => array (
  325. 'arguments' => array('node'),
  326. ),
  327. 'tripal_feature_interpro_results' => array (
  328. 'arguments' => array('node'=> null),
  329. 'template' => 'tripal_feature_interpro_results',
  330. )
  331. );
  332. }
  333. /*******************************************************************************
  334. * Prepare interpro result for the feature shown on the page
  335. */
  336. //function theme_tripal_analysis_interpro_results ($node) {
  337. // $feature = $node->feature;
  338. // $content = tripal_get_interpro_results($feature->feature_id);
  339. // return $content;
  340. //}
  341. function tripal_analysis_interpro_preprocess_tripal_feature_interpro_results(&$variables){
  342. $feature = $variables['node']->feature;
  343. // we don't know how many analysis are the old style HTML version and how many are the newer
  344. // XML format. So, to be backwards compatible we should get both.
  345. $variables['tripal_analysis_interpro']['results']['html'] = tripal_get_interpro_HTML_results($feature->feature_id);
  346. $variables['tripal_analysis_interpro']['results']['xml'] = tripal_get_interpro_XML_results($feature->feature_id);
  347. }
  348. /*******************************************************************************
  349. * Prepare interpro result for the feature shown on the page
  350. */
  351. function theme_parse_EBI_Interpro_XML_index_version ($node) {
  352. $feature = $node->feature;
  353. $content = tripal_get_interpro_results_index_version($feature->feature_id);
  354. return $content;
  355. }
  356. /**
  357. *
  358. */
  359. function tripal_get_interpro_XML_results($feature_id){
  360. // Get the blast results stored as XML from the analysisfeatureprop table
  361. // the type for the property is named 'analysis_blast_output_iteration_hits'
  362. // and is found in the 'tripal' controlled vocabulary. This CV term was
  363. // added by this module.
  364. $select = array(
  365. 'analysisfeature_id' => array(
  366. 'feature_id' => $feature_id,
  367. ),
  368. 'type_id' => array(
  369. 'name' => 'analysis_interpro_xmloutput_hit',
  370. 'cv_id' => array(
  371. 'name' => 'tripal'
  372. ),
  373. ),
  374. );
  375. $afeatureprops = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
  376. // iterate through all of the interpro XML properties for this feature
  377. $results = array ();
  378. foreach ($afeatureprops as $index => $afeatureprop) {
  379. // get the analysis feature record
  380. $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
  381. array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
  382. $analysisfeature = $analysisfeature_arr[0];
  383. // get the analysis record and the analysis_id
  384. $analysis = tripal_core_generate_chado_var('analysis',
  385. array('analysis_id' => $analysisfeature->analysis_id));
  386. $analysis_id = $analysis->analysis_id;
  387. // parse the XML and add it to the array of blast results to be returned
  388. $interpro_xml = $afeatureprop->value;
  389. $orf = tripal_analysis_interpro_get_result_object($interpro_xml,$feature_id);
  390. $results[$analysis->analysis_id]['protein_ORFs'][] = $orf;
  391. $results[$analysis->analysis_id]['analysis'] = $analysis;
  392. // iterate through all of the protein ORFs and combine the terms into one large list
  393. if(!is_array($results[$analysis->analysis_id]['allterms'])){
  394. $results[$analysis->analysis_id]['allterms'] = array();
  395. }
  396. if(!is_array($results[$analysis->analysis_id]['goterms'])){
  397. $results[$analysis->analysis_id]['goterms'] = array();
  398. }
  399. $results[$analysis->analysis_id]['allterms'] = array_merge($results[$analysis->analysis_id]['allterms'],$orf['iprterms']);
  400. $results[$analysis->analysis_id]['goterms'] = array_merge($results[$analysis->analysis_id]['goterms'],$orf['goterms']);
  401. $i++;
  402. }
  403. return $results;
  404. }
  405. /*******************************************************************************
  406. * tripal_get_interpro_results()
  407. * Get interpro result from featureprop table for the feature
  408. */
  409. function tripal_get_interpro_HTML_results($feature_id){
  410. // Get cvterm_id for 'analysis_interpro_output_hit' which is required
  411. // for inserting into the analysisfeatureprop table
  412. $previous_db = tripal_db_set_active('chado');
  413. $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT
  414. INNER JOIN cv ON cv.cv_id = CVT.cv_id
  415. WHERE CVT.name = 'analysis_interpro_output_hit'
  416. AND CV.name = 'tripal'";
  417. $type_id = db_result(db_query($sql));
  418. // Get analysis times for the feature
  419. $sql = "SELECT A.analysis_id AS aid
  420. FROM {analysis} A
  421. INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id
  422. INNER JOIN analysisfeatureprop AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
  423. WHERE feature_id = %d
  424. AND AFP.type_id = %d
  425. GROUP BY A.analysis_id
  426. ";
  427. $hasResult = db_result(db_query($sql, $feature_id, $type_id));
  428. $result = db_query($sql, $feature_id, $type_id);
  429. // Show interpro result ORDER BY time
  430. if ($hasResult) { // If there is any result, show expandable box
  431. $content .= "<table class=\"tripal_interpro_results_table\">
  432. <tr><td>";
  433. while ($ana = db_fetch_object($result)) {
  434. // Show analysis date
  435. $sql = "SELECT name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
  436. FROM {analysis}
  437. WHERE analysis_id = %d";
  438. $ana_details = db_fetch_object(db_query($sql, $ana->aid));
  439. // Find node id for the analysis
  440. tripal_db_set_active($previous_db);
  441. $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $ana->aid));
  442. $ana_url = url("node/".$ana_nid);
  443. $previous_db = tripal_db_set_active('chado');
  444. // Show content
  445. $content .= "<strong>Analysis Date:</strong> $ana_details->time
  446. (<a href=$ana_url>$ana_details->name</a>)";
  447. // Show interpro results
  448. $sql = "SELECT AFP.value AS afpvalue
  449. FROM {analysisfeatureprop} AFP
  450. INNER JOIN analysisfeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
  451. WHERE AF.analysis_id = %d
  452. AND AF.feature_id = %d
  453. ";
  454. $interpro_results = db_query($sql, $ana->aid, $feature_id);
  455. while ($afp = db_fetch_object($interpro_results)) {
  456. $content .= $afp->afpvalue;
  457. }
  458. }
  459. $content .= '</td></tr></table>';
  460. }
  461. tripal_db_set_active($previous_db);
  462. return $content;
  463. }
  464. /*******************************************************************************
  465. * tripal_get_interpro_results()
  466. * Get interpro result from featureprop table for the feature
  467. */
  468. function tripal_get_interpro_results_index_version($feature_id){
  469. // Get cvterm_id for 'analysis_interpro_output_hit' which is required
  470. // for inserting into the analysisfeatureprop table
  471. $previous_db = tripal_db_set_active('chado');
  472. $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
  473. "INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
  474. "WHERE CVT.name = 'analysis_interpro_output_hit' ".
  475. "AND CV.name = 'tripal'";
  476. $type_id = db_result(db_query($sql));
  477. // Get xml string from analysisfeatureprop value column
  478. $sql = "SELECT AFP.value AS afpvalue FROM {analysisfeatureprop} AFP ".
  479. "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".
  480. "INNER JOIN analysisprop AP ON AP.analysis_id = AF.analysis_id ".
  481. "WHERE feature_id = %d ".
  482. "AND AFP.type_id = %d ";
  483. $result = db_query($sql, $feature_id, $type_id);
  484. tripal_db_set_active($previous_db);
  485. if (db_result($result)) {
  486. // get the HTML content for viewing each of the XML file
  487. while ($analysisfeatureprop = db_fetch_object($result)) {
  488. $content .= $analysisfeatureprop->afpvalue;
  489. }
  490. }
  491. return $content;
  492. }
  493. /*******************************************************************************
  494. * Tripal Interpro administrative setting form. This function is called by
  495. * tripal_analysis module which asks for an admin form to show on the page
  496. */
  497. function tripal_analysis_interpro_get_settings() {
  498. // Get an array of node types with internal names as keys
  499. $options = node_get_types('names');
  500. // Add 'chado_feature' to allowed content types for showing interpro results
  501. $allowedoptions ['chado_feature'] = "Show Interpro results on feature pages";
  502. $form['description'] = array(
  503. '#type' => 'item',
  504. '#value' => t("Some chado features were analyzed using InterProScan. This option allows user to display the interpro analysis results. Please read user manual for storage and display of interpro files. Check the box to enable the analysis results. Uncheck to disable it."),
  505. '#weight' => 0,
  506. );
  507. $form['tripal_analysis_interpro_setting'] = array(
  508. '#type' => 'checkboxes',
  509. '#options' => $allowedoptions,
  510. '#default_value' => variable_get('tripal_analysis_interpro_setting',
  511. array('chado_feature')),
  512. );
  513. $settings->form = $form;
  514. $settings->title = "Tripal Interpro";
  515. return $settings;
  516. }
  517. /*******************************************************************************
  518. * Set the permission types that the chado module uses. Essentially we
  519. * want permissionis that protect creation, editing and deleting of chado
  520. * data objects
  521. */
  522. function tripal_analysis_interpro_perm(){
  523. return array(
  524. 'access chado_analysis_interpro content',
  525. 'create chado_analysis_interpro content',
  526. 'delete chado_analysis_interpro content',
  527. 'edit chado_analysis_interpro content',
  528. );
  529. }
  530. /*******************************************************************************
  531. * The following function proves access control for users trying to
  532. * perform actions on data managed by this module
  533. */
  534. function chado_analysis_interpro_access($op, $node, $account){
  535. if ($op == 'create') {
  536. return user_access('create chado_analysis_interpro content', $account);
  537. }
  538. if ($op == 'update') {
  539. if (user_access('edit chado_analysis_interpro content', $account)) {
  540. return TRUE;
  541. }
  542. }
  543. if ($op == 'delete') {
  544. if (user_access('delete chado_analysis_interpro content', $account)) {
  545. return TRUE;
  546. }
  547. }
  548. if ($op == 'view') {
  549. if (user_access('access chado_analysis_interpro content', $account)) {
  550. return TRUE;
  551. }
  552. }
  553. return FALSE;
  554. }