tripal_genetic.api.inc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @file
  4. * @todo Add file header description
  5. */
  6. /**
  7. *
  8. */
  9. function tripal_genetic_get_genotypes_by_feature_id($feature_id) {
  10. /**
  11. $sql = 'SELECT nd_experiment_id FROM nd_experiment_genotype WHERE genotype_id IN (SELECT genotype_id FROM feature_genotype WHERE feature_id=%d)';
  12. $resource = db_query($sql, $feature_id);
  13. $values['nd_experiment_id'] = array();
  14. while ($r = db_fetch_object($resource)) {
  15. $values['nd_experiment_id'][] = $r->nd_experiment_id;
  16. }
  17. $object = tripal_core_generate_chado_var('nd_experiment',$values);
  18. $object = tripal_core_expand_chado_vars($object, 'table', 'nd_experiment_genotype');
  19. $object = tripal_core_expand_chado_vars($object, 'table', 'feature_genotype');
  20. $object = tripal_core_expand_chado_vars($object, 'table', 'nd_experiment_stock');
  21. */
  22. $sql = 'SELECT genotype_id FROM {genotype} WHERE genotype_id IN (SELECT genotype_id FROM {feature_genotype} WHERE feature_id=%d)';
  23. $resource = db_query($sql, $feature_id);
  24. $values['genotype_id'] = array();
  25. while ($r = db_fetch_object($resource)) {
  26. $values['genotype_id'][] = $r->genotype_id;
  27. }
  28. if (!empty($values['genotype_id'])) {
  29. $object = tripal_core_generate_chado_var('genotype', $values);
  30. }
  31. else {
  32. $object = array();
  33. }
  34. return $object;
  35. }
  36. /**
  37. * Implements hook_chado_schema_v1_11_table()
  38. * Purpose: To add descriptions and foreign keys to default table description
  39. * Note: This array will be merged with the array from all other implementations
  40. *
  41. * @return
  42. * Array describing the genotype table
  43. *
  44. * @ingroup tripal_schema_api
  45. */
  46. function tripal_genetic_chado_schema_v1_11_genotype() {
  47. $description = array();
  48. $referring_tables = array('analysisfeature',
  49. 'feature_genotype',
  50. 'phendesc',
  51. 'phenotype_comparison',
  52. 'phenstatement',
  53. 'stock_genotype',
  54. );
  55. $description['referring_tables'] = $referring_tables;
  56. return $description;
  57. }
  58. /**
  59. * Implements hook_chado_schema_v1_2_table()
  60. * Purpose: To add descriptions and foreign keys to default table description
  61. * Note: This array will be merged with the array from all other implementations
  62. *
  63. * @return
  64. * Array describing the genotype table
  65. *
  66. * @ingroup tripal_schema_api
  67. */
  68. function tripal_genetic_chado_schema_v1_2_genotype() {
  69. $description = array();
  70. $referring_tables = array('analysisfeature',
  71. 'feature_genotype',
  72. 'phendesc',
  73. 'phenotype_comparison',
  74. 'phenstatement',
  75. 'stock_genotype',
  76. );
  77. $description['referring_tables'] = $referring_tables;
  78. return $description;
  79. }