tripal_analysis.api.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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_schema_v1_11_table()
  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_schema_v1_11_analysis() {
  121. $description = array();
  122. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_schema_v1_11_analysis()
  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_schema_v1_2_table()
  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 analysis table
  139. *
  140. * @ingroup tripal_schema_api
  141. */
  142. function tripal_analysis_chado_schema_v1_2_analysis() {
  143. $description = array();
  144. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_schema_v1_2_analysis()
  145. $referring_tables = array(
  146. 'analysisfeature',
  147. 'analysisprop',
  148. 'phylotree',
  149. 'quantification'
  150. );
  151. $description['referring_tables'] = $referring_tables;
  152. return $description;
  153. }