tripal_featuremap.DEPRECATED.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. return chado_get_property('featuremap', $featuremap_id, $property, 'featuremap_property');
  24. }
  25. /**
  26. * @deprecated Restructured API to make naming more readable and consistent.
  27. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  28. * This function has been replaced by chado_insert_property().
  29. *
  30. * @see chado_insert_property().
  31. */
  32. function tripal_featuremap_insert_property($featuremap_id, $property, $value, $update_if_present = 0) {
  33. tripal_report_error(
  34. 'tripal_deprecated',
  35. TRIPAL_NOTICE,
  36. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  37. array(
  38. '%old_function'=>'tripal_featuremap_insert_property',
  39. '%new_function' => 'chado_insert_property'
  40. )
  41. );
  42. return chado_insert_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $update_if_present);
  43. }
  44. /**
  45. * @deprecated Restructured API to make naming more readable and consistent.
  46. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  47. * This function has been replaced by chado_update_property().
  48. *
  49. * @see chado_update_property().
  50. */
  51. function tripal_featuremap_update_property($featuremap_id, $property, $value, $insert_if_missing = 0) {
  52. tripal_report_error(
  53. 'tripal_deprecated',
  54. TRIPAL_NOTICE,
  55. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  56. array(
  57. '%old_function'=>'tripal_featuremap_update_property',
  58. '%new_function' => 'chado_update_property'
  59. )
  60. );
  61. return chado_update_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $insert_if_missing);
  62. }
  63. /**
  64. * @deprecated Restructured API to make naming more readable and consistent.
  65. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  66. * This function has been replaced by chado_delete_property().
  67. *
  68. * @see chado_delete_property().
  69. */
  70. function tripal_featuremap_delete_property($featuremap_id, $property) {
  71. tripal_report_error(
  72. 'tripal_deprecated',
  73. TRIPAL_NOTICE,
  74. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  75. array(
  76. '%old_function'=>'tripal_featuremap_delete_property',
  77. '%new_function' => 'chado_delete_property'
  78. )
  79. );
  80. return chado_delete_property('featuremap', $featuremap_id, $property, 'featuremap_property');
  81. }
  82. /**
  83. * @deprecated Restructured API to make naming more readable and consistent.
  84. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
  85. * This function has been replaced by chado_associate_dbxref().
  86. *
  87. * @see chado_associate_dbxref().
  88. */
  89. function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbxref) {
  90. tripal_report_error(
  91. 'tripal_deprecated',
  92. TRIPAL_NOTICE,
  93. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  94. array(
  95. '%old_function'=>'tripal_featuremap_add_featuremap_dbxref',
  96. '%new_function' => 'chado_associate_dbxref'
  97. )
  98. );
  99. // break apart the dbxref
  100. $dbname = '';
  101. $accession = '';
  102. if(preg_match('/^(.*?):(.*?)$/', $featuremap_dbxref, $matches)) {
  103. $dbname = $matches[1];
  104. $accession = $matches[2];
  105. }
  106. else {
  107. return FALSE;
  108. }
  109. // check to see if the featuremap_dbxref record already exist
  110. $values = array(
  111. 'dbxref_id' => array(
  112. 'accession' => $accession,
  113. 'db_id' => array(
  114. 'name' => $dbname,
  115. ),
  116. ),
  117. 'featuremap_id' => $featuremap_id,
  118. );
  119. $options = array('statement_name' => 'sel_featuremapdbxref_dbpu');
  120. $results = chado_select_record('featuremap_dbxref', array('*'), $values, $options);
  121. // if the featuremap_dbxref record exist then we don't need to re-add it.
  122. if(count($results) > 0) {
  123. return $results[0];
  124. }
  125. // make sure our database already exists
  126. $db = tripal_db_add_db($dbname);
  127. // get the database cross-reference
  128. $dbxvalues = array(
  129. 'accession' => $accession,
  130. 'db_id' => $db->db_id,
  131. );
  132. $dbxoptions = array('statement_name' => 'sel_dbxref_acdb');
  133. $results = chado_select_record('dbxref', array('dbxref_id'), $dbxvalues, $dbxoptions);
  134. // if the accession doesn't exist then add it
  135. if(count($results) == 0){
  136. $dbxref = tripal_db_add_dbxref($db->db_id, $accession);
  137. }
  138. else {
  139. $dbxref = $results[0];
  140. }
  141. // now add the record
  142. $options = array('statement_name' => 'ins_featuremapdbxref_dbpu');
  143. $results = chado_insert_record('featuremap_dbxref', $values, $options);
  144. if (!$results) {
  145. tripal_report_error('t_featuremap', TRIPAL_ERROR, "Cannot add map dbxref: %db:%accession.",
  146. array('%db' => $dbname, '%accession' => $accession));
  147. return FALSE;
  148. }
  149. return $results;
  150. }