tripal_analysis.api.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. /**
  3. * @file
  4. * API functions relating to Analysis'
  5. *
  6. * @defgroup tripal_analysis_api Analysis Module API
  7. * @ingroup tripal_analysis
  8. * @ingroup tripal_api
  9. */
  10. /**
  11. * Retrieve properties of a given type for a given analysis
  12. *
  13. * @param $analysis_id
  14. * The analysis_id of the properties you would like to retrieve
  15. * @param $property
  16. * The cvterm name of the properties to retrieve
  17. *
  18. * @return
  19. * An analysis chado variable with the specified properties expanded
  20. *
  21. * @ingroup tripal_analysis_api
  22. */
  23. function tripal_analysis_get_property($analysis_id, $property) {
  24. return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
  25. }
  26. /**
  27. * Insert a given property
  28. *
  29. * @param $analysis_id
  30. * The analysis_id of the property to insert
  31. * @param $property
  32. * The cvterm name of the property to insert
  33. * @param $value
  34. * The value of the property to insert
  35. * @param $update_if_present
  36. * A boolean indicated whether to update the record if it's already present
  37. *
  38. * @return
  39. * True of success, False otherwise
  40. *
  41. * @ingroup tripal_analysis_api
  42. */
  43. function tripal_analysis_insert_property($analysis_id, $property, $value, $update_if_present = 0) {
  44. return tripal_core_insert_property('analysis', $analysis_id, $property, 'tripal', $value, $update_if_present);
  45. }
  46. /**
  47. * Update a given property
  48. *
  49. * @param $analysis_id
  50. * The analysis_id of the property to update
  51. * @param $property
  52. * The cvterm name of the property to update
  53. * @param $value
  54. * The value of the property to update
  55. * @param $insert_if_missing
  56. * A boolean indicated whether to insert the record if it's absent
  57. *
  58. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  59. * and then it will be updated with the supplied value
  60. *
  61. * @return
  62. * True of success, False otherwise
  63. *
  64. * @ingroup tripal_analysis_api
  65. */
  66. function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0) {
  67. return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
  68. }
  69. /**
  70. * Delete a given property
  71. *
  72. * @param $analysis_id
  73. * The analysis_id of the property to delete
  74. * @param $property
  75. * The cvterm name of the property to delete
  76. *
  77. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  78. * and then it will be deleted
  79. *
  80. * @return
  81. * True of success, False otherwise
  82. *
  83. * @ingroup tripal_analysis_api
  84. */
  85. function tripal_analysis_delete_property($analysis_id, $property) {
  86. return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
  87. }
  88. /**
  89. * Retreives the node of a sync'ed analysis
  90. *
  91. * @param $analysis_id
  92. * The analysis_id of the property to delete
  93. *
  94. * @return
  95. * node of analysis on success, null otherwise
  96. *
  97. * @ingroup tripal_analysis_api
  98. */
  99. function tripal_analysis_get_node($analysis_id) {
  100. $sql = "SELECT *
  101. FROM chado_analysis CA
  102. INNER JOIN node N on CA.nid = N.nid
  103. WHERE analysis_id = %d";
  104. $node = db_fetch_object(db_query($sql, $analysis_id));
  105. return $node;
  106. }
  107. /**
  108. * @section Chado Table Descriptions
  109. */
  110. /**
  111. * Implements hook_chado_analysis_schema()
  112. * Purpose: To add descriptions and foreign keys to default table description
  113. * Note: This array will be merged with the array from all other implementations
  114. *
  115. * @return
  116. * Array describing the analysis table
  117. *
  118. * @ingroup tripal_schema_api
  119. */
  120. function tripal_analysis_chado_analysis_schema() {
  121. $description = array();
  122. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_analysis_schema()
  123. $referring_tables = array(
  124. 'analysisfeature',
  125. 'analysisprop',
  126. 'phylotree',
  127. 'quantification'
  128. );
  129. $description['referring_tables'] = $referring_tables;
  130. return $description;
  131. }
  132. /**
  133. * Implements hook_chado_analysisfeature_schema()
  134. * Purpose: To add descriptions and foreign keys to default table description
  135. * Note: This array will be merged with the array from all other implementations
  136. *
  137. * @return
  138. * Array describing the analysisfeature table
  139. *
  140. * @ingroup tripal_schema_api
  141. */
  142. function tripal_analysis_chado_analysisfeature_schema() {
  143. $description = array();
  144. $description['foreign keys']['feature'] = array(
  145. 'table' => 'feature',
  146. 'columns' => array(
  147. 'feature_id' => 'feature_id',
  148. ),
  149. );
  150. $description['foreign keys']['analysis'] = array(
  151. 'table' => 'analysis',
  152. 'columns' => array(
  153. 'analysis_id' => 'analysis_id',
  154. ),
  155. );
  156. return $description;
  157. }
  158. /**
  159. * Implements hook_chado_analysisfeatureprop_schema()
  160. * Purpose: To add descriptions and foreign keys to default table description
  161. * Note: This array will be merged with the array from all other implementations
  162. *
  163. * @return
  164. * Array describing the analysisfeatureprop table
  165. *
  166. * @ingroup tripal_schema_api
  167. */
  168. function tripal_analysis_chado_analysisfeatureprop_schema() {
  169. $description = array();
  170. $description['foreign keys']['analysisfeature'] = array(
  171. 'table' => 'analysisfeature',
  172. 'columns' => array(
  173. 'analysisfeature_id' => 'analysisfeature_id',
  174. ),
  175. );
  176. $description['foreign keys']['cvterm'] = array(
  177. 'table' => 'cvterm',
  178. 'columns' => array(
  179. 'type_id' => 'cvterm_id',
  180. ),
  181. );
  182. return $description;
  183. }
  184. /**
  185. * Implements hook_chado_analysisprop_schema()
  186. * Purpose: To add descriptions and foreign keys to default table description
  187. * Note: This array will be merged with the array from all other implementations
  188. *
  189. * @return
  190. * Array describing the analysisprop table
  191. *
  192. * @ingroup tripal_schema_api
  193. */
  194. function tripal_analysis_chado_analysisprop_schema() {
  195. $description = array();
  196. $description['foreign keys']['cvterm'] = array(
  197. 'table' => 'cvterm',
  198. 'columns' => array(
  199. 'type_id' => 'cvterm_id',
  200. ),
  201. );
  202. $description['foreign keys']['analysis'] = array(
  203. 'table' => 'analysis',
  204. 'columns' => array(
  205. 'analysis_id' => 'analysis_id',
  206. ),
  207. );
  208. return $description;
  209. }