tripal_analysis.api.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /**
  3. * @file
  4. * API functions relating to Analysis'
  5. *
  6. * @defgroup tripal_analysis_api Analysis Module API
  7. * @ingroup tripal_api
  8. */
  9. /**
  10. * Register tripal_analysis sub-modules
  11. *
  12. * @param $modulename
  13. * The name of the module to be registered as a tripal analysis submodule
  14. *
  15. * @ingroup tripal_analysis
  16. */
  17. function tripal_analysis_register_child($modulename) {
  18. $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = '%s'";
  19. if(!db_result($sql, $modulename)) {
  20. $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
  21. db_query($sql, $modulename);
  22. }
  23. }
  24. /**
  25. * Un-register a tripal analysis sub-module
  26. *
  27. * @param $modulename
  28. * The name of the module to un-register
  29. *
  30. * @ingroup tripal_analysis
  31. */
  32. function tripal_analysis_unregister_child($modulename) {
  33. if (db_table_exists('tripal_analysis')) {
  34. $sql = "DELETE FROM {tripal_analysis} WHERE modulename = '%s'";
  35. db_query($sql, $modulename);
  36. }
  37. }
  38. /**
  39. * Retrieve properties of a given type for a given analysis
  40. *
  41. * @param $analysis_id
  42. * The analysis_id of the properties you would like to retrieve
  43. * @param $property
  44. * The cvterm name of the properties to retrieve
  45. * @param $cvname
  46. * The name of the vocabulary to which the term belongs. Defaults to 'tripal'.
  47. *
  48. * @return
  49. * An analysis chado variable with the specified properties expanded
  50. *
  51. * @ingroup tripal_analysis_api
  52. */
  53. function tripal_analysis_get_property($analysis_id, $property, $cvname = 'tripal') {
  54. return tripal_core_get_property('analysis', $analysis_id, $property, $cvname);
  55. }
  56. /**
  57. * Insert a given property
  58. *
  59. * @param $analysis_id
  60. * The analysis_id of the property to insert
  61. * @param $property
  62. * The cvterm name of the property to insert
  63. * @param $value
  64. * The value of the property to insert
  65. * @param $update_if_present
  66. * A boolean indicated whether to update the record if it's already present
  67. * @param $cvname
  68. * The name of the vocabulary to which the term belongs. Defaults to 'tripal'.
  69. *
  70. * @return
  71. * True of success, False otherwise
  72. *
  73. * @ingroup tripal_analysis_api
  74. */
  75. function tripal_analysis_insert_property($analysis_id, $property, $value, $update_if_present = 0, $cvname = 'tripal') {
  76. return tripal_core_insert_property('analysis', $analysis_id, $property, $cvname, $value, $update_if_present);
  77. }
  78. /**
  79. * Update a given property
  80. *
  81. * @param $analysis_id
  82. * The analysis_id of the property to update
  83. * @param $property
  84. * The cvterm name of the property to update
  85. * @param $value
  86. * The value of the property to update
  87. * @param $insert_if_missing
  88. * A boolean indicated whether to insert the record if it's absent
  89. * @param $cvname
  90. * The name of the vocabulary to which the term belongs. Defaults to 'tripal'.
  91. *
  92. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  93. * and then it will be updated with the supplied value
  94. *
  95. * @return
  96. * True of success, False otherwise
  97. *
  98. * @ingroup tripal_analysis_api
  99. */
  100. function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0, $cvname = 'tripal') {
  101. return tripal_core_update_property('analysis', $analysis_id, $property, $cvname, $value, $insert_if_missing);
  102. }
  103. /**
  104. * Delete a given property
  105. *
  106. * @param $analysis_id
  107. * The analysis_id of the property to delete
  108. * @param $property
  109. * The cvterm name of the property to delete
  110. * @param $cvname
  111. * The name of the vocabulary to which the term belongs. Defaults to 'tripal'.
  112. *
  113. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  114. * and then it will be deleted
  115. *
  116. * @return
  117. * True of success, False otherwise
  118. *
  119. * @ingroup tripal_analysis_api
  120. */
  121. function tripal_analysis_delete_property($analysis_id, $property, $cvname = 'tripal') {
  122. return tripal_core_delete_property('analysis', $analysis_id, $property, $cvname);
  123. }
  124. /**
  125. * Retreives the node of a sync'ed analysis
  126. *
  127. * @param $analysis_id
  128. * The analysis_id of the property to delete
  129. *
  130. * @return
  131. * node of analysis on success, null otherwise
  132. *
  133. * @ingroup tripal_analysis_api
  134. */
  135. function tripal_analysis_get_node($analysis_id) {
  136. $sql = "SELECT *
  137. FROM {chado_analysis} CA
  138. INNER JOIN {node} N on CA.nid = N.nid
  139. WHERE analysis_id = %d";
  140. $node = db_fetch_object(db_query($sql, $analysis_id));
  141. return $node;
  142. }