OBOImporterTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace Tests;
  3. use StatonLab\TripalTestSuite\DBTransaction;
  4. use StatonLab\TripalTestSuite\TripalTestCase;
  5. class OBOImporterTest extends TripalTestCase {
  6. // Uncomment to auto start and rollback db transactions per test method.
  7. use DBTransaction;
  8. // /**
  9. // * @group obo
  10. // */
  11. // public function test_PTO_loads() {
  12. // $this->load_pto_full();
  13. //
  14. // $exists = db_select('chado.cv', 'c')
  15. // ->fields('c', ['cv_id'])
  16. // ->condition('name', 'plaint_trait_ontology');
  17. // $this->assertNotNull($exists);
  18. //
  19. // }
  20. /**
  21. * @group obo
  22. */
  23. public function testGO_SLIM_loads() {
  24. $this->load_goslim_plant();
  25. $exists = db_select('chado.cv', 'c')
  26. ->fields('c', ['cv_id'])
  27. ->condition('name', 'core_test_goslim_plant')
  28. ->execute()
  29. ->fetchField();
  30. $this->assertNotNull($exists);
  31. }
  32. private function load_pto_full() {
  33. $name = 'core_test_PTO_mini';
  34. $path = 'http://purl.obolibrary.org/obo/to.obo';
  35. $obo_id = db_select('public.tripal_cv_obo', 't')
  36. ->fields('t', ['obo_id'])
  37. ->condition('t.name', $name)->execute()->fetchField();
  38. if (!$obo_id) {
  39. $obo_id = db_insert('public.tripal_cv_obo')
  40. ->fields(['name' => $name, 'path' => $path])
  41. ->execute();
  42. }
  43. $run_args = ['obo_id' => $obo_id];
  44. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  45. $importer = new \OBOImporter();
  46. $importer->create($run_args);
  47. $importer->prepareFiles();
  48. $importer->run();
  49. }
  50. private function load_goslim_plant() {
  51. $name = 'core_test_goslim_plant';
  52. $path = 'http://www.geneontology.org/ontology/subsets/goslim_plant.obo';
  53. $obo_id = db_select('public.tripal_cv_obo', 't')
  54. ->fields('t', ['obo_id'])
  55. ->condition('t.name', $name)
  56. ->execute()
  57. ->fetchField();
  58. if (!$obo_id) {
  59. $obo_id = db_insert('public.tripal_cv_obo')
  60. ->fields(['name' => $name, 'path' => $path])
  61. ->execute();
  62. }
  63. $run_args = ['obo_id' => $obo_id];
  64. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  65. $importer = new \OBOImporter();
  66. $importer->create($run_args);
  67. $importer->prepareFiles();
  68. $importer->run();
  69. }
  70. }