tripal_chado.DEPRECATED.api.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * These api functions are deprecated, if your site is currently using them
  6. * please update your code with the newer tripal_chado functions.
  7. */
  8. /**
  9. * @defgroup tripal_chado_DEPRECATED_api
  10. * @ingroup tripal_chado_api
  11. * @{
  12. * Deprecated legacy api code.
  13. * @}
  14. */
  15. /**
  16. * Publishes content in Chado as a new TripalEntity entity.
  17. *
  18. * @param $values
  19. * A key/value associative array that supports the following keys:
  20. * - bundle_name: The name of the the TripalBundle (e.g. bio_data-12345).
  21. * @param $job_id
  22. * (Optional) The numeric job ID as provided by the Tripal jobs system. There
  23. * is no need to specify this argument if this function is being called
  24. * outside of the jobs systems.
  25. *
  26. * @return boolean
  27. * TRUE if all of the records of the given bundle type were published, and
  28. * FALSE if a failure occured.
  29. *
  30. * @ingroup tripal_chado_DEPRECATED_api
  31. */
  32. function tripal_chado_publish_records($values, $job_id = null) {
  33. chado_publish_records($values, $job_id = null);
  34. }
  35. /**
  36. * Returns an array of tokens based on Tripal Entity Fields.
  37. *
  38. * @param $base_table
  39. * The name of a base table in Chado.
  40. * @return
  41. * An array of tokens where the key is the machine_name of the token.
  42. *
  43. * @ingroup tripal_chado_DEPRECATED_api
  44. */
  45. function tripal_get_chado_tokens($base_table) {
  46. chado_get_chado_tokens($base_table);
  47. }
  48. /**
  49. * Replace all Chado Tokens in a given string.
  50. *
  51. * NOTE: If there is no value for a token then the token is removed.
  52. *
  53. * @param string $string
  54. * The string containing tokens.
  55. * @param $record
  56. * A Chado record as generated by chado_generate_var()
  57. *
  58. * @return
  59. * The string will all tokens replaced with values.
  60. *
  61. * @ingroup tripal_chado_DEPRECATED_api
  62. */
  63. function tripal_replace_chado_tokens($string, $record) {
  64. chado_replace_chado_tokens($string, $record);
  65. }
  66. /**
  67. * Migrate Tripal content types
  68. *
  69. * Migrate specified Tripal content type and publish all its content. The content type
  70. * will be created if it does not already exist.
  71. *
  72. * @param $type
  73. * A type array specifying the vocabular, accession, term_name, and chado data_table
  74. * e.g.
  75. * $type = array(
  76. * 'vocabulary' => 'OBI',
  77. * 'accession' => '0100026',
  78. * 'term_name' => 'organism',
  79. * 'storage_args' => array (
  80. * 'data_table' => $table
  81. * )
  82. * )
  83. * @ingroup tripal_chado_DEPRECATED_api
  84. */
  85. function tripal_chado_migrate_tripal_content_type($type = array()) {
  86. chado_migrate_tripal_content_type($type = array());
  87. }
  88. /**
  89. * Add a materialized view to the chado database to help speed data access. This
  90. * function supports the older style where postgres column specifications
  91. * are provided using the $mv_table, $mv_specs and $indexed variables. It also
  92. * supports the newer preferred method where the materialized view is described
  93. * using the Drupal Schema API array.
  94. *
  95. * @param $name
  96. * The name of the materialized view.
  97. * @param $modulename
  98. * The name of the module submitting the materialized view
  99. * (e.g. 'tripal_library').
  100. * @param $mv_schema
  101. * If using the newer Schema API array to define the materialized view then
  102. * this variable should contain the array or a string representation of the
  103. * array.
  104. * @param $query
  105. * The SQL query that loads the materialized view with data.
  106. * @param $comment
  107. * A string containing a description of the materialized view.
  108. * @param $redirect
  109. * Optional (default: TRUE). By default this function redirects back to
  110. * admin pages. However, when called by Drush we don't want to redirect. This
  111. * parameter allows this to be used as a true API function.
  112. *
  113. * @ingroup tripal_chado_DEPRECATED_api
  114. */
  115. function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = null, $redirect = true)
  116. {
  117. chado_add_mview($name, $modulename, $mv_schema, $query, $comment = null, $redirect = true);
  118. }
  119. /**
  120. * Edits a materialized view to the chado database to help speed data access.
  121. * This function supports the older style where postgres column specifications
  122. * are provided using the $mv_table, $mv_specs and $indexed variables. It also
  123. * supports the newer preferred method where the materialized view is described
  124. * using the Drupal Schema API array.
  125. *
  126. * @param $mview_id
  127. * The mview_id of the materialized view to edit.
  128. * @param $name
  129. * The name of the materialized view.
  130. * @param $modulename
  131. * The name of the module submitting the materialized view
  132. * (e.g. 'tripal_library').
  133. * @param $mv_table
  134. * The name of the table to add to chado. This is the table that can be
  135. * queried.
  136. * @param $mv_specs
  137. * The table definition.
  138. * @param $indexed
  139. * The columns that are to be indexed.
  140. * @param $query
  141. * The SQL query that loads the materialized view with data.
  142. * @param $special_index
  143. * currently not used.
  144. * @param $comment
  145. * A string containing a description of the materialized view.
  146. * @param $mv_schema
  147. * If using the newer Schema API array to define the materialized view then
  148. * this variable should contain the array.
  149. *
  150. * @ingroup tripal_chado_DEPRECATED_api
  151. */
  152. function tripal_edit_mview(
  153. $mview_id,
  154. $name,
  155. $modulename,
  156. $mv_table,
  157. $mv_specs,
  158. $indexed,
  159. $query,
  160. $special_index,
  161. $comment = null,
  162. $mv_schema = null
  163. ) {
  164. chado_edit_mview(
  165. $mview_id,
  166. $name,
  167. $modulename,
  168. $mv_table,
  169. $mv_specs,
  170. $indexed,
  171. $query,
  172. $special_index,
  173. $comment = null,
  174. $mv_schema = null
  175. );
  176. }
  177. /**
  178. * Retrieve the materialized view_id given the name.
  179. *
  180. * @param $view_name
  181. * The name of the materialized view.
  182. *
  183. * @return
  184. * The unique identifier for the given view.
  185. *
  186. * @ingroup tripal_chado_DEPRECATED_api
  187. */
  188. function tripal_get_mview_id($view_name)
  189. {
  190. chado_get_mview_id($view_name);
  191. }
  192. /**
  193. * Populates the specified Materialized View.
  194. *
  195. * @param $mview_id
  196. * The unique ID of the materialized view for the action to be performed on.
  197. *
  198. * @ingroup tripal_chado_DEPRECATED_api
  199. */
  200. function tripal_refresh_mview($mview_id)
  201. {
  202. chado_refresh_mview($mview_id);
  203. }
  204. /**
  205. * Retrieves the list of materialized view IDs and their names.
  206. *
  207. * @return
  208. * An array of objects with the following properties: mview_id, name.
  209. *
  210. * @ingroup tripal_chado_DEPRECATED_api
  211. *
  212. */
  213. function tripal_get_mviews()
  214. {
  215. chado_get_mviews();
  216. }
  217. /**
  218. * Does the specified action for the specified Materialized View.
  219. *
  220. * @param $op
  221. * The action to be taken. One of update or delete.
  222. * @param $mview_id
  223. * The unique ID of the materialized view for the action to be performed on.
  224. *
  225. * @ingroup tripal_chado_DEPRECATED_api
  226. */
  227. function tripal_delete_mview($mview_id)
  228. {
  229. chado_delete_mview($mview_id);
  230. }
  231. /**
  232. * Update a Materialized View.
  233. *
  234. * @param $mview_id
  235. * The unique identifier for the materialized view to be updated.
  236. *
  237. * @return
  238. * True if successful, FALSE otherwise.
  239. *
  240. * @ingroup tripal_chado_DEPRECATED_api
  241. */
  242. function tripal_populate_mview($mview_id) {
  243. chado_populate_mview($mview_id);
  244. }
  245. /**
  246. * Alter the name of the schema housing Chado and/or Drupal.
  247. *
  248. * This example implementation shows a solution for the case where your chado
  249. * database was well established in the "public" schema and you added Drupal
  250. * later in a "drupal" schema. Please note that this has not been tested and
  251. * while we can ensure that Tripal will work as expected, we have no control
  252. * over whether Drupal is compatible with not being in the public schema. That's
  253. * why we recommened the organization we have (ie: Chado in a "chado" schema and
  254. * Drupal in the "public schema).
  255. *
  256. * @param $schema_name
  257. * The current name of the schema as known by Tripal. This is likely the
  258. * default set in tripal_get_schema_name() but in the case of multiple alter
  259. * hooks, it might be different.
  260. * @param $context
  261. * This is an array of items to provide context.
  262. * - schema: this is the schema that was passed to tripal_get_schema_name()
  263. * and will be either "chado" or "drupal". This should be used to
  264. * determine you are changing the name of the correct schema.
  265. *
  266. * @ingroup tripal_chado_DEPRECATED_api
  267. */
  268. function hook_tripal_get_schema_name_alter($schema_name, $context)
  269. {
  270. hook_chado_get_schema_name_alter($schema_name, $context);
  271. }
  272. /**
  273. * Retrieve the name of the PostgreSQL schema housing Chado or Drupal.
  274. *
  275. * @param $schema
  276. * Wehter you want the schema name for 'chado' or 'drupal'. Chado is the
  277. * default.
  278. * @return
  279. * The name of the PostgreSQL schema housing the $schema specified.
  280. *
  281. * @ingroup tripal_chado_DEPRECATED_api
  282. */
  283. function tripal_get_schema_name($schema = 'chado')
  284. {
  285. chado_get_schema_name($schema = 'chado');
  286. }
  287. /**
  288. * Adds a new Chado table to the semantic web support for Chado.
  289. *
  290. * Newly added tables (i.e. custom tables) need to be integrated into the
  291. * semantic web infrastructure. After a new table is created and added to
  292. * the Chado schema, this function should be called to indicate that the
  293. * table should be included in the semantic web. No associations are made for
  294. * the columns. The associations should be added using the
  295. * tripal_associate_chado_semweb_term() function.
  296. *
  297. * If the table has already been added previously then this function does
  298. * nothing. It will not overwrite existing assocations.
  299. *
  300. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  301. * '_temp', are not supported.
  302. *
  303. * @param $chado_table
  304. * The name of the Chado table.
  305. *
  306. * @ingroup tripal_chado_semweb_api
  307. */
  308. function tripal_add_chado_semweb_table($chado_table)
  309. {
  310. chado_add_chado_semweb_table($chado_table);
  311. }
  312. /**
  313. * Associates a controlled vocabulary term with a field in a Chado table.
  314. *
  315. * For sharing of data via the semantic web we need to associate a
  316. * term from a controlled vocabulary with every column of every table in Chado.
  317. *
  318. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  319. * '_temp', are not supported.
  320. *
  321. * @param $chado_table
  322. * The name of the table in Chado. This argument is optional. If left empty
  323. * or set to NULL then all fields in all Chado tables with that have the
  324. * $column_name will be associated with the provided $term.
  325. * @param $chado_column
  326. * The column name in the Chado table to which the term should be associated.
  327. * @param $term
  328. * A cvterm object as returned by chado_generate_var().
  329. * @param $update
  330. * Set to TRUE if the association should be updated to use the new term
  331. * if a term is already associated with the table and column. Default is
  332. * FALSE. If not TRUE and a term is already associated, then no change
  333. * occurs.
  334. *
  335. * @return boolean
  336. * Returns TRUE if the association was made successfully and FALSE otherwise.
  337. *
  338. * @ingroup tripal_chado_semweb_api
  339. */
  340. function tripal_associate_chado_semweb_term(
  341. $chado_table,
  342. $chado_column,
  343. $term,
  344. $update = false
  345. ) {
  346. chado_associate_chado_semweb_term(
  347. $chado_table,
  348. $chado_column,
  349. $term,
  350. $update = false
  351. );
  352. }
  353. /**
  354. * Retrieves the term that maps to the given Chado table and field.
  355. *
  356. * @param $chado_table
  357. * The name of the Chado table.
  358. * @param $chado_column
  359. * The name of the Chado field.
  360. * @param $options
  361. * An associative array of one or more of the following keys:
  362. * -return_object: Set to TRUE to return the cvterm object rather than
  363. * the string version of the term.
  364. *
  365. * @return
  366. * Returns a string-based representation of the term (e.g. SO:0000704). If
  367. * the 'return_object' options is provided then a cvterm object is returned.
  368. * returns NULL if no term is mapped to the table and column.
  369. *
  370. * @ingroup tripal_chado_semweb_api
  371. */
  372. function tripal_get_chado_semweb_term($chado_table, $chado_column, $options = array())
  373. {
  374. chado_get_chado_semweb_term($chado_table, $chado_column, $options = array());
  375. }
  376. /**
  377. * Formats a controlled vocabulary term from Chado for use with Tripal.
  378. *
  379. * @param $cvterm
  380. * A cvterm object.
  381. * @return
  382. * The semantic web name for the term.
  383. *
  384. * @ingroup tripal_chado_semweb_api
  385. */
  386. function tripal_format_chado_semweb_term($cvterm)
  387. {
  388. chado_format_chado_semweb_term($cvterm);
  389. }
  390. /**
  391. * Retreive the column name in a Chado table that matches a given term.
  392. *
  393. * @param $chado_table
  394. * The name of the Chado table.
  395. * @param $term
  396. * The term. This can be a term name or a unique identifer of the form
  397. * {db}:{accession} or of the form {db}__{term_name}.
  398. *
  399. * @return
  400. * The name of the Chado column that matches the given term or FALSE if the
  401. * term is not mapped to the Chado table.
  402. *
  403. * @ingroup tripal_chado_semweb_api
  404. */
  405. function tripal_get_chado_semweb_column($chado_table, $term)
  406. {
  407. chado_get_chado_semweb_column($chado_table, $term);
  408. }