tripal_genetic.api.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_genotype_schema()
  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_genotype_schema() {
  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_genotype_schema()
  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_feature_genotype_schema() {
  69. $description = array();
  70. $description['foreign keys']['feature'] = array(
  71. 'table' => 'feature',
  72. 'columns' => array(
  73. 'feature_id' => 'feature_id',
  74. 'chromosome_id' => 'feature_id',
  75. ),
  76. );
  77. $description['foreign keys']['genotype'] = array(
  78. 'table' => 'genotype',
  79. 'columns' => array(
  80. 'genotype_id' => 'genotype_id',
  81. ),
  82. );
  83. $description['foreign keys']['cvterm'] = array(
  84. 'table' => 'cvterm',
  85. 'columns' => array(
  86. 'cvterm_id' => 'cvterm_id',
  87. ),
  88. );
  89. return $description;
  90. }