tripal_feature.module 40 KB

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