tripal_feature.module 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. <?php
  2. /**
  3. * @file
  4. * @todo Add file header description
  5. */
  6. /**
  7. * @defgroup tripal_feature Feature Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Provides functions for managing chado features including creating details pages for each feature
  11. * @}
  12. */
  13. require_once "api/tripal_feature.api.inc";
  14. require_once "api/tripal_feature.schema.api.inc";
  15. require_once "theme/tripal_feature.theme.inc";
  16. require_once "includes/tripal_feature.admin.inc";
  17. require_once "includes/tripal_feature.fasta_loader.inc";
  18. require_once "includes/tripal_feature.gff_loader.inc";
  19. require_once "includes/tripal_feature.seq_extract.inc";
  20. require_once "includes/tripal_feature.delete.inc";
  21. require_once "includes/tripal_feature.chado_node.inc";
  22. require_once "includes/tripal_feature.blocks.inc";
  23. /**
  24. *
  25. * @ingroup tripal_feature
  26. */
  27. function tripal_feature_init() {
  28. drupal_add_css(drupal_get_path('module', 'tripal_feature') . '/theme/css/tripal_feature.css');
  29. drupal_add_js(drupal_get_path('module', 'tripal_feature') . '/theme/js/tripal_feature.js');
  30. }
  31. /**
  32. * Implements hook_views_api()
  33. *
  34. * Purpose: Essentially this hook tells drupal that there is views support for
  35. * for this module which then includes tripal_db.views.inc where all the
  36. * views integration code is
  37. *
  38. * @ingroup tripal_feature
  39. */
  40. function tripal_feature_views_api() {
  41. return array(
  42. 'api' => 2.0,
  43. );
  44. }
  45. /**
  46. * Display help and module information
  47. *
  48. * @param
  49. * path which path of the site we're displaying help
  50. * @param
  51. * arg array that holds the current path as would be returned from arg() function
  52. *
  53. * @return
  54. * help text for the path
  55. *
  56. * @ingroup tripal_feature
  57. */
  58. function tripal_feature_help($path, $arg) {
  59. $output = '';
  60. switch ($path) {
  61. case "admin/help#tripal_feature":
  62. $output='<p>' . t("Displays links to nodes created on this date") . '</p>';
  63. break;
  64. }
  65. return $output;
  66. }
  67. /**
  68. * Set the permission types that the chado module uses. Essentially we
  69. * want permissionis that protect creation, editing and deleting of chado
  70. * data objects
  71. *
  72. * @ingroup tripal_feature
  73. */
  74. function tripal_feature_permissions() {
  75. return array(
  76. 'access chado_feature content' => array(
  77. 'title' => t('View Features'),
  78. 'description' => t('Allow users to view feature pages.'),
  79. ),
  80. 'create chado_feature content' => array(
  81. 'title' => t('Create Features'),
  82. 'description' => t('Allow users to create new feature pages.'),
  83. ),
  84. 'delete chado_feature content' => array(
  85. 'title' => t('Delete Features'),
  86. 'description' => t('Allow users to delete feature pages.'),
  87. ),
  88. 'edit chado_feature content' => array(
  89. 'title' => t('Edit Features'),
  90. 'description' => t('Allow users to edit feature pages.'),
  91. ),
  92. 'adminster tripal feature' => array(
  93. 'title' => t('Administer Features'),
  94. 'description' => t('Allow users to administer all features.'),
  95. ),
  96. );
  97. }
  98. /**
  99. * Menu items are automatically added for the new node types created
  100. * by this module to the 'Create Content' Navigation menu item. This function
  101. * adds more menu items needed for this module.
  102. *
  103. * @ingroup tripal_feature
  104. */
  105. function tripal_feature_menu() {
  106. $items = array();
  107. // the administative settings menu
  108. $items['find/sequences'] = array(
  109. 'title' => 'Sequence Retrieval',
  110. 'description' => 'Download a file of sequences',
  111. 'page callback' => 'tripal_feature_seq_extract_page',
  112. 'access arguments' => array('access chado_feature content'),
  113. 'type' => MENU_CALLBACK,
  114. );
  115. $items['find/sequences/ajax'] = array(
  116. 'title' => 'Sequence Retrieval',
  117. 'page callback' => 'tripal_feature_seq_extract_form_ahah_update',
  118. 'access arguments' => array('access chado_feature content'),
  119. 'type' => MENU_CALLBACK,
  120. );
  121. // the administative settings menu
  122. $items['admin/tripal/chado/tripal_feature'] = array(
  123. 'title' => 'Features',
  124. 'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.',
  125. 'page callback' => 'tripal_feature_admin_feature_view',
  126. 'access arguments' => array('administer tripal features'),
  127. 'type' => MENU_NORMAL_ITEM,
  128. );
  129. $items['admin/tripal/chado/tripal_feature/delete'] = array(
  130. 'title' => ' Delete',
  131. 'description' => 'Delete multiple features from Chado',
  132. 'page callback' => 'drupal_get_form',
  133. 'page arguments' => array('tripal_feature_delete_form'),
  134. 'access arguments' => array('administer tripal features'),
  135. 'type' => MENU_LOCAL_TASK,
  136. 'weight' => 2
  137. );
  138. $items['admin/tripal/chado/tripal_feature/sync'] = array(
  139. 'title' => ' Sync',
  140. 'description' => 'Create pages on this site for features stored in Chado',
  141. 'page callback' => 'drupal_get_form',
  142. 'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_feature', 'chado_feature'),
  143. 'access arguments' => array('administer tripal feature'),
  144. 'type' => MENU_LOCAL_TASK,
  145. 'weight' => 1
  146. );
  147. $items['admin/tripal/chado/tripal_feature/configuration'] = array(
  148. 'title' => 'Settings',
  149. 'description' => 'Configure the Tripal Feature module.',
  150. 'page callback' => 'drupal_get_form',
  151. 'page arguments' => array('tripal_feature_admin'),
  152. 'access arguments' => array('administer tripal features'),
  153. 'type' => MENU_LOCAL_TASK,
  154. 'weight' => 5
  155. );
  156. $items['admin/tripal/chado/tripal_feature/help'] = array(
  157. 'title' => 'Help',
  158. 'description' => 'Help with the Tripal Feature module.',
  159. 'page callback' => 'theme',
  160. 'page arguments' => array('tripal_feature_help'),
  161. 'access arguments' => array('administer tripal features'),
  162. 'type' => MENU_LOCAL_TASK,
  163. 'weight' => 10
  164. );
  165. /** Loaders */
  166. $items['admin/tripal/loaders/fasta_loader'] = array(
  167. 'title' => 'Multi-FASTA file Loader',
  168. 'description' => 'Load sequences from a multi-FASTA file into Chado',
  169. 'page callback' => 'drupal_get_form',
  170. 'page arguments' => array('tripal_feature_fasta_load_form'),
  171. 'access arguments' => array('administer tripal features'),
  172. 'type' => MENU_NORMAL_ITEM,
  173. );
  174. $items['admin/tripal/loaders/gff3_load'] = array(
  175. 'title' => 'GFF3 file Loader',
  176. 'description' => 'Import a GFF3 file into Chado',
  177. 'page callback' => 'drupal_get_form',
  178. 'page arguments' => array('tripal_feature_gff3_load_form'),
  179. 'access arguments' => array('administer tripal features'),
  180. 'type' => MENU_NORMAL_ITEM,
  181. );
  182. // the menu link for addressing any feature (by name, uniquename, synonym)
  183. $items['feature/%'] = array(
  184. 'page callback' => 'tripal_feature_match_features_page',
  185. 'page arguments' => array(1),
  186. 'access arguments' => array('access chado_feature content'),
  187. 'type' => MENU_LOCAL_TASK,
  188. );
  189. // Enable admin view
  190. $items['admin/tripal/chado/tripal_feature/views/features/enable'] = array(
  191. 'title' => 'Enable feature Administrative View',
  192. 'page callback' => 'tripal_views_admin_enable_view',
  193. 'page arguments' => array('tripal_feature_admin_features', 'admin/tripal/chado/tripal_feature'),
  194. 'access arguments' => array('administer tripal feature'),
  195. 'type' => MENU_CALLBACK,
  196. );
  197. return $items;
  198. }
  199. /**
  200. * We need to let drupal know about our theme functions and their arguments.
  201. * We create theme functions to allow users of the module to customize the
  202. * look and feel of the output generated in this module
  203. *
  204. * @ingroup tripal_feature
  205. */
  206. function tripal_feature_theme($existing, $type, $theme, $path) {
  207. $core_path = drupal_get_path('module', 'tripal_core');
  208. $items = array(
  209. 'node__chado_feature' => array(
  210. 'template' => 'node--chado-generic',
  211. 'render element' => 'node',
  212. 'base hook' => 'node',
  213. 'path' => "$core_path/theme",
  214. ),
  215. 'tripal_feature_alignments' => array(
  216. 'variables' => array('node' => NULL),
  217. 'template' => 'tripal_feature_alignments',
  218. 'path' => "$path/theme/tripal_feature",
  219. ),
  220. 'tripal_feature_analyses' => array(
  221. 'variables' => array('node' => NULL),
  222. 'template' => 'tripal_feature_analyses',
  223. 'path' => "$path/theme/tripal_feature",
  224. ),
  225. 'tripal_feature_base' => array(
  226. 'variables' => array('node' => NULL),
  227. 'template' => 'tripal_feature_base',
  228. 'path' => "$path/theme/tripal_feature",
  229. ),
  230. 'tripal_feature_featurepos' => array(
  231. 'arguments' => array('node' => NULL),
  232. 'template' => 'tripal_feature_featurepos',
  233. 'path' => "$path/theme/tripal_feature",
  234. ),
  235. 'tripal_feature_sequence' => array(
  236. 'variables' => array('node' => NULL),
  237. 'template' => 'tripal_feature_sequence',
  238. 'path' => "$path/theme/tripal_feature",
  239. ),
  240. 'tripal_feature_proteins' => array(
  241. 'variables' => array('node' => NULL),
  242. 'template' => 'tripal_feature_proteins',
  243. 'path' => "$path/theme/tripal_feature",
  244. ),
  245. 'tripal_feature_publications' => array(
  246. 'variables' => array('node' => NULL),
  247. 'template' => 'tripal_feature_publications',
  248. 'path' => "$path/theme/tripal_feature",
  249. ),
  250. 'tripal_feature_synonyms' => array(
  251. 'variables' => array('node' => NULL),
  252. 'template' => 'tripal_feature_synonyms',
  253. 'path' => "$path/theme/tripal_feature",
  254. ),
  255. 'tripal_feature_references' => array(
  256. 'variables' => array('node' => NULL),
  257. 'template' => 'tripal_feature_references',
  258. 'path' => "$path/theme/tripal_feature",
  259. ),
  260. 'tripal_feature_properties' => array(
  261. 'variables' => array('node' => NULL),
  262. 'template' => 'tripal_feature_properties',
  263. 'path' => "$path/theme/tripal_feature",
  264. ),
  265. 'tripal_feature_terms' => array(
  266. 'variables' => array('node' => NULL),
  267. 'template' => 'tripal_feature_terms',
  268. 'path' => "$path/theme/tripal_feature",
  269. ),
  270. 'tripal_feature_relationships' => array(
  271. 'variables' => array('node' => NULL),
  272. 'template' => 'tripal_feature_relationships',
  273. 'path' => "$path/theme/tripal_feature",
  274. ),
  275. 'tripal_feature_help' => array(
  276. 'template' => 'tripal_feature_help',
  277. 'variables' => array(NULL),
  278. 'path' => drupal_get_path('module', 'tripal_feature') . '/theme'
  279. ),
  280. // template for the organism page
  281. 'tripal_organism_feature_browser' => array(
  282. 'variables' => array('node' => NULL),
  283. 'template' => 'tripal_organism_feature_browser',
  284. 'path' => "$path/theme/tripal_organism",
  285. ),
  286. 'tripal_organism_feature_counts' => array(
  287. 'variables' => array('node' => NULL),
  288. 'template' => 'tripal_organism_feature_counts',
  289. 'path' => "$path/theme/tripal_organism",
  290. ),
  291. // themed forms
  292. 'tripal_feature_seq_extract_form' => array(
  293. 'arguments' => array('form'),
  294. ),
  295. // themed teaser
  296. 'tripal_feature_teaser' => array(
  297. 'variables' => array('node' => NULL),
  298. 'template' => 'tripal_feature_teaser',
  299. 'path' => "$path/theme/tripal_feature",
  300. ),
  301. );
  302. return $items;
  303. }
  304. /**
  305. *
  306. *
  307. * @ingroup tripal_feature
  308. */
  309. function tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) {
  310. $sql = "
  311. SELECT
  312. F.name, F.feature_id, F.uniquename,
  313. FS.name as src_name, FS.feature_id as src_feature_id, FS.uniquename as src_uniquename,
  314. CVT.name as cvname, CVT.cvterm_id,
  315. CVTS.name as src_cvname, CVTS.cvterm_id as src_cvterm_id,
  316. FL.fmin, FL.fmax, FL.is_fmin_partial, FL.is_fmax_partial,FL.strand, FL.phase
  317. FROM {featureloc} FL
  318. INNER JOIN {feature} F ON FL.feature_id = F.feature_id
  319. INNER JOIN {feature} FS ON FS.feature_id = FL.srcfeature_id
  320. INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
  321. INNER JOIN {cvterm} CVTS ON FS.type_id = CVTS.cvterm_id
  322. ";
  323. if (strcmp($side, 'as_parent')==0) {
  324. $sql .= "WHERE FL.srcfeature_id = :feature_id ";
  325. }
  326. if (strcmp($side, 'as_child')==0) {
  327. $sql .= "WHERE FL.feature_id = :feature_id ";
  328. }
  329. $flresults = chado_query($sql, array(':feature_id' => $feature_id));
  330. // copy the results into an array
  331. $i=0;
  332. $featurelocs = array();
  333. while ($loc = $flresults->fetchObject()) {
  334. // if a drupal node exists for this feature then add the nid to the
  335. // results object
  336. $loc->fnid = chado_get_node_id('feature', $loc->feature_id);
  337. $loc->snid = chado_get_node_id('feature', $loc->src_feature_id);
  338. // add the result to the array
  339. $featurelocs[$i++] = $loc;
  340. }
  341. // Add the relationship feature locs if aggregate is turned on
  342. if ($aggregate and strcmp($side, 'as_parent')==0) {
  343. // get the relationships for this feature without substituting any children
  344. // for the parent. We want all relationships
  345. $relationships = tripal_feature_get_aggregate_relationships($feature_id, 0);
  346. foreach ($relationships as $rindex => $rel) {
  347. // get the featurelocs for each of the relationship features
  348. $rel_featurelocs = tripal_feature_load_featurelocs($rel->subject_id, 'as_child', 0);
  349. foreach ($rel_featurelocs as $findex => $rfloc) {
  350. $featurelocs[$i++] = $rfloc;
  351. }
  352. }
  353. }
  354. usort($featurelocs, 'tripal_feature_sort_locations');
  355. return $featurelocs;
  356. }
  357. /**
  358. * used to sort the feature locs by start position
  359. *
  360. * @ingroup tripal_feature
  361. */
  362. function tripal_feature_sort_locations($a, $b) {
  363. return strnatcmp($a->fmin, $b->fmin);
  364. }
  365. /**
  366. *
  367. *
  368. * @ingroup tripal_feature
  369. */
  370. function tripal_feature_load_relationships($feature_id, $side = 'as_subject') {
  371. // get the relationships for this feature. The query below is used for both
  372. // querying the object and subject relationships
  373. $sql = "
  374. SELECT
  375. FS.name as subject_name, FS.uniquename as subject_uniquename,
  376. CVTS.name as subject_type, CVTS.cvterm_id as subject_type_id,
  377. FR.subject_id, FR.type_id as relationship_type_id, FR.object_id, FR.rank,
  378. CVT.name as rel_type,
  379. FO.name as object_name, FO.uniquename as object_uniquename,
  380. CVTO.name as object_type, CVTO.cvterm_id as object_type_id
  381. FROM {feature_relationship} FR
  382. INNER JOIN {cvterm} CVT ON FR.type_id = CVT.cvterm_id
  383. INNER JOIN {feature} FS ON FS.feature_id = FR.subject_id
  384. INNER JOIN {feature} FO ON FO.feature_id = FR.object_id
  385. INNER JOIN {cvterm} CVTO ON FO.type_id = CVTO.cvterm_id
  386. INNER JOIN {cvterm} CVTS ON FS.type_id = CVTS.cvterm_id
  387. ";
  388. if (strcmp($side, 'as_object')==0) {
  389. $sql .= " WHERE FR.object_id = :feature_id";
  390. }
  391. if (strcmp($side, 'as_subject')==0) {
  392. $sql .= " WHERE FR.subject_id = :feature_id";
  393. }
  394. $sql .= " ORDER BY FR.rank";
  395. // get the relationships
  396. $results = chado_query($sql, array(':feature_id' => $feature_id));
  397. // iterate through the relationships, put these in an array and add
  398. // in the Drupal node id if one exists
  399. $i=0;
  400. $nodesql = "SELECT nid FROM {chado_feature} WHERE feature_id = :feature_id";
  401. $relationships = array();
  402. while ($rel = $results->fetchObject()) {
  403. $node = db_query($nodesql, array(':feature_id' => $rel->subject_id))->fetchObject();
  404. if ($node) {
  405. $rel->subject_nid = $node->nid;
  406. }
  407. $node = db_query($nodesql, array(':feature_id' => $rel->object_id))->fetchObject();
  408. if ($node) {
  409. $rel->object_nid = $node->nid;
  410. }
  411. $relationships[$i++] = $rel;
  412. }
  413. return $relationships;
  414. }
  415. /**
  416. *
  417. *
  418. * @ingroup tripal_feature
  419. */
  420. function tripal_feature_get_aggregate_relationships($feature_id, $substitute=1,
  421. $levels=0, $base_type_id=NULL, $depth=0) {
  422. // we only want to recurse to as many levels deep as indicated by the
  423. // $levels variable, but only if this variable is > 0. If 0 then we
  424. // recurse until we reach the end of the relationships tree.
  425. if ($levels > 0 and $levels == $depth) {
  426. return NULL;
  427. }
  428. // first get the relationships for this feature
  429. return tripal_feature_load_relationships($feature_id, 'as_object');
  430. }
  431. /**
  432. *
  433. *
  434. * @ingroup tripal_feature
  435. */
  436. function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
  437. // if we don't have any featurelocs then no point in continuing
  438. if (!$featurelocs) {
  439. return array();
  440. }
  441. // get the list of relationships (including any aggregators) and iterate
  442. // through each one to find information needed to color-code the reference sequence
  443. $relationships = tripal_feature_get_aggregate_relationships($feature_id);
  444. if (!$relationships) {
  445. return array();
  446. }
  447. // iterate through each of the realtionships features and get their
  448. // locations
  449. foreach ($relationships as $rindex => $rel) {
  450. // get the featurelocs for each of the relationship features
  451. $rel_featurelocs = tripal_feature_load_featurelocs($rel->subject_id, 'as_child', 0);
  452. foreach ($rel_featurelocs as $rfindex => $rel_featureloc) {
  453. // keep track of this unique source feature
  454. $src = $rel_featureloc->src_feature_id . "-" . $rel_featureloc->src_cvterm_id;
  455. // copy over the results to the relationship object. Since there can
  456. // be more than one feature location for each relationship feature we
  457. // use the '$src' variable to keep track of these.
  458. $rel->featurelocs = new stdClass();
  459. $rel->featurelocs->$src = new stdClass();
  460. $rel->featurelocs->$src->src_uniquename = $rel_featureloc->src_uniquename;
  461. $rel->featurelocs->$src->src_cvterm_id = $rel_featureloc->src_cvterm_id;
  462. $rel->featurelocs->$src->src_cvname = $rel_featureloc->src_cvname;
  463. $rel->featurelocs->$src->fmin = $rel_featureloc->fmin;
  464. $rel->featurelocs->$src->fmax = $rel_featureloc->fmax;
  465. $rel->featurelocs->$src->src_name = $rel_featureloc->src_name;
  466. // keep track of the individual parts for each relationship
  467. $start = $rel->featurelocs->$src->fmin;
  468. $end = $rel->featurelocs->$src->fmax;
  469. $type = $rel->subject_type;
  470. $rel_locs[$src]['parts'][$start][$type]['start'] = $start;
  471. $rel_locs[$src]['parts'][$start][$type]['end'] = $end;
  472. $rel_locs[$src]['parts'][$start][$type]['type'] = $type;
  473. }
  474. }
  475. // the featurelocs array provided to the function contains the locations
  476. // where this feature is found. We want to get the sequence for each
  477. // location and then annotate it with the parts found from the relationships
  478. // locations determiend above.
  479. $floc_sequences = array();
  480. foreach ($featurelocs as $featureloc) {
  481. // build the src name so we can keep track of the different parts for each feature
  482. $src = $featureloc->srcfeature_id->feature_id . "-" . $featureloc->srcfeature_id->type_id->cvterm_id;
  483. // orient the parts to the beginning of the feature sequence
  484. if (!empty($rel_locs[$src]['parts'])) {
  485. $parts = $rel_locs[$src]['parts'];
  486. $rparts = array(); // we will fill this up if we're on the reverse strand
  487. foreach ($parts as $start => $types) {
  488. foreach ($types as $type_name => $type) {
  489. if ($featureloc->strand >= 0) {
  490. // this is on the forward strand. We need to convert the start on the src feature to the
  491. // start on this feature's sequence
  492. $parts[$start][$type_name]['start'] = $parts[$start][$type_name]['start'] - $featureloc->fmin;
  493. $parts[$start][$type_name]['end'] = $parts[$start][$type_name]['end'] - $featureloc->fmin;
  494. $parts[$start][$type_name]['type'] = $type_name;
  495. }
  496. else {
  497. // this is on the reverse strand. We need to swap the start and stop and calculate from the
  498. // begining of the reverse sequence
  499. $size = ($featureloc->fmax - $featureloc->fmin);
  500. $start_orig = $parts[$start][$type_name]['start'];
  501. $end_orig = $parts[$start][$type_name]['end'];
  502. $new_start = $size - ($end_orig - $featureloc->fmin);
  503. $new_end = $size - ($start_orig - $featureloc->fmin);
  504. $rparts[$new_start][$type_name]['start'] = $new_start;
  505. $rparts[$new_start][$type_name]['end'] = $new_end;
  506. $rparts[$new_start][$type_name]['type'] = $type_name;
  507. }
  508. }
  509. }
  510. // now sort the parts
  511. // if we're on the reverse strand we need to resort
  512. if ($featureloc->strand >= 0) {
  513. usort($parts, 'tripal_feature_sort_rel_parts_by_start');
  514. }
  515. else {
  516. usort($rparts, 'tripal_feature_sort_rel_parts_by_start');
  517. $parts = $rparts;
  518. }
  519. $floc_sequences[$src]['src'] = $src;
  520. $floc_sequences[$src]['type'] = $featureloc->feature_id->type_id->name;
  521. $args = array(':feature_id' => $featureloc->srcfeature_id->feature_id);
  522. $start = $featureloc->fmin + 1;
  523. $size = $featureloc->fmax - $featureloc->fmin;
  524. // TODO: fix the hard coded $start and $size
  525. // the $start and $size variables are hard-coded in the SQL statement
  526. // because the db_query function places quotes around all placeholders
  527. // (e.g. :start & :size) and screws up the substring function
  528. $sql = "
  529. SELECT substring(residues from $start for $size) as residues
  530. FROM {feature}
  531. WHERE feature_id = :feature_id
  532. ";
  533. $sequence = chado_query($sql, $args)->fetchObject();
  534. $residues = $sequence->residues;
  535. if ($featureloc->strand < 0) {
  536. $residues = tripal_feature_reverse_complement($residues);
  537. }
  538. $strand = '.';
  539. if ($featureloc->strand == 1) {
  540. $strand = '+';
  541. }
  542. elseif ($featureloc->strand == -1) {
  543. $strand = '-';
  544. }
  545. $defline = $featureloc->feature_id->name . " " . $featureloc->srcfeature_id->name . ":" . ($featureloc->fmin + 1) . ".." . $featureloc->fmax . " " . $strand;
  546. $floc_sequences[$src]['formatted_seq'] = tripal_feature_color_sequence($residues, $parts, $defline);
  547. }
  548. }
  549. return $floc_sequences;
  550. }
  551. /**
  552. *
  553. *
  554. * @ingroup tripal_feature
  555. */
  556. function tripal_feature_get_matched_alignments($feature) {
  557. // This function is for features that align through an intermediate such
  558. // as 'EST_match' or 'match'. This occurs in the case where two sequences
  559. // align but where one does not align perfectly. Some ESTs may be in a contig
  560. // but not all of the EST. Portions may overhang and not be included in the
  561. // consensus if quality is bad.
  562. // For example:
  563. //
  564. // Feature 1: Contig --------------------
  565. // Feature 2: EST_match -------
  566. // Feature 3: EST ---------
  567. //
  568. // The feature provided to the function will always be the feature 1. The
  569. // featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
  570. // alignment of feature 3 with feature 2
  571. //
  572. // Features may align to more than one feature and are not matches. We do
  573. // not want to include these, so we have to filter on the SO terms:
  574. // match, or %_match
  575. //
  576. $sql = "
  577. SELECT
  578. FL1.featureloc_id as left_featureloc_id,
  579. FL1.srcfeature_id as left_srcfeature_id,
  580. FL1.feature_id as left_feature_id,
  581. FL1.fmin as left_fmin,
  582. FL1.is_fmin_partial as left_is_fmin_partial,
  583. FL1.fmax as left_fmax,
  584. FL1.is_fmax_partial as left_is_fmax_partial,
  585. FL1.strand as left_strand,
  586. FL1.phase as left_phase,
  587. FL1.locgroup as left_locgroup,
  588. FL1.rank as left_rank,
  589. FL2.featureloc_id as right_featureloc_id,
  590. FL2.srcfeature_id as right_srcfeature_id,
  591. FL2.feature_id as right_feature_id,
  592. FL2.fmin as right_fmin,
  593. FL2.is_fmin_partial as right_is_fmin_partial,
  594. FL2.fmax as right_fmax,
  595. FL2.is_fmax_partial as right_is_fmax_partial,
  596. FL2.strand as right_strand,
  597. FL2.phase as right_phase,
  598. FL2.locgroup as right_locgroup,
  599. FL2.rank as right_rank
  600. FROM {feature} F1
  601. INNER JOIN {featureloc} FL1 on FL1.srcfeature_id = F1.feature_id
  602. INNER JOIN {feature} F2 on FL1.feature_id = F2.feature_id
  603. INNER JOIN {featureloc} FL2 on FL2.feature_id = F2.feature_id
  604. INNER JOIN {cvterm} CVT2 on F2.type_id = CVT2.cvterm_id
  605. WHERE
  606. F1.feature_id = :feature_id AND
  607. (CVT2.name = 'match' or CVT2.name like '%_match')
  608. ORDER BY FL1.fmin
  609. ";
  610. $results = chado_query($sql, array(':feature_id' => $feature->feature_id));
  611. // iterate through the results and add them to our featurelocs array
  612. $featurelocs = array();
  613. while ($fl = $results->fetchObject()) {
  614. // ignore featurelocs where the left and right srcfeature is the same
  615. if (strcmp($fl->left_srcfeature_id, $fl->right_srcfeature_id) == 0) {
  616. continue;
  617. }
  618. $featurelocs[] = $fl ;
  619. }
  620. return $featurelocs;
  621. }
  622. /**
  623. *
  624. *
  625. * @ingroup tripal_feature
  626. */
  627. function tripal_feature_load_organism_feature_counts($organism) {
  628. // don't show the browser if the settings in the admin page is turned off
  629. // instead return the array indicating the status of the browser
  630. $show_counts = variable_get('tripal_feature_summary_setting', 'show_feature_summary');
  631. if (strcmp($show_counts, 'show_feature_summary')!=0) {
  632. return array('enabled' => FALSE );
  633. }
  634. $args = array();
  635. $names = array();
  636. $order = array();
  637. // build the where clause for the SQL statement if we have a custom term list
  638. // we'll also keep track of the names the admin provided (if any) and the
  639. // order that the terms should appear.
  640. $is_custom = 0;
  641. $temp = rtrim(variable_get('tripal_feature_summary_report_mapping', ''));
  642. $where = '';
  643. if ($temp) {
  644. $is_custom = 1;
  645. $temp = explode("\n", $temp);
  646. $i = 0;
  647. foreach ($temp as $key => $value) {
  648. // separate the key value pairs
  649. $temp2 = explode("=", $value);
  650. $feature_type = rtrim($temp2[0]);
  651. $args[] = $feature_type;
  652. $order[] = $feature_type;
  653. // if a new name is provided then use that otherwise just
  654. // use the feature type
  655. if (count($temp2) == 2) {
  656. $names[":name$i"] = rtrim($temp2[1]);
  657. }
  658. else {
  659. $names[":name$i"] = $feature_type;
  660. }
  661. $where .= " OFC.feature_type = :name$i OR ";
  662. $i++;
  663. }
  664. if ($where) {
  665. $where = drupal_substr($where, 0, -5); # remove OR from the end
  666. $where = "($where) AND";
  667. }
  668. }
  669. // get the feature counts. This is dependent on a materialized view
  670. // installed with the organism module
  671. $sql = "
  672. SELECT OFC.num_features,OFC.feature_type,CVT.definition
  673. FROM {organism_feature_count} OFC
  674. INNER JOIN {cvterm} CVT on OFC.cvterm_id = CVT.cvterm_id
  675. WHERE $where organism_id = :organism_id
  676. ORDER BY num_features desc
  677. ";
  678. $args[':organism_id'] = $organism->organism_id;
  679. $org_features = chado_query($sql, $args);
  680. // iterate through the types
  681. $types = array();
  682. while ($type = $org_features->fetchObject()) {
  683. $types[$type->feature_type] = $type;
  684. // if we don't have an order this means we didn't go through the loop
  685. // above to set the names, so do that now
  686. if (!$is_custom) {
  687. $names[] = $type->feature_type;
  688. $order[] = $type->feature_type;
  689. }
  690. }
  691. # now reorder the types
  692. $ordered_types = array();
  693. foreach ($order as $type) {
  694. $ordered_types[] = $types[$type];
  695. }
  696. return array( 'types' => $ordered_types, 'names' => $names, 'enabled' => TRUE );
  697. }
  698. /**
  699. * used to sort the list of relationship parts by start position
  700. *
  701. * @ingroup tripal_feature
  702. */
  703. function tripal_feature_sort_rel_parts_by_start($a, $b) {
  704. foreach ($a as $type_name => $details) {
  705. $astart = $a[$type_name]['start'];
  706. break;
  707. }
  708. foreach ($b as $type_name => $details) {
  709. $bstart = $b[$type_name]['start'];
  710. break;
  711. }
  712. return strnatcmp($astart, $bstart);
  713. }
  714. /**
  715. * used to sort the list of relationship parts by start position
  716. *
  717. * @ingroup tripal_feature
  718. */
  719. function tripal_feature_sort_rel_parts_by_end($a, $b) {
  720. $val = strnatcmp($b['end'], $a['end']);
  721. if ($val == 0) {
  722. return strcmp($a['type'], $b['type']);
  723. }
  724. return $val;
  725. }
  726. /**
  727. *
  728. *
  729. * @ingroup tripal_feature
  730. */
  731. function tripal_feature_color_sequence($sequence, $parts, $defline) {
  732. $types = array();
  733. // first get the list of types so we can create a color legend
  734. foreach ($parts as $index => $t) {
  735. foreach ($t as $type_name => $details) {
  736. $types[$type_name] = 1;
  737. }
  738. }
  739. $newseq = "<div id=\"tripal_feature-featureloc_sequence-legend\">Legend: ";
  740. foreach ($types as $type_name => $present) {
  741. $newseq .= "<span id=\"tripal_feature-legend-$type_name\" class=\"tripal_feature-legend-item tripal_feature-featureloc_sequence-$type_name\" script=\"\">$type_name</span>";
  742. }
  743. $newseq .= "</div>Hold the cursor over a type above to highlight its positions in the sequence below. The colors in the sequence below merge when types overlap.";
  744. // set the background color of the rows based on the type
  745. $pos = 0;
  746. $newseq .= "<pre id=\"tripal_feature-featureloc_sequence\">";
  747. $newseq .= ">$defline\n";
  748. // iterate through the parts. They should be in order.
  749. $ends = array();
  750. $seqcount = 0;
  751. foreach ($parts as $index => $types) {
  752. // get the start for this part. All types in this part start at the
  753. // same position so we only need the first record
  754. foreach ($types as $type => $child) {
  755. $start = $child['start'];
  756. break;
  757. }
  758. // add in the sequence up to the start of this part
  759. for ($i = $pos; $i < $start; $i++) {
  760. $newseq .= $sequence{$pos};
  761. $seqcount++;
  762. if ($seqcount % 50 == 0) {
  763. $newseq .= "\n";
  764. }
  765. if (array_key_exists($pos, $ends)) {
  766. foreach ($ends[$pos] as $end) {
  767. $newseq .= "</span>";
  768. }
  769. }
  770. $pos++;
  771. }
  772. // we want to sort the parts by their end. We want the span tag to
  773. // to be added in the order the parts end.
  774. usort($types, 'tripal_feature_sort_rel_parts_by_end');
  775. // now add the child span for all types that start at this position
  776. foreach ($types as $type) {
  777. $class = "tripal_feature-featureloc_sequence-" . $type['type'];
  778. $newseq .= "<span class=\"$class\">";
  779. // add the end position
  780. $end = $type['end'];
  781. $ends[$end][] = $end;
  782. }
  783. }
  784. // add in rest of the sequence
  785. for ($i = $pos; $i < strlen($sequence); $i++) {
  786. $newseq .= $sequence{$pos};
  787. $seqcount++;
  788. if ($seqcount % 50 == 0) {
  789. $newseq .= "\n";
  790. }
  791. if (array_key_exists($pos, $ends)) {
  792. foreach ($ends[$pos] as $end) {
  793. $newseq .= "</span>";
  794. }
  795. }
  796. $pos++;
  797. }
  798. $newseq .= "</pre>";
  799. return $newseq;
  800. }
  801. /**
  802. *
  803. *
  804. * @ingroup tripal_feature
  805. */
  806. function tripal_feature_cv_chart($chart_id) {
  807. // we only want the chart to show feature types setup by the admin
  808. $temp = rtrim(variable_get('tripal_feature_summary_report_mapping', ''));
  809. $where = '';
  810. if ($temp) {
  811. $temp = explode("\n", $temp);
  812. foreach ($temp as $key => $value) {
  813. $temp2 = explode("=", $value);
  814. $feature_type = rtrim($temp2[0]);
  815. $where .= "CNT.feature_type = '$feature_type' OR \n";
  816. }
  817. if ($where) {
  818. $where = drupal_substr($where, 0, -5); # remove OR from the end
  819. $where = "($where) AND";
  820. }
  821. }
  822. $organism_id = preg_replace("/^tripal_feature_cv_chart_(\d+)$/", "$1", $chart_id);
  823. // The CV module will create the JSON array necessary for buillding a
  824. // pie chart using jgChart and Google Charts. We have to pass to it
  825. // a table that contains count information, tell it which column
  826. // contains the cvterm_id and provide a filter for getting the
  827. // results we want from the table.
  828. $options = array(
  829. count_mview => 'organism_feature_count',
  830. cvterm_id_column => 'cvterm_id',
  831. count_column => 'num_features',
  832. size => '550x200',
  833. filter => "$where CNT.organism_id = $organism_id",
  834. );
  835. return $options;
  836. }
  837. /**
  838. *
  839. *
  840. * @ingroup tripal_feature
  841. */
  842. function tripal_feature_cv_tree($tree_id) {
  843. // The CV module will create the JSON array necessary for buillding a
  844. // pie chart using jgChart and Google Charts. We have to pass to it
  845. // a table that contains count information, tell it which column
  846. // contains the cvterm_id and provide a filter for getting the
  847. // results we want from the table.
  848. $organism_id = preg_replace("/^tripal_feature_cv_tree_(\d+)$/", "$1", $tree_id);
  849. $options = array(
  850. cv_id => tripal_cv_get_cv_id('sequence'),
  851. count_mview => 'organism_feature_count',
  852. cvterm_id_column => 'cvterm_id',
  853. count_column => 'num_features',
  854. filter => "CNT.organism_id = $organism_id",
  855. label => 'Features',
  856. );
  857. return $options;
  858. }
  859. /**
  860. *
  861. *
  862. * @ingroup tripal_feature
  863. */
  864. function tripal_feature_del_vocabulary() {
  865. //include the file containing the required functions for adding taxonomy vocabs
  866. module_load_include('inc', 'taxonomy', 'taxonomy.admin');
  867. // get the vocabularies
  868. $vocabularies = taxonomy_get_vocabularies();
  869. // These taxonomic terms are hard coded because we
  870. // know we have these relationships in the chado tables
  871. // through foreign key relationships. The tripal
  872. // modules that correspond to these chado "modules" don't
  873. // need to be installed for the taxonomy to work.
  874. foreach ($vocabularies as $vocab) {
  875. if ($vocab->name == 'Feature Type') {
  876. taxonomy_vocabulary_delete($vocab->vid);
  877. }
  878. if ($vocab->name == 'Organism') {
  879. taxonomy_vocabulary_delete($vocab->vid);
  880. }
  881. if ($vocab->name == 'Library') {
  882. taxonomy_vocabulary_delete($vocab->vid);
  883. }
  884. if ($vocab->name == 'Analysis') {
  885. taxonomy_vocabulary_delete($vocab->vid);
  886. }
  887. }
  888. }
  889. /**
  890. *
  891. *
  892. * @ingroup tripal_feature
  893. */
  894. function tripal_feature_job_describe_args($callback, $args) {
  895. $new_args = array();
  896. if ($callback == 'tripal_feature_load_fasta') {
  897. $new_args['FASTA file'] = $args[0];
  898. $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[1]));
  899. $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
  900. $new_args['Sequence Type'] = $args[2];
  901. $new_args['Name Match Type'] = $args[14];
  902. $new_args['Name RE'] = $args[4];
  903. $new_args['Unique Name RE'] = $args[5];
  904. // add in the relationship arguments
  905. $new_args['Relationship Type'] = $args[8];
  906. $new_args['Relationship Parent RE'] = $args[9];
  907. $new_args['Relationship Parent Type'] = $args[10];
  908. // add in the database reference arguments
  909. if ($args[7]) {
  910. $db = tripal_core_chado_select('db', array('name'), array('db_id' => $args[7]));
  911. }
  912. $new_args['Database Reference'] = $db[0]->name;
  913. $new_args['Accession RE'] = $args[6];
  914. $new_args['Method'] = $args[11];
  915. // add in the analysis
  916. if ($args[13]) {
  917. $analysis = tripal_core_chado_select('analysis', array('name'), array('analysis_id' => $args[13]));
  918. }
  919. $new_args['Analysis'] = $analysis[0]->name;
  920. }
  921. if ($callback == 'tripal_feature_delete_features') {
  922. if ($args[0]) {
  923. $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[0]));
  924. $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
  925. }
  926. else {
  927. $new_args['Organism'] = '';
  928. }
  929. if ($args[1]) {
  930. $analysis = tripal_core_chado_select('analysis', array('name'), array('analysis_id' => $args[1]));
  931. $new_args['Analysis'] = $analysis[0]->name;
  932. }
  933. else {
  934. $new_args['Analysis'] = '';
  935. }
  936. $new_args['Sequence Type'] = $args[2];
  937. $new_args['Is Unique Name'] = $args[3];
  938. $new_args['Features Names'] = $args[4];
  939. }
  940. elseif ($callback == 'tripal_feature_load_gff3') {
  941. $new_args['GFF File'] = $args[0];
  942. $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[1]));
  943. $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
  944. $analysis = tripal_core_chado_select('analysis', array('name'), array('analysis_id' => $args[2]));
  945. $new_args['Analysis'] = $analysis[0]->name;
  946. $new_args['Use a Transaction'] = ($args[7] == 1) ? "Yes" : "No";
  947. $new_args['Import only new features'] = ($args[3] == 1) ? "Yes" : "No";
  948. $new_args['Import all and update'] = ($args[4] == 1) ? "Yes" : "No";
  949. $new_args['Import all and replace'] = ($args[5] == 1) ? "Yes" : "No";
  950. $new_args['Delete features'] = ($args[6] == 1) ? "Yes" : "No";
  951. if ($args[8]) {
  952. $target_organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[8]));
  953. $new_args['Target organism'] = $target_organism[0]->genus . " " . $target_organism[0]->species;
  954. }
  955. else {
  956. $new_args['Target organism'] = '';
  957. }
  958. $new_args['Target type'] = $args[9];
  959. $new_args['Create target'] = ($args[10] == 1) ? "Yes" : "No";
  960. $new_args['Starting line'] = $args[11];
  961. $new_args['Landmark Type'] = $args[12];
  962. $new_args['Alternate ID attribute'] = $args[13];
  963. $new_args['Create Organism'] = ($args[14] == 1) ? "Yes" : "No";
  964. }
  965. return $new_args;
  966. }
  967. /**
  968. * Implements hook_coder_ignore().
  969. * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
  970. */
  971. function tripal_feature_coder_ignore() {
  972. return array(
  973. 'path' => drupal_get_path('module', 'tripal_feature'),
  974. 'line prefix' => drupal_get_path('module', 'tripal_feature'),
  975. );
  976. }
  977. /*
  978. * Uses the value provided in the $id argument to find all features that match
  979. * that ID by name, featurename or synonym. If it matches uniquenly to a single
  980. * feature it will redirect to that feature page, otherwise, a list of matching
  981. * features is shown.
  982. */
  983. function tripal_feature_match_features_page($id) {
  984. // if the URL alias configuration is set such that the URL
  985. // always begins with 'feature' then we want to use the ID as it is and
  986. // forward it on. Otherwise, try to find the matching feature.
  987. $url_alias = variable_get('chado_feature_url_string', '/feature/[genus]/[species]/[type]/[uniquename]');
  988. if (!$url_alias) {
  989. $url_alias = '/feature/[genus]/[species]/[type]/[uniquename]';
  990. }
  991. $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash
  992. if (preg_match('/^feature\//', $url_alias)) {
  993. drupal_goto($id);
  994. }
  995. $sql = "
  996. SELECT
  997. F.name, F.uniquename, F.feature_id,
  998. O.genus, O.species, O.organism_id,
  999. CVT.cvterm_id, CVT.name as type_name,
  1000. CF.nid,
  1001. array_agg(S.name) as synonyms
  1002. FROM {feature} F
  1003. INNER JOIN {organism} O on F.organism_id = O.organism_id
  1004. INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id
  1005. LEFT JOIN {feature_synonym} FS on FS.feature_id = F.feature_id
  1006. LEFT JOIN {synonym} S on S.synonym_id = FS.synonym_id
  1007. INNER JOIN public.chado_feature CF on CF.feature_id = F.feature_id
  1008. WHERE
  1009. F.uniquename = :uname or
  1010. F.name = :fname' or
  1011. S.name = :sname
  1012. GROUP BY F.name, F.uniquename, F.feature_id, O.genus, O.species,
  1013. O.organism_id, CVT.cvterm_id, CVT.name, CF.nid
  1014. ";
  1015. $results = chado_query($sql, array(':uname' => $id, ':fname' => $id, ':sname' => $id));
  1016. $num_matches = 0;
  1017. // iterate through the matches and build the table for showing matches
  1018. $header = array('Uniquename', 'Name', 'Type', 'Species', 'Synonyms');
  1019. $rows = array();
  1020. $curr_match;
  1021. while ($match = $results->fetchObject()) {
  1022. $curr_match = $match;
  1023. $synonyms = $match->synonyms;
  1024. $synonyms = preg_replace('/[\"\{\}]/', '', $synonyms);
  1025. $rows[] = array(
  1026. $match->uniquename,
  1027. "<a href=\"" . url("node/" . $match->nid) . "\">" . $match->name . "</a>",
  1028. $match->type_name,
  1029. '<i>' . $match->genus . ' ' . $match->species . '</i>',
  1030. $synonyms,
  1031. );
  1032. $num_matches++;
  1033. }
  1034. // if we have more than one match then generate the table, otherwise, redirect
  1035. // to the matched feature
  1036. if ($num_matches == 1) {
  1037. drupal_goto("node/" . $curr_match->nid);
  1038. }
  1039. if ($num_matches == 0) {
  1040. return "<p>No features matched the given name '$id'</p>";
  1041. }
  1042. $table_attrs = array(
  1043. 'class' => 'tripal-table tripal-table-horz'
  1044. );
  1045. $output = "<p>The following features match the name '$id'.</p>";
  1046. $output .= theme_table($header, $rows, $table_attrs, $caption);
  1047. return $output;
  1048. }
  1049. /**
  1050. * Implementation of hook_form_alter()
  1051. *
  1052. * @param $form
  1053. * @param $form_state
  1054. * @param $form_id
  1055. */
  1056. function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
  1057. if ($form_id == "tripal_feature_seq_extract_form") {
  1058. // updating the form through the ahah callback sets the action of
  1059. // the form to the ahah callback URL. We need to set it back
  1060. // to the normal form URL
  1061. $form['#action'] = url("find/sequences");
  1062. }
  1063. // turn off preview button for insert/updates
  1064. if ($form_id == "chado_feature_node_form") {
  1065. $form['actions']['preview']['#access'] = FALSE;
  1066. }
  1067. }