tripal_chado.DEPRECATED.api.inc 12 KB

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