OBOImporterTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. * A helper function for loading any OBO.
  10. *
  11. * @param $name - ontology name. This goes in the tripal_cv_obo table.
  12. * @param $path - path to the OBO. this can be a file path or a URL.
  13. *
  14. * @throws \Exception
  15. */
  16. private function loadOBO($name, $path) {
  17. $obo_id = db_select('public.tripal_cv_obo', 't')
  18. ->fields('t', ['obo_id'])
  19. ->condition('t.name', $name)
  20. ->execute()
  21. ->fetchField();
  22. if (!$obo_id) {
  23. $obo_id = db_insert('public.tripal_cv_obo')
  24. ->fields(['name' => $name, 'path' => $path])
  25. ->execute();
  26. }
  27. $run_args = ['obo_id' => $obo_id];
  28. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  29. $importer = new \OBOImporter();
  30. $importer->create($run_args);
  31. $importer->prepareFiles();
  32. $importer->run();
  33. }
  34. /**
  35. * Tests that an OBO from a local path can be loaded.
  36. *
  37. * For this test we will use a test ontology.
  38. *
  39. * @group obo
  40. */
  41. public function testLocalOBO() {
  42. $name = 'tripal_obo_test';
  43. $path = __DIR__ . '/../example_files/test.obo';
  44. $this->loadOBO($name, $path);
  45. // Make sure we have a proper vocabulary record.
  46. $tot_cv_id = db_select('chado.cv', 'c')
  47. ->fields('c', ['cv_id'])
  48. ->condition('name', 'tripal_obo_test')
  49. ->execute()
  50. ->fetchField();
  51. $this->assertNotFalse($tot_cv_id,
  52. "Missing the 'tripal_obo_test' cv record after loading the test.obo file");
  53. // Make sure we have a proper database record.
  54. $tot_db_id = db_select('chado.db', 'd')
  55. ->fields('d', ['db_id'])
  56. ->condition('name', 'TOT')
  57. ->execute()
  58. ->fetchField();
  59. $this->assertNotFalse($tot_db_id,
  60. "Missing the 'TOT' db record after loading the test.obo file");
  61. return [[$tot_cv_id, $tot_db_id]];
  62. }
  63. /**
  64. * Test that all nodes in our test OBO are loaded.
  65. *
  66. * @group obo
  67. * @dataProvider testLocalOBO
  68. */
  69. public function testCVterms($cv_id, $db_id) {
  70. // Our test OBO has 14 nodes.
  71. $nodes = [
  72. ['TOT:001' => 'node01'],
  73. ['TOT:002' => 'node02'],
  74. ['TOT:003' => 'node03'],
  75. ['TOT:004' => 'node04'],
  76. ['TOT:005' => 'node05'],
  77. ['TOT:006' => 'node06'],
  78. ['TOT:007' => 'node07'],
  79. ['TOT:008' => 'node08'],
  80. ['TOT:009' => 'node09'],
  81. ['TOT:010' => 'node10'],
  82. ['TOT:011' => 'node11'],
  83. ['TOT:012' => 'node12'],
  84. ['TOT:013' => 'node13'],
  85. ['TOT:014' => 'node14'],
  86. ];
  87. // Test that the proper records were added to identify the term.
  88. foreach ($nodes as $id => $node_name) {
  89. // Check that cvterm record is inserted.
  90. $cvterm_id = db_select('chado.cvterm', 'cvt')
  91. ->fields('cvt', ['cvterm_id'])
  92. ->condition('cvt.name', $node_name)
  93. ->condition('cvt.cv_id', $cv_id)
  94. ->execute()
  95. ->fetchField();
  96. $this->assertNotFalse($cvterm_id,
  97. "Missing the cvterm record with name, '$node' after loading the test.obo file");
  98. // Check that the dbxref record is inserted.
  99. $accession = preg_replace('/TOT:/', '', $id);
  100. $dbxref_id = db_select('chado.dbxref', 'dbx')
  101. ->fields('dbx', ['dbxref_id'])
  102. ->condition('accession', $accession)
  103. ->condition('db_id', $db_id);
  104. $this->assertNotFalse($cvterm_id,
  105. "Missing the dbxref record forid, '$id' after loading the test.obo file");
  106. }
  107. // Test node 11 to make sure the definition was inserted correctly.
  108. // The definition for node11 has an extra colon and a comment. The colon
  109. // should not throw off the insertion of the full definition and
  110. // the comment should be excluded.
  111. $def = db_select('chado.cvterm', 'cvt')
  112. ->fields('cvt', ['definition'])
  113. ->condition('cvt.name', 'node11')
  114. ->condition('cvt.cv_id', $cv_id)
  115. ->execute()
  116. ->fetchField();
  117. $this->assertNotFalse($def,
  118. "The definition for node11 was not added.");
  119. $this->assertEquals('This is node 11 : Yo', $def,
  120. "The definition for node11 is incorrect. it was stored as \"$def\" but should be \"def: This is node 11 : Yo\".");
  121. // Make sure that colons in term names don't screw up the term. This test
  122. // corresponds to the term with id CHEBI:132502 in the test.obo file.
  123. $exists = db_select('chado.cv', 'c')
  124. ->fields('c', ['cv_id'])
  125. ->condition('name', 'fatty acid 18')
  126. ->execute()
  127. ->fetchField();
  128. $this->assertFalse($exists);
  129. // Node14 should be marked as obsolete.
  130. $sql = "
  131. SELECT CVT.is_obsolete
  132. FROM {cvterm} CVT
  133. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  134. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  135. WHERE DB.name = 'TOT' and DBX.accession = '014'
  136. ";
  137. $is_obsolete = chado_query($sql)->fetchField();
  138. $this->assertEquals(1, $is_obsolete,
  139. "The term, node14, should be marked as obsolete after loading of the test.obo file.");
  140. // Every vocabulary should have an is_a term added to support the is_a
  141. // relationships.
  142. $sql = "
  143. SELECT CVT.is_relationshiptype
  144. FROM {cvterm} CVT
  145. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  146. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  147. WHERE CVT.name = 'is_a' and DB.name = 'TOT'
  148. ";
  149. $is_reltype = chado_query($sql)->fetchField();
  150. $this->assertNotFalse($is_reltype,
  151. "The cvterm record for, is_a, should have been added during loading of the test.obo file.");
  152. $this->assertEquals(1, $is_reltype,
  153. "The cvterm record, is_a, should be marked as a relationship type.");
  154. }
  155. /**
  156. * Test that insertion of synonyms works.
  157. *
  158. * The term 'node11' has a synonym:"crazy node" EXACT []
  159. *
  160. * @group obo
  161. * @dataProvider testLocalOBO
  162. */
  163. public function testSynonyms($cv_id, $db_id) {
  164. $query = db_select('chado.cvtermsynonym', 'cvts');
  165. $query->fields('cvts', ['synonym']);
  166. $query->join('chado.cvterm', 'cvt', 'cvts.cvterm_id = cvt.cvterm_id');
  167. $query->condition('cvt.name', 'node11');
  168. $synonym = $query->execute()->fetchField();
  169. $this->assertNotFalse($synonym,
  170. "Failed to find the 'crazy node' synonym record for node 11 after loading the test.obo file.");
  171. $this->assertEquals("crazy node", $synonym,
  172. "Failed to properly add the 'crazy node' synonym for node 11 instead the following was loaded: $synonym");
  173. }
  174. /**
  175. * Test that insertion of subset works.
  176. *
  177. * The term 'node11' belongs to the test_crazy subset. Everything else belongs
  178. * to the test_normal subset.
  179. *
  180. *
  181. * @group obo
  182. * @dataProvider testLocalOBO
  183. */
  184. public function testSubset($cv_id, $db_id) {
  185. $sql = "
  186. SELECT CVT.name
  187. FROM {cvtermprop} CVTP
  188. INNER JOIN {cvterm} CVTPT on CVTPT.cvterm_id = CVTP.type_id
  189. INNER JOIN {cvterm} CVT on CVT.cvterm_id = CVTP.cvterm_id
  190. INNER JOIN {dbxref} DBX on CVT.dbxref_id = DBX.dbxref_id
  191. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  192. WHERE CVTPT.name = 'Subgroup' and DB.name = 'TOT' and CVTP.value = 'test_crazy'
  193. ";
  194. $term_name = chado_query($sql)->fetchField();
  195. $this->assertNotFalse($term_name,
  196. "This cvtermprop record for the subset 'test_crazy' is missing.");
  197. $this->assertEquals('node11', $term_name,
  198. "This cvtermprop record for the subset 'test_crazy' is assigned to term, $term_name, instead of node11.");
  199. $sql = "
  200. SELECT count(CVT.cvterm_id)
  201. FROM {cvtermprop} CVTP
  202. INNER JOIN {cvterm} CVTPT on CVTPT.cvterm_id = CVTP.type_id
  203. INNER JOIN {cvterm} CVT on CVT.cvterm_id = CVTP.cvterm_id
  204. INNER JOIN {dbxref} DBX on CVT.dbxref_id = DBX.dbxref_id
  205. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  206. WHERE CVTPT.name = 'Subgroup' and DB.name = 'TOT' and CVTP.value = 'test_normal'
  207. ";
  208. $subset_count = chado_query($sql)->fetchField();
  209. $this->assertNotFalse($subset_count,
  210. "This cvtermprop record for the subset 'test_normal' are missing.");
  211. // There should be 12 terms that belong to subset 'test_normal' as node14
  212. // does not belong to a subset.
  213. $this->assertEquals(12, $subset_count,
  214. "There are $subset_count cvtermprop record for the subset 'test_normal' but there should be 13.");
  215. }
  216. /**
  217. * Test that the insertion of xref works.
  218. *
  219. * The term 'node11' belongs to the test_crazy subset. Everything else belongs
  220. * to the test_normal subset.
  221. *
  222. *
  223. * @group obo
  224. * @dataProvider testLocalOBO
  225. */
  226. public function testXref($cv_id, $db_id) {
  227. $sql = "
  228. SELECT concat(DB2.name, ':', DBX2.accession)
  229. FROM {cvterm} CVT
  230. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  231. INNER JOIN {db} on DB.db_id = DBX.db_id
  232. INNER JOIN {cvterm_dbxref} CVTDBX on CVTDBX.cvterm_id = CVT.cvterm_id
  233. INNER JOIN {dbxref} DBX2 on DBX2.dbxref_id = CVTDBX.dbxref_id
  234. INNER JOIN {db} DB2 on DB2.db_id = DBX2.db_id
  235. WHERE DB.name = 'TOT' and CVT.name = 'node11'
  236. ORDER BY DBX.accession
  237. ";
  238. $xref_id = chado_query($sql)->fetchField();
  239. $this->assertNotFalse($xref_id,
  240. "This cvterm_dbxref record for the xref 'GO:0043226' is missing for node11.");
  241. $this->assertEquals('GO:0043226', $xref_id,
  242. "This cvterm_dbxref record for node 11 is, $xref_id, instead of GO:0043226.");
  243. }
  244. /**
  245. * Test that the insertion of comments works.
  246. *
  247. * The term 'node11' contains a comment.
  248. *
  249. * @group obo
  250. * @dataProvider testLocalOBO
  251. */
  252. public function testComment($cv_id, $db_id) {
  253. $sql = "
  254. SELECT CVTP.value
  255. FROM {cvterm} CVT
  256. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  257. INNER JOIN {db} on DB.db_id = DBX.db_id
  258. INNER JOIN {cvtermprop} CVTP on CVTP.cvterm_id = CVT.cvterm_id
  259. INNER JOIN {cvterm} CVTPT on CVTPT.cvterm_id = CVTP.type_id
  260. WHERE DB.name = 'TOT' and CVTPT.name = 'comment' and CVT.name = 'node11'
  261. ORDER BY DBX.accession
  262. ";
  263. $comment = chado_query($sql)->fetchField();
  264. $this->assertNotFalse($xref_id,
  265. "This cvterm_dbxref record for the xref 'This is a crazy node' is missing for node11.");
  266. $this->assertEquals('This is a crazy node', $comment,
  267. "This cvterm_dbxref record for node11 is, \"$comment\", instead of \"This is a crazy node\".");
  268. }
  269. /**
  270. * Tests that the cvtermpath is properly loaded.
  271. *
  272. * @group obo
  273. * @dataProvider testLocalOBO
  274. */
  275. public function testRelationships($cv_id, $db_id) {
  276. $relationships = [
  277. ['node02', 'is_a', 'node01'],
  278. ['node03', 'is_a', 'node01'],
  279. ['node04', 'is_a', 'node01'],
  280. ['node04', 'has_part', 'node11'],
  281. ['node05', 'is_a', 'node01'],
  282. ['node06', 'is_a', 'node03'],
  283. ['node07', 'is_a', 'node03'],
  284. ['node08', 'is_a', 'node07'],
  285. ['node09', 'is_a', 'node04'],
  286. ['node09', 'is_a', 'node07'],
  287. ['node10', 'is_a', 'node05'],
  288. ['node11', 'is_a', 'node09'],
  289. ['node11', 'is_a', 'node10'],
  290. ['node12', 'is_a', 'node10'],
  291. ['node13', 'is_a', 'node11'],
  292. ];
  293. foreach ($relationships as $relationship) {
  294. $subject = $relationship[0];
  295. $type = $relationship[1];
  296. $object = $relationship[2];
  297. $sql = "
  298. SELECT CVTR.cvterm_relationship_id
  299. FROM {cvterm} CVT
  300. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  301. INNER JOIN {db} on DB.db_id = DBX.db_id
  302. INNER JOIN {cvterm_relationship} CVTR on CVTR.subject_id = CVT.cvterm_id
  303. INNER JOIN {cvterm} CVT2 on CVT2.cvterm_id = CVTR.object_id
  304. INNER JOIN {cvterm} CVT3 on CVT3.cvterm_id = CVTR.type_id
  305. WHERE DB.name = 'TOT' AND CVT2.name = :object AND
  306. CVT3.name = :type AND CVT.name = :subject
  307. ";
  308. $args = [':object' => $object, ':type' => $type, ':subject' => $subject];
  309. $rel_id = chado_query($sql, $args)->fetchField();
  310. $this->assertNotFalse($rel_id,
  311. "The following relationship could not be found: $subect $type $object.");
  312. }
  313. // Now make sure we have no more relationships than what we are supposed
  314. // to have.
  315. $sql = "
  316. SELECT count(CVTR.cvterm_relationship_id)
  317. FROM {cvterm} CVT
  318. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  319. INNER JOIN {db} on DB.db_id = DBX.db_id
  320. INNER JOIN {cvterm_relationship} CVTR on CVTR.object_id = CVT.cvterm_id
  321. WHERE DB.name = 'TOT' AND CVT.is_relationshiptype = 0
  322. ";
  323. $rel_count = chado_query($sql)->fetchField();
  324. $expected = count($relationships);
  325. $this->assertEquals($expected, $rel_count,
  326. "There are an incorrect number of relationships. There were $rel_count found but there should be $expected.");
  327. }
  328. /**
  329. * Tests that the cvtermpath is properly loaded.
  330. *
  331. * @group obo
  332. * @dataProvider testLocalOBO
  333. */
  334. public function testCVtermPath($cv_id, $db_id) {
  335. // For now we won't include distance or type in the check because depending
  336. // how the tree was loaded and if there are multiple paths to a node
  337. // then there's no guarantee we'll always get the same path. Therefore the
  338. // type and pathdistance may be different (althoug not incorrect).
  339. $relationships = [
  340. // Node01 as root: note that the root term always has a link to itself
  341. // in the cvtermpath table.
  342. ['node01', 'node01'],
  343. ['node01', 'node02'],
  344. ['node01', 'node03'],
  345. ['node01', 'node04'],
  346. ['node01', 'node05'],
  347. ['node01', 'node06'],
  348. ['node01', 'node07'],
  349. ['node01', 'node08'],
  350. ['node01', 'node09'],
  351. ['node01', 'node10'],
  352. ['node01', 'node11'],
  353. ['node01', 'node12'],
  354. ['node01', 'node13'],
  355. // Node03 as root.
  356. ['node03', 'node04'],
  357. ['node03', 'node06'],
  358. ['node03', 'node07'],
  359. ['node03', 'node08'],
  360. ['node03', 'node09'],
  361. ['node03', 'node11'],
  362. ['node03', 'node13'],
  363. // Node04 as root.
  364. ['node04', 'node09'],
  365. ['node04', 'node11'],
  366. ['node04', 'node13'],
  367. // Node05 as root.
  368. ['node05', 'node04'],
  369. ['node05', 'node09'],
  370. ['node05', 'node10'],
  371. ['node05', 'node11'],
  372. ['node05', 'node12'],
  373. ['node05', 'node13'],
  374. // Node07 as root.
  375. ['node07', 'node04'],
  376. ['node07', 'node08'],
  377. ['node07', 'node09'],
  378. ['node07', 'node11'],
  379. ['node07', 'node13'],
  380. // Node09 as root.
  381. ['node09', 'node04'],
  382. ['node09', 'node11'],
  383. ['node09', 'node13'],
  384. // Node10 as root.
  385. ['node10', 'node04'],
  386. ['node10', 'node09'],
  387. ['node10', 'node11'],
  388. ['node10', 'node12'],
  389. ['node10', 'node13'],
  390. // Node11 as root.
  391. ['node11', 'node04'],
  392. ['node11', 'node09'],
  393. ['node11', 'node13'],
  394. ];
  395. // Populate the cvtermpath for our test OBO.
  396. chado_update_cvtermpath($cv_id);
  397. foreach ($relationships as $relationship) {
  398. $object = $relationship[0];
  399. $subject = $relationship[1];
  400. $sql = "
  401. SELECT cvtermpath_id
  402. FROM {cvtermpath} CVTP
  403. INNER JOIN {cvterm} CVTO on CVTO.cvterm_id = CVTP.object_id
  404. INNER JOIN {cvterm} CVTS on CVTS.cvterm_id = CVTP.subject_id
  405. INNER JOIN {cvterm} CVTT on CVTT.cvterm_id = CVTP.type_id
  406. WHERE CVTP.cv_id = :cv_id and CVTO.name = :object and
  407. CVTS.name = :subject
  408. ";
  409. $args = [
  410. ':cv_id' => $cv_id,
  411. ':object' => $object,
  412. ':subject' => $subject,
  413. ];
  414. $cvtermpath_id = chado_query($sql, $args)->fetchField();
  415. $this->assertNotFalse($cvtermpath_id,
  416. "Cound not find the cvtermpath record for the relationship: $subject => $object.");
  417. }
  418. // Now make sure we have no additional entries.
  419. $sql = "
  420. SELECT count(cvtermpath_id)
  421. FROM {cvtermpath} CVTP
  422. INNER JOIN {cvterm} CVTO on CVTO.cvterm_id = CVTP.object_id
  423. INNER JOIN {cvterm} CVTS on CVTS.cvterm_id = CVTP.subject_id
  424. INNER JOIN {cvterm} CVTT on CVTT.cvterm_id = CVTP.type_id
  425. WHERE CVTP.cv_id = :cv_id
  426. ";
  427. $args = [':cv_id' => $cv_id];
  428. $rel_count = chado_query($sql, $args)->fetchField();
  429. $expected = count($relationships);
  430. $this->assertEquals($expected, $rel_count,
  431. "There are an incorrect number of paths. There were $rel_count found but there should be $expected.");
  432. }
  433. /**
  434. * Tests that the EBI Lookup is properly working.
  435. *
  436. * The term CHEBI:132502 should have been loaded via EBI.
  437. *
  438. * @group obo
  439. * @dataProvider testLocalOBO
  440. */
  441. public function testEBILookup($cv_id, $db_id) {
  442. $sql = "
  443. SELECT CVT.cvterm_id
  444. FROM {cvterm} CVT
  445. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  446. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  447. WHERE DB.name = 'CHEBI' and DBX.accession = '132502'
  448. ";
  449. $cvterm_id = chado_query($sql)->fetchField();
  450. $this->assertNotFalse($cvterm_id,
  451. "The term, CHEBI:132502, is not present the EBI OLS lookup must not have succeeded.");
  452. }
  453. /**
  454. * Tests when changes are made between OBO loads.
  455. *
  456. * Sometimes an ontology can change the names of it's terms, or set some
  457. * as obsolete, etc. We need to makes sure that when changes are made and
  458. * the OBO is reloaded that the terms are properly update.
  459. *
  460. * @group obo
  461. * @dataProvider testLocalOBO
  462. */
  463. public function testOBOChanges($cv_id, $db_id) {
  464. $name = 'tripal_obo_test_update';
  465. $path = __DIR__ . '/../example_files/test.update.obo';
  466. $this->loadOBO($name, $path);
  467. // Did the name of term 13 change?
  468. $sql = "
  469. SELECT CVT.name
  470. FROM {cvterm} CVT
  471. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  472. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  473. WHERE DB.name = 'TOT' and DBX.accession = '013'
  474. ";
  475. $name = chado_query($sql)->fetchField();
  476. $this->assertEquals('New name 13.', $name,
  477. "The name for node13 (TOT:013) failed to update to 'New name 13'.");
  478. // Node15 is new, and node02 got removed. Node15 now uses node02's name and
  479. // has TOT:002 as an alt_id. So, node02 should be marked as obsolete
  480. $sql = "
  481. SELECT CVT.is_obsolete
  482. FROM {cvterm} CVT
  483. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  484. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  485. WHERE DB.name = 'TOT' and DBX.accession = '002'
  486. ";
  487. $is_obsolete = chado_query($sql)->fetchField();
  488. $this->assertEquals(1, $is_obsolete,
  489. "The node02 (TOT:002) should be marked as obsolete after update.");
  490. // Node16 is new, and node08 is now obsolete. Node16 now uses node08's name,
  491. // so, node08 should be marked as obsolete and have the word '(obsolete)'
  492. // added to prevent future conflicts.
  493. $sql = "
  494. SELECT CVT.name
  495. FROM {cvterm} CVT
  496. INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
  497. INNER JOIN {db} DB on DB.db_id = DBX.db_id
  498. WHERE DB.name = 'TOT' and DBX.accession = '008'
  499. ";
  500. $name = chado_query($sql)->fetchField();
  501. $this->assertEquals("node08 (obsolete)", $name,
  502. "The node08 (TOT:008) should be marked as obsolete after update.");
  503. }
  504. /**
  505. * @group obo
  506. * @group chado
  507. */
  508. public function testfindEBITerm_finder_retrieves_term() {
  509. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
  510. $importer_private = new \OBOImporter();
  511. $importer = reflect($importer_private);
  512. $id = 'PECO:0007085';
  513. $result = $importer->findEBITerm($id);
  514. $this->assertNotEmpty($result);
  515. $this->assertEquals('fertilizer exposure', $result['name'][0]);
  516. }
  517. }