tripal_chado.DEPRECATED.api.inc

These api functions are deprecated, if your site is currently using them please update your code with the newer tripal_chado functions.

File

tripal_chado/api/tripal_chado.DEPRECATED.api.inc
View source
  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_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_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. chado_add_mview($name, $modulename, $mv_schema, $query, $comment = null, $redirect = true);
  117. }
  118. /**
  119. * Edits a materialized view to the chado database to help speed data access.
  120. * This function supports the older style where postgres column specifications
  121. * are provided using the $mv_table, $mv_specs and $indexed variables. It also
  122. * supports the newer preferred method where the materialized view is described
  123. * using the Drupal Schema API array.
  124. *
  125. * @param $mview_id
  126. * The mview_id of the materialized view to edit.
  127. * @param $name
  128. * The name of the materialized view.
  129. * @param $modulename
  130. * The name of the module submitting the materialized view
  131. * (e.g. 'tripal_library').
  132. * @param $mv_table
  133. * The name of the table to add to chado. This is the table that can be
  134. * queried.
  135. * @param $mv_specs
  136. * The table definition.
  137. * @param $indexed
  138. * The columns that are to be indexed.
  139. * @param $query
  140. * The SQL query that loads the materialized view with data.
  141. * @param $special_index
  142. * currently not used.
  143. * @param $comment
  144. * A string containing a description of the materialized view.
  145. * @param $mv_schema
  146. * If using the newer Schema API array to define the materialized view then
  147. * this variable should contain the array.
  148. *
  149. * @ingroup tripal_chado_DEPRECATED_api
  150. */
  151. function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
  152. $indexed, $query, $special_index, $comment = null, $mv_schema = null) {
  153. chado_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
  154. $indexed, $query, $special_index, $comment = null,$mv_schema = null);
  155. }
  156. /**
  157. * Retrieve the materialized view_id given the name.
  158. *
  159. * @param $view_name
  160. * The name of the materialized view.
  161. *
  162. * @return
  163. * The unique identifier for the given view.
  164. *
  165. * @ingroup tripal_chado_DEPRECATED_api
  166. */
  167. function tripal_get_mview_id($view_name) {
  168. chado_get_mview_id($view_name);
  169. }
  170. /**
  171. * Populates the specified Materialized View.
  172. *
  173. * @param $mview_id
  174. * The unique ID of the materialized view for the action to be performed on.
  175. *
  176. * @ingroup tripal_chado_DEPRECATED_api
  177. */
  178. function tripal_refresh_mview($mview_id) {
  179. chado_refresh_mview($mview_id);
  180. }
  181. /**
  182. * Retrieves the list of materialized view IDs and their names.
  183. *
  184. * @return
  185. * An array of objects with the following properties: mview_id, name.
  186. *
  187. * @ingroup tripal_chado_DEPRECATED_api
  188. *
  189. */
  190. function tripal_get_mviews() {
  191. chado_get_mviews();
  192. }
  193. /**
  194. * Does the specified action for the specified Materialized View.
  195. *
  196. * @param $op
  197. * The action to be taken. One of update or delete.
  198. * @param $mview_id
  199. * The unique ID of the materialized view for the action to be performed on.
  200. *
  201. * @ingroup tripal_chado_DEPRECATED_api
  202. */
  203. function tripal_delete_mview($mview_id) {
  204. chado_delete_mview($mview_id);
  205. }
  206. /**
  207. * Update a Materialized View.
  208. *
  209. * @param $mview_id
  210. * The unique identifier for the materialized view to be updated.
  211. *
  212. * @return
  213. * True if successful, FALSE otherwise.
  214. *
  215. * @ingroup tripal_chado_DEPRECATED_api
  216. */
  217. function tripal_populate_mview($mview_id) {
  218. chado_populate_mview($mview_id);
  219. }
  220. /**
  221. * Alter the name of the schema housing Chado and/or Drupal.
  222. *
  223. * This example implementation shows a solution for the case where your chado
  224. * database was well established in the "public" schema and you added Drupal
  225. * later in a "drupal" schema. Please note that this has not been tested and
  226. * while we can ensure that Tripal will work as expected, we have no control
  227. * over whether Drupal is compatible with not being in the public schema. That's
  228. * why we recommened the organization we have (ie: Chado in a "chado" schema and
  229. * Drupal in the "public schema).
  230. *
  231. * @param $schema_name
  232. * The current name of the schema as known by Tripal. This is likely the
  233. * default set in tripal_get_schema_name() but in the case of multiple alter
  234. * hooks, it might be different.
  235. * @param $context
  236. * This is an array of items to provide context.
  237. * - schema: this is the schema that was passed to tripal_get_schema_name()
  238. * and will be either "chado" or "drupal". This should be used to
  239. * determine you are changing the name of the correct schema.
  240. *
  241. * @ingroup tripal_chado_DEPRECATED_api
  242. */
  243. function hook_tripal_get_schema_name_alter($schema_name, $context)
  244. {
  245. hook_chado_get_schema_name_alter($schema_name, $context);
  246. }
  247. /**
  248. * Retrieve the name of the PostgreSQL schema housing Chado or Drupal.
  249. *
  250. * @param $schema
  251. * Wehter you want the schema name for 'chado' or 'drupal'. Chado is the
  252. * default.
  253. * @return
  254. * The name of the PostgreSQL schema housing the $schema specified.
  255. *
  256. * @ingroup tripal_chado_DEPRECATED_api
  257. */
  258. function tripal_get_schema_name($schema = 'chado') {
  259. chado_get_schema_name($schema);
  260. }
  261. /**
  262. * Adds a new Chado table to the semantic web support for Chado.
  263. *
  264. * Newly added tables (i.e. custom tables) need to be integrated into the
  265. * semantic web infrastructure. After a new table is created and added to
  266. * the Chado schema, this function should be called to indicate that the
  267. * table should be included in the semantic web. No associations are made for
  268. * the columns. The associations should be added using the
  269. * tripal_associate_chado_semweb_term() function.
  270. *
  271. * If the table has already been added previously then this function does
  272. * nothing. It will not overwrite existing assocations.
  273. *
  274. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  275. * '_temp', are not supported.
  276. *
  277. * @param $chado_table
  278. * The name of the Chado table.
  279. *
  280. * @ingroup tripal_chado_DEPRECATED_api
  281. */
  282. function tripal_add_chado_semweb_table($chado_table) {
  283. chado_add_semweb_table($chado_table);
  284. }
  285. /**
  286. * Associates a controlled vocabulary term with a field in a Chado table.
  287. *
  288. * For sharing of data via the semantic web we need to associate a
  289. * term from a controlled vocabulary with every column of every table in Chado.
  290. *
  291. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  292. * '_temp', are not supported.
  293. *
  294. * @param $chado_table
  295. * The name of the table in Chado. This argument is optional. If left empty
  296. * or set to NULL then all fields in all Chado tables with that have the
  297. * $column_name will be associated with the provided $term.
  298. * @param $chado_column
  299. * The column name in the Chado table to which the term should be associated.
  300. * @param $term
  301. * A cvterm object as returned by chado_generate_var().
  302. * @param $update
  303. * Set to TRUE if the association should be updated to use the new term
  304. * if a term is already associated with the table and column. Default is
  305. * FALSE. If not TRUE and a term is already associated, then no change
  306. * occurs.
  307. *
  308. * @return boolean
  309. * Returns TRUE if the association was made successfully and FALSE otherwise.
  310. *
  311. * @ingroup tripal_chado_DEPRECATED_api
  312. */
  313. function tripal_associate_chado_semweb_term($chado_table, $chado_column, $term,
  314. $update = false) {
  315. chado_associate_semweb_term($chado_table, $chado_column, $term, $update);
  316. }
  317. /**
  318. * Retrieves the term that maps to the given Chado table and field.
  319. *
  320. * @param $chado_table
  321. * The name of the Chado table.
  322. * @param $chado_column
  323. * The name of the Chado field.
  324. * @param $options
  325. * An associative array of one or more of the following keys:
  326. * -return_object: Set to TRUE to return the cvterm object rather than
  327. * the string version of the term.
  328. *
  329. * @return
  330. * Returns a string-based representation of the term (e.g. SO:0000704). If
  331. * the 'return_object' options is provided then a cvterm object is returned.
  332. * returns NULL if no term is mapped to the table and column.
  333. *
  334. * @ingroup tripal_chado_DEPRECATED_api
  335. */
  336. function tripal_get_chado_semweb_term($chado_table, $chado_column, $options = array()) {
  337. chado_get_semweb_term($chado_table, $chado_column, $options);
  338. }
  339. /**
  340. * Formats a controlled vocabulary term from Chado for use with Tripal.
  341. *
  342. * @param $cvterm
  343. * A cvterm object.
  344. * @return
  345. * The semantic web name for the term.
  346. *
  347. * @ingroup tripal_chado_DEPRECATED_api
  348. */
  349. function tripal_format_chado_semweb_term($cvterm) {
  350. chado_format_semweb_term($cvterm);
  351. }
  352. /**
  353. * Retreive the column name in a Chado table that matches a given term.
  354. *
  355. * @param $chado_table
  356. * The name of the Chado table.
  357. * @param $term
  358. * The term. This can be a term name or a unique identifer of the form
  359. * {db}:{accession} or of the form {db}__{term_name}.
  360. *
  361. * @return
  362. * The name of the Chado column that matches the given term or FALSE if the
  363. * term is not mapped to the Chado table.
  364. *
  365. * @ingroup tripal_chado_DEPRECATED_api
  366. */
  367. function tripal_get_chado_semweb_column($chado_table, $term) {
  368. chado_get_semweb_column($chado_table, $term);
  369. }