OBOImporterTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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->assertNotFalse($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. //
  34. // $exists = db_select('chado.cv', 'c')
  35. // ->fields('c', ['cv_id'])
  36. // ->condition('name', 'core_test_goslim_plant')
  37. // ->execute()
  38. // ->fetchField();
  39. // $this->assertNotFalse($exists);
  40. //
  41. }
  42. private function load_pto_mini() {
  43. $name = 'core_test_PTO_mini';
  44. $path = __DIR__ . '/../example_files/pto_colon.obo';
  45. $obo_id = db_select('public.tripal_cv_obo', 't')
  46. ->fields('t', ['obo_id'])
  47. ->condition('t.name', $name)->execute()->fetchField();
  48. if (!$obo_id) {
  49. $obo_id = db_insert('public.tripal_cv_obo')
  50. ->fields(['name' => $name, 'path' => $path])
  51. ->execute();
  52. }
  53. $run_args = ['obo_id' => $obo_id];
  54. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  55. $importer = new \OBOImporter();
  56. $importer->create($run_args);
  57. $importer->prepareFiles();
  58. $importer->run();
  59. }
  60. private function load_goslim_plant() {
  61. $name = 'core_test_goslim_plant';
  62. $path = 'http://www.geneontology.org/ontology/subsets/goslim_plant.obo';
  63. $obo_id = db_select('public.tripal_cv_obo', 't')
  64. ->fields('t', ['obo_id'])
  65. ->condition('t.name', $name)
  66. ->execute()
  67. ->fetchField();
  68. if (!$obo_id) {
  69. $obo_id = db_insert('public.tripal_cv_obo')
  70. ->fields(['name' => $name, 'path' => $path])
  71. ->execute();
  72. }
  73. $run_args = ['obo_id' => $obo_id];
  74. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  75. $importer = new \OBOImporter();
  76. $importer->create($run_args);
  77. $importer->prepareFiles();
  78. $importer->run();
  79. }
  80. }