tripal_feature.api.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <?php
  2. /**
  3. * @file
  4. * @todo Add file header description
  5. */
  6. /**
  7. * Implements hook_chado_feature_schema()
  8. * Purpose: To add descriptions to default table description
  9. * Note: This array will be merged with the array from all other implementations
  10. *
  11. * @return
  12. * Array describing the feature table
  13. *
  14. * @ingroup tripal_schema_api
  15. */
  16. function tripal_feature_chado_schema_v1_11_feature() {
  17. $description = array();
  18. $referring_tables = array('analysisfeature',
  19. 'element',
  20. 'feature_cvterm',
  21. 'feature_dbxref',
  22. 'feature_expression',
  23. 'feature_genotype',
  24. 'feature_phenotype',
  25. 'feature_pub',
  26. 'feature_relationship',
  27. 'feature_synonym',
  28. 'featureloc',
  29. 'featurepos',
  30. 'featureprop',
  31. 'featurerange',
  32. 'library_feature',
  33. 'phylonode',
  34. 'wwwuser_feature'
  35. );
  36. $description['referring_tables'] = $referring_tables;
  37. return $description;
  38. }
  39. /**
  40. * Implements hook_chado_featureprop_schema()
  41. * Purpose: To add descriptions to default table description
  42. * Note: This array will be merged with the array from all other implementations
  43. *
  44. * @return
  45. * Array describing the featureprop table
  46. *
  47. * @ingroup tripal_schema_api
  48. */
  49. function tripal_feature_chado_schema_v1_11_featureprop() {
  50. $description = array();
  51. $referring_tables = array('analysisfeature',
  52. 'featureprop_pub',
  53. );
  54. $description['referring_tables'] = $referring_tables;
  55. return $description;
  56. }
  57. /**
  58. * Implements hook_chado_schema_v1_11_table()
  59. * Purpose: To add descriptions to default table description
  60. * Note: This array will be merged with the array from all other implementations
  61. *
  62. * @return
  63. * Array describing the featureloc table
  64. *
  65. * @ingroup tripal_schema_api
  66. */
  67. function tripal_feature_chado_schema_v1_11_featureloc() {
  68. $description = array();
  69. $referring_tables = array('analysisfeature',
  70. 'featureloc_pub',
  71. );
  72. $description['referring_tables'] = $referring_tables;
  73. return $description;
  74. }
  75. /**
  76. * Implements hook_chado_schema_v1_2_table()
  77. * Purpose: To add descriptions and to default table description
  78. * Note: This array will be merged with the array from all other implementations
  79. *
  80. * @return
  81. * Array describing the featureloc table
  82. *
  83. * @ingroup tripal_schema_api
  84. */
  85. function tripal_feature_chado_schema_v1_2_featureloc() {
  86. $description = array();
  87. $referring_tables = array('analysisfeature',
  88. 'featureloc_pub',
  89. );
  90. $description['referring_tables'] = $referring_tables;
  91. return $description;
  92. }
  93. /**
  94. * Retrieve properties from the analysisfeatureprop table for a feature.
  95. *
  96. * @param $analysis_id
  97. * The analysis ID for the analysis feature. This argument is optional but
  98. * if specified it must also be accompanied with a feature ID.
  99. * @param $feature_id
  100. * The feature ID for the analysis feature. This argument is optional but
  101. * if specified it must also be accompanied with an analysis ID.
  102. * @param $analysisfeature_id
  103. * The analysis feature ID for the analysis feature. This argument is
  104. * optional and can be used rather than specifying the $analysis_id and
  105. * $feature_id arguments. If all three arguments are specified (e.g.
  106. * an $analysis_id, $feature_id and $analysisfeature_id, then the
  107. * $analysisfeature_id is used and the other two arguments are ignored.
  108. * @param $property
  109. * The cvterm name of the properties to retrieve
  110. * @param $cv_name
  111. * Optional. The name of the cv to which the property belongs. By
  112. * default this is the 'tripal' cv.
  113. *
  114. * @return
  115. * An analysisfeature chado variable with the specified properties expanded
  116. *
  117. * @ingroup tripal_feature_api
  118. */
  119. function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NUll,
  120. $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
  121. // check that the incoming arguments are correct
  122. if (($analysis_id and !$feature_id) or
  123. (!$analysis_id and $feature_id)) {
  124. watchdog('tripal_feature',
  125. 'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
  126. array(), WATCHDOG_WARNING);
  127. }
  128. // get the analysisfeature_id if one is not provided
  129. if (!$analysisfeature_id) {
  130. $columns = array('analysisfeature_id');
  131. $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
  132. $result = tripal_core_chado_select('analysisfeature', $columns, $values);
  133. $analysisfeature_id = $result[0]->analysisfeature_id;
  134. }
  135. // get the property.
  136. return tripal_core_get_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
  137. }
  138. /**
  139. * Insert a property for an analysis feature
  140. *
  141. * @param $analysis_id
  142. * The analysis ID for the analysis feature. This argument is optional but
  143. * if specified it must also be accompanied with a feature ID.
  144. * @param $feature_id
  145. * The feature ID for the analysis feature. This argument is optional but
  146. * if specified it must also be accompanied with an analysis ID.
  147. * @param $analysisfeature_id
  148. * The analysis feature ID for the analysis feature. This argument is
  149. * optional and can be used rather than specifying the $analysis_id and
  150. * $feature_id arguments. If all three arguments are specified (e.g.
  151. * an $analysis_id, $feature_id and $analysisfeature_id, then the
  152. * $analysisfeature_id is used and the other two arguments are ignored.
  153. * @param $property
  154. * The cvterm name of the property to insert
  155. * @param $value
  156. * The value of the property to insert
  157. * @param $update_if_present
  158. * A boolean indicated whether to update the record if it's already present
  159. * @param $cv_name
  160. * Optional. The name of the cv to which the property belongs. By
  161. * default this is the 'tripal' cv.
  162. *
  163. * @return
  164. * True of success, False otherwise
  165. *
  166. * @ingroup tripal_feature_api
  167. */
  168. function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NUll,
  169. $analysisfeature_id = NULL, $property, $value, $update_if_present = 0,
  170. $cv_name = 'tripal') {
  171. // check that the incoming arguments are correct
  172. if (($analysis_id and !$feature_id) or
  173. (!$analysis_id and $feature_id)) {
  174. watchdog('tripal_feature',
  175. 'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
  176. array(), WATCHDOG_WARNING);
  177. }
  178. // get the analysisfeature_id if one is not provided
  179. if (!$analysisfeature_id) {
  180. $columns = array('analysisfeature_id');
  181. $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
  182. $result = tripal_core_chado_select('analysisfeature', $columns, $values);
  183. $analysisfeature_id = $result[0]->analysisfeature_id;
  184. }
  185. // insert the property.
  186. return tripal_core_insert_property('analysisfeature', $analysisfeature_id,
  187. $property, $cv_name, $value, $update_if_present);
  188. }
  189. /**
  190. * Update an analysis feature property using the property name. Use this
  191. * when a property only exists once for a given analysis feature. When more
  192. * than one value can exist for the same property use the
  193. * tripal_feature_analysis_update_property_by_id() function.
  194. *
  195. * @param $analysis_id
  196. * The analysis ID for the analysis feature. This argument is optional but
  197. * if specified it must also be accompanied with a feature ID.
  198. * @param $feature_id
  199. * The feature ID for the analysis feature. This argument is optional but
  200. * if specified it must also be accompanied with an analysis ID.
  201. * @param $analysisfeature_id
  202. * The analysis feature ID for the analysis feature. This argument is
  203. * optional and can be used rather than specifying the $analysis_id and
  204. * $feature_id arguments. If all three arguments are specified (e.g.
  205. * an $analysis_id, $feature_id and $analysisfeature_id, then the
  206. * $analysisfeature_id is used and the other two arguments are ignored.
  207. * @param $property
  208. * The cvterm name of the property to update
  209. * @param $value
  210. * The value of the property to update
  211. * @param $insert_if_missing
  212. * A boolean indicated whether to insert the record if it's absent
  213. * @param $cv_name
  214. * Optional. The name of the cv to which the property belongs. By
  215. * default this is the 'tripal' cv.
  216. *
  217. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  218. * and then it will be updated with the supplied value
  219. *
  220. * @return
  221. * True of success, False otherwise
  222. *
  223. * @ingroup tripal_feature_api
  224. */
  225. function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NUll,
  226. $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0,
  227. $cv_name = 'tripal') {
  228. // check that the incoming arguments are correct
  229. if (($analysis_id and !$feature_id) or
  230. (!$analysis_id and $feature_id)) {
  231. watchdog('tripal_feature',
  232. 'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
  233. array(), WATCHDOG_WARNING);
  234. }
  235. // get the analysisfeature_id if one is not provided
  236. if (!$analysisfeature_id) {
  237. $columns = array('analysisfeature_id');
  238. $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
  239. $result = tripal_core_chado_select('analysisfeature', $columns, $values);
  240. $analysisfeature_id = $result[0]->analysisfeature_id;
  241. }
  242. // update the property.
  243. return tripal_core_update_property('analysisfeature', $analysisfeature_id, $property, $cv_name, $value, $insert_if_missing);
  244. }
  245. /**
  246. * Update a property for an analysis feature using the analysisfeatureprop_id.
  247. *
  248. * @param $analysisfeatureprop_id
  249. * The analysis feature property ID for the analysis feature.
  250. * @param $property
  251. * The cvterm name of the property
  252. * @param $value
  253. * The value of the property
  254. * @param $cv_name
  255. * Optional. The name of the cv to which the property belongs. By
  256. * default this is the 'tripal' cv.
  257. * *
  258. * @return
  259. * True of success, False otherwise
  260. *
  261. * @ingroup tripal_feature_api
  262. */
  263. function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
  264. $property, $value, $cv_name = 'tripal') {
  265. // update the property.
  266. return tripal_core_update_property_by_id('analysisfeature',
  267. $analysisfeatureprop_id, $property, $cv_name, $value);
  268. }
  269. /**
  270. * Delete an analysis feature property using the property name. Use this
  271. * when a property only exists once for a given analysis feature. When more
  272. * than one value can exist for the same property use the
  273. * tripal_feature_analysis_delete_property_by_id() function.
  274. *
  275. * @param $analysis_id
  276. * The analysis ID for the analysis feature. This argument is optional but
  277. * if specified it must also be accompanied with a feature ID.
  278. * @param $feature_id
  279. * The feature ID for the analysis feature. This argument is optional but
  280. * if specified it must also be accompanied with an analysis ID.
  281. * @param $analysisfeature_id
  282. * The analysis feature ID for the analysis feature. This argument is
  283. * optional and can be used rather than specifying the $analysis_id and
  284. * $feature_id arguments. If all three arguments are specified (e.g.
  285. * an $analysis_id, $feature_id and $analysisfeature_id, then the
  286. * $analysisfeature_id is used and the other two arguments are ignored.
  287. * @param $property
  288. * The cvterm name of the property to delete
  289. * @param $cv_name
  290. * Optional. The name of the cv to which the property belongs. By
  291. * default this is the 'tripal' cv.
  292. *
  293. * Note: The property will be identified using the unique combination of the $analysis_id and $property
  294. * and then it will be deleted
  295. *
  296. * @return
  297. * True of success, False otherwise
  298. *
  299. * @ingroup tripal_feature_api
  300. */
  301. function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll,
  302. $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
  303. // check that the incoming arguments are correct
  304. if (($analysis_id and !$feature_id) or
  305. (!$analysis_id and $feature_id)) {
  306. watchdog('tripal_feature',
  307. 'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
  308. array(), WATCHDOG_WARNING);
  309. }
  310. // get the analysisfeature_id if one is not provided
  311. if (!$analysisfeature_id) {
  312. $columns = array('analysisfeature_id');
  313. $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
  314. $result = tripal_core_chado_select('analysisfeature', $columns, $values);
  315. $analysisfeature_id = $result[0]->analysisfeature_id;
  316. }
  317. // get the property.
  318. return tripal_core_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
  319. }
  320. /**
  321. * Delete a property using the analysisfeatureprop_id
  322. *
  323. * @param $analysisfeatureprop_id
  324. * The analysis feature property ID for the analysis feature.
  325. *
  326. * @return
  327. * True of success, False otherwise
  328. *
  329. * @ingroup tripal_feature_api
  330. */
  331. function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id) {
  332. // get the property.
  333. return tripal_core_delete_property_by_id('analysisfeature', $analysisfeatureprop_id);
  334. }
  335. /**
  336. * Retrieve properties of a given type for a given feature
  337. *
  338. * @param $feature_id
  339. * The feature_id of the properties you would like to retrieve
  340. * @param $property
  341. * The cvterm name of the properties to retrieve
  342. * @param $cv_name
  343. * Optional. The name of the cv to which the property belongs. By
  344. * default this is the 'tripal' cv.
  345. *
  346. * @return
  347. * A feature chado variable with the specified properties expanded
  348. *
  349. * @ingroup tripal_feature_api
  350. */
  351. function tripal_feature_get_property($feature_id, $property, $cv_name='tripal') {
  352. return tripal_core_get_property('feature', $feature_id, $property, $cv_name);
  353. }
  354. /**
  355. * Insert a given property
  356. *
  357. * @param $feature_id
  358. * The feature_id of the property to insert
  359. * @param $property
  360. * The cvterm name of the property to insert
  361. * @param $value
  362. * The value of the property to insert
  363. * @param $update_if_present
  364. * A boolean indicated whether to update the record if it's already present
  365. * @param $cv_name
  366. * Optional. The name of the cv to which the property belongs. By
  367. * default this is the 'tripal' cv.
  368. *
  369. * @return
  370. * True of success, False otherwise
  371. *
  372. * @ingroup tripal_feature_api
  373. */
  374. function tripal_feature_insert_property($feature_id, $property, $value,
  375. $update_if_present = 0, $cv_name = 'tripal') {
  376. return tripal_core_insert_property('feature', $feature_id, $property,
  377. $cv_name, $value, $update_if_present);
  378. }
  379. /**
  380. * Update a feature property using the property name. Only use this
  381. * if the property is unique and only exist once for the feature.
  382. *
  383. * @param $feature_id
  384. * The feature_id of the property to update
  385. * @param $property
  386. * The cvterm name of the property to update
  387. * @param $value
  388. * The value of the property to update
  389. * @param $insert_if_missing
  390. * A boolean indicated whether to insert the record if it's absent
  391. * @param $cv_name
  392. * Optional. The name of the cv to which the property belongs. By
  393. * default this is the 'tripal' cv.
  394. *
  395. * Note: The property will be identified using the unique combination of the $feature_id and $property
  396. * and then it will be updated with the supplied value
  397. *
  398. * @return
  399. * True of success, False otherwise
  400. *
  401. * @ingroup tripal_feature_api
  402. */
  403. function tripal_feature_update_property($feature_id, $property,
  404. $value, $insert_if_missing = 0, $cv_name = 'tripal') {
  405. return tripal_core_update_property('feature', $feature_id, $property, $cv_name, $value, $insert_if_missing);
  406. }
  407. /**
  408. * Update a given feature property using the featureprop_id
  409. *
  410. * @param $featureprop_id
  411. * The featureprop_id of the property to update
  412. * @param $property
  413. * The cvterm name of the property
  414. * @param $value
  415. * The value of the property
  416. * @param $cv_name
  417. * Optional. The name of the cv to which the property belongs. By
  418. * default this is the 'tripal' cv.
  419. *
  420. * @return
  421. * True of success, False otherwise
  422. *
  423. * @ingroup tripal_feature_api
  424. */
  425. function tripal_feature_update_property_by_id($featureprop_id, $property,
  426. $value, $cv_name = 'tripal') {
  427. return tripal_core_update_property_by_id('feature', $featureprop_id, $property, $cv_name, $value);
  428. }
  429. /**
  430. * Delete a given feature property using the property name. Only use this
  431. * if the property is unique and only exists once for the feature.
  432. *
  433. * @param $feature_id
  434. * The feature_id of the property to delete
  435. * @param $property
  436. * The cvterm name of the property to delete
  437. * @param $cv_name
  438. * Optional. The name of the cv to which the property belongs. By
  439. * default this is the 'tripal' cv.
  440. *
  441. * Note: The property will be identified using the unique combination of the $feature_id and $property
  442. * and then it will be deleted
  443. *
  444. * @return
  445. * True of success, False otherwise
  446. *
  447. * @ingroup tripal_feature_api
  448. */
  449. function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
  450. return tripal_core_delete_property('feature', $feature_id, $property, $cv_name);
  451. }
  452. /**
  453. * Delete a given feature property using the featureprop_id
  454. *
  455. * @param $featureprop_id
  456. * The feature_id of the property to delete
  457. *
  458. * @return
  459. * True of success, False otherwise
  460. *
  461. * @ingroup tripal_feature_api
  462. */
  463. function tripal_feature_delete_property_by_id($featureprop_id) {
  464. return tripal_core_delete_property_by_id('feature', $featureprop_id);
  465. }