tripal_genetic.api.inc 2.8 KB

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