tripal_genetic.api.inc 2.3 KB

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