OBOImporterTest.php 20 KB

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