GFF3ImporterTest.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. <?php
  2. namespace Tests;
  3. use StatonLab\TripalTestSuite\DBTransaction;
  4. use StatonLab\TripalTestSuite\TripalTestCase;
  5. class GFF3ImporterTest extends TripalTestCase {
  6. use DBTransaction;
  7. /**
  8. * Confirm basic GFF importer functionality.
  9. *
  10. * @group gff
  11. */
  12. public function testGFFImporter() {
  13. $gff_file = ['file_local' => __DIR__ . '/../data/small_gene.gff'];
  14. $fasta = ['file_local' => __DIR__ . '/../data/short_scaffold.fasta'];
  15. $analysis = factory('chado.analysis')->create();
  16. $organism = factory('chado.organism')->create();
  17. $run_args = [
  18. 'analysis_id' => $analysis->analysis_id,
  19. 'organism_id' => $organism->organism_id,
  20. 'use_transaction' => 1,
  21. 'add_only' => 0,
  22. 'update' => 1,
  23. 'create_organism' => 0,
  24. 'create_target' => 0,
  25. // regexps for mRNA and protein.
  26. 're_mrna' => NULL,
  27. 're_protein' => NULL,
  28. // optional
  29. 'target_organism_id' => NULL,
  30. 'target_type' => NULL,
  31. 'start_line' => NULL,
  32. 'landmark_type' => NULL,
  33. 'alt_id_attr' => NULL,
  34. ];
  35. $this->loadLandmarks($analysis, $organism, $fasta);
  36. $this->runGFFLoader($run_args, $gff_file);
  37. // This protein is an explicit protein / polypeptide imported from the GFF
  38. // file.
  39. $name = 'test_protein_001.1';
  40. $query = db_select('chado.feature', 'f')
  41. ->fields('f', ['uniquename'])
  42. ->condition('f.uniquename', $name)
  43. ->execute()
  44. ->fetchField();
  45. $this->assertEquals($name, $query);
  46. }
  47. /**
  48. * Run the GFF loader on gff_tag_unescaped_character.gff for testing.
  49. *
  50. * This tests whether the GFF loader adds IDs that contain a comma.
  51. * The GFF loader should allow it
  52. */
  53. public function testGFFImporterUnescapedTagWithComma() {
  54. $gff_file = ['file_local' => __DIR__ . '/../data/gff_tag_unescaped_character.gff'];
  55. $analysis = factory('chado.analysis')->create();
  56. $organism = factory('chado.organism')->create();
  57. $run_args = [
  58. 'analysis_id' => $analysis->analysis_id,
  59. 'organism_id' => $organism->organism_id,
  60. 'use_transaction' => 1,
  61. 'add_only' => 0,
  62. 'update' => 1,
  63. 'create_organism' => 0,
  64. 'create_target' => 0,
  65. // regexps for mRNA and protein.
  66. 're_mrna' => NULL,
  67. 're_protein' => NULL,
  68. // optional
  69. 'target_organism_id' => NULL,
  70. 'target_type' => NULL,
  71. 'start_line' => NULL,
  72. 'landmark_type' => NULL,
  73. 'alt_id_attr' => NULL,
  74. ];
  75. $this->loadLandmarks($analysis, $organism);
  76. // This should throw an error based on the tag name having the comma
  77. $hasException = false;
  78. try {
  79. $this->runGFFLoader($run_args, $gff_file);
  80. }
  81. catch (\Exception $ex) {
  82. $hasException = true;
  83. }
  84. $this->assertEquals($hasException, true);
  85. }
  86. /**
  87. * Run the GFF loader on gff_tagvalue_unescaped_character.gff for testing.
  88. *
  89. * This tests whether the GFF loader adds IDs that contain a comma.
  90. * The GFF loader should allow it
  91. */
  92. public function testGFFImporterEscapedTagValueWithEncodedCharacter() {
  93. $gff_file = ['file_local' => __DIR__ . '/../data/gff_tagvalue_encoded_character.gff'];
  94. $analysis = factory('chado.analysis')->create();
  95. $organism = factory('chado.organism')->create();
  96. $run_args = [
  97. 'analysis_id' => $analysis->analysis_id,
  98. 'organism_id' => $organism->organism_id,
  99. 'use_transaction' => 1,
  100. 'add_only' => 0,
  101. 'update' => 1,
  102. 'create_organism' => 0,
  103. 'create_target' => 0,
  104. // regexps for mRNA and protein.
  105. 're_mrna' => NULL,
  106. 're_protein' => NULL,
  107. // optional
  108. 'target_organism_id' => NULL,
  109. 'target_type' => NULL,
  110. 'start_line' => NULL,
  111. 'landmark_type' => NULL,
  112. 'alt_id_attr' => NULL,
  113. ];
  114. $this->loadLandmarks($analysis, $organism);
  115. $this->runGFFLoader($run_args, $gff_file);
  116. $results = db_query("SELECT * FROM chado.feature
  117. WHERE uniquename = 'FRAEX38873_v2_000000010,20';",array());
  118. $this->assertEquals($results->rowCount(), 1);
  119. }
  120. /**
  121. * Run the GFF loader on gff_tagvalue_unescaped_character.gff for testing.
  122. *
  123. * This tests whether the GFF loader adds IDs that contain a comma.
  124. * The GFF loader should allow it
  125. */
  126. public function testGFFImporterUnescapedTagValueWithComma() {
  127. $gff_file = ['file_local' => __DIR__ . '/../data/gff_tagvalue_unescaped_character.gff'];
  128. $analysis = factory('chado.analysis')->create();
  129. $organism = factory('chado.organism')->create();
  130. $run_args = [
  131. 'analysis_id' => $analysis->analysis_id,
  132. 'organism_id' => $organism->organism_id,
  133. 'use_transaction' => 1,
  134. 'add_only' => 0,
  135. 'update' => 1,
  136. 'create_organism' => 0,
  137. 'create_target' => 0,
  138. // regexps for mRNA and protein.
  139. 're_mrna' => NULL,
  140. 're_protein' => NULL,
  141. // optional
  142. 'target_organism_id' => NULL,
  143. 'target_type' => NULL,
  144. 'start_line' => NULL,
  145. 'landmark_type' => NULL,
  146. 'alt_id_attr' => NULL,
  147. ];
  148. $this->loadLandmarks($analysis, $organism);
  149. // This should throw an error based on the tag name having the comma
  150. $hasException = false;
  151. try {
  152. $this->runGFFLoader($run_args, $gff_file);
  153. }
  154. catch (\Exception $ex) {
  155. $hasException = true;
  156. }
  157. $this->assertEquals($hasException, true);
  158. }
  159. /**
  160. * Run the GFF loader on gff_seqid_invalid_character.gff for testing.
  161. * Seqids seem to also be called landmarks within GFF loader.
  162. * This tests whether the GFF loader has any issues with characters like
  163. * single quotes.
  164. */
  165. public function testGFFImporterSeqidWithInvalidCharacter() {
  166. $gff_file = ['file_local' =>
  167. __DIR__ . '/../data/gff_seqid_invalid_character.gff'];
  168. $analysis = factory('chado.analysis')->create();
  169. $organism = factory('chado.organism')->create();
  170. $run_args = [
  171. 'analysis_id' => $analysis->analysis_id,
  172. 'organism_id' => $organism->organism_id,
  173. 'use_transaction' => 1,
  174. 'add_only' => 0,
  175. 'update' => 1,
  176. 'create_organism' => 0,
  177. 'create_target' => 0,
  178. // regexps for mRNA and protein.
  179. 're_mrna' => NULL,
  180. 're_protein' => NULL,
  181. // optional
  182. 'target_organism_id' => NULL,
  183. 'target_type' => NULL,
  184. 'start_line' => NULL,
  185. 'landmark_type' => NULL,
  186. 'alt_id_attr' => NULL,
  187. ];
  188. $this->loadLandmarks($analysis, $organism);
  189. // This will produce an exception due to quote character in Seqid
  190. $hasException = false;
  191. try {
  192. $this->runGFFLoader($run_args, $gff_file);
  193. }
  194. catch (\Exception $ex) {
  195. $hasException = true;
  196. }
  197. $this->assertEquals($hasException, true);
  198. }
  199. /**
  200. * Run the GFF loader on gff_unescaped_ids.gff for testing.
  201. *
  202. * This tests whether the GFF loader adds IDs that contain whitespaces.
  203. * The GFF loader should allow it
  204. */
  205. public function testGFFImporterUnescapedWhitespaceID() {
  206. $gff_file = ['file_local' => __DIR__ . '/../data/gff_unescaped_ids.gff'];
  207. $analysis = factory('chado.analysis')->create();
  208. $organism = factory('chado.organism')->create();
  209. $run_args = [
  210. 'analysis_id' => $analysis->analysis_id,
  211. 'organism_id' => $organism->organism_id,
  212. 'use_transaction' => 1,
  213. 'add_only' => 0,
  214. 'update' => 1,
  215. 'create_organism' => 0,
  216. 'create_target' => 0,
  217. // regexps for mRNA and protein.
  218. 're_mrna' => NULL,
  219. 're_protein' => NULL,
  220. // optional
  221. 'target_organism_id' => NULL,
  222. 'target_type' => NULL,
  223. 'start_line' => NULL,
  224. 'landmark_type' => NULL,
  225. 'alt_id_attr' => NULL,
  226. ];
  227. $this->loadLandmarks($analysis, $organism);
  228. // This should go through just fine
  229. $this->runGFFLoader($run_args, $gff_file);
  230. $results = db_query("SELECT * FROM chado.feature WHERE uniquename =
  231. 'FRAEX38873_v2_000000010 SPACED';");
  232. $this->assertEquals($results->rowCount(), 1);
  233. }
  234. /**
  235. * Run the GFF loader on gff_rightarrow_ids.gff for testing.
  236. *
  237. * This tests whether the GFF loader fails if ID contains
  238. * arrow >. It should not fail.
  239. */
  240. public function testGFFImporterRightArrowID() {
  241. $gff_file = ['file_local' => __DIR__ . '/../data/gff_rightarrow_id.gff'];
  242. $analysis = factory('chado.analysis')->create();
  243. $organism = factory('chado.organism')->create();
  244. $run_args = [
  245. 'analysis_id' => $analysis->analysis_id,
  246. 'organism_id' => $organism->organism_id,
  247. 'use_transaction' => 1,
  248. 'add_only' => 0,
  249. 'update' => 1,
  250. 'create_organism' => 0,
  251. 'create_target' => 0,
  252. // regexps for mRNA and protein.
  253. 're_mrna' => NULL,
  254. 're_protein' => NULL,
  255. // optional
  256. 'target_organism_id' => NULL,
  257. 'target_type' => NULL,
  258. 'start_line' => NULL,
  259. 'landmark_type' => NULL,
  260. 'alt_id_attr' => NULL,
  261. ];
  262. $this->loadLandmarks($analysis, $organism);
  263. // This will produce an exception due to right arrow in ID
  264. $this->runGFFLoader($run_args, $gff_file);
  265. $results = db_query("SELECT * FROM chado.feature
  266. WHERE uniquename = '>FRAEX38873_v2_000000010';");
  267. // We expect this record to get inserted.
  268. $this->assertEquals($results->rowCount(), 1);
  269. }
  270. /**
  271. * Run the GFF loader on gff_duplicate_ids.gff for testing.
  272. *
  273. * This tests whether the GFF loader detects duplicate IDs which makes a
  274. * GFF file invalid since IDs should be unique. The GFF loader should throw
  275. * and exception which this test checks for
  276. */
  277. public function testGFFImporterDuplicateIDsExceptionCheck() {
  278. $gff_file = ['file_local' => __DIR__ . '/../data/gff_duplicate_ids.gff'];
  279. $analysis = factory('chado.analysis')->create();
  280. $organism = factory('chado.organism')->create();
  281. $run_args = [
  282. 'analysis_id' => $analysis->analysis_id,
  283. 'organism_id' => $organism->organism_id,
  284. 'use_transaction' => 1,
  285. 'add_only' => 0,
  286. 'update' => 1,
  287. 'create_organism' => 0,
  288. 'create_target' => 0,
  289. // regexps for mRNA and protein.
  290. 're_mrna' => NULL,
  291. 're_protein' => NULL,
  292. // optional
  293. 'target_organism_id' => NULL,
  294. 'target_type' => NULL,
  295. 'start_line' => NULL,
  296. 'landmark_type' => NULL,
  297. 'alt_id_attr' => NULL,
  298. ];
  299. $hasException = false;
  300. try {
  301. $this->loadLandmarks($analysis, $organism);
  302. // This will produce an exception of duplicate feature ID
  303. $this->runGFFLoader($run_args, $gff_file);
  304. }
  305. catch(\Exception $ex) {
  306. $hasException = true;
  307. }
  308. // We expect an exception to happen so we are looking for a return of true
  309. $this->assertEquals($hasException, true);
  310. }
  311. /**
  312. * Run the GFF loader on gff_invalidstartend.gff for testing.
  313. *
  314. * This tests whether the GFF loader fixes start end values
  315. */
  316. public function testGFFImporterInvalidStartEnd() {
  317. $gff_file = ['file_local' => __DIR__ . '/../data/gff_invalidstartend.gff'];
  318. $analysis = factory('chado.analysis')->create();
  319. $organism = factory('chado.organism')->create();
  320. $run_args = [
  321. 'analysis_id' => $analysis->analysis_id,
  322. 'organism_id' => $organism->organism_id,
  323. 'use_transaction' => 1,
  324. 'add_only' => 0,
  325. 'update' => 1,
  326. 'create_organism' => 0,
  327. 'create_target' => 0,
  328. // regexps for mRNA and protein.
  329. 're_mrna' => NULL,
  330. 're_protein' => NULL,
  331. // optional
  332. 'target_organism_id' => NULL,
  333. 'target_type' => NULL,
  334. 'start_line' => NULL,
  335. 'landmark_type' => NULL,
  336. 'alt_id_attr' => NULL,
  337. ];
  338. $this->loadLandmarks($analysis, $organism);
  339. // This will produce an exception of duplicate feature ID
  340. $this->runGFFLoader($run_args, $gff_file);
  341. $results = db_select('chado.feature', 'f')
  342. ->fields('f', ['uniquename'])
  343. ->condition('f.uniquename', 'FRAEX38873_v2_000000010')
  344. ->execute()
  345. ->fetchAll();
  346. // We expect the feature to still be added to the database
  347. // since the GFF Loader caters for reversing backward numbers
  348. $this->assertEquals(count($results), 1);
  349. }
  350. /**
  351. * Run the GFF loader on gff_score.gff for testing.
  352. *
  353. * This tests whether the GFF loader interprets the score values
  354. */
  355. public function testGFFImporterScoreTest() {
  356. $gff_file = ['file_local' => __DIR__ . '/../data/gff_score.gff'];
  357. $analysis = factory('chado.analysis')->create();
  358. $organism = factory('chado.organism')->create();
  359. $run_args = [
  360. 'analysis_id' => $analysis->analysis_id,
  361. 'organism_id' => $organism->organism_id,
  362. 'use_transaction' => 1,
  363. 'add_only' => 0,
  364. 'update' => 1,
  365. 'create_organism' => 0,
  366. 'create_target' => 0,
  367. // regexps for mRNA and protein.
  368. 're_mrna' => NULL,
  369. 're_protein' => NULL,
  370. // optional
  371. 'target_organism_id' => NULL,
  372. 'target_type' => NULL,
  373. 'start_line' => NULL,
  374. 'landmark_type' => NULL,
  375. 'alt_id_attr' => NULL,
  376. ];
  377. $this->loadLandmarks($analysis, $organism);
  378. $this->runGFFLoader($run_args, $gff_file);
  379. // Test that integer values get placed in the db
  380. $results = db_query('SELECT * FROM chado.analysisfeature WHERE significance = 2 LIMIT 1', array(
  381. ));
  382. foreach ($results as $row){
  383. $this->assertEquals($row->significance,2);
  384. }
  385. // Test that decimal/float values get placed in the db
  386. $results = db_query('SELECT * FROM chado.analysisfeature WHERE significance = 2.5 LIMIT 1', array(
  387. ));
  388. foreach ($results as $row){
  389. $this->assertEquals($row->significance,2.5);
  390. }
  391. // Test that negative score values get placed in the db
  392. $results = db_query('SELECT * FROM chado.analysisfeature WHERE significance = -2.5 LIMIT 1', array(
  393. ));
  394. foreach ($results as $row){
  395. $this->assertEquals($row->significance,-2.5);
  396. }
  397. }
  398. /**
  399. * Run the GFF loader on gff_strand.gff for testing.
  400. *
  401. * This tests whether the GFF loader interprets the strand values
  402. */
  403. public function testGFFImporterInvalidStrandTest() {
  404. $gff_file = ['file_local' => __DIR__ . '/../data/gff_strand_invalid.gff'];
  405. $analysis = factory('chado.analysis')->create();
  406. $organism = factory('chado.organism')->create();
  407. $run_args = [
  408. 'analysis_id' => $analysis->analysis_id,
  409. 'organism_id' => $organism->organism_id,
  410. 'use_transaction' => 1,
  411. 'add_only' => 0,
  412. 'update' => 1,
  413. 'create_organism' => 0,
  414. 'create_target' => 0,
  415. // regexps for mRNA and protein.
  416. 're_mrna' => NULL,
  417. 're_protein' => NULL,
  418. // optional
  419. 'target_organism_id' => NULL,
  420. 'target_type' => NULL,
  421. 'start_line' => NULL,
  422. 'landmark_type' => NULL,
  423. 'alt_id_attr' => NULL,
  424. ];
  425. $this->loadLandmarks($analysis, $organism);
  426. $isException = false;
  427. try {
  428. $this->runGFFLoader($run_args, $gff_file);
  429. }
  430. catch(\Exception $ex) {
  431. $isException = true;
  432. }
  433. $this->assertEquals($isException, true);
  434. }
  435. /**
  436. * Run the GFF loader on gff_strand.gff for testing.
  437. *
  438. * This tests whether the GFF loader interprets the strand values
  439. */
  440. public function testGFFImporterStrandTest() {
  441. $gff_file = ['file_local' => __DIR__ . '/../data/gff_strand.gff'];
  442. $analysis = factory('chado.analysis')->create();
  443. $organism = factory('chado.organism')->create();
  444. $run_args = [
  445. 'analysis_id' => $analysis->analysis_id,
  446. 'organism_id' => $organism->organism_id,
  447. 'use_transaction' => 1,
  448. 'add_only' => 0,
  449. 'update' => 1,
  450. 'create_organism' => 0,
  451. 'create_target' => 0,
  452. // regexps for mRNA and protein.
  453. 're_mrna' => NULL,
  454. 're_protein' => NULL,
  455. // optional
  456. 'target_organism_id' => NULL,
  457. 'target_type' => NULL,
  458. 'start_line' => NULL,
  459. 'landmark_type' => NULL,
  460. 'alt_id_attr' => NULL,
  461. ];
  462. $this->loadLandmarks($analysis, $organism);
  463. $this->runGFFLoader($run_args, $gff_file);
  464. // Test that integer values for strand that get placed in the db
  465. // Strand data gets saved in chado.featureloc
  466. $results = db_query('SELECT * FROM chado.featureloc fl
  467. LEFT JOIN chado.feature f ON (fl.feature_id = f.feature_id)
  468. WHERE uniquename = :uniquename LIMIT 1',
  469. array(
  470. ':uniquename' => 'FRAEX38873_v2_000000010'
  471. )
  472. );
  473. foreach ($results as $row) {
  474. $this->assertEquals($row->strand, 1); // +
  475. }
  476. $results = db_query('SELECT * FROM chado.featureloc fl
  477. LEFT JOIN chado.feature f ON (fl.feature_id = f.feature_id)
  478. WHERE uniquename = :uniquename LIMIT 1',
  479. array(
  480. ':uniquename' => 'FRAEX38873_v2_000000010.1'
  481. )
  482. );
  483. foreach ($results as $row) {
  484. $this->assertEquals($row->strand,-1); // -
  485. }
  486. $results = db_query('SELECT * FROM chado.featureloc fl
  487. LEFT JOIN chado.feature f ON (fl.feature_id = f.feature_id)
  488. WHERE uniquename = :uniquename LIMIT 1',
  489. array(
  490. ':uniquename' => 'FRAEX38873_v2_000000010.2'
  491. )
  492. );
  493. foreach ($results as $row) {
  494. $this->assertEquals($row->strand, 0); // ?
  495. }
  496. $results = db_query('SELECT * FROM chado.featureloc fl
  497. LEFT JOIN chado.feature f ON (fl.feature_id = f.feature_id)
  498. WHERE uniquename = :uniquename LIMIT 1',
  499. array(
  500. ':uniquename' => 'FRAEX38873_v2_000000010.3'
  501. )
  502. );
  503. foreach ($results as $row) {
  504. $this->assertEquals($row->strand, 0); // .
  505. }
  506. // This GFF should create 5 featureloc records
  507. $results = db_query('SELECT COUNT(*) as c FROM chado.featureloc;');
  508. foreach ($results as $row) {
  509. $this->assertEquals($row->c, 5);
  510. }
  511. }
  512. /**
  513. * Run the GFF loader on gff_phase.gff for testing.
  514. *
  515. * This tests whether the GFF loader interprets the phase values correctly
  516. * for CDS rows.
  517. */
  518. public function testGFFImporterPhaseTest() {
  519. $gff_file = ['file_local' => __DIR__ . '/../data/gff_phase.gff'];
  520. $analysis = factory('chado.analysis')->create();
  521. $organism = factory('chado.organism')->create();
  522. $run_args = [
  523. 'analysis_id' => $analysis->analysis_id,
  524. 'organism_id' => $organism->organism_id,
  525. 'use_transaction' => 1,
  526. 'add_only' => 0,
  527. 'update' => 1,
  528. 'create_organism' => 0,
  529. 'create_target' => 0,
  530. // regexps for mRNA and protein.
  531. 're_mrna' => NULL,
  532. 're_protein' => NULL,
  533. // optional
  534. 'target_organism_id' => NULL,
  535. 'target_type' => NULL,
  536. 'start_line' => NULL,
  537. 'landmark_type' => NULL,
  538. 'alt_id_attr' => NULL,
  539. ];
  540. $this->loadLandmarks($analysis, $organism);
  541. $this->runGFFLoader($run_args, $gff_file);
  542. $results = db_query("SELECT * FROM chado.feature
  543. WHERE uniquename = :uniquename LIMIT 1", array(
  544. ':uniquename' => 'FRAEX38873_v2_000000010.1.cds1'
  545. )
  546. );
  547. // Check to make sure it returns a single row (implying a match)
  548. // by the uniquename specified
  549. $this->assertEquals($results->rowCount(), 1);
  550. $results = db_query("SELECT * FROM chado.featureloc
  551. WHERE phase = 1 LIMIT 1", array(
  552. )
  553. );
  554. // Check to make sure it returns a single row (implying a match)
  555. // by phase value 1
  556. $this->assertEquals($results->rowCount(), 1);
  557. }
  558. /**
  559. * Run the GFF loader on gff_phase_invalid_number.gff for testing.
  560. *
  561. * This tests whether the GFF loader interprets the phase values correctly
  562. * for CDS rows when a number outside of the range 0,1,2 is specified.
  563. */
  564. public function testGFFImporterInvalidPhaseNumberTest() {
  565. $gff_file = ['file_local' => __DIR__ . '/../data/gff_phase_invalid_number.gff'];
  566. $analysis = factory('chado.analysis')->create();
  567. $organism = factory('chado.organism')->create();
  568. $run_args = [
  569. 'analysis_id' => $analysis->analysis_id,
  570. 'organism_id' => $organism->organism_id,
  571. 'use_transaction' => 1,
  572. 'add_only' => 0,
  573. 'update' => 1,
  574. 'create_organism' => 0,
  575. 'create_target' => 0,
  576. // regexps for mRNA and protein.
  577. 're_mrna' => NULL,
  578. 're_protein' => NULL,
  579. // optional
  580. 'target_organism_id' => NULL,
  581. 'target_type' => NULL,
  582. 'start_line' => NULL,
  583. 'landmark_type' => NULL,
  584. 'alt_id_attr' => NULL,
  585. ];
  586. $this->loadLandmarks($analysis, $organism);
  587. $hasException = false;
  588. try {
  589. $this->runGFFLoader($run_args, $gff_file);
  590. }
  591. catch (\Exception $ex) {
  592. $hasException = true;
  593. }
  594. // An exception should have been thrown since the phase number is invalid
  595. $this->assertEquals($hasException, true);
  596. }
  597. /**
  598. * Run the GFF loader on gff_phase_invalid_character.gff for testing.
  599. *
  600. * This tests whether the GFF loader interprets the phase values correctly
  601. * for CDS rows when a character outside of the range 0,1,2 is specified.
  602. */
  603. public function testGFFImporterInvalidPhaseCharacterTest() {
  604. $gff_file = ['file_local' => __DIR__ . '/../data/gff_phase_invalid_character.gff'];
  605. $analysis = factory('chado.analysis')->create();
  606. $organism = factory('chado.organism')->create();
  607. $run_args = [
  608. 'analysis_id' => $analysis->analysis_id,
  609. 'organism_id' => $organism->organism_id,
  610. 'use_transaction' => 1,
  611. 'add_only' => 0,
  612. 'update' => 1,
  613. 'create_organism' => 0,
  614. 'create_target' => 0,
  615. // regexps for mRNA and protein.
  616. 're_mrna' => NULL,
  617. 're_protein' => NULL,
  618. // optional
  619. 'target_organism_id' => NULL,
  620. 'target_type' => NULL,
  621. 'start_line' => NULL,
  622. 'landmark_type' => NULL,
  623. 'alt_id_attr' => NULL,
  624. ];
  625. $this->loadLandmarks($analysis, $organism);
  626. $hasException = false;
  627. try {
  628. $this->runGFFLoader($run_args, $gff_file);
  629. }
  630. catch (\Exception $ex) {
  631. $hasException = true;
  632. }
  633. // An exception should have been thrown since the phase number is invalid
  634. $this->assertEquals($hasException, true);
  635. }
  636. /**
  637. * Run the GFF loader on small_gene.gff for testing.
  638. *
  639. * This gff has many attributes that we would like to test in the
  640. * testGFFImporterAttribute*() methods.
  641. */
  642. private function initGFFImporterAttributes() {
  643. $gff = ['file_local' => __DIR__ . '/../data/small_gene.gff'];
  644. $fasta = ['file_local' => __DIR__ . '/../data/short_scaffold.fasta'];
  645. $analysis = factory('chado.analysis')->create();
  646. $organism = factory('chado.organism')->create();
  647. $run_args = [
  648. 'analysis_id' => $analysis->analysis_id,
  649. 'organism_id' => $organism->organism_id,
  650. 'use_transaction' => 1,
  651. 'add_only' => 0,
  652. 'update' => 1,
  653. 'create_organism' => 0,
  654. 'create_target' => 0,
  655. ///regexps for mRNA and protein.
  656. 're_mrna' => NULL,
  657. 're_protein' => NULL,
  658. //optional
  659. 'target_organism_id' => $organism->organism_id,
  660. 'target_type' => NULL,
  661. 'start_line' => NULL,
  662. 'landmark_type' => NULL,
  663. 'alt_id_attr' => NULL,
  664. ];
  665. $this->loadLandmarks($analysis, $organism, $fasta);
  666. $this->runGFFLoader($run_args, $gff);
  667. $this->organism = $organism;
  668. $this->analysis = $analysis;
  669. $this->gene_cvt = chado_get_cvterm(array(
  670. 'name' => 'gene',
  671. 'cv_id' => array(
  672. 'name' => 'sequence',
  673. ),
  674. ))->cvterm_id;
  675. $this->mrna_cvt = chado_get_cvterm(array(
  676. 'name' => 'mRNA',
  677. 'cv_id' => array(
  678. 'name' => 'sequence',
  679. ),
  680. ))->cvterm_id;
  681. $this->supercontig_cvt = chado_get_cvterm(array(
  682. 'name' => 'supercontig',
  683. 'cv_id' => array(
  684. 'name' => 'sequence',
  685. ),
  686. ))->cvterm_id;
  687. $this->gene_1_uname = 'test_gene_001';
  688. $this->gene_2_uname = 'test_gene_002';
  689. $this->scaffold_1_uname = 'scaffold1';
  690. }
  691. /**
  692. * Ensures that the feature record is loaded correctly into chado.
  693. *
  694. * @group gff
  695. */
  696. public function testGFFImporterAttributeFeature() {
  697. $this->initGFFImporterAttributes();
  698. $organism = $this->organism;
  699. $query = db_select('chado.feature', 'f')
  700. ->fields('f')
  701. ->condition('uniquename', $this->gene_1_uname)
  702. ->condition('type_id', $this->gene_cvt)
  703. ->execute();
  704. $gene_1 = $query->fetchObject();
  705. $this->assertEquals('test_gene_001', $gene_1->uniquename);
  706. $this->assertEquals('test_gene_001', $gene_1->name);
  707. $this->assertEquals($organism->organism_id, $gene_1->organism_id);
  708. $this->assertEquals($this->gene_cvt, $gene_1->type_id);
  709. }
  710. /**
  711. * Ensures the feature alias is loaded correctly into chado.
  712. *
  713. * @group gff
  714. */
  715. public function testGFFImporterAttributeAlias() {
  716. $this->initGFFImporterAttributes();
  717. $alias = 'first_test_gene';
  718. $gene_1 = db_select('chado.feature', 'f')
  719. ->fields('f')
  720. ->condition('uniquename', $this->gene_1_uname)
  721. ->condition('type_id', $this->gene_cvt)
  722. ->execute()->fetchObject();
  723. $query = db_select('chado.feature_synonym', 'fs');
  724. $query->join('chado.synonym', 's', 's.synonym_id = fs.synonym_id');
  725. $query->fields('s');
  726. $query->condition('fs.feature_id', $gene_1->feature_id);
  727. $query = $query->execute();
  728. $result = $query->fetchObject();
  729. $this->assertEquals($alias, $result->name);
  730. }
  731. /**
  732. * Ensures that the dbxref records are loaded correctly into chado.
  733. *
  734. * @group gff
  735. */
  736. public function testGFFImporterAttributeDbxref() {
  737. $this->initGFFImporterAttributes();
  738. $test_db_name = 'TEST_DB';
  739. $dbx_accession = 'test_gene_dbx_001';
  740. $test_db = chado_get_db(array('name' => $test_db_name));
  741. $gff_db = chado_get_db(array('name' => 'GFF_source'));
  742. $gene_1 = db_select('chado.feature', 'f')
  743. ->fields('f')
  744. ->condition('uniquename', $this->gene_1_uname)
  745. ->condition('type_id', $this->gene_cvt)
  746. ->execute()->fetchObject();
  747. $dbx_query = db_select('chado.feature_dbxref', 'fdbx');
  748. $dbx_query->join('chado.dbxref', 'dbx', 'dbx.dbxref_id = fdbx.dbxref_id');
  749. $dbx_query->fields('dbx');
  750. $dbx_query->condition('fdbx.feature_id', $gene_1->feature_id);
  751. $gff_query = clone $dbx_query;
  752. $dbx_query->condition('dbx.db_id', $test_db->db_id);
  753. $dbx_query = $dbx_query->execute();
  754. $gff_query->condition('dbx.db_id', $gff_db->db_id);
  755. $gff_query = $gff_query->execute();
  756. $dbxref = $dbx_query->fetchObject();
  757. $gff_dbxref = $gff_query->fetchObject();
  758. $this->assertEquals($dbx_accession, $dbxref->accession);
  759. $this->assertEquals($this->gene_1_uname, $gff_dbxref->accession);
  760. }
  761. /**
  762. * Ensures ontology term records loaded correctly into chado.
  763. *
  764. * @group gff
  765. */
  766. public function testGFFImporterAttributeOntology() {
  767. $this->initGFFImporterAttributes();
  768. $ontology_db = 'SO';
  769. $ontology_accession = '0000704';
  770. $gene_1 = db_select('chado.feature', 'f')
  771. ->fields('f')
  772. ->condition('uniquename', $this->gene_1_uname)
  773. ->condition('type_id', $this->gene_cvt)
  774. ->execute()->fetchObject();
  775. $term = chado_get_cvterm(array(
  776. 'dbxref_id' => array(
  777. 'accession' => $ontology_accession,
  778. 'db_id' => array(
  779. 'name' => $ontology_db,
  780. ),
  781. ),
  782. ));
  783. $feature_cvt = db_select('chado.feature_cvterm', 'fcvt')
  784. ->fields('fcvt')
  785. ->condition('cvterm_id', $term->cvterm_id)
  786. ->condition('feature_id', $gene_1->feature_id)
  787. ->execute();
  788. $this->assertEquals(1, $feature_cvt->rowCount());
  789. }
  790. /**
  791. * Ensures feature parent record loaded correctly into chado.
  792. *
  793. * @group gff
  794. */
  795. public function testGFFImporterAttributeParent() {
  796. $this->initGFFImporterAttributes();
  797. $mrna_uname = 'test_mrna_001.1';
  798. $rel_cvt = chado_get_cvterm(array(
  799. 'name' => 'part_of',
  800. 'cv_id' => array(
  801. 'name' => 'sequence',
  802. ),
  803. ))->cvterm_id;
  804. $mrna = db_select('chado.feature', 'f')
  805. ->fields('f')
  806. ->condition('uniquename', $mrna_uname)
  807. ->condition('type_id', $this->mrna_cvt)
  808. ->execute()->fetchObject();
  809. $query = db_select('chado.feature_relationship', 'fr');
  810. $query->join('chado.feature', 'f', 'f.feature_id = fr.object_id');
  811. $query->fields('f');
  812. $query->condition('fr.subject_id', $mrna->feature_id);
  813. $query->condition('fr.type_id', $rel_cvt);
  814. $query = $query->execute();
  815. $parent = $query->fetchObject();
  816. $this->assertEquals('test_gene_001', $parent->uniquename);
  817. $this->assertEquals('test_gene_001', $parent->name);
  818. $this->assertEquals($this->gene_cvt, $parent->type_id);
  819. $this->assertEquals($this->organism->organism_id, $parent->organism_id);
  820. }
  821. /**
  822. * Ensure target record loaded correctly into chado.
  823. *
  824. * @group gff
  825. */
  826. public function testGFFImporterAttributeTarget() {
  827. $this->initGFFImporterAttributes();
  828. $target_feature = 'scaffold1';
  829. $start = 99;
  830. $end = 200;
  831. $target_type = 'supercontig';
  832. $target_cvt = chado_get_cvterm(array(
  833. 'name' => $target_type,
  834. 'cv_id' => array(
  835. 'name' => 'sequence',
  836. ),
  837. ))->cvterm_id;
  838. $source_feature = db_select('chado.feature', 'f')
  839. ->fields('f')
  840. ->condition('uniquename', $target_feature)
  841. ->condition('type_id', $target_cvt)
  842. ->execute()->fetchObject();
  843. $gene_1 = db_select('chado.feature', 'f')
  844. ->fields('f')
  845. ->condition('uniquename', $this->gene_1_uname)
  846. ->condition('type_id', $this->gene_cvt)
  847. ->execute()->fetchObject();
  848. $featureloc = db_select('chado.featureloc', 'fl')
  849. ->fields('fl')
  850. ->condition('fl.feature_id', $gene_1->feature_id)
  851. ->condition('fl.srcfeature_id', $source_feature->feature_id)
  852. ->execute()->fetchObject();
  853. $this->assertEquals($start, $featureloc->fmin);
  854. $this->assertEquals($end, $featureloc->fmax);
  855. }
  856. /**
  857. * Ensure properties loaded correctly into chado.
  858. *
  859. * @group gff
  860. */
  861. public function testGFFImporterAttributeProperty() {
  862. $this->initGFFImporterAttributes();
  863. $gap_1 = 'test_gap_1';
  864. $gap_2 = 'test_gap_2';
  865. $note_val = 'test_gene_001_note';
  866. $gene_1 = db_select('chado.feature', 'f')
  867. ->fields('f')
  868. ->condition('uniquename', $this->gene_1_uname)
  869. ->condition('type_id', $this->gene_cvt)
  870. ->execute()->fetchObject();
  871. $gap_cvt = chado_get_cvterm(array(
  872. 'name' => 'Gap',
  873. 'cv_id' => array(
  874. 'name' => 'feature_property',
  875. ),
  876. ))->cvterm_id;
  877. $note_cvt = chado_get_cvterm(array(
  878. 'name' => 'Note',
  879. 'cv_id' => array(
  880. 'name' => 'feature_property',
  881. ),
  882. ))->cvterm_id;
  883. // Assert gaps loaded correctly
  884. $gaps_query = db_select('chado.featureprop', 'fp')
  885. ->fields('fp')
  886. ->condition('feature_id', $gene_1->feature_id)
  887. ->condition('type_id', $gap_cvt)
  888. ->execute();
  889. while (($gap = $gaps_query->fetchObject())) {
  890. $gaps[$gap->value] = $gap;
  891. }
  892. $this->assertEquals($gap_1, $gaps[$gap_1]->value);
  893. $this->assertEquals(0, $gaps[$gap_1]->rank);
  894. // Assert note loaded correctly
  895. $note = db_select('chado.featureprop', 'fp')
  896. ->fields('fp')
  897. ->condition('feature_id', $gene_1->feature_id)
  898. ->condition('type_id', $note_cvt)
  899. ->execute()->fetchObject();
  900. $this->assertEquals($note_val, $note->value);
  901. $this->assertEquals(0, $note->rank);
  902. }
  903. /**
  904. * Ensure derives from information loaded correctly into chado.
  905. *
  906. * @group gff
  907. */
  908. public function testGFFImporterAttributeDerivesFrom() {
  909. $this->initGFFImporterAttributes();
  910. $gene_2 = db_select('chado.feature', 'f')
  911. ->fields('f')
  912. ->condition('uniquename', $this->gene_2_uname)
  913. ->condition('type_id', $this->gene_cvt)
  914. ->execute()->fetchObject();
  915. $derivesfrom_cvt = chado_get_cvterm(array(
  916. 'name' => 'derives_from',
  917. 'cv_id' => array(
  918. 'name' => 'sequence',
  919. ),
  920. ))->cvterm_id;
  921. $query = db_select('chado.feature', 'f');
  922. $query->join('chado.feature_relationship', 'fr', 'f.feature_id = fr.object_id');
  923. $query->fields('f');
  924. $query->condition('fr.subject_id', $gene_2->feature_id);
  925. $query->condition('fr.type_id', $derivesfrom_cvt);
  926. $query = $query->execute();
  927. $derivesfrom_feature = $query->fetchObject();
  928. $this->assertEquals($this->gene_1_uname, $derivesfrom_feature->uniquename);
  929. $this->assertEquals($this->gene_1_uname, $derivesfrom_feature->name);
  930. $this->assertEquals($this->gene_cvt, $derivesfrom_feature->type_id);
  931. }
  932. /**
  933. * Ensure FASTA information loaded correctly into chado.
  934. *
  935. * @group gff
  936. */
  937. public function testGFFImporterAttributeFastas() {
  938. $this->initGFFImporterAttributes();
  939. $scaffold = db_select('chado.feature', 'f')
  940. ->fields('f')
  941. ->condition('uniquename', $this->scaffold_1_uname)
  942. ->condition('type_id', $this->supercontig_cvt)
  943. ->execute()->fetchObject();
  944. $this->assertEquals(720, $scaffold->seqlen);
  945. $this->assertEquals(720, strlen($scaffold->residues));
  946. $this->assertEquals('83578d8afdaec399c682aa6c0ddd29c9', $scaffold->md5checksum);
  947. }
  948. /**
  949. * Test that when checked, explicit proteins are created when specified within
  950. * the GFF file. Explicit proteins will not respect the skip_protein argument
  951. * and will therefore be added to the database.
  952. *
  953. * @group gff
  954. * @ticket 77
  955. *
  956. */
  957. public function testGFFPolypeptide() {
  958. $gff_file = ['file_local' => __DIR__ . '/../data/simpleGFF.gff'];
  959. $analysis = factory('chado.analysis')->create();
  960. $organism = factory('chado.organism')->create();
  961. $run_args = [
  962. // The new argument
  963. 'skip_protein' => 1,
  964. 'analysis_id' => $analysis->analysis_id,
  965. 'organism_id' => $organism->organism_id,
  966. 'use_transaction' => 1,
  967. 'add_only' => 0,
  968. 'update' => 1,
  969. 'create_organism' => 0,
  970. 'create_target' => 0,
  971. // regexps for mRNA and protein.
  972. 're_mrna' => NULL,
  973. 're_protein' => NULL,
  974. // optional
  975. 'target_organism_id' => NULL,
  976. 'target_type' => NULL,
  977. 'start_line' => NULL,
  978. 'landmark_type' => NULL,
  979. 'alt_id_attr' => NULL,
  980. ];
  981. $this->loadLandmarks($analysis, $organism);
  982. $this->runGFFLoader($run_args, $gff_file);
  983. $identifier = [
  984. 'cv_id' => ['name' => 'sequence'],
  985. 'name' => 'polypeptide',
  986. ];
  987. $protein_type_id = tripal_get_cvterm($identifier);
  988. $name = 'FRAEX38873_v2_000000010.1.3_test_protein';
  989. $query = db_select('chado.feature', 'f')
  990. ->fields('f', ['uniquename'])
  991. ->condition('f.uniquename', $name)
  992. ->condition('f.type_id', $protein_type_id->cvterm_id)
  993. ->execute()
  994. ->fetchAll();
  995. $this->assertEquals(1, count($query));
  996. }
  997. /**
  998. * Add a skip protein option. Test that when checked, implicit proteins are
  999. * not created, but that they are created when unchecked.
  1000. *
  1001. * @group gff
  1002. * @ticket 77
  1003. *
  1004. */
  1005. public function testGFFNoProteinOption() {
  1006. $gff_file = ['file_local' => __DIR__ . '/../data/gff_protein_generation.gff'];
  1007. $analysis = factory('chado.analysis')->create();
  1008. $organism = factory('chado.organism')->create();
  1009. $run_args = [
  1010. //Skip protein feature generation
  1011. 'skip_protein' => 1,
  1012. 'analysis_id' => $analysis->analysis_id,
  1013. 'organism_id' => $organism->organism_id,
  1014. 'use_transaction' => 1,
  1015. 'add_only' => 0,
  1016. 'update' => 1,
  1017. 'create_organism' => 0,
  1018. 'create_target' => 0,
  1019. ///regexps for mRNA and protein.
  1020. 're_mrna' => NULL,
  1021. 're_protein' => NULL,
  1022. //optional
  1023. 'target_organism_id' => NULL,
  1024. 'target_type' => NULL,
  1025. 'start_line' => NULL,
  1026. 'landmark_type' => NULL,
  1027. 'alt_id_attr' => NULL,
  1028. ];
  1029. $this->loadLandmarks($analysis, $organism);
  1030. $this->runGFFLoader($run_args, $gff_file);
  1031. $identifier = [
  1032. 'cv_id' => ['name' => 'sequence'],
  1033. 'name' => 'polypeptide',
  1034. ];
  1035. $protein_type_id = tripal_get_cvterm($identifier);
  1036. $name = "FRAEX38873_v2_000000190.1-protein";
  1037. $results = db_select('chado.feature', 'f')
  1038. ->fields('f', ['uniquename'])
  1039. ->condition('f.uniquename', $name)
  1040. ->condition('f.type_id', $protein_type_id->cvterm_id)
  1041. ->execute()
  1042. ->fetchAll();
  1043. // There should be no proteins since we used the skip_proteins flag and no
  1044. // explicit proteins were specified in the test file
  1045. $this->assertEquals(0, count($results));
  1046. // Now perform a unit test where we do not skip proteins generation
  1047. $run_args['skip_protein'] = 0;
  1048. $this->runGFFLoader($run_args, $gff_file);
  1049. $query = db_select('chado.feature', 'f')
  1050. ->fields('f', ['uniquename'])
  1051. ->condition('f.uniquename', $name)
  1052. ->condition('f.type_id', $protein_type_id->cvterm_id)
  1053. ->execute()
  1054. ->fetchObject();
  1055. $this->assertEquals($name, $query->uniquename);
  1056. }
  1057. /**
  1058. * The GFF importer should still create explicitly defined proteins if
  1059. * skip_protein is true.
  1060. *
  1061. * @group gff
  1062. * @ticket 77
  1063. */
  1064. public function testGFFImporterLoadsExplicitProteins() {
  1065. $gff_file = ['file_local' => __DIR__ . '/../data/simpleGFF.gff'];
  1066. $analysis = factory('chado.analysis')->create();
  1067. $organism = factory('chado.organism')->create();
  1068. $run_args = [
  1069. //The new argument
  1070. 'skip_protein' => 1,
  1071. ///
  1072. 'analysis_id' => $analysis->analysis_id,
  1073. 'organism_id' => $organism->organism_id,
  1074. 'use_transaction' => 1,
  1075. 'add_only' => 0,
  1076. 'update' => 1,
  1077. 'create_organism' => 0,
  1078. 'create_target' => 0,
  1079. ///regexps for mRNA and protein.
  1080. 're_mrna' => NULL,
  1081. 're_protein' => NULL,
  1082. //optional
  1083. 'target_organism_id' => NULL,
  1084. 'target_type' => NULL,
  1085. 'start_line' => NULL,
  1086. 'landmark_type' => NULL,
  1087. 'alt_id_attr' => NULL,
  1088. ];
  1089. $this->loadLandmarks($analysis, $organism);
  1090. $this->runGFFLoader($run_args, $gff_file);
  1091. $name = 'FRAEX38873_v2_000000010.1.3_test_protein';
  1092. $query = db_select('chado.feature', 'f')
  1093. ->fields('f', ['uniquename'])
  1094. ->condition('f.uniquename', $name)
  1095. ->execute()
  1096. ->fetchField();
  1097. $this->assertEquals($name, $query);
  1098. }
  1099. private function runGFFLoader($run_args, $file) {
  1100. // silent(function ($run_args, $file) {
  1101. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/GFF3Importer');
  1102. $importer = new \GFF3Importer();
  1103. $importer->create($run_args, $file);
  1104. $importer->prepareFiles();
  1105. $importer->run();
  1106. // });
  1107. }
  1108. private function loadLandmarks($analysis, $organism, $landmark_file = array()) {
  1109. if (empty($landmark_file)) {
  1110. $landmark_file = ['file_local' => __DIR__ . '/../data/empty_landmarks.fasta'];
  1111. }
  1112. $run_args = [
  1113. 'organism_id' => $organism->organism_id,
  1114. 'analysis_id' => $analysis->analysis_id,
  1115. 'seqtype' => 'supercontig',
  1116. 'method' => 2, //default insert and update
  1117. 'match_type' => 1, //unique name default
  1118. //optional
  1119. 're_name' => NULL,
  1120. 're_uname' => NULL,
  1121. 're_accession' => NULL,
  1122. 'db_id' => NULL,
  1123. 'rel_type' => NULL,
  1124. 're_subject' => NULL,
  1125. 'parent_type' => NULL,
  1126. ];
  1127. module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/FASTAImporter');
  1128. //silent(function ($run_args, $landmark_file) {
  1129. $importer = new \FASTAImporter();
  1130. $importer->create($run_args, $landmark_file);
  1131. $importer->prepareFiles();
  1132. $importer->run();
  1133. // });
  1134. }
  1135. }