tripal_analysis.api.inc 3.9 KB

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