GFF3ImporterTest.php 39 KB

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