OBOImporterTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_colon_issue() {
  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. ->execute()
  18. ->fetchField();
  19. $this->assertNotNull($exists);
  20. //hte colon splitting issue: a new CV will created named fatty acid 18
  21. $exists = db_select('chado.cv', 'c')
  22. ->fields('c', ['cv_id'])
  23. ->condition('name', 'fatty acid 18')
  24. ->execute()
  25. ->fetchField();
  26. $this->assertFalse($exists);
  27. }
  28. /**
  29. * @group obo
  30. */
  31. public function testGO_SLIM_load() {
  32. $this->load_goslim_plant();
  33. $exists = db_select('chado.cv', 'c')
  34. ->fields('c', ['cv_id'])
  35. ->condition('name', 'core_test_goslim_plant')
  36. ->execute()
  37. ->fetchField();
  38. $this->assertNotNull($exists);
  39. }
  40. private function load_pto_mini() {
  41. $name = 'core_test_PTO_mini';
  42. $path = __DIR__ . '/../example_files/pto_colon.obo';
  43. $obo_id = db_select('public.tripal_cv_obo', 't')
  44. ->fields('t', ['obo_id'])
  45. ->condition('t.name', $name)->execute()->fetchField();
  46. if (!$obo_id) {
  47. $obo_id = db_insert('public.tripal_cv_obo')
  48. ->fields(['name' => $name, 'path' => $path])
  49. ->execute();
  50. }
  51. $run_args = ['obo_id' => $obo_id];
  52. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  53. $importer = new \OBOImporter();
  54. $importer->create($run_args);
  55. $importer->prepareFiles();
  56. $importer->run();
  57. }
  58. private function load_goslim_plant() {
  59. $name = 'core_test_goslim_plant';
  60. $path = 'http://www.geneontology.org/ontology/subsets/goslim_plant.obo';
  61. $obo_id = db_select('public.tripal_cv_obo', 't')
  62. ->fields('t', ['obo_id'])
  63. ->condition('t.name', $name)
  64. ->execute()
  65. ->fetchField();
  66. if (!$obo_id) {
  67. $obo_id = db_insert('public.tripal_cv_obo')
  68. ->fields(['name' => $name, 'path' => $path])
  69. ->execute();
  70. }
  71. $run_args = ['obo_id' => $obo_id];
  72. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  73. $importer = new \OBOImporter();
  74. $importer->create($run_args);
  75. $importer->prepareFiles();
  76. $importer->run();
  77. }
  78. }