/test/unit/bio/appl/sim4/test_report.rb

https://github.com/domthu/bioruby · Ruby · 870 lines · 682 code · 173 blank · 15 comment · 0 complexity · 1a684e656b202cd3fc8cd7371be06cdd MD5 · raw file

  1. #
  2. # test/unit/bio/appl/sim4/test_report.rb - Unit test for Bio::Sim4
  3. #
  4. # Copyright:: Copyright (C) 2009
  5. # Naohisa Goto <ng@bioruby.org>
  6. # License:: The Ruby License
  7. #
  8. # $Id:$
  9. #
  10. # loading helper routine for testing bioruby
  11. require 'pathname'
  12. load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4,
  13. 'bioruby_test_helper.rb')).cleanpath.to_s
  14. # libraries needed for the tests
  15. require 'test/unit'
  16. require 'bio/appl/sim4/report'
  17. module Bio
  18. class TestDataForSim4Report
  19. DataPath = Pathname.new(File.join(BioRubyTestDataPath, 'sim4')).cleanpath.to_s
  20. def initialize(filename)
  21. @filename = filename
  22. end
  23. def read
  24. File.read(File.join(DataPath,@filename))
  25. end
  26. def report
  27. Bio::Sim4::Report.new(self.read)
  28. end
  29. def self.report(filename)
  30. self.new(filename).report
  31. end
  32. def self.report1
  33. filename = "simple-A4.sim4"
  34. self.new(filename).report
  35. end
  36. def self.report2
  37. filename = "simple2-A4.sim4"
  38. self.new(filename).report
  39. end
  40. def self.report4
  41. filename = "complement-A4.sim4"
  42. self.new(filename).report
  43. end
  44. end #class TestDataForSim4Report
  45. class TestSim4Report < Test::Unit::TestCase
  46. def setup
  47. @sim4 = TestDataForSim4Report.report1
  48. end
  49. def test_hits
  50. assert_kind_of(Array, @sim4.hits)
  51. assert_equal(1, @sim4.hits.size)
  52. assert_instance_of(Bio::Sim4::Report::Hit, @sim4.hits[0])
  53. end
  54. def test_all_hits
  55. assert_kind_of(Array, @sim4.all_hits)
  56. assert_equal(1, @sim4.all_hits.size)
  57. assert_instance_of(Bio::Sim4::Report::Hit, @sim4.all_hits[0])
  58. end
  59. def exec_test_seq1_len(sd)
  60. assert_equal(94, sd.len)
  61. end
  62. private :exec_test_seq1_len
  63. def test_seq1
  64. sd = @sim4.seq1
  65. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  66. assert_equal('mrna1', sd.entry_id)
  67. assert_equal('mrna1', sd.definition)
  68. assert_equal('sample10-1.fst', sd.filename)
  69. exec_test_seq1_len(sd)
  70. end
  71. def exec_test_each(meth)
  72. count = 0
  73. assert_nothing_raised {
  74. @sim4.__send__(meth) do |x|
  75. count += 1
  76. end
  77. }
  78. assert_equal(1, count)
  79. @sim4.__send__(meth) do |x|
  80. assert_instance_of(Bio::Sim4::Report::Hit, x)
  81. end
  82. end
  83. private :exec_test_each
  84. def test_each
  85. exec_test_each(:each)
  86. end
  87. def test_each_hit
  88. exec_test_each(:each_hit)
  89. end
  90. def test_num_hits
  91. assert_equal(1, @sim4.num_hits)
  92. end
  93. def test_query_def
  94. assert_equal('mrna1', @sim4.query_def)
  95. end
  96. def test_query_id
  97. assert_equal('mrna1', @sim4.query_id)
  98. end
  99. def test_query_len
  100. assert_equal(94, @sim4.query_len)
  101. end
  102. end #class TestSim4Report
  103. class TestSim4ReportHit < Test::Unit::TestCase
  104. def setup
  105. @hit = TestDataForSim4Report.report1.hits.first
  106. end
  107. def test_align
  108. a = [
  109. [ "TTGTTTCCGTCGCTGGTTATTGTCTAGAACGCAAAAATAG",
  110. "||||||||||||||||||||||||||||||||||||||||",
  111. "TTGTTTCCGTCGCTGGTTATTGTCTAGAACGCAAAAATAG" ],
  112. [ " ",
  113. "<<<...<<<",
  114. "CTG...TAC" ],
  115. [ "TCTACACATCACTAGCGTGGGTGGGCGGAAAGAGCAGCTCGCCACT CAAGCTAA",
  116. "|||||||||||||||| |||||||||||||-|||||||||||||||-||||||||",
  117. "TCTACACATCACTAGCCTGGGTGGGCGGAA GAGCAGCTCGCCACTTCAAGCTAA" ]
  118. ]
  119. assert_equal(a, @hit.align)
  120. end
  121. def test_complement?
  122. assert_equal(nil, @hit.complement?)
  123. end
  124. def test_definition
  125. assert_equal('genome1', @hit.definition)
  126. end
  127. def test_each
  128. count = 0
  129. assert_nothing_raised {
  130. @hit.each do |x|
  131. count += 1
  132. end
  133. }
  134. assert_equal(2, count)
  135. @hit.each do |x|
  136. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  137. end
  138. end
  139. def exec_test_exons(meth)
  140. assert_kind_of(Array, @hit.__send__(meth))
  141. assert_equal(2, @hit.__send__(meth).size)
  142. @hit.__send__(meth).each do |x|
  143. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  144. end
  145. end
  146. private :exec_test_exons
  147. def test_exons
  148. exec_test_exons(:exons)
  149. end
  150. def test_hit_id
  151. assert_equal('genome1', @hit.hit_id)
  152. end
  153. def test_hsps
  154. exec_test_exons(:hsps)
  155. end
  156. def test_introns
  157. assert_kind_of(Array, @hit.introns)
  158. assert_equal(1, @hit.introns.size)
  159. @hit.introns.each do |x|
  160. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  161. end
  162. end
  163. def test_len
  164. assert_equal(599, @hit.len)
  165. end
  166. def test_query_def
  167. assert_equal('mrna1', @hit.query_def)
  168. end
  169. def test_query_id
  170. assert_equal('mrna1', @hit.query_id)
  171. end
  172. def test_query_len
  173. assert_equal(94, @hit.query_len)
  174. end
  175. def test_segmentpairs
  176. assert_kind_of(Array, @hit.segmentpairs)
  177. assert_equal(3, @hit.segmentpairs.size)
  178. @hit.segmentpairs.each do |x|
  179. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  180. end
  181. end
  182. def exec_test_seq1_len(sd)
  183. assert_equal(94, sd.len)
  184. end
  185. private :exec_test_seq1_len
  186. def test_seq1
  187. sd = @hit.seq1
  188. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  189. assert_equal('mrna1', sd.entry_id)
  190. assert_equal('mrna1', sd.definition)
  191. assert_equal('sample10-1.fst', sd.filename)
  192. exec_test_seq1_len(sd)
  193. end
  194. def test_seq2
  195. sd = @hit.seq2
  196. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  197. assert_equal('genome1', sd.entry_id)
  198. assert_equal('genome1', sd.definition)
  199. assert_equal(599, sd.len)
  200. #assert_equal('sample10-2.fst', sd.filename)
  201. assert_equal('sample10-2.fst (genome1)', sd.filename)
  202. end
  203. def test_target_def
  204. assert_equal('genome1', @hit.target_def)
  205. end
  206. def test_target_id
  207. assert_equal('genome1', @hit.target_id)
  208. end
  209. def test_target_len
  210. assert_equal(599, @hit.target_len)
  211. end
  212. end #class TestSim4ReportHit
  213. class TestSim4ReportSegmentPair_exon < Test::Unit::TestCase
  214. def setup
  215. @exon = TestDataForSim4Report.report1.hits[0].exons[1]
  216. end
  217. def test_align_len
  218. assert_equal(55, @exon.align_len)
  219. end
  220. def test_direction
  221. assert_equal("", @exon.direction)
  222. end
  223. def test_hit_from
  224. assert_equal(404, @exon.hit_from)
  225. end
  226. def test_hit_to
  227. assert_equal(457, @exon.hit_to)
  228. end
  229. def test_hseq
  230. hseq = "TCTACACATCACTAGCCTGGGTGGGCGGAA GAGCAGCTCGCCACTTCAAGCTAA"
  231. assert_equal(hseq, @exon.hseq)
  232. end
  233. def test_midline
  234. midline = "|||||||||||||||| |||||||||||||-|||||||||||||||-||||||||"
  235. assert_equal(midline, @exon.midline)
  236. end
  237. def test_percent_identity
  238. #assert_equal(94, @exon.percent_identity)
  239. assert_equal("94", @exon.percent_identity)
  240. end
  241. def test_qseq
  242. qseq = "TCTACACATCACTAGCGTGGGTGGGCGGAAAGAGCAGCTCGCCACT CAAGCTAA"
  243. assert_equal(qseq, @exon.qseq)
  244. end
  245. def test_query_from
  246. assert_equal(41, @exon.query_from)
  247. end
  248. def test_query_to
  249. assert_equal(94, @exon.query_to)
  250. end
  251. def exec_test_seq1_from_to(seg)
  252. assert_equal(41, seg.from)
  253. assert_equal(94, seg.to)
  254. end
  255. private :exec_test_seq1_from_to
  256. def test_seq1
  257. assert_instance_of(Bio::Sim4::Report::Segment, @exon.seq1)
  258. assert_equal("TCTACACATCACTAGCGTGGGTGGGCGGAAAGAGCAGCTCGCCACT CAAGCTAA",
  259. @exon.seq1.seq)
  260. exec_test_seq1_from_to(@exon.seq1)
  261. end
  262. def test_seq2
  263. assert_instance_of(Bio::Sim4::Report::Segment, @exon.seq2)
  264. assert_equal(404, @exon.seq2.from)
  265. assert_equal(457, @exon.seq2.to)
  266. assert_equal("TCTACACATCACTAGCCTGGGTGGGCGGAA GAGCAGCTCGCCACTTCAAGCTAA",
  267. @exon.seq2.seq)
  268. end
  269. end #class TestSim4ReportSegmentPair_exon
  270. class TestSim4ReportSegmentPair_intron < Test::Unit::TestCase
  271. def setup
  272. @intron = TestDataForSim4Report.report1.hits[0].introns[0]
  273. end
  274. def test_align_len
  275. assert_equal(9, @intron.align_len)
  276. end
  277. def test_direction
  278. assert_equal(nil, @intron.direction)
  279. end
  280. def test_hit_from
  281. assert_equal(185, @intron.hit_from)
  282. end
  283. def test_hit_to
  284. assert_equal(403, @intron.hit_to)
  285. end
  286. def test_hseq
  287. hseq = "CTG...TAC"
  288. assert_equal(hseq, @intron.hseq)
  289. end
  290. def test_midline
  291. midline = "<<<...<<<"
  292. assert_equal(midline, @intron.midline)
  293. end
  294. def test_percent_identity
  295. assert_equal(nil, @intron.percent_identity)
  296. end
  297. def test_qseq
  298. qseq = " "
  299. assert_equal(qseq, @intron.qseq)
  300. end
  301. def test_query_from
  302. assert_equal(0, @intron.query_from)
  303. end
  304. def test_query_to
  305. assert_equal(0, @intron.query_to)
  306. end
  307. def test_seq1
  308. assert_instance_of(Bio::Sim4::Report::Segment, @intron.seq1)
  309. assert_equal(0, @intron.seq1.from)
  310. assert_equal(0, @intron.seq1.to)
  311. assert_equal(" ", @intron.seq1.seq)
  312. end
  313. def test_seq2
  314. assert_instance_of(Bio::Sim4::Report::Segment, @intron.seq2)
  315. assert_equal(185, @intron.seq2.from)
  316. assert_equal(403, @intron.seq2.to)
  317. assert_equal("CTG...TAC", @intron.seq2.seq)
  318. end
  319. end #class TestSim4ReportSegmentPair_intron
  320. class TestSim4Report2 < TestSim4Report
  321. def setup
  322. @sim4 = TestDataForSim4Report.report2
  323. end
  324. def test_query_len
  325. assert_equal(96, @sim4.query_len)
  326. end
  327. def exec_test_seq1_len(sd)
  328. assert_equal(96, sd.len)
  329. end
  330. private :exec_test_seq1_len
  331. end #class TestSim4Report2
  332. class TestSim4ReportHit2 < TestSim4ReportHit
  333. def setup
  334. @hit = TestDataForSim4Report.report2.hits.first
  335. end
  336. def test_align
  337. a = [
  338. [ "AGTTGTTTCCGTCGCTGGTTATTGTCTAGAACGCAAAAATAG",
  339. "||||||||||||||||||||||||||||||||||||||||||",
  340. "AGTTGTTTCCGTCGCTGGTTATTGTCTAGAACGCAAAAATAG" ],
  341. [ " ",
  342. "<<<...<<<",
  343. "CTG...TAC" ],
  344. [ "TCTACACATCACTAGCGTGGGTGGGCGGAAAGAGCAGCTCGCCACT CAAGCTAA",
  345. "|||||||||||||||| |||||||||||||-|||||||||||||||-||||||||",
  346. "TCTACACATCACTAGCCTGGGTGGGCGGAA GAGCAGCTCGCCACTTCAAGCTAA" ]
  347. ]
  348. assert_equal(a, @hit.align)
  349. end
  350. def test_query_len
  351. assert_equal(96, @hit.query_len)
  352. end
  353. def exec_test_seq1_len(sd)
  354. assert_equal(96, sd.len)
  355. end
  356. private :exec_test_seq1_len
  357. end #class TestSim4ReportHit2
  358. class TestSim4ReportSegmentPair2_exon < TestSim4ReportSegmentPair_exon
  359. def setup
  360. @exon = TestDataForSim4Report.report2.hits[0].exons[1]
  361. end
  362. def test_query_from
  363. assert_equal(43, @exon.query_from)
  364. end
  365. def test_query_to
  366. assert_equal(96, @exon.query_to)
  367. end
  368. def exec_test_seq1_from_to(seg)
  369. assert_equal(43, seg.from)
  370. assert_equal(96, seg.to)
  371. end
  372. private :exec_test_seq1_from_to
  373. end #class TestSim4ReportSegmentPair2_exon
  374. class TestSim4ReportSegmentPair2_intron < TestSim4ReportSegmentPair_intron
  375. def setup
  376. @intron = TestDataForSim4Report.report2.hits[0].introns[0]
  377. end
  378. end #class TestSim4ReportSegmentPair2_intron
  379. class TestSim4Report4 < TestSim4Report
  380. def setup
  381. @sim4 = TestDataForSim4Report.report4
  382. end
  383. def exec_test_seq1_len(sd)
  384. assert_equal(284, sd.len)
  385. end
  386. private :exec_test_seq1_len
  387. def test_seq1
  388. sd = @sim4.seq1
  389. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  390. assert_equal('mrna4c', sd.entry_id)
  391. assert_equal('mrna4c', sd.definition)
  392. assert_equal('sample41-1c.fst', sd.filename)
  393. exec_test_seq1_len(sd)
  394. end
  395. def test_query_def
  396. assert_equal('mrna4c', @sim4.query_def)
  397. end
  398. def test_query_id
  399. assert_equal('mrna4c', @sim4.query_id)
  400. end
  401. def test_query_len
  402. assert_equal(284, @sim4.query_len)
  403. end
  404. end #class TestSim4Report4
  405. class TestSim4ReportHit4 < TestSim4ReportHit
  406. def setup
  407. @hit = TestDataForSim4Report.report4.hits.first
  408. end
  409. def test_align
  410. a = [
  411. [ "TTTTAGCCGGCACGAGATTG AGCGTATGATCACGCGCGCGGCCTCCT CAGAGTGATGCATGATACAACTT AT ",
  412. "||||||||||||||||||||-||||-||||||||||||||||||||||-|-|||| ||||||||||||||||- |-",
  413. "TTTTAGCCGGCACGAGATTGCAGCG ATGATCACGCGCGCGGCCTCCTAC GAGTCATGCATGATACAACTTCTTG"],
  414. [ " ",
  415. ">>>...>>>",
  416. "GTT...GAT" ],
  417. [ "ATATGTACTTAGCTGGCAACCGAGATTTACTTTCGAAGCACTGTGATGAACCCGCGGCCCTTTGAGCGCT",
  418. "|||||||||||||-|||||||||||||||||||||||| |||||||||||||||||-|||||||||||||",
  419. "ATATGTACTTAGC GGCAACCGAGATTTACTTTCGAAGGACTGTGATGAACCCGCG CCCTTTGAGCGCT" ],
  420. [ "", "", "" ],
  421. [ "TATATATGTACTTAGCGG ACACCGAGATTTACTTTCGAAGGACTGTGGATGAACCCGCGCCCTTTGAGCGCT",
  422. "||||||||||||||||||-|-|||||||||||||||||||||||||||-||||||||||||||||||||||||",
  423. "TATATATGTACTTAGCGGCA ACCGAGATTTACTTTCGAAGGACTGTG ATGAACCCGCGCCCTTTGAGCGCT" ]
  424. ]
  425. assert_equal(a, @hit.align)
  426. end
  427. def test_complement?
  428. assert_equal(true, @hit.complement?)
  429. end
  430. def test_definition
  431. assert_equal('genome4', @hit.definition)
  432. end
  433. def test_each
  434. count = 0
  435. assert_nothing_raised {
  436. @hit.each do |x|
  437. count += 1
  438. end
  439. }
  440. assert_equal(3, count)
  441. @hit.each do |x|
  442. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  443. end
  444. end
  445. def exec_test_exons(meth)
  446. assert_kind_of(Array, @hit.__send__(meth))
  447. assert_equal(3, @hit.__send__(meth).size)
  448. @hit.__send__(meth).each do |x|
  449. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  450. end
  451. end
  452. private :exec_test_exons
  453. def test_hit_id
  454. assert_equal('genome4', @hit.hit_id)
  455. end
  456. def test_introns
  457. assert_kind_of(Array, @hit.introns)
  458. assert_equal(2, @hit.introns.size)
  459. @hit.introns.each do |x|
  460. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  461. end
  462. end
  463. def test_len
  464. assert_equal(770, @hit.len)
  465. end
  466. def test_query_def
  467. assert_equal('mrna4c', @hit.query_def)
  468. end
  469. def test_query_id
  470. assert_equal('mrna4c', @hit.query_id)
  471. end
  472. def test_query_len
  473. assert_equal(284, @hit.query_len)
  474. end
  475. def test_segmentpairs
  476. assert_kind_of(Array, @hit.segmentpairs)
  477. assert_equal(5, @hit.segmentpairs.size)
  478. @hit.segmentpairs.each do |x|
  479. assert_instance_of(Bio::Sim4::Report::SegmentPair, x)
  480. end
  481. end
  482. def exec_test_seq1_len(sd)
  483. assert_equal(284, sd.len)
  484. end
  485. private :exec_test_seq1_len
  486. def test_seq1
  487. sd = @hit.seq1
  488. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  489. assert_equal('mrna4c', sd.entry_id)
  490. assert_equal('mrna4c', sd.definition)
  491. assert_equal('sample41-1c.fst', sd.filename)
  492. exec_test_seq1_len(sd)
  493. end
  494. def test_seq2
  495. sd = @hit.seq2
  496. assert_instance_of(Bio::Sim4::Report::SeqDesc, sd)
  497. assert_equal('genome4', sd.entry_id)
  498. assert_equal('genome4', sd.definition)
  499. assert_equal(770, sd.len)
  500. #assert_equal('sample40-2.fst', sd.filename)
  501. assert_equal('sample40-2.fst (genome4)', sd.filename)
  502. end
  503. def test_target_def
  504. assert_equal('genome4', @hit.target_def)
  505. end
  506. def test_target_id
  507. assert_equal('genome4', @hit.target_id)
  508. end
  509. def test_target_len
  510. assert_equal(770, @hit.target_len)
  511. end
  512. end #class TestSim4ReportHit4
  513. class TestSim4ReportSegmentPair4_exon < TestSim4ReportSegmentPair_exon
  514. def setup
  515. @exon = TestDataForSim4Report.report4.hits[0].exons[1]
  516. end
  517. def test_align_len
  518. assert_equal(70, @exon.align_len)
  519. end
  520. def test_direction
  521. assert_equal("==", @exon.direction)
  522. end
  523. def test_hit_from
  524. assert_equal(563, @exon.hit_from)
  525. end
  526. def test_hit_to
  527. assert_equal(630, @exon.hit_to)
  528. end
  529. def test_hseq
  530. hseq = "ATATGTACTTAGC GGCAACCGAGATTTACTTTCGAAGGACTGTGATGAACCCGCG CCCTTTGAGCGCT"
  531. assert_equal(hseq, @exon.hseq)
  532. end
  533. def test_midline
  534. midline = "|||||||||||||-|||||||||||||||||||||||| |||||||||||||||||-|||||||||||||"
  535. assert_equal(midline, @exon.midline)
  536. end
  537. def test_percent_identity
  538. #assert_equal(95, @exon.percent_identity)
  539. assert_equal("95", @exon.percent_identity)
  540. end
  541. def test_qseq
  542. qseq = "ATATGTACTTAGCTGGCAACCGAGATTTACTTTCGAAGCACTGTGATGAACCCGCGGCCCTTTGAGCGCT"
  543. assert_equal(qseq, @exon.qseq)
  544. end
  545. def test_query_from
  546. assert_equal(73, @exon.query_from)
  547. end
  548. def test_query_to
  549. assert_equal(142, @exon.query_to)
  550. end
  551. def exec_test_seq1_from_to(seg)
  552. assert_equal(73, seg.from)
  553. assert_equal(142, seg.to)
  554. end
  555. private :exec_test_seq1_from_to
  556. def test_seq1
  557. assert_instance_of(Bio::Sim4::Report::Segment, @exon.seq1)
  558. assert_equal("ATATGTACTTAGCTGGCAACCGAGATTTACTTTCGAAGCACTGTGATGAACCCGCGGCCCTTTGAGCGCT",
  559. @exon.seq1.seq)
  560. exec_test_seq1_from_to(@exon.seq1)
  561. end
  562. def test_seq2
  563. assert_instance_of(Bio::Sim4::Report::Segment, @exon.seq2)
  564. assert_equal(563, @exon.seq2.from)
  565. assert_equal(630, @exon.seq2.to)
  566. assert_equal("ATATGTACTTAGC GGCAACCGAGATTTACTTTCGAAGGACTGTGATGAACCCGCG CCCTTTGAGCGCT",
  567. @exon.seq2.seq)
  568. end
  569. end #class TestSim4ReportSegmentPair4_exon
  570. class TestSim4ReportSegmentPair4_intron < TestSim4ReportSegmentPair_intron
  571. def setup
  572. @intron = TestDataForSim4Report.report4.hits[0].introns[0]
  573. end
  574. def test_hit_from
  575. assert_equal(425, @intron.hit_from)
  576. end
  577. def test_hit_to
  578. assert_equal(562, @intron.hit_to)
  579. end
  580. def test_hseq
  581. hseq = "GTT...GAT"
  582. assert_equal(hseq, @intron.hseq)
  583. end
  584. def test_midline
  585. midline = ">>>...>>>"
  586. assert_equal(midline, @intron.midline)
  587. end
  588. def test_seq2
  589. assert_instance_of(Bio::Sim4::Report::Segment, @intron.seq2)
  590. assert_equal(425, @intron.seq2.from)
  591. assert_equal(562, @intron.seq2.to)
  592. assert_equal("GTT...GAT", @intron.seq2.seq)
  593. end
  594. end #class TestSim4ReportSegmentPair4_intron
  595. class TestSim4ReportSegmentPair4_intron1 < Test::Unit::TestCase
  596. def setup
  597. @intron = TestDataForSim4Report.report4.hits[0].introns[1]
  598. end
  599. def test_align_len
  600. assert_equal(0, @intron.align_len)
  601. end
  602. def test_direction
  603. assert_equal(nil, @intron.direction)
  604. end
  605. def test_hit_from
  606. assert_equal(631, @intron.hit_from)
  607. end
  608. def test_hit_to
  609. assert_equal(699, @intron.hit_to)
  610. end
  611. def test_hseq
  612. assert_equal("", @intron.hseq)
  613. end
  614. def test_midline
  615. assert_equal("", @intron.midline)
  616. end
  617. def test_percent_identity
  618. assert_equal(nil, @intron.percent_identity)
  619. end
  620. def test_qseq
  621. assert_equal("", @intron.qseq)
  622. end
  623. def test_query_from
  624. assert_equal(143, @intron.query_from)
  625. end
  626. def test_query_to
  627. assert_equal(212, @intron.query_to)
  628. end
  629. def test_seq1
  630. assert_instance_of(Bio::Sim4::Report::Segment, @intron.seq1)
  631. assert_equal(143, @intron.seq1.from)
  632. assert_equal(212, @intron.seq1.to)
  633. assert_equal("", @intron.seq1.seq)
  634. end
  635. def test_seq2
  636. assert_instance_of(Bio::Sim4::Report::Segment, @intron.seq2)
  637. assert_equal(631, @intron.seq2.from)
  638. assert_equal(699, @intron.seq2.to)
  639. assert_equal("", @intron.seq2.seq)
  640. end
  641. end #class TestSim4ReportSegmentPair4_intron1
  642. class TestSim4ReportSeqDesc < Test::Unit::TestCase
  643. def setup
  644. @str1 = 'seq1 = c_NC_000011.5_101050001-101075000.fst, 25000 bp'
  645. @str2 = '>ref|NC_000011.5|NC_000011:c101075000-101050001 Homo sapiens chromosome 11, complete sequence'
  646. @seqdesc = Bio::Sim4::Report::SeqDesc.parse(@str1, @str2)
  647. end
  648. def test_entry_id
  649. assert_equal('ref|NC_000011.5|NC_000011:c101075000-101050001',
  650. @seqdesc.entry_id)
  651. end
  652. def test_definition
  653. assert_equal("ref|NC_000011.5|NC_000011:c101075000-101050001 Homo sapiens chromosome 11, complete sequence",
  654. @seqdesc.definition)
  655. end
  656. def test_len
  657. assert_equal(25000, @seqdesc.len)
  658. end
  659. def test_filename
  660. assert_equal('c_NC_000011.5_101050001-101075000.fst', @seqdesc.filename)
  661. end
  662. def test_self_parse
  663. assert_instance_of(Bio::Sim4::Report::SeqDesc,
  664. Bio::Sim4::Report::SeqDesc.parse(@str1, @str2))
  665. assert_instance_of(Bio::Sim4::Report::SeqDesc,
  666. Bio::Sim4::Report::SeqDesc.parse(@str1))
  667. end
  668. def test_self_new
  669. assert_instance_of(Bio::Sim4::Report::SeqDesc,
  670. Bio::Sim4::Report::SeqDesc.new('SEQID',
  671. 'SEQDEF',
  672. 123,
  673. 'file.sim4'))
  674. end
  675. end #class TestSim4ReportSeqDesc
  676. class TestSim4ReportSegment < Test::Unit::TestCase
  677. def setup
  678. @seq = "TCTACACATCACTAGCGTGGGTGGGCGGAAAGAGCAGCTCGCCACT CAAGCTAA".freeze
  679. @segment = Bio::Sim4::Report::Segment.new("123", "176", @seq.dup)
  680. end
  681. def test_from
  682. assert_equal(123, @segment.from)
  683. end
  684. def test_to
  685. assert_equal(176, @segment.to)
  686. end
  687. def test_seq
  688. assert_equal(@seq, @segment.seq)
  689. end
  690. def test_self_new
  691. assert_instance_of(Bio::Sim4::Report::Segment,
  692. Bio::Sim4::Report::Segment.new(1,9))
  693. assert_instance_of(Bio::Sim4::Report::Segment,
  694. Bio::Sim4::Report::Segment.new(2,4, "ATG"))
  695. end
  696. end #class TestSim4ReportSegment
  697. end #module Bio