tripal_organism.module 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <?php
  2. require_once "tripal_organism.api.inc";
  3. /**
  4. * @file
  5. * @defgroup tripal_organism Organism
  6. * @ingroup tripal_modules
  7. */
  8. /**
  9. *
  10. * @ingroup tripal_organism
  11. */
  12. function tripal_organism_init() {
  13. // add the jGCharts JS and CSS
  14. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_organism.js');
  15. drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_organism.css');
  16. }
  17. /**
  18. * Provide information to drupal about the node types that we're creating
  19. * in this module
  20. *
  21. * @ingroup tripal_organism
  22. */
  23. function tripal_organism_node_info() {
  24. $nodes = array();
  25. $nodes['chado_organism'] = array(
  26. 'name' => t('Organism'),
  27. 'module' => 'chado_organism',
  28. 'description' => t('An organism from the chado database'),
  29. 'has_title' => FALSE,
  30. 'title_label' => t('Organism'),
  31. 'has_body' => FALSE,
  32. 'body_label' => t('Organism Description'),
  33. 'locked' => TRUE
  34. );
  35. return $nodes;
  36. }
  37. /**
  38. * Display block with organisms
  39. * @param op - parameter to define the phase being called for the block
  40. * @param delta - id of the block to return (ignored when op is list)
  41. * @param edit - when op is save, contains the submitted form data
  42. *
  43. * @ingroup tripal_organism
  44. */
  45. function tripal_organism_block($op = 'list', $delta = '0', $edit = array()) {
  46. switch ($op) {
  47. case 'list':
  48. $blocks['base']['info'] = t('Tripal Organism Details');
  49. $blocks['base']['cache'] = BLOCK_NO_CACHE;
  50. $blocks['description']['info'] = t('Tripal Organism Description');
  51. $blocks['description']['cache'] = BLOCK_NO_CACHE;
  52. $blocks['image']['info'] = t('Tripal Organism Image');
  53. $blocks['image']['cache'] = BLOCK_NO_CACHE;
  54. return $blocks;
  55. case 'view':
  56. if (user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
  57. $nid = arg(1);
  58. $node = node_load($nid);
  59. $block = array();
  60. switch ($delta) {
  61. case 'base':
  62. $block['subject'] = t('Organism Details');
  63. $block['content'] = theme('tripal_organism_base', $node);
  64. break;
  65. case 'description':
  66. $block['subject'] = t('Organism Description');
  67. $block['content'] = theme('tripal_organism_description', $node);
  68. break;
  69. case 'image':
  70. $block['subject'] = t('Organism Image');
  71. $block['content'] = theme('tripal_organism_image', $node);
  72. break;
  73. default:
  74. }
  75. return $block;
  76. }
  77. }
  78. }
  79. /**
  80. * Menu items are automatically added for the new node types created
  81. * by this module to the 'Create Content' Navigation menu item. This function
  82. * adds more menu items needed for this module.
  83. *
  84. * @ingroup tripal_organism
  85. */
  86. function tripal_organism_menu() {
  87. $items = array();
  88. // the administative settings menu
  89. $items['admin/tripal/tripal_organism'] = array(
  90. 'title' => 'Organisms',
  91. 'description' => 'Basic Description of Tripal Organism Module Functionality',
  92. 'page callback' => 'tripal_organism_module_description_page',
  93. 'access arguments' => array('adminster tripal organism'),
  94. 'type' => MENU_NORMAL_ITEM,
  95. );
  96. $items['admin/tripal/tripal_organism/configuration'] = array(
  97. 'title' => 'Configuration',
  98. 'description' => 'Manage integration of Chado organisms including associated features',
  99. 'page callback' => 'drupal_get_form',
  100. 'page arguments' => array('tripal_organism_admin'),
  101. 'access arguments' => array('adminster tripal organism'),
  102. 'type' => MENU_NORMAL_ITEM,
  103. );
  104. return $items;
  105. }
  106. /**
  107. * The following function proves access control for users trying to
  108. * perform actions on data managed by this module
  109. *
  110. * @ingroup tripal_organism
  111. */
  112. function chado_organism_access($op, $node, $account) {
  113. if ($op == 'create') {
  114. if (!user_access('create chado_organism content', $account)) {
  115. return FALSE;
  116. }
  117. }
  118. if ($op == 'update') {
  119. if (!user_access('edit chado_organism content', $account)) {
  120. return FALSE;
  121. }
  122. }
  123. if ($op == 'delete') {
  124. if (!user_access('delete chado_organism content', $account)) {
  125. return FALSE;
  126. }
  127. }
  128. if ($op == 'view') {
  129. if (!user_access('access chado_organism content', $account)) {
  130. return FALSE;
  131. }
  132. }
  133. return NULL;
  134. }
  135. /**
  136. * Set the permission types that the chado module uses. Essentially we
  137. * want permissionis that protect creation, editing and deleting of chado
  138. * data objects
  139. *
  140. *
  141. @ingroup tripal_organism
  142. */
  143. function tripal_organism_perm() {
  144. return array(
  145. 'access chado_organism content',
  146. 'create chado_organism content',
  147. 'delete chado_organism content',
  148. 'edit chado_organism content',
  149. 'adminster tripal organism',
  150. );
  151. }
  152. /**
  153. * Purpose: Provide Guidance to new Tripal Admin
  154. *
  155. * @return HTML Formatted text
  156. *
  157. * @ingroup tripal_organism
  158. */
  159. function tripal_organism_module_description_page() {
  160. $text = '';
  161. $text .= '<h3>Tripal Organism Administrative Tools Quick Links:</h3>';
  162. $text .= "<ul>
  163. <li><a href=\"" . url("admin/tripal/tripal_organism/configuration") . "\">Organism Configuration</a></li>
  164. </ul>";
  165. $text .= '<h3>Module Description:</h3>';
  166. $text .= '<p>The Tripal Organism module allows you to add, edit and/or delete chado organisms.
  167. Furthermore, it also provides listing of organisms and details page for each organism.
  168. Basically, the chado organism module is designed to hold information about a given species.
  169. For more information on the chado organism module see the
  170. <a href="http://gmod.org/wiki/Chado_Organism_Module">GMOD wiki page</a></p>';
  171. $text .= '<h3>Setup Instructions:</h3>';
  172. $text .= '<p>After installation of the organism module. The following tasks should be performed.
  173. <ol>
  174. <li><p><b>Set Permissions</b>: The organism module supports the Drupal user permissions interface for
  175. controlling access to organism content and functions. These permissions include viewing,
  176. creating, editing or administering of
  177. organism content. The default is that only the original site administrator has these
  178. permissions. You can <a href="' . url('admin/user/roles') . '">add roles</a> for classifying users,
  179. <a href="' . url('admin/user/user') . '">assign users to roles</a> and
  180. <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the organism content to
  181. those roles. For a simple setup, allow anonymous users access to view organism content and
  182. allow the site administrator all other permissions.</p></li>
  183. <li><p><b>Create Organisms</b>: Organism pages can be created in two ways:
  184. <ol>
  185. <li><b>Sync Organisms</b>: If your organism has been pre-loaded into Chado then you need to sync the organism.
  186. This process is what creates the pages for viewing online. Not all organisms need be synced, only those
  187. that you want shown on the site. Use the the
  188. <a href="' . url('admin/tripal/tripal_organism/configuration') . '">Organism Configuration page</a>
  189. to sync organisms. </li>
  190. <li><b>Manually Add An Organism</b>: If your organism is not already present in the Chado database
  191. you can create an organism using the <a href="' . url('node/add/chado-organism') . '">Create Organism page</a>.
  192. Once saved, the organism will be present in Chado and also "synced".
  193. </ol></p></li>
  194. <li><p><b>Indexing</b>: Once organism pages are ready for public access,
  195. you can index the organism pages for searching if you want to ues the Drupal default search mechanism.
  196. Use the <a href="' . url('admin/tripal/tripal_organism/configuration') . '">Organism Configuration page</a>
  197. to either Index (for the first time) or "Reindex" (after updating data)
  198. the organism pages for searching. Once the site is 100% indexed the pages will be searchable using Drupal\'s
  199. full text searching. You can find the percent indexed for the entire site by visiting the
  200. <a href="' . url('admin/settings/search') . '">Search settings page</a>. Indexing
  201. can take quite a while if you have a lot of data</p></li>
  202. <li><p><b>Set Taxonomy</b>: Drupal provides a mechanism for categorizing content to allow
  203. for advanced searching. Drupal calls this "Taxonomy", but is essentially categorizing the pages.
  204. You can categorize feature pages by the
  205. organism to which they belong. This allows for filtering of search results by organism.
  206. Use the <a href="' . url('admin/tripal/tripal_organism/configuration') . '">Organism Configuration page</a> to
  207. set the Taxonomy.</p></li>
  208. </ol>';
  209. $text .= '<h3>Features of this Module:</h3>';
  210. $text .= '<p>Aside from organism page setup (as described in the Setup section above),
  211. The Tripal organism module also provides the following functionality
  212. <ul>
  213. <li><p><b>Integration with Drupal Views</b>: <a href="http://drupal.org/project/views">Drupal Views</a> is
  214. a powerful tool that allows the site administrator to create lists or basic searching forms of Chado content.
  215. It provides a graphical interface within Drupal to allow the site admin to directly query the Chado database
  216. and create custom lists without PHP programming or customization of Tripal source code. Views can also
  217. be created to filter content that has not yet been synced with Druapl in order to protect access to non
  218. published data (only works if Chado was installed using Tripal). You can see a list of available pre-existing
  219. Views <a href="' . url('admin/build/views/') . '">here</a>, as well as create your own. </p></li>
  220. <li><p><b>Basic Organism List</b>: This module provides a basic <a href="' . url('organisms') . '">organism list</a>
  221. for showing the list of organisms in Chado. <a href="http://drupal.org/project/views">Drupal Views</a> must be
  222. installed. You can use the Views interface to alter the appearance of this list.</p></li>
  223. </ul>
  224. </p>';
  225. $text .= '<h3>Page Customizations</h3>';
  226. $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
  227. Below is a description of several methods. These methods may be used in conjunction with one another to
  228. provide fine-grained control.
  229. <ul>
  230. <li><p><b>Integration with Drupal Panels</b>: <a href="http://drupal.org/project/views">Drupal Panels</a>
  231. allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming. Tripal comes with pre-set layouts for organism pages. However,
  232. Panels become useful if you prefer a layout that is different from the pre-set layouts. Chado content
  233. is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
  234. Panel\'s GUI.</p></li>
  235. <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
  236. <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
  237. to any page without need to edit template files or knowing PHP. You must first download and install CCK.
  238. With CCK, the site administartor can create a new field to appear on the page. For example, currently,
  239. the Chado publication module is not yet supported by Tripal. Therefore, the site administrator can add a text
  240. field to the organism pages. This content is not stored in Chado, but will appear on the organism page. A field
  241. added by CCK will also appear in the form when editing a organism to allow users to manually enter the appropriate
  242. text. If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
  243. indicate that it is not to be shown (using the CCK interface), then manually add the new content type
  244. where desired by editing the templates (as described below). If using Panels, the CCK field can be added to the
  245. location desired using the Panels interface.</p></li>
  246. <li><p><b>Drupal Node Templates</b>: The Tripal packages comes with a "theme_tripal" directory that contains the
  247. themeing for Chado content. The organism module has a template file for organism "nodes" (Tripal organism pages). This file
  248. is named "node-chado_organism.tpl.php", and provides javascript, HTML and PHP code for display of the organism
  249. pages. You can edit this file to control which types of information (or which organism "blocks") are displayed for organisms. Be sure to
  250. copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
  251. future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
  252. for instructions on how to access variables and other Chado content within the template file.</p></li>
  253. <li><p><b>Organism "Block" Templates</b>: In the "theme_tripal" directory is a subdirectory named "tripal_organism".
  254. Inside this directory is a set of templates that control distinct types of information for organisms. For example,
  255. there is a "base" template for displaying of data directly from the Chado organism table, and a "references"
  256. template for showing external site references for a organism (data from the organism_dbxref table). These templates are used both by Drupal blocks
  257. for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
  258. provides (also desribed above). You can customize this template as you desire. Be sure to copy the
  259. template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
  260. future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
  261. for instructions on how to access variables and other Chado content within the template files.</p></li>
  262. </li>
  263. <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
  264. will see a "Resources" sidebar on each page. The links that appear on the sidebar are automatically generated
  265. using Javascript for all of the organism "Blocks" that appear on the page. If you want to add additional links
  266. (e.g. a dynamic link to GBrowse for the organism) and you want that link to appear in the
  267. "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
  268. section at the bottom of the template file where the resources section is found.</p></li>
  269. </ul>
  270. </p>';
  271. return $text;
  272. }
  273. /**
  274. * Administrative settings for chado_orgnism
  275. *
  276. * @ingroup tripal_organism
  277. */
  278. function tripal_organism_admin() {
  279. $form = array();
  280. // before proceeding check to see if we have any
  281. // currently processing jobs. If so, we don't want
  282. // to give the opportunity to sync libraries
  283. $active_jobs = FALSE;
  284. if (tripal_get_module_active_jobs('tripal_organism')) {
  285. $active_jobs = TRUE;
  286. }
  287. // add the field set for syncing libraries
  288. if (!$active_jobs) {
  289. get_tripal_organism_admin_form_sync_set($form);
  290. get_tripal_organism_admin_form_reindex_set($form);
  291. get_tripal_organism_admin_form_taxonomy_set($form);
  292. get_tripal_organism_admin_form_cleanup_set($form);
  293. }
  294. else {
  295. $form['notice'] = array(
  296. '#type' => 'fieldset',
  297. '#title' => t('Organism Management Temporarily Unavailable')
  298. );
  299. $form['notice']['message'] = array(
  300. '#value' => t('Currently, organism management jobs are waiting or are running. . Managemment features have been hidden until these jobs complete. Please check back later once these jobs have finished. You can view the status of pending jobs in the Tripal jobs page.'),
  301. );
  302. }
  303. return system_settings_form($form);
  304. }
  305. /**
  306. *
  307. *
  308. * @ingroup tripal_organism
  309. */
  310. function get_tripal_organism_admin_form_cleanup_set(&$form) {
  311. $form['cleanup'] = array(
  312. '#type' => 'fieldset',
  313. '#title' => t('Clean Up')
  314. );
  315. $form['cleanup']['description'] = array(
  316. '#type' => 'item',
  317. '#value' => t("With Drupal and chado residing in different databases ".
  318. "it is possible that nodes in Drupal and organisms in Chado become ".
  319. "\"orphaned\". This can occur if an organism node in Drupal is ".
  320. "deleted but the corresponding chado organism is not and/or vice ".
  321. "versa. Click the button below to resolve these discrepancies."),
  322. '#weight' => 1,
  323. );
  324. $form['cleanup']['button'] = array(
  325. '#type' => 'submit',
  326. '#value' => t('Clean up orphaned organisms'),
  327. '#weight' => 2,
  328. );
  329. }
  330. /**
  331. *
  332. *
  333. * @ingroup tripal_organism
  334. */
  335. function get_tripal_organism_admin_form_taxonomy_set(&$form) {
  336. $form['taxonify'] = array(
  337. '#type' => 'fieldset',
  338. '#title' => t('Assign Drupal Taxonomy to Organism Features')
  339. );
  340. // get the list of libraries
  341. $sql = "SELECT * FROM {Organism} ORDER BY genus,species";
  342. $org_rset = chado_query($sql);
  343. // iterate through all of the libraries
  344. $org_boxes = array();
  345. while ($organism = db_fetch_object($org_rset)) {
  346. $org_boxes[$organism->organism_id] = "$organism->genus $organism->species";
  347. }
  348. $form['taxonify']['description'] = array(
  349. '#type' => 'item',
  350. '#value' => t("Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
  351. "nodes. These terms allow for advanced filtering during searching. This option allows ".
  352. "for setting taxonomy only for features that belong to the selected organisms below. All other features will be unaffected. To set taxonomy for all features in the site see the Feature Administration page."),
  353. '#weight' => 1,
  354. );
  355. $form['taxonify']['tx-organisms'] = array(
  356. '#title' => t('Organisms'),
  357. '#type' => t('checkboxes'),
  358. '#description' => t("Check the organisms whose features you want to reset taxonomy. Note: this list contains all organisms, even those that may not be synced."),
  359. '#required' => FALSE,
  360. '#prefix' => '<div id="lib_boxes">',
  361. '#suffix' => '</div>',
  362. '#options' => $org_boxes,
  363. '#weight' => 2
  364. );
  365. $form['taxonify']['tx-button'] = array(
  366. '#type' => 'submit',
  367. '#value' => t('Set Feature Taxonomy'),
  368. '#weight' => 3
  369. );
  370. }
  371. /**
  372. *
  373. * @ingroup tripal_organism
  374. */
  375. function get_tripal_organism_admin_form_reindex_set(&$form) {
  376. // define the fieldsets
  377. $form['reindex'] = array(
  378. '#type' => 'fieldset',
  379. '#title' => t('Reindex Organism Features')
  380. );
  381. // get the list of libraries
  382. $sql = "SELECT * FROM {Organism} ORDER BY genus,species";
  383. $org_rset = chado_query($sql);
  384. // iterate through all of the libraries
  385. $org_boxes = array();
  386. while ($organism = db_fetch_object($org_rset)) {
  387. $org_boxes[$organism->organism_id] = "$organism->genus $organism->species";
  388. }
  389. $form['reindex']['description'] = array(
  390. '#type' => 'item',
  391. '#value' => t("This option allows for reindexing of only those features that belong to the selected organisms below. All other features will be unaffected. To reindex all features in the site see the Feature Administration page."),
  392. '#weight' => 1,
  393. );
  394. $form['reindex']['re-organisms'] = array(
  395. '#title' => t('Organisms'),
  396. '#type' => t('checkboxes'),
  397. '#description' => t("Check the organisms whoee features you want to reindex. Note: this list contains all organisms, even those that may not be synced."),
  398. '#required' => FALSE,
  399. '#prefix' => '<div id="lib_boxes">',
  400. '#suffix' => '</div>',
  401. '#options' => $org_boxes,
  402. '#weight' => 2,
  403. );
  404. $form['reindex']['re-button'] = array(
  405. '#type' => 'submit',
  406. '#value' => t('Reindex Features'),
  407. '#weight' => 3,
  408. );
  409. }
  410. /**
  411. *
  412. * @ingroup tripal_organism
  413. */
  414. function get_tripal_organism_admin_form_sync_set(&$form) {
  415. // define the fieldsets
  416. $form['sync'] = array(
  417. '#type' => 'fieldset',
  418. '#title' => t('Sync Organisms')
  419. );
  420. // before proceeding check to see if we have any
  421. // currently processing jobs. If so, we don't want
  422. // to give the opportunity to sync libraries
  423. $active_jobs = FALSE;
  424. if (tripal_get_module_active_jobs('tripal_organism')) {
  425. $active_jobs = TRUE;
  426. }
  427. if (!$active_jobs) {
  428. // get the list of organisms
  429. $sql = "SELECT * FROM {Organism} ORDER BY genus,species";
  430. $org_rset = chado_query($sql);
  431. // if we've added any organisms to the list that can be synced
  432. // then we want to build the form components to allow the user
  433. // to select one or all of them. Otherwise, just present
  434. // a message stating that all organisms are currently synced.
  435. $org_boxes = array();
  436. $added = 0;
  437. while ($organism = db_fetch_object($org_rset)) {
  438. // check to see if the organism is already present as a node in drupal.
  439. // if so, then skip it.
  440. $sql = "SELECT * FROM {chado_organism} WHERE organism_id = %d";
  441. if (!db_fetch_object(db_query($sql, $organism->organism_id))) {
  442. $org_boxes[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
  443. $added++;
  444. }
  445. }
  446. // if we have organisms we need to add to the checkbox then
  447. // build that form element
  448. if ($added > 0) {
  449. $org_boxes['all'] = "All Organisms";
  450. $form['sync']['organisms'] = array(
  451. '#title' => t('Available Organisms'),
  452. '#type' => t('checkboxes'),
  453. '#description' => t("Check the organisms you want to sync. Drupal content will be created for each of the organisms listed above. Select 'All Organisms' to sync all of them."),
  454. '#required' => FALSE,
  455. '#prefix' => '<div id="org_boxes">',
  456. '#suffix' => '</div>',
  457. '#options' => $org_boxes,
  458. );
  459. $form['sync']['button'] = array(
  460. '#type' => 'submit',
  461. '#value' => t('Submit Sync Job')
  462. );
  463. }
  464. // we don't have any organisms to select from
  465. else {
  466. $form['sync']['value'] = array(
  467. '#value' => t('All organisms in Chado are currently synced with Drupal.')
  468. );
  469. }
  470. }
  471. // we don't want to present a form since we have an active job running
  472. else {
  473. $form['sync']['value'] = array(
  474. '#value' => t('Currently, jobs exist related to chado organisms. Please check back later for organisms that can by synced once these jobs have finished. You can view the status of pending jobs in the Tripal jobs page.')
  475. );
  476. }
  477. }
  478. /**
  479. *
  480. * @ingroup tripal_organism
  481. */
  482. function tripal_organism_admin_validate($form, &$form_state) {
  483. global $user; // we need access to the user info
  484. $job_args = array();
  485. if ($form_state['values']['op'] == t('Submit Sync Job')) {
  486. // check to see if the user wants to sync chado and drupal. If
  487. // so then we need to register a job to do so with tripal
  488. $organisms = $form_state['values']['organisms'];
  489. $do_all = FALSE;
  490. $to_sync = array();
  491. foreach ($organisms as $organism_id) {
  492. if (preg_match("/^all$/i" , $organism_id)) {
  493. $do_all = TRUE;
  494. }
  495. if ($organism_id and preg_match("/^\d+$/i" , $organism_id)) {
  496. // get the list of organisms
  497. $sql = "SELECT * FROM {Organism} WHERE organism_id = %d";
  498. $organism = db_fetch_object(chado_query($sql, $organism_id));
  499. $to_sync[$organism_id] = "$organism->genus $organism->species";
  500. }
  501. }
  502. // submit the job the tripal job manager
  503. if ($do_all) {
  504. tripal_add_job('Sync all organisms' , 'tripal_organism',
  505. 'tripal_organism_sync_organisms' , $job_args , $user->uid);
  506. }
  507. else{
  508. foreach ($to_sync as $organism_id => $name) {
  509. $job_args[0] = $organism_id;
  510. tripal_add_job("Sync organism: $name" , 'tripal_organism',
  511. 'tripal_organism_sync_organisms' , $job_args , $user->uid);
  512. }
  513. }
  514. }
  515. // -------------------------------------
  516. // Submit the Reindex Job if selected
  517. if ($form_state['values']['op'] == t('Reindex Features')) {
  518. $organisms = $form_state['values']['re-organisms'];
  519. foreach ($organisms as $organism_id) {
  520. if ($organism_id and preg_match("/^\d+$/i" , $organism_id)) {
  521. // get the organism info
  522. $sql = "SELECT * FROM {organism} WHERE organism_id = %d";
  523. $organism = db_fetch_object(chado_query($sql , $organism_id));
  524. $job_args[0] = $organism_id;
  525. tripal_add_job("Reindex features for organism: $organism->genus ".
  526. "$organism->species", 'tripal_organism' ,
  527. 'tripal_organism_reindex_features', $job_args, $user->uid);
  528. }
  529. }
  530. }
  531. // -------------------------------------
  532. // Submit the taxonomy Job if selected
  533. if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
  534. $organisms = $form_state['values']['tx-organisms'];
  535. foreach ($organisms as $organism_id) {
  536. if ($organism_id and preg_match("/^\d+$/i", $organism_id)) {
  537. // get the organism info
  538. $sql = "SELECT * FROM {organism} WHERE organism_id = %d";
  539. $organism = db_fetch_object(chado_query($sql , $organism_id));
  540. $job_args[0] = $organism_id;
  541. tripal_add_job("Set taxonomy for features in organism: ".
  542. "$organism->genus $organism->species" , 'tripal_organism',
  543. 'tripal_organism_taxonify_features', $job_args, $user->uid);
  544. }
  545. }
  546. }
  547. // -------------------------------------
  548. // Submit the Cleanup Job if selected
  549. if ($form_state['values']['op'] == t('Clean up orphaned organisms')) {
  550. tripal_add_job('Cleanup orphaned organisms', 'tripal_organism',
  551. 'tripal_organism_cleanup', $job_args, $user->uid);
  552. }
  553. }
  554. /**
  555. * We need to let drupal know about our theme functions and their arguments.
  556. * We create theme functions to allow users of the module to customize the
  557. * look and feel of the output generated in this module
  558. *
  559. * @ingroup tripal_organism
  560. */
  561. function tripal_organism_theme() {
  562. return array(
  563. 'tripal_organism_base' => array(
  564. 'arguments' => array('node' => NULL),
  565. 'template' => 'tripal_organism_base',
  566. ),
  567. 'tripal_organism_description' => array(
  568. 'arguments' => array('node' => NULL),
  569. 'template' => 'tripal_organism_description',
  570. ),
  571. 'tripal_organism_image' => array(
  572. 'arguments' => array('node' => NULL),
  573. 'template' => 'tripal_organism_image',
  574. ),
  575. 'tripal_organism_teaser' => array(
  576. 'arguments' => array('node' => NULL),
  577. 'template' => 'tripal_organism_teaser',
  578. ),
  579. );
  580. }
  581. /**
  582. *
  583. * @ingroup tripal_organism
  584. */
  585. function tripal_organism_nodeapi(&$node, $op, $teaser, $page) {
  586. switch ($op) {
  587. case 'view':
  588. switch ($node->type) {
  589. }
  590. }
  591. }
  592. /**
  593. *
  594. * @ingroup tripal_organism
  595. */
  596. function tripal_organism_cron() {
  597. // we want to make sure that any new organisms or features that were
  598. // added to the database external to drupal automatically get new
  599. // nodes created for themselves in drupal.
  600. // tripal_organism_sync_organisms();
  601. }
  602. /**
  603. *
  604. * @ingroup tripal_organism
  605. */
  606. function chado_organism_validate($node, &$form) {
  607. // if this is an update, we want to make sure that a different organism doesn't
  608. // already have this genus and speces
  609. if ($node->organism_id) {
  610. $sql = "SELECT *
  611. FROM {organism} O
  612. WHERE genus = '%s' and species = '%s' AND NOT organism_id = %d";
  613. $result = db_fetch_object(chado_query($sql, $node->genus, $node->species, $node->organism_id));
  614. if ($result) {
  615. form_set_error('genus', t("Update cannot proceed. The organism genus
  616. '$node->genus' and species '$node->species' is already present in the database."));
  617. watchdog('tripal_organism',
  618. 'Update organism: genus and species already exists: %values',
  619. array('%values' => "genus = $node->genus, species = $node->species"),
  620. WATCHDOG_WARNING);
  621. }
  622. }
  623. // if this is an insert then check to make sure the genus and species are unique
  624. else {
  625. $values = array(
  626. 'genus' => $node->genus,
  627. 'species' => $node->species,
  628. );
  629. $organism = tripal_core_chado_select('organism', array('organism_id'), $values);
  630. if (sizeof($organism) > 0) {
  631. form_set_error('genus', 'Cannot add the organism with this genus and species.
  632. The organism already exists.');
  633. watchdog('tripal_organism',
  634. 'Insert organism: genus and species already exists: %values',
  635. array('%values' => "genus = $node->genus, species = $node->species"),
  636. WATCHDOG_WARNING);
  637. }
  638. }
  639. }
  640. /**
  641. * When a new chado_organism node is created we also need to add information
  642. * to our chado_organism table. This function is called on insert of a new node
  643. * of type 'chado_organism' and inserts the necessary information.
  644. *
  645. * @ingroup tripal_organism
  646. */
  647. function chado_organism_insert($node) {
  648. $values = array(
  649. 'genus' => $node->genus,
  650. 'species' => $node->species,
  651. 'abbreviation' => $node->abbreviation,
  652. 'common_name' => $node->common_name,
  653. 'comment' => $node->description
  654. );
  655. // if there is an organism_id in the $node object then this must be a sync so
  656. // we can skip adding the organism as it is already there, although
  657. // we do need to proceed with the rest of the insert
  658. if (!$node->organism_id) {
  659. $organism = tripal_core_chado_insert('organism', $values);
  660. if (!$organism) {
  661. drupal_set_message(t('Unable to add organism.', 'warning'));
  662. watchdog('tripal_organism',
  663. 'Insert Organism: Unable to create organism where values:%values',
  664. array('%values' => print_r($values, TRUE)),
  665. WATCHDOG_WARNING
  666. );
  667. return;
  668. }
  669. $organism_id = $organism['organism_id'];
  670. }
  671. else {
  672. $organism_id = $node->organism_id;
  673. }
  674. // Make sure the entry for this organism doesn't already exist in the
  675. // chado_organism table if it doesn't exist then we want to add it.
  676. if (!chado_get_id_for_node('organism', $node) ) {
  677. // next add the item to the drupal table
  678. $sql = "INSERT INTO {chado_organism} (nid, vid, organism_id) ".
  679. "VALUES (%d, %d, %d)";
  680. chado_query($sql, $node->nid, $node->vid, $organism_id);
  681. }
  682. // set the title for the node
  683. $record = new stdClass();
  684. $record->title = "$node->genus $node->species";
  685. $record->nid = $node->nid;
  686. drupal_write_record('node', $record, 'nid');
  687. drupal_write_record('node_revisions', $record, 'nid');
  688. // add the image
  689. chado_organism_add_image($node);
  690. }
  691. /**
  692. * Update organisms
  693. *
  694. * @ingroup tripal_organism
  695. */
  696. function chado_organism_update($node) {
  697. if ($node->revision) {
  698. // there is no way to handle revisions in Chado but leave
  699. // this here just to make not we've addressed it.
  700. }
  701. $match = array(
  702. 'organism_id' => chado_get_id_for_node('organism', $node),
  703. );
  704. $values = array(
  705. 'genus' => $node->genus,
  706. 'species' => $node->species,
  707. 'abbreviation' => $node->abbreviation,
  708. 'common_name' => $node->common_name,
  709. 'comment' => $node->description
  710. );
  711. $org_status = tripal_core_chado_update('organism', $match, $values);
  712. // set the title for the node
  713. $record = new stdClass();
  714. $record->title = "$node->genus $node->species";
  715. $record->nid = $node->nid;
  716. drupal_write_record('node', $record, 'nid');
  717. drupal_write_record('node_revisions', $record, 'nid');
  718. // add the image
  719. chado_organism_add_image($node);
  720. }
  721. /**
  722. * Delete organism from both drupal and chado databases. Check dependency before
  723. * deleting from chado.
  724. *
  725. * @ingroup tripal_organism
  726. */
  727. function chado_organism_delete($node) {
  728. $organism_id = chado_get_id_for_node('organism', $node);
  729. // if we don't have an organism id for this node then this isn't a node of
  730. // type chado_organism or the entry in the chado_organism table was lost.
  731. if (!$organism_id) {
  732. return;
  733. }
  734. // Remove data from the {chado_organism}, {node}, and {node_revisions} tables
  735. $sql_del = "DELETE FROM {chado_organism} ".
  736. "WHERE nid = %d ".
  737. "AND vid = %d";
  738. db_query($sql_del, $node->nid, $node->vid);
  739. $sql_del = "DELETE FROM {node} ".
  740. "WHERE nid = %d ".
  741. "AND vid = %d";
  742. db_query($sql_del, $node->nid, $node->vid);
  743. $sql_del = "DELETE FROM {node_revisions} ".
  744. "WHERE nid = %d ".
  745. "AND vid = %d";
  746. db_query($sql_del, $node->nid, $node->vid);
  747. // Test dependency before deleting from chado database. If a library or
  748. // feature depends on this organism, don't delete it
  749. $sql = "SELECT feature_id FROM {feature} WHERE organism_id = %d";
  750. $check_feature = db_result(chado_query($sql, $organism_id));
  751. $sql = "SELECT library_id FROM {library} WHERE organism_id = %d";
  752. $check_lib = db_result(chado_query($sql, $organism_id));
  753. if ($check_lib == 0 && $check_feature == 0) {
  754. tripal_core_chado_delete('organism', array('organism_id' => $organism_id));
  755. }
  756. else {
  757. drupal_set_message(t("Organism deleted from drupal. Warning: at least one ".
  758. "library or feature depends on this organism. It was ".
  759. "not removed from chado."));
  760. }
  761. }
  762. /**
  763. *
  764. *
  765. * @ingroup tripal_organism
  766. */
  767. function chado_organism_add_image($node) {
  768. // check to see if a file was uploaded. If so then copy it to the images
  769. // directory for display with the organism
  770. if (isset($_FILES['files']) && $_FILES['files']['name']['organism_image'] &&
  771. is_uploaded_file($_FILES['files']['tmp_name']['organism_image'])) {
  772. $dest = file_directory_path() . "/tripal/tripal_organism/images";
  773. $validators = array(
  774. 'file_validate_is_image' => array(),
  775. );
  776. file_check_directory($dest, FILE_CREATE_DIRECTORY, 'organism_image');
  777. if (!$file = file_save_upload('organism_image', $validators, $dest)) {
  778. drupal_set_message(t("Organism image was not uploaded."));
  779. }
  780. // move this image into the images directory
  781. file_move($file->filepath, $dest . "/" . $node->nid . ".jpg", FILE_EXISTS_REPLACE);
  782. }
  783. }
  784. /**
  785. * When editing or creating a new node of type 'chado_organism' we need
  786. * a form. This function creates the form that will be used for this.
  787. *
  788. * @ingroup tripal_organism
  789. */
  790. function chado_organism_form($node, $param) {
  791. $organism = $node->organism;
  792. // add in the comment since it is a text field and may not be included if too big
  793. $organism = tripal_core_expand_chado_vars($organism, 'field', 'organism.comment');
  794. // get form defaults
  795. $abbreviation = $node->abbreviation;
  796. if (!$abbreviation) {
  797. $abbreviation = $organism->abbreviation;
  798. }
  799. $genus = $node->genus;
  800. if (!$genus) {
  801. $genus = $organism->genus;
  802. }
  803. $species = $node->species;
  804. if (!$species) {
  805. $species = $organism->species;
  806. }
  807. $common_name = $node->common_name;
  808. if (!$common_name) {
  809. $common_name = $organism->common_name;
  810. }
  811. $description = $node->description;
  812. if (!$description) {
  813. $description = $organism->comment;
  814. }
  815. $organism_image = $node->organism_image;
  816. $form = array();
  817. $form['#attributes']['enctype'] = 'multipart/form-data';
  818. // keep track of the organism id if we have one. If we do have one then
  819. // this would indicate an update as opposed to an insert.
  820. $form['organism_id'] = array(
  821. '#type' => 'value',
  822. '#value' => $organism->organism_id,
  823. );
  824. $form['abbreviation']= array(
  825. '#type' => 'textfield',
  826. '#title' => t('Abbreviation'),
  827. '#required' => TRUE,
  828. '#default_value' => $organism->abbreviation,
  829. '#weight' => 3
  830. );
  831. $form['genus']= array(
  832. '#type' => 'textfield',
  833. '#title' => t('Genus'),
  834. '#required' => TRUE,
  835. '#default_value' => $organism->genus,
  836. '#weight' => 1
  837. );
  838. $form['species']= array(
  839. '#type' => 'textfield',
  840. '#title' => t('Species'),
  841. '#required' => TRUE,
  842. '#default_value' => $organism->species,
  843. '#weight' => 2
  844. );
  845. $form['common_name']= array(
  846. '#type' => 'textfield',
  847. '#title' => t('Common Name'),
  848. '#required' => TRUE,
  849. '#default_value' => $organism->common_name,
  850. '#weight' => 4
  851. );
  852. $form['description']= array(
  853. '#type' => 'textarea',
  854. '#rows' => 15,
  855. '#title' => t('Description'),
  856. '#required' => TRUE,
  857. '#default_value' => $organism->comment,
  858. '#weight' => 5
  859. );
  860. $form['organism_image']= array(
  861. '#type' => 'file',
  862. '#title' => t('Organism Image'),
  863. '#description' => 'Add an image for this organism',
  864. '#weight' => 6
  865. );
  866. return $form;
  867. }
  868. /**
  869. * When a node is requested by the user this function is called to allow us
  870. * to add auxiliary data to the node object.
  871. *
  872. * @ingroup tripal_organism
  873. */
  874. function chado_organism_load($node) {
  875. // find the organism and add in the details
  876. $organism_id = chado_get_id_for_node('organism', $node);
  877. $values = array('organism_id' => $organism_id);
  878. $organism = tripal_core_generate_chado_var('organism', $values);
  879. // add in the description field
  880. $organism = tripal_core_expand_chado_vars($organism, 'field', 'organism.comment');
  881. $additions = new stdClass();
  882. $additions->organism = $organism;
  883. return $additions;
  884. }
  885. /**
  886. * This function customizes the view of the chado_organism node. It allows
  887. * us to generate the markup.
  888. *
  889. * @ingroup tripal_organism
  890. */
  891. function chado_organism_view($node, $teaser = FALSE, $page = FALSE) {
  892. // use drupal's default node view:
  893. $node = node_prepare($node, $teaser);
  894. return $node;
  895. }
  896. /**
  897. * Synchronize organisms from chado to drupal
  898. *
  899. * @ingroup tripal_organism
  900. */
  901. function tripal_organism_sync_organisms($organism_id = NULL, $job_id = NULL) {
  902. global $user;
  903. $page_content = '';
  904. if (!$organism_id) {
  905. $sql = "SELECT * FROM {Organism} O";
  906. $results = chado_query($sql);
  907. }
  908. else {
  909. $sql = "SELECT * FROM {Organism} L WHERE organism_id = %d";
  910. $results = chado_query($sql, $organism_id);
  911. }
  912. // We'll use the following SQL statement for checking if the organism
  913. // already exists as a drupal node.
  914. $sql = "SELECT * FROM {chado_organism} ".
  915. "WHERE organism_id = %d";
  916. while ($organism = db_fetch_object($results)) {
  917. // check if this organism already exists in the drupal database. if it
  918. // does then skip this organism and go to the next one.
  919. if (!db_fetch_object(db_query($sql, $organism->organism_id))) {
  920. $new_node = new stdClass();
  921. $new_node->type = 'chado_organism';
  922. $new_node->uid = $user->uid;
  923. $new_node->title = "$organism->genus $organism->species";
  924. $new_node->organism_id = $organism->organism_id;
  925. $new_node->genus = $organism->genus;
  926. $new_node->species = $organism->species;
  927. $new_node->description = '';
  928. node_validate($new_node);
  929. if (!form_get_errors()) {
  930. $node = node_submit($new_node);
  931. node_save($node);
  932. if ($node->nid) {
  933. print "Added $organism->common_name\n";
  934. }
  935. }
  936. else {
  937. print "Failed to insert organism $organism->common_name\n";
  938. }
  939. }
  940. else {
  941. print "Skipped $organism->common_name\n";
  942. }
  943. }
  944. return $page_content;
  945. }
  946. /**
  947. * Display help and module information
  948. * @param path which path of the site we're displaying help
  949. * @param arg array that holds the current path as would be returned from arg()
  950. * function
  951. * @return help text for the path
  952. *
  953. * @ingroup tripal_organism
  954. */
  955. function tripal_organism_help($path, $arg) {
  956. $output = '';
  957. switch ($path) {
  958. case "admin/help#tripal_organism":
  959. $output = '<p>'.
  960. t("Displays links to nodes created on this date") .
  961. '</p>';
  962. break;
  963. }
  964. return $output;
  965. }
  966. /**
  967. * This function uses organism_id's of all drupal organism nodes as input and
  968. * pull the organism information (genus, species, common_name, comment) from
  969. * chado database. The return type is an object array that stores $organism
  970. * objects sorted by common_name
  971. *
  972. * @ingroup tripal_organism
  973. */
  974. function get_chado_organisms() {
  975. $sql_drupal = "SELECT COUNT (organism_id) FROM {chado_organism}";
  976. $no_orgs = db_result(db_query($sql_drupal));
  977. if ($no_orgs != 0) {
  978. $sql = "SELECT organism_id, nid FROM {chado_organism}";
  979. $result = chado_query($sql);
  980. $sql = "SELECT genus, species, common_name, comment ".
  981. "FROM {Organism} ".
  982. "WHERE organism_id=%d";
  983. $organisms = array();
  984. $count = 0;
  985. while ($data = db_fetch_object($result)) {
  986. $organism = db_fetch_object(chado_query($sql, $data->organism_id));
  987. $organism->node_id = $data->nid;
  988. // Use common_name plus $count as the key so we can sort by common
  989. // name later. Since common_name is not unique, we need to add $count
  990. // to the key
  991. $key = drupal_strtolower($organism->common_name) . $count;
  992. $organisms [$key] = $organism;
  993. $count ++;
  994. }
  995. //Sort organisms by common name
  996. ksort($organisms, SORT_STRING);
  997. return $organisms;
  998. }
  999. }
  1000. /**
  1001. *
  1002. * @ingroup tripal_organism
  1003. */
  1004. function tripal_organism_reindex_features($organism_id = NULL, $job_id = NULL) {
  1005. $i = 0;
  1006. if (!$organism_id) {
  1007. return;
  1008. }
  1009. $sql = "SELECT * ".
  1010. "FROM {feature} ".
  1011. "WHERE organism_id = $organism_id ".
  1012. "ORDER BY feature_id";
  1013. $results = chado_query($sql);
  1014. // load into ids array
  1015. $count = 0;
  1016. $ids = array();
  1017. while ($id = db_fetch_object($results)) {
  1018. $ids[$count] = $id->feature_id;
  1019. $count++;
  1020. }
  1021. $interval = intval($count * 0.01);
  1022. foreach ($ids as $feature_id) {
  1023. // update the job status every 1% features
  1024. if ($job_id and $i % $interval == 0) {
  1025. tripal_job_set_progress($job_id , intval(($i/$count)*100));
  1026. }
  1027. tripal_feature_sync_feature($feature_id);
  1028. $i++;
  1029. }
  1030. }
  1031. /**
  1032. *
  1033. * @ingroup tripal_organism
  1034. */
  1035. function tripal_organism_taxonify_features($organism_id = NULL, $job_id = NULL) {
  1036. $i = 0;
  1037. if (!$organism_id) {
  1038. return;
  1039. }
  1040. $sql = "SELECT * ".
  1041. "FROM {feature} ".
  1042. "WHERE organism_id = $organism_id ".
  1043. "ORDER BY feature_id";
  1044. $results = chado_query($sql);
  1045. // load into ids array
  1046. $count = 0;
  1047. $ids = array();
  1048. while ($id = db_fetch_object($results)) {
  1049. $ids[$count] = $id->feature_id;
  1050. $count++;
  1051. }
  1052. // make sure our vocabularies are set before proceeding
  1053. tripal_feature_set_vocabulary();
  1054. // use this SQL for getting the nodes
  1055. $nsql = "SELECT * FROM {chado_feature} CF ".
  1056. " INNER JOIN {node} N ON N.nid = CF.nid ".
  1057. "WHERE feature_id = %d";
  1058. // iterate through the features and set the taxonomy
  1059. $interval = intval($count * 0.01);
  1060. foreach ($ids as $feature_id) {
  1061. // update the job status every 1% features
  1062. if ($job_id and $i % $interval == 0) {
  1063. tripal_job_set_progress($job_id, intval(($i/$count)*100));
  1064. }
  1065. $node = db_fetch_object(db_query($nsql, $feature_id));
  1066. tripal_feature_set_taxonomy($node, $feature_id);
  1067. $i++;
  1068. }
  1069. }
  1070. /**
  1071. * Remove orphaned drupal nodes
  1072. *
  1073. * @param $dummy
  1074. * Not Used -kept for backwards compatibility
  1075. * @param $job_id
  1076. * The id of the tripal job executing this function
  1077. *
  1078. * @ingroup tripal_organism
  1079. */
  1080. function tripal_organism_cleanup($dummy = NULL, $job_id = NULL) {
  1081. return tripal_core_clean_orphaned_nodes('organism', $job_id);
  1082. }
  1083. /**
  1084. * Implements hook_views_api()
  1085. * Purpose: Essentially this hook tells drupal that there is views support for
  1086. * for this module which then includes tripal_db.views.inc where all the
  1087. * views integration code is
  1088. *
  1089. * @ingroup tripal_organism
  1090. */
  1091. function tripal_organism_views_api() {
  1092. return array(
  1093. 'api' => 2.0,
  1094. );
  1095. }
  1096. /**
  1097. *
  1098. *
  1099. * @ingroup tripal_organism
  1100. */
  1101. function tripal_organism_job_describe_args($callback, $args) {
  1102. $new_args = array();
  1103. if ($callback == 'tripal_organism_sync_organisms') {
  1104. $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[0]));
  1105. $new_args['Organism'] = $organism[0]->genus ." ". $organism[0]->species;
  1106. }
  1107. return $new_args;
  1108. }