tripal_feature.DEPRECATED.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <?php
  2. /**
  3. * @file
  4. * Wrapper functions to provide backwards compatibility for the tripal feature
  5. * api
  6. */
  7. /**
  8. * @deprecated Restructured API to make naming more readable and consistent.
  9. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  10. * now. This function has been replaced by chado_get_property().
  11. *
  12. * @see chado_get_property().
  13. */
  14. function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
  15. tripal_report_error(
  16. 'tripal_deprecated',
  17. TRIPAL_NOTICE,
  18. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  19. [
  20. '%old_function' => 'tripal_feature_analysis_get_property',
  21. '%new_function' => 'chado_get_property',
  22. ]
  23. );
  24. // check that the incoming arguments are correct
  25. if (($analysis_id and !$feature_id) or
  26. (!$analysis_id and $feature_id)) {
  27. tripal_report_error('tripal_feature', TRIPAL_WARNING,
  28. 'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
  29. []);
  30. }
  31. // get the analysisfeature_id if one is not provided
  32. if (!$analysisfeature_id) {
  33. $columns = ['analysisfeature_id'];
  34. $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
  35. $result = chado_select_record('analysisfeature', $columns, $values);
  36. $analysisfeature_id = $result[0]->analysisfeature_id;
  37. }
  38. $record = [
  39. 'table' => 'analysisfeature',
  40. 'id' => $analysisfeature_id,
  41. ];
  42. $property = [
  43. 'type_name' => $property,
  44. 'cv_name' => $cv_name,
  45. ];
  46. // get the property.
  47. return chado_get_property($record, $property);
  48. }
  49. /**
  50. * @deprecated Restructured API to make naming more readable and consistent.
  51. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  52. * now. This function has been replaced by chado_insert_property().
  53. *
  54. * @see chado_insert_property().
  55. */
  56. function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $value, $update_if_present = 0, $cv_name = 'tripal') {
  57. tripal_report_error(
  58. 'tripal_deprecated',
  59. TRIPAL_NOTICE,
  60. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  61. [
  62. '%old_function' => 'tripal_feature_analysis_insert_property',
  63. '%new_function' => 'chado_insert_property',
  64. ]
  65. );
  66. // check that the incoming arguments are correct
  67. if (($analysis_id and !$feature_id) or
  68. (!$analysis_id and $feature_id)) {
  69. tripal_report_error('tripal_feature', TRIPAL_WARNING,
  70. 'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
  71. []);
  72. }
  73. // get the analysisfeature_id if one is not provided
  74. if (!$analysisfeature_id) {
  75. $columns = ['analysisfeature_id'];
  76. $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
  77. $result = chado_select_record('analysisfeature', $columns, $values);
  78. $analysisfeature_id = $result[0]->analysisfeature_id;
  79. }
  80. $record = [
  81. 'table' => 'analysisfeature',
  82. 'id' => $analysisfeature_id,
  83. ];
  84. $property = [
  85. 'type_name' => $property,
  86. 'cv_name' => $cv_name,
  87. 'value' => $value,
  88. ];
  89. $options = [
  90. 'update_if_present' => $update_if_present,
  91. ];
  92. // insert the property.
  93. return chado_insert_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
  98. * now. This function has been replaced by chado_update_property().
  99. *
  100. * @see chado_update_property().
  101. */
  102. function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0, $cv_name = 'tripal') {
  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. [
  108. '%old_function' => 'tripal_feature_analysis_update_property',
  109. '%new_function' => 'chado_update_property',
  110. ]
  111. );
  112. // check that the incoming arguments are correct
  113. if (($analysis_id and !$feature_id) or
  114. (!$analysis_id and $feature_id)) {
  115. tripal_report_error('tripal_feature', TRIPAL_WARNING,
  116. 'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
  117. []);
  118. }
  119. // get the analysisfeature_id if one is not provided
  120. if (!$analysisfeature_id) {
  121. $columns = ['analysisfeature_id'];
  122. $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
  123. $result = chado_select_record('analysisfeature', $columns, $values);
  124. $analysisfeature_id = $result[0]->analysisfeature_id;
  125. }
  126. $record = [
  127. 'table' => 'analysisfeature',
  128. 'id' => $analysisfeature_id,
  129. ];
  130. $property = [
  131. 'type_name' => $property,
  132. 'cv_name' => $cv_name,
  133. 'value' => $value,
  134. ];
  135. $options = [
  136. 'insert_if_missing' => $insert_if_missing,
  137. ];
  138. // update the property.
  139. return chado_update_property($record, $property, $options);
  140. }
  141. /**
  142. * @deprecated Restructured API to make naming more readable and consistent.
  143. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  144. * now. This function has been replaced by chado_update_property().
  145. *
  146. * @see chado_update_property().
  147. */
  148. function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id, $property, $value, $cv_name = 'tripal') {
  149. tripal_report_error(
  150. 'tripal_deprecated',
  151. TRIPAL_NOTICE,
  152. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  153. [
  154. '%old_function' => 'tripal_feature_analysis_update_property_by_id',
  155. '%new_function' => 'chado_update_property',
  156. ]
  157. );
  158. $record = [
  159. 'table' => 'analysisfeature',
  160. 'prop_id' => $analysisfeatureprop_id,
  161. ];
  162. $property = [
  163. 'type_name' => $property,
  164. 'cv_name' => $cv_name,
  165. 'value' => $value,
  166. ];
  167. // update the property.
  168. return chado_update_property($record, $property);
  169. }
  170. /**
  171. * @deprecated Restructured API to make naming more readable and consistent.
  172. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  173. * now. This function has been replaced by chado_delete_property().
  174. *
  175. * @see chado_delete_property().
  176. */
  177. function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
  178. tripal_report_error(
  179. 'tripal_deprecated',
  180. TRIPAL_NOTICE,
  181. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  182. [
  183. '%old_function' => 'tripal_feature_analysis_delete_property',
  184. '%new_function' => 'chado_delete_property',
  185. ]
  186. );
  187. // check that the incoming arguments are correct
  188. if (($analysis_id and !$feature_id) or
  189. (!$analysis_id and $feature_id)) {
  190. tripal_report_error('tripal_feature', TRIPAL_WARNING,
  191. 'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
  192. []);
  193. }
  194. // get the analysisfeature_id if one is not provided
  195. if (!$analysisfeature_id) {
  196. $columns = ['analysisfeature_id'];
  197. $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
  198. $result = chado_select_record('analysisfeature', $columns, $values);
  199. $analysisfeature_id = $result[0]->analysisfeature_id;
  200. }
  201. $record = [
  202. 'table' => 'analysisfeature',
  203. 'id' => $analysisfeature_id,
  204. ];
  205. $property = [
  206. 'type_name' => $property,
  207. 'cv_name' => $cv_name,
  208. ];
  209. // get the property.
  210. return chado_delete_property($record, $property);
  211. }
  212. /**
  213. * @deprecated Restructured API to make naming more readable and consistent.
  214. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  215. * now. This function has been replaced by chado_delete_record().
  216. *
  217. * @see chado_delete_record().
  218. */
  219. function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id) {
  220. tripal_report_error(
  221. 'tripal_deprecated',
  222. TRIPAL_NOTICE,
  223. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  224. [
  225. '%old_function' => 'tripal_feature_analysis_delete_property_by_id',
  226. '%new_function' => 'chado_delete_record',
  227. ]
  228. );
  229. // construct the array that will match the exact record to update
  230. $match = [
  231. 'analysisfeatureprop_id' => $analysisfeatureprop_id,
  232. ];
  233. return chado_delete_record('analysisfeatureprop', $match);
  234. }
  235. /**
  236. * @deprecated Restructured API to make naming more readable and consistent.
  237. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  238. * now. This function has been replaced by chado_get_property().
  239. *
  240. * @see chado_get_property().
  241. */
  242. function tripal_feature_get_property($feature_id, $property, $cv_name = 'tripal') {
  243. tripal_report_error(
  244. 'tripal_deprecated',
  245. TRIPAL_NOTICE,
  246. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  247. [
  248. '%old_function' => 'tripal_feature_get_property',
  249. '%new_function' => 'chado_get_property',
  250. ]
  251. );
  252. $record = [
  253. 'table' => 'feature',
  254. 'id' => $feature_id,
  255. ];
  256. $property = [
  257. 'type_name' => $property,
  258. 'cv_name' => $cv_name,
  259. ];
  260. return chado_get_property($record, $property);
  261. }
  262. /**
  263. * @deprecated Restructured API to make naming more readable and consistent.
  264. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  265. * now. This function has been replaced by chado_insert_property().
  266. *
  267. * @see chado_insert_property().
  268. */
  269. function tripal_feature_insert_property($feature_id, $property, $value, $update_if_present = 0, $cv_name = 'tripal') {
  270. tripal_report_error(
  271. 'tripal_deprecated',
  272. TRIPAL_NOTICE,
  273. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  274. [
  275. '%old_function' => 'tripal_feature_insert_property',
  276. '%new_function' => 'chado_insert_property',
  277. ]
  278. );
  279. $record = [
  280. 'table' => 'feature',
  281. 'id' => $feature_id,
  282. ];
  283. $property = [
  284. 'type_name' => $property,
  285. 'cv_name' => $cv_name,
  286. 'value' => $value,
  287. ];
  288. $options = [
  289. 'update_if_present' => $update_if_present,
  290. ];
  291. return chado_insert_property($record, $property, $options);
  292. }
  293. /**
  294. * @deprecated Restructured API to make naming more readable and consistent.
  295. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  296. * now. This function has been replaced by chado_update_property().
  297. *
  298. * @see chado_update_property().
  299. */
  300. function tripal_feature_update_property($feature_id, $property, $value, $insert_if_missing = 0, $cv_name = 'tripal') {
  301. tripal_report_error(
  302. 'tripal_deprecated',
  303. TRIPAL_NOTICE,
  304. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  305. [
  306. '%old_function' => 'tripal_feature_update_property',
  307. '%new_function' => 'chado_update_property',
  308. ]
  309. );
  310. $record = [
  311. 'table' => 'feature',
  312. 'id' => $feature_id,
  313. ];
  314. $property = [
  315. 'type_name' => $property,
  316. 'cv_name' => $cv_name,
  317. 'value' => $value,
  318. ];
  319. $options = [
  320. 'insert_if_missing' => insert_if_missing,
  321. ];
  322. return chado_update_property($record, $property, $options);
  323. }
  324. /**
  325. * @deprecated Restructured API to make naming more readable and consistent.
  326. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  327. * now. This function has been replaced by chado_update_property().
  328. *
  329. * @see chado_update_property().
  330. */
  331. function tripal_feature_update_property_by_id($featureprop_id, $property, $value, $cv_name = 'tripal') {
  332. tripal_report_error(
  333. 'tripal_deprecated',
  334. TRIPAL_NOTICE,
  335. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  336. [
  337. '%old_function' => 'tripal_feature_update_property_by_id',
  338. '%new_function' => 'chado_update_property',
  339. ]
  340. );
  341. $record = [
  342. 'table' => 'feature',
  343. 'prop_id' => $featureprop_id,
  344. ];
  345. $property = [
  346. 'type_name' => $property,
  347. 'cv_name' => $cv_name,
  348. 'value' => $value,
  349. ];
  350. return chado_update_property($record, $property);
  351. }
  352. /**
  353. * @deprecated Restructured API to make naming more readable and consistent.
  354. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  355. * now. This function has been replaced by chado_delete_property().
  356. *
  357. * @see chado_delete_property().
  358. */
  359. function tripal_feature_delete_property($feature_id, $property, $cv_name = 'tripal') {
  360. tripal_report_error(
  361. 'tripal_deprecated',
  362. TRIPAL_NOTICE,
  363. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  364. [
  365. '%old_function' => 'tripal_feature_delete_property',
  366. '%new_function' => 'chado_delete_property',
  367. ]
  368. );
  369. $record = [
  370. 'table' => 'feature',
  371. 'id' => $feature_id,
  372. ];
  373. $property = [
  374. 'type_name' => $property,
  375. 'cv_name' => $cv_name,
  376. ];
  377. return chado_delete_property($record, $property);
  378. }
  379. /**
  380. * @deprecated Restructured API to make naming more readable and consistent.
  381. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  382. * now. This function has been replaced by chado_delete_record().
  383. *
  384. * @see chado_delete_record().
  385. */
  386. function tripal_feature_delete_property_by_id($featureprop_id) {
  387. tripal_report_error(
  388. 'tripal_deprecated',
  389. TRIPAL_NOTICE,
  390. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  391. [
  392. '%old_function' => 'tripal_feature_delete_property_by_id',
  393. '%new_function' => 'chado_delete_record',
  394. ]
  395. );
  396. // construct the array that will match the exact record to update
  397. $match = [
  398. 'featureprop_id' => $featureprop_id,
  399. ];
  400. return chado_delete_record('featureprop', $match);
  401. }
  402. /**
  403. * @deprecated Restructured API to make naming more readable and consistent.
  404. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  405. * now. This function has been replaced by
  406. * tripal_reverse_compliment_sequence().
  407. *
  408. * @see tripal_reverse_compliment_sequence().
  409. */
  410. function tripal_feature_reverse_complement($sequence) {
  411. tripal_report_error(
  412. 'tripal_deprecated',
  413. TRIPAL_NOTICE,
  414. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  415. [
  416. '%old_function' => 'tripal_feature_reverse_complement',
  417. '%new_function' => 'tripal_reverse_compliment_sequence',
  418. ]
  419. );
  420. return tripal_reverse_compliment_sequence($sequence);
  421. }
  422. /**
  423. * @deprecated Restructured API to make naming more readable and consistent.
  424. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  425. * now. This function has been replaced by tripal_associate_dbxref().
  426. *
  427. * @see tripal_associate_dbxref().
  428. */
  429. function tripal_feature_add_dbxref($feature_id, $dbname, $accession) {
  430. tripal_report_error(
  431. 'tripal_deprecated',
  432. TRIPAL_NOTICE,
  433. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  434. [
  435. '%old_function' => 'tripal_feature_add_dbxref',
  436. '%new_function' => 'tripal_associate_dbxref',
  437. ]
  438. );
  439. return tripal_associate_dbxref(
  440. 'feature',
  441. $feature_id,
  442. [
  443. 'accession' => $accession,
  444. 'db_name' => $dbname,
  445. ]
  446. );
  447. }
  448. /**
  449. * @deprecated Restructured API to make naming more readable and consistent.
  450. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  451. * now. This function has been replaced by tripal_associate_cvterm().
  452. *
  453. * @see tripal_associate_cvterm().
  454. */
  455. function tripal_feature_add_cvterm($feature_id, $cvname, $cvterm) {
  456. tripal_report_error(
  457. 'tripal_deprecated',
  458. TRIPAL_NOTICE,
  459. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  460. [
  461. '%old_function' => 'tripal_feature_add_cvterm',
  462. '%new_function' => 'tripal_associate_cvterm',
  463. ]
  464. );
  465. return tripal_associate_cvterm(
  466. 'feature',
  467. $feature_id,
  468. [
  469. 'name' => $cvterm,
  470. 'cv_name' => $cvname,
  471. ]
  472. );
  473. }