tripal_featuremap.DEPRECATED.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /**
  3. * @file
  4. * Wrapper functions to provide backwards compatibility for the tripal featuremap api
  5. */
  6. /**
  7. * @deprecated Restructured API to make naming more readable and consistent.
  8. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  9. * This function has been replaced by chado_get_property().
  10. *
  11. * @see chado_get_property().
  12. */
  13. function tripal_featuremap_get_property($featuremap_id, $property) {
  14. tripal_report_error(
  15. 'tripal_deprecated',
  16. TRIPAL_NOTICE,
  17. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  18. array(
  19. '%old_function'=>'tripal_featuremap_get_property',
  20. '%new_function' => 'chado_get_property'
  21. )
  22. );
  23. $record = array(
  24. 'table' => 'featuremap',
  25. 'id' => $featuremap_id,
  26. );
  27. $property = array(
  28. 'type_name' => $property,
  29. 'cv_name' => 'featuremap_property',
  30. );
  31. return chado_get_property($record, $property);
  32. }
  33. /**
  34. * @deprecated Restructured API to make naming more readable and consistent.
  35. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  36. * This function has been replaced by chado_insert_property().
  37. *
  38. * @see chado_insert_property().
  39. */
  40. function tripal_featuremap_insert_property($featuremap_id, $property, $value, $update_if_present = 0) {
  41. tripal_report_error(
  42. 'tripal_deprecated',
  43. TRIPAL_NOTICE,
  44. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  45. array(
  46. '%old_function'=>'tripal_featuremap_insert_property',
  47. '%new_function' => 'chado_insert_property'
  48. )
  49. );
  50. $record = array(
  51. 'table' => 'featuremap',
  52. 'id' => $featuremap_id,
  53. );
  54. $property = array(
  55. 'type_name' => $property,
  56. 'cv_name' => 'featuremap_property',
  57. 'value' => $value,
  58. );
  59. $options = array(
  60. 'update_if_present' => $update_if_present,
  61. );
  62. return chado_insert_property($record, $property, $options);
  63. }
  64. /**
  65. * @deprecated Restructured API to make naming more readable and consistent.
  66. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  67. * This function has been replaced by chado_update_property().
  68. *
  69. * @see chado_update_property().
  70. */
  71. function tripal_featuremap_update_property($featuremap_id, $property, $value, $insert_if_missing = 0) {
  72. tripal_report_error(
  73. 'tripal_deprecated',
  74. TRIPAL_NOTICE,
  75. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  76. array(
  77. '%old_function'=>'tripal_featuremap_update_property',
  78. '%new_function' => 'chado_update_property'
  79. )
  80. );
  81. $record = array(
  82. 'table' => 'featuremap',
  83. 'id' => $featuremap_id,
  84. );
  85. $property = array(
  86. 'type_name' => $property,
  87. 'cv_name' => 'featuremap_property',
  88. 'value' => $value,
  89. );
  90. $options = array(
  91. 'insert_if_missing' => $insert_if_missing,
  92. );
  93. return chado_update_property($record, $property, $options);
  94. }
  95. /**
  96. * @deprecated Restructured API to make naming more readable and consistent.
  97. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  98. * This function has been replaced by chado_delete_property().
  99. *
  100. * @see chado_delete_property().
  101. */
  102. function tripal_featuremap_delete_property($featuremap_id, $property) {
  103. tripal_report_error(
  104. 'tripal_deprecated',
  105. TRIPAL_NOTICE,
  106. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  107. array(
  108. '%old_function'=>'tripal_featuremap_delete_property',
  109. '%new_function' => 'chado_delete_property'
  110. )
  111. );
  112. $record = array(
  113. 'table' => 'featuremap',
  114. 'id' => $featuremap_id,
  115. );
  116. $property = array(
  117. 'type_name' => $property,
  118. 'cv_name' => 'featuremap_property',
  119. );
  120. return chado_delete_property($record, $property);
  121. }
  122. /**
  123. * @deprecated Restructured API to make naming more readable and consistent.
  124. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  125. * This function has been replaced by chado_associate_dbxref().
  126. *
  127. * @see chado_associate_dbxref().
  128. */
  129. function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbxref) {
  130. tripal_report_error(
  131. 'tripal_deprecated',
  132. TRIPAL_NOTICE,
  133. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  134. array(
  135. '%old_function'=>'tripal_featuremap_add_featuremap_dbxref',
  136. '%new_function' => 'chado_associate_dbxref'
  137. )
  138. );
  139. // break apart the dbxref
  140. $dbname = '';
  141. $accession = '';
  142. if(preg_match('/^(.*?):(.*?)$/', $featuremap_dbxref, $matches)) {
  143. $dbname = $matches[1];
  144. $accession = $matches[2];
  145. }
  146. else {
  147. return FALSE;
  148. }
  149. // check to see if the featuremap_dbxref record already exist
  150. $values = array(
  151. 'dbxref_id' => array(
  152. 'accession' => $accession,
  153. 'db_id' => array(
  154. 'name' => $dbname,
  155. ),
  156. ),
  157. 'featuremap_id' => $featuremap_id,
  158. );
  159. $options = array('statement_name' => 'sel_featuremapdbxref_dbpu');
  160. $results = chado_select_record('featuremap_dbxref', array('*'), $values, $options);
  161. // if the featuremap_dbxref record exist then we don't need to re-add it.
  162. if(count($results) > 0) {
  163. return $results[0];
  164. }
  165. // make sure our database already exists
  166. $db = tripal_db_add_db($dbname);
  167. // get the database cross-reference
  168. $dbxvalues = array(
  169. 'accession' => $accession,
  170. 'db_id' => $db->db_id,
  171. );
  172. $dbxoptions = array('statement_name' => 'sel_dbxref_acdb');
  173. $results = chado_select_record('dbxref', array('dbxref_id'), $dbxvalues, $dbxoptions);
  174. // if the accession doesn't exist then add it
  175. if(count($results) == 0){
  176. $dbxref = tripal_db_add_dbxref($db->db_id, $accession);
  177. }
  178. else {
  179. $dbxref = $results[0];
  180. }
  181. // now add the record
  182. $options = array('statement_name' => 'ins_featuremapdbxref_dbpu');
  183. $results = chado_insert_record('featuremap_dbxref', $values, $options);
  184. if (!$results) {
  185. tripal_report_error('t_featuremap', TRIPAL_ERROR, "Cannot add map dbxref: %db:%accession.",
  186. array('%db' => $dbname, '%accession' => $accession));
  187. return FALSE;
  188. }
  189. return $results;
  190. }