OBOImporterTest.php 22 KB

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