tripal_analysis.api.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. *
  46. * @return
  47. * An analysis chado variable with the specified properties expanded
  48. *
  49. * @ingroup tripal_analysis_api
  50. */
  51. function tripal_analysis_get_property($analysis_id, $property) {
  52. return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
  53. }
  54. /**
  55. * Insert a given property
  56. *
  57. * @param $analysis_id
  58. * The analysis_id of the property to insert
  59. * @param $property
  60. * The cvterm name of the property to insert
  61. * @param $value
  62. * The value of the property to insert
  63. * @param $update_if_present
  64. * A boolean indicated whether to update the record if it's already present
  65. *
  66. * @return
  67. * True of success, False otherwise
  68. *
  69. * @ingroup tripal_analysis_api
  70. */
  71. function tripal_analysis_insert_property($analysis_id, $property, $value, $update_if_present = 0) {
  72. return tripal_core_insert_property('analysis', $analysis_id, $property, 'tripal', $value, $update_if_present);
  73. }
  74. /**
  75. * Update a given property
  76. *
  77. * @param $analysis_id
  78. * The analysis_id of the property to update
  79. * @param $property
  80. * The cvterm name of the property to update
  81. * @param $value
  82. * The value of the property to update
  83. * @param $insert_if_missing
  84. * A boolean indicated whether to insert the record if it's absent
  85. *
  86. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  87. * and then it will be updated with the supplied value
  88. *
  89. * @return
  90. * True of success, False otherwise
  91. *
  92. * @ingroup tripal_analysis_api
  93. */
  94. function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0) {
  95. return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
  96. }
  97. /**
  98. * Delete a given property
  99. *
  100. * @param $analysis_id
  101. * The analysis_id of the property to delete
  102. * @param $property
  103. * The cvterm name of the property to delete
  104. *
  105. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  106. * and then it will be deleted
  107. *
  108. * @return
  109. * True of success, False otherwise
  110. *
  111. * @ingroup tripal_analysis_api
  112. */
  113. function tripal_analysis_delete_property($analysis_id, $property) {
  114. return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
  115. }
  116. /**
  117. * Retreives the node of a sync'ed analysis
  118. *
  119. * @param $analysis_id
  120. * The analysis_id of the property to delete
  121. *
  122. * @return
  123. * node of analysis on success, null otherwise
  124. *
  125. * @ingroup tripal_analysis_api
  126. */
  127. function tripal_analysis_get_node($analysis_id) {
  128. $sql = "SELECT *
  129. FROM chado_analysis CA
  130. INNER JOIN node N on CA.nid = N.nid
  131. WHERE analysis_id = %d";
  132. $node = db_fetch_object(db_query($sql, $analysis_id));
  133. return $node;
  134. }