OBOImporterTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. * @ticket 525
  11. */
  12. public function test_PTO_loads() {
  13. $this->load_pto_mini();
  14. $exists = db_select('chado.cv', 'c')
  15. ->fields('c', ['cv_id'])
  16. ->condition('name', 'core_test_PTO_mini');
  17. $this->assertNotNull($exists);
  18. }
  19. /**
  20. * @group obo
  21. */
  22. public function testGO_SLIM_loads() {
  23. $this->load_goslim_plant();
  24. $exists = db_select('chado.cv', 'c')
  25. ->fields('c', ['cv_id'])
  26. ->condition('name', 'core_test_goslim_plant')
  27. ->execute()
  28. ->fetchField();
  29. $this->assertNotNull($exists);
  30. }
  31. private function load_pto_mini() {
  32. $name = 'core_test_PTO_mini';
  33. $path = __DIR__ . '/../example_files/pto_colon.obo';
  34. $obo_id = db_select('public.tripal_cv_obo', 't')
  35. ->fields('t', ['obo_id'])
  36. ->condition('t.name', $name)->execute()->fetchField();
  37. if (!$obo_id) {
  38. $obo_id = db_insert('public.tripal_cv_obo')
  39. ->fields(['name' => $name, 'path' => $path])
  40. ->execute();
  41. }
  42. $run_args = ['obo_id' => $obo_id];
  43. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  44. $importer = new \OBOImporter();
  45. $importer->create($run_args);
  46. $importer->prepareFiles();
  47. $importer->run();
  48. }
  49. private function load_goslim_plant() {
  50. $name = 'core_test_goslim_plant';
  51. $path = 'http://www.geneontology.org/ontology/subsets/goslim_plant.obo';
  52. $obo_id = db_select('public.tripal_cv_obo', 't')
  53. ->fields('t', ['obo_id'])
  54. ->condition('t.name', $name)
  55. ->execute()
  56. ->fetchField();
  57. if (!$obo_id) {
  58. $obo_id = db_insert('public.tripal_cv_obo')
  59. ->fields(['name' => $name, 'path' => $path])
  60. ->execute();
  61. }
  62. $run_args = ['obo_id' => $obo_id];
  63. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  64. $importer = new \OBOImporter();
  65. $importer->create($run_args);
  66. $importer->prepareFiles();
  67. $importer->run();
  68. }
  69. }