tripal_chado.DEPRECATED.api.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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. * @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. return 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. return 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. return 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. return chado_add_mview($name, $modulename, $mv_schema, $query, $comment, $redirect);
  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. return 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. return 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. return 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. return 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. return 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. return 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. return hook_chado_get_schema_name_alter($schema_name, $context);
  245. }
  246. /**
  247. * Retrieve the name of the PostgreSQL schema housing Chado or Drupal.
  248. *
  249. * @param $schema
  250. * Wehter you want the schema name for 'chado' or 'drupal'. Chado is the
  251. * default.
  252. * @return
  253. * The name of the PostgreSQL schema housing the $schema specified.
  254. *
  255. * @ingroup tripal_chado_DEPRECATED_api
  256. */
  257. function tripal_get_schema_name($schema = 'chado') {
  258. return chado_get_schema_name($schema);
  259. }
  260. /**
  261. * Adds a new Chado table to the semantic web support for Chado.
  262. *
  263. * Newly added tables (i.e. custom tables) need to be integrated into the
  264. * semantic web infrastructure. After a new table is created and added to
  265. * the Chado schema, this function should be called to indicate that the
  266. * table should be included in the semantic web. No associations are made for
  267. * the columns. The associations should be added using the
  268. * tripal_associate_chado_semweb_term() function.
  269. *
  270. * If the table has already been added previously then this function does
  271. * nothing. It will not overwrite existing assocations.
  272. *
  273. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  274. * '_temp', are not supported.
  275. *
  276. * @param $chado_table
  277. * The name of the Chado table.
  278. *
  279. * @ingroup tripal_chado_DEPRECATED_api
  280. */
  281. function tripal_add_chado_semweb_table($chado_table) {
  282. return chado_add_semweb_table($chado_table);
  283. }
  284. /**
  285. * Associates a controlled vocabulary term with a field in a Chado table.
  286. *
  287. * For sharing of data via the semantic web we need to associate a
  288. * term from a controlled vocabulary with every column of every table in Chado.
  289. *
  290. * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
  291. * '_temp', are not supported.
  292. *
  293. * @param $chado_table
  294. * The name of the table in Chado. This argument is optional. If left empty
  295. * or set to NULL then all fields in all Chado tables with that have the
  296. * $column_name will be associated with the provided $term.
  297. * @param $chado_column
  298. * The column name in the Chado table to which the term should be associated.
  299. * @param $term
  300. * A cvterm object as returned by chado_generate_var().
  301. * @param $update
  302. * Set to TRUE if the association should be updated to use the new term
  303. * if a term is already associated with the table and column. Default is
  304. * FALSE. If not TRUE and a term is already associated, then no change
  305. * occurs.
  306. *
  307. * @return boolean
  308. * Returns TRUE if the association was made successfully and FALSE otherwise.
  309. *
  310. * @ingroup tripal_chado_DEPRECATED_api
  311. */
  312. function tripal_associate_chado_semweb_term($chado_table, $chado_column, $term,
  313. $update = false) {
  314. return chado_associate_semweb_term($chado_table, $chado_column, $term, $update);
  315. }
  316. /**
  317. * Retrieves the term that maps to the given Chado table and field.
  318. *
  319. * @param $chado_table
  320. * The name of the Chado table.
  321. * @param $chado_column
  322. * The name of the Chado field.
  323. * @param $options
  324. * An associative array of one or more of the following keys:
  325. * -return_object: Set to TRUE to return the cvterm object rather than
  326. * the string version of the term.
  327. *
  328. * @return
  329. * Returns a string-based representation of the term (e.g. SO:0000704). If
  330. * the 'return_object' options is provided then a cvterm object is returned.
  331. * returns NULL if no term is mapped to the table and column.
  332. *
  333. * @ingroup tripal_chado_DEPRECATED_api
  334. */
  335. function tripal_get_chado_semweb_term($chado_table, $chado_column, $options = array()) {
  336. return chado_get_semweb_term($chado_table, $chado_column, $options);
  337. }
  338. /**
  339. * Formats a controlled vocabulary term from Chado for use with Tripal.
  340. *
  341. * @param $cvterm
  342. * A cvterm object.
  343. * @return
  344. * The semantic web name for the term.
  345. *
  346. * @ingroup tripal_chado_DEPRECATED_api
  347. */
  348. function tripal_format_chado_semweb_term($cvterm) {
  349. return chado_format_semweb_term($cvterm);
  350. }
  351. /**
  352. * Retreive the column name in a Chado table that matches a given term.
  353. *
  354. * @param $chado_table
  355. * The name of the Chado table.
  356. * @param $term
  357. * The term. This can be a term name or a unique identifer of the form
  358. * {db}:{accession} or of the form {db}__{term_name}.
  359. *
  360. * @return
  361. * The name of the Chado column that matches the given term or FALSE if the
  362. * term is not mapped to the Chado table.
  363. *
  364. * @ingroup tripal_chado_DEPRECATED_api
  365. */
  366. function tripal_get_chado_semweb_column($chado_table, $term) {
  367. return chado_get_semweb_column($chado_table, $term);
  368. }