tripal_analysis_interpro.module 24 KB

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