bio 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/ChangeLog +2105 -3728
  2. data/KNOWN_ISSUES.rdoc +35 -3
  3. data/README.rdoc +8 -2
  4. data/RELEASE_NOTES.rdoc +166 -0
  5. data/bin/bioruby +4 -1
  6. data/bioruby.gemspec +146 -1
  7. data/bioruby.gemspec.erb +3 -1
  8. data/doc/ChangeLog-before-1.3.1 +3961 -0
  9. data/doc/Tutorial.rd +154 -22
  10. data/doc/Tutorial.rd.html +125 -68
  11. data/lib/bio.rb +21 -6
  12. data/lib/bio/appl/bl2seq/report.rb +11 -202
  13. data/lib/bio/appl/blast/format0.rb +0 -193
  14. data/lib/bio/appl/blast/report.rb +2 -147
  15. data/lib/bio/appl/blast/wublast.rb +0 -208
  16. data/lib/bio/appl/fasta.rb +4 -19
  17. data/lib/bio/appl/fasta/format10.rb +0 -14
  18. data/lib/bio/appl/genscan/report.rb +0 -176
  19. data/lib/bio/appl/hmmer.rb +1 -15
  20. data/lib/bio/appl/hmmer/report.rb +0 -100
  21. data/lib/bio/appl/meme/mast.rb +156 -0
  22. data/lib/bio/appl/meme/mast/report.rb +91 -0
  23. data/lib/bio/appl/meme/motif.rb +48 -0
  24. data/lib/bio/appl/psort.rb +0 -111
  25. data/lib/bio/appl/psort/report.rb +1 -45
  26. data/lib/bio/appl/pts1.rb +2 -4
  27. data/lib/bio/appl/sosui/report.rb +5 -54
  28. data/lib/bio/appl/targetp/report.rb +1 -104
  29. data/lib/bio/appl/tmhmm/report.rb +0 -36
  30. data/lib/bio/command.rb +94 -10
  31. data/lib/bio/data/aa.rb +1 -77
  32. data/lib/bio/data/codontable.rb +1 -95
  33. data/lib/bio/data/na.rb +1 -26
  34. data/lib/bio/db/aaindex.rb +1 -38
  35. data/lib/bio/db/fasta.rb +1 -134
  36. data/lib/bio/db/fasta/format_qual.rb +204 -0
  37. data/lib/bio/db/fasta/qual.rb +102 -0
  38. data/lib/bio/db/fastq.rb +645 -0
  39. data/lib/bio/db/fastq/fastq_to_biosequence.rb +40 -0
  40. data/lib/bio/db/fastq/format_fastq.rb +175 -0
  41. data/lib/bio/db/genbank/genbank.rb +1 -86
  42. data/lib/bio/db/gff.rb +0 -17
  43. data/lib/bio/db/go.rb +4 -72
  44. data/lib/bio/db/kegg/common.rb +112 -0
  45. data/lib/bio/db/kegg/compound.rb +29 -20
  46. data/lib/bio/db/kegg/drug.rb +74 -34
  47. data/lib/bio/db/kegg/enzyme.rb +26 -5
  48. data/lib/bio/db/kegg/genes.rb +128 -15
  49. data/lib/bio/db/kegg/genome.rb +3 -41
  50. data/lib/bio/db/kegg/glycan.rb +19 -24
  51. data/lib/bio/db/kegg/orthology.rb +16 -56
  52. data/lib/bio/db/kegg/reaction.rb +81 -28
  53. data/lib/bio/db/kegg/taxonomy.rb +1 -52
  54. data/lib/bio/db/litdb.rb +1 -16
  55. data/lib/bio/db/phyloxml/phyloxml.xsd +582 -0
  56. data/lib/bio/db/phyloxml/phyloxml_elements.rb +1174 -0
  57. data/lib/bio/db/phyloxml/phyloxml_parser.rb +954 -0
  58. data/lib/bio/db/phyloxml/phyloxml_writer.rb +228 -0
  59. data/lib/bio/db/prosite.rb +2 -95
  60. data/lib/bio/db/rebase.rb +5 -6
  61. data/lib/bio/db/sanger_chromatogram/abif.rb +120 -0
  62. data/lib/bio/db/sanger_chromatogram/chromatogram.rb +133 -0
  63. data/lib/bio/db/sanger_chromatogram/chromatogram_to_biosequence.rb +32 -0
  64. data/lib/bio/db/sanger_chromatogram/scf.rb +210 -0
  65. data/lib/bio/io/das.rb +0 -44
  66. data/lib/bio/io/ddbjxml.rb +1 -181
  67. data/lib/bio/io/flatfile.rb +1 -7
  68. data/lib/bio/io/flatfile/autodetection.rb +6 -0
  69. data/lib/bio/io/keggapi.rb +0 -442
  70. data/lib/bio/io/ncbirest.rb +130 -132
  71. data/lib/bio/io/ncbisoap.rb +2 -1
  72. data/lib/bio/io/pubmed.rb +0 -88
  73. data/lib/bio/location.rb +0 -73
  74. data/lib/bio/pathway.rb +0 -171
  75. data/lib/bio/sequence.rb +18 -1
  76. data/lib/bio/sequence/adapter.rb +3 -0
  77. data/lib/bio/sequence/format.rb +16 -0
  78. data/lib/bio/sequence/quality_score.rb +205 -0
  79. data/lib/bio/tree.rb +70 -5
  80. data/lib/bio/util/restriction_enzyme/single_strand.rb +3 -2
  81. data/lib/bio/util/sirna.rb +1 -23
  82. data/lib/bio/version.rb +1 -1
  83. data/sample/demo_aaindex.rb +67 -0
  84. data/sample/demo_aminoacid.rb +101 -0
  85. data/sample/demo_bl2seq_report.rb +220 -0
  86. data/sample/demo_blast_report.rb +285 -0
  87. data/sample/demo_codontable.rb +119 -0
  88. data/sample/demo_das.rb +105 -0
  89. data/sample/demo_ddbjxml.rb +212 -0
  90. data/sample/demo_fasta_remote.rb +51 -0
  91. data/sample/demo_fastaformat.rb +105 -0
  92. data/sample/demo_genbank.rb +132 -0
  93. data/sample/demo_genscan_report.rb +202 -0
  94. data/sample/demo_gff1.rb +49 -0
  95. data/sample/demo_go.rb +98 -0
  96. data/sample/demo_hmmer_report.rb +149 -0
  97. data/sample/demo_kegg_compound.rb +57 -0
  98. data/sample/demo_kegg_drug.rb +65 -0
  99. data/sample/demo_kegg_genome.rb +74 -0
  100. data/sample/demo_kegg_glycan.rb +72 -0
  101. data/sample/demo_kegg_orthology.rb +62 -0
  102. data/sample/demo_kegg_reaction.rb +66 -0
  103. data/sample/demo_kegg_taxonomy.rb +92 -0
  104. data/sample/demo_keggapi.rb +502 -0
  105. data/sample/demo_litdb.rb +42 -0
  106. data/sample/demo_locations.rb +99 -0
  107. data/sample/demo_ncbi_rest.rb +130 -0
  108. data/sample/demo_nucleicacid.rb +49 -0
  109. data/sample/demo_pathway.rb +196 -0
  110. data/sample/demo_prosite.rb +120 -0
  111. data/sample/demo_psort.rb +138 -0
  112. data/sample/demo_psort_report.rb +70 -0
  113. data/sample/demo_pubmed.rb +118 -0
  114. data/sample/demo_sirna.rb +63 -0
  115. data/sample/demo_sosui_report.rb +89 -0
  116. data/sample/demo_targetp_report.rb +135 -0
  117. data/sample/demo_tmhmm_report.rb +68 -0
  118. data/sample/pmfetch.rb +13 -4
  119. data/sample/pmsearch.rb +15 -4
  120. data/sample/test_phyloxml_big.rb +205 -0
  121. data/test/bioruby_test_helper.rb +61 -0
  122. data/test/data/KEGG/1.1.1.1.enzyme +935 -0
  123. data/test/data/KEGG/C00025.compound +102 -0
  124. data/test/data/KEGG/D00063.drug +104 -0
  125. data/test/data/KEGG/G00024.glycan +47 -0
  126. data/test/data/KEGG/G01366.glycan +18 -0
  127. data/test/data/KEGG/K02338.orthology +902 -0
  128. data/test/data/KEGG/R00006.reaction +14 -0
  129. data/test/data/fastq/README.txt +109 -0
  130. data/test/data/fastq/error_diff_ids.fastq +20 -0
  131. data/test/data/fastq/error_double_qual.fastq +22 -0
  132. data/test/data/fastq/error_double_seq.fastq +22 -0
  133. data/test/data/fastq/error_long_qual.fastq +20 -0
  134. data/test/data/fastq/error_no_qual.fastq +20 -0
  135. data/test/data/fastq/error_qual_del.fastq +20 -0
  136. data/test/data/fastq/error_qual_escape.fastq +20 -0
  137. data/test/data/fastq/error_qual_null.fastq +0 -0
  138. data/test/data/fastq/error_qual_space.fastq +21 -0
  139. data/test/data/fastq/error_qual_tab.fastq +21 -0
  140. data/test/data/fastq/error_qual_unit_sep.fastq +20 -0
  141. data/test/data/fastq/error_qual_vtab.fastq +20 -0
  142. data/test/data/fastq/error_short_qual.fastq +20 -0
  143. data/test/data/fastq/error_spaces.fastq +20 -0
  144. data/test/data/fastq/error_tabs.fastq +21 -0
  145. data/test/data/fastq/error_trunc_at_plus.fastq +19 -0
  146. data/test/data/fastq/error_trunc_at_qual.fastq +19 -0
  147. data/test/data/fastq/error_trunc_at_seq.fastq +18 -0
  148. data/test/data/fastq/error_trunc_in_plus.fastq +19 -0
  149. data/test/data/fastq/error_trunc_in_qual.fastq +20 -0
  150. data/test/data/fastq/error_trunc_in_seq.fastq +18 -0
  151. data/test/data/fastq/error_trunc_in_title.fastq +17 -0
  152. data/test/data/fastq/illumina_full_range_as_illumina.fastq +8 -0
  153. data/test/data/fastq/illumina_full_range_as_sanger.fastq +8 -0
  154. data/test/data/fastq/illumina_full_range_as_solexa.fastq +8 -0
  155. data/test/data/fastq/illumina_full_range_original_illumina.fastq +8 -0
  156. data/test/data/fastq/longreads_as_illumina.fastq +40 -0
  157. data/test/data/fastq/longreads_as_sanger.fastq +40 -0
  158. data/test/data/fastq/longreads_as_solexa.fastq +40 -0
  159. data/test/data/fastq/longreads_original_sanger.fastq +120 -0
  160. data/test/data/fastq/misc_dna_as_illumina.fastq +16 -0
  161. data/test/data/fastq/misc_dna_as_sanger.fastq +16 -0
  162. data/test/data/fastq/misc_dna_as_solexa.fastq +16 -0
  163. data/test/data/fastq/misc_dna_original_sanger.fastq +16 -0
  164. data/test/data/fastq/misc_rna_as_illumina.fastq +16 -0
  165. data/test/data/fastq/misc_rna_as_sanger.fastq +16 -0
  166. data/test/data/fastq/misc_rna_as_solexa.fastq +16 -0
  167. data/test/data/fastq/misc_rna_original_sanger.fastq +16 -0
  168. data/test/data/fastq/sanger_full_range_as_illumina.fastq +8 -0
  169. data/test/data/fastq/sanger_full_range_as_sanger.fastq +8 -0
  170. data/test/data/fastq/sanger_full_range_as_solexa.fastq +8 -0
  171. data/test/data/fastq/sanger_full_range_original_sanger.fastq +8 -0
  172. data/test/data/fastq/solexa_full_range_as_illumina.fastq +8 -0
  173. data/test/data/fastq/solexa_full_range_as_sanger.fastq +8 -0
  174. data/test/data/fastq/solexa_full_range_as_solexa.fastq +8 -0
  175. data/test/data/fastq/solexa_full_range_original_solexa.fastq +8 -0
  176. data/test/data/fastq/wrapping_as_illumina.fastq +12 -0
  177. data/test/data/fastq/wrapping_as_sanger.fastq +12 -0
  178. data/test/data/fastq/wrapping_as_solexa.fastq +12 -0
  179. data/test/data/fastq/wrapping_original_sanger.fastq +24 -0
  180. data/test/data/meme/db +0 -0
  181. data/test/data/meme/mast +0 -0
  182. data/test/data/meme/mast.out +13 -0
  183. data/test/data/meme/meme.out +3 -0
  184. data/test/data/phyloxml/apaf.xml +666 -0
  185. data/test/data/phyloxml/bcl_2.xml +2097 -0
  186. data/test/data/phyloxml/made_up.xml +144 -0
  187. data/test/data/phyloxml/ncbi_taxonomy_mollusca_short.xml +65 -0
  188. data/test/data/phyloxml/phyloxml_examples.xml +415 -0
  189. data/test/data/sanger_chromatogram/test_chromatogram_abif.ab1 +0 -0
  190. data/test/data/sanger_chromatogram/test_chromatogram_scf_v2.scf +0 -0
  191. data/test/data/sanger_chromatogram/test_chromatogram_scf_v3.scf +0 -0
  192. data/test/functional/bio/appl/test_pts1.rb +7 -5
  193. data/test/functional/bio/io/test_ensembl.rb +4 -3
  194. data/test/functional/bio/io/test_pubmed.rb +9 -3
  195. data/test/functional/bio/io/test_soapwsdl.rb +5 -4
  196. data/test/functional/bio/io/test_togows.rb +5 -4
  197. data/test/functional/bio/sequence/test_output_embl.rb +6 -4
  198. data/test/functional/bio/test_command.rb +54 -5
  199. data/test/runner.rb +5 -3
  200. data/test/unit/bio/appl/bl2seq/test_report.rb +5 -4
  201. data/test/unit/bio/appl/blast/test_ncbioptions.rb +4 -2
  202. data/test/unit/bio/appl/blast/test_report.rb +5 -4
  203. data/test/unit/bio/appl/blast/test_rpsblast.rb +5 -4
  204. data/test/unit/bio/appl/gcg/test_msf.rb +5 -5
  205. data/test/unit/bio/appl/genscan/test_report.rb +8 -9
  206. data/test/unit/bio/appl/hmmer/test_report.rb +5 -4
  207. data/test/unit/bio/appl/iprscan/test_report.rb +6 -5
  208. data/test/unit/bio/appl/mafft/test_report.rb +6 -5
  209. data/test/unit/bio/appl/meme/mast/test_report.rb +46 -0
  210. data/test/unit/bio/appl/meme/test_mast.rb +103 -0
  211. data/test/unit/bio/appl/meme/test_motif.rb +38 -0
  212. data/test/unit/bio/appl/paml/codeml/test_rates.rb +5 -4
  213. data/test/unit/bio/appl/paml/codeml/test_report.rb +5 -4
  214. data/test/unit/bio/appl/paml/test_codeml.rb +5 -4
  215. data/test/unit/bio/appl/sim4/test_report.rb +5 -4
  216. data/test/unit/bio/appl/sosui/test_report.rb +6 -5
  217. data/test/unit/bio/appl/targetp/test_report.rb +5 -3
  218. data/test/unit/bio/appl/test_blast.rb +5 -4
  219. data/test/unit/bio/appl/test_fasta.rb +4 -2
  220. data/test/unit/bio/appl/test_pts1.rb +4 -2
  221. data/test/unit/bio/appl/tmhmm/test_report.rb +6 -5
  222. data/test/unit/bio/data/test_aa.rb +5 -3
  223. data/test/unit/bio/data/test_codontable.rb +5 -4
  224. data/test/unit/bio/data/test_na.rb +5 -3
  225. data/test/unit/bio/db/biosql/tc_biosql.rb +5 -1
  226. data/test/unit/bio/db/embl/test_common.rb +4 -2
  227. data/test/unit/bio/db/embl/test_embl.rb +6 -6
  228. data/test/unit/bio/db/embl/test_embl_rel89.rb +6 -6
  229. data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +7 -8
  230. data/test/unit/bio/db/embl/test_sptr.rb +6 -8
  231. data/test/unit/bio/db/embl/test_uniprot.rb +6 -5
  232. data/test/unit/bio/db/fasta/test_format_qual.rb +346 -0
  233. data/test/unit/bio/db/kegg/test_compound.rb +146 -0
  234. data/test/unit/bio/db/kegg/test_drug.rb +194 -0
  235. data/test/unit/bio/db/kegg/test_enzyme.rb +241 -0
  236. data/test/unit/bio/db/kegg/test_genes.rb +32 -4
  237. data/test/unit/bio/db/kegg/test_glycan.rb +260 -0
  238. data/test/unit/bio/db/kegg/test_orthology.rb +50 -0
  239. data/test/unit/bio/db/kegg/test_reaction.rb +96 -0
  240. data/test/unit/bio/db/pdb/test_pdb.rb +4 -2
  241. data/test/unit/bio/db/sanger_chromatogram/test_abif.rb +76 -0
  242. data/test/unit/bio/db/sanger_chromatogram/test_scf.rb +98 -0
  243. data/test/unit/bio/db/test_aaindex.rb +6 -6
  244. data/test/unit/bio/db/test_fasta.rb +5 -46
  245. data/test/unit/bio/db/test_fastq.rb +829 -0
  246. data/test/unit/bio/db/test_gff.rb +4 -2
  247. data/test/unit/bio/db/test_lasergene.rb +7 -5
  248. data/test/unit/bio/db/test_medline.rb +4 -2
  249. data/test/unit/bio/db/test_newick.rb +6 -6
  250. data/test/unit/bio/db/test_nexus.rb +4 -2
  251. data/test/unit/bio/db/test_phyloxml.rb +769 -0
  252. data/test/unit/bio/db/test_phyloxml_writer.rb +328 -0
  253. data/test/unit/bio/db/test_prosite.rb +6 -5
  254. data/test/unit/bio/db/test_qual.rb +63 -0
  255. data/test/unit/bio/db/test_rebase.rb +5 -3
  256. data/test/unit/bio/db/test_soft.rb +7 -6
  257. data/test/unit/bio/io/flatfile/test_autodetection.rb +6 -7
  258. data/test/unit/bio/io/flatfile/test_buffer.rb +6 -5
  259. data/test/unit/bio/io/flatfile/test_splitter.rb +4 -4
  260. data/test/unit/bio/io/test_ddbjxml.rb +4 -3
  261. data/test/unit/bio/io/test_ensembl.rb +5 -3
  262. data/test/unit/bio/io/test_fastacmd.rb +4 -3
  263. data/test/unit/bio/io/test_flatfile.rb +6 -5
  264. data/test/unit/bio/io/test_soapwsdl.rb +4 -3
  265. data/test/unit/bio/io/test_togows.rb +4 -2
  266. data/test/unit/bio/sequence/test_aa.rb +5 -3
  267. data/test/unit/bio/sequence/test_common.rb +4 -2
  268. data/test/unit/bio/sequence/test_compat.rb +4 -2
  269. data/test/unit/bio/sequence/test_dblink.rb +5 -3
  270. data/test/unit/bio/sequence/test_na.rb +4 -2
  271. data/test/unit/bio/sequence/test_quality_score.rb +330 -0
  272. data/test/unit/bio/shell/plugin/test_seq.rb +5 -3
  273. data/test/unit/bio/test_alignment.rb +5 -3
  274. data/test/unit/bio/test_command.rb +4 -3
  275. data/test/unit/bio/test_db.rb +5 -3
  276. data/test/unit/bio/test_feature.rb +4 -2
  277. data/test/unit/bio/test_location.rb +4 -2
  278. data/test/unit/bio/test_map.rb +5 -3
  279. data/test/unit/bio/test_pathway.rb +4 -2
  280. data/test/unit/bio/test_reference.rb +4 -2
  281. data/test/unit/bio/test_sequence.rb +5 -3
  282. data/test/unit/bio/test_shell.rb +5 -3
  283. data/test/unit/bio/test_tree.rb +6 -6
  284. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +4 -2
  285. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +4 -2
  286. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +4 -2
  287. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +4 -2
  288. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +4 -2
  289. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +4 -2
  290. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +4 -2
  291. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +4 -2
  292. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +4 -2
  293. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +4 -2
  294. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +4 -2
  295. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +4 -2
  296. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +17 -13
  297. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +17 -13
  298. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +4 -2
  299. data/test/unit/bio/util/test_color_scheme.rb +5 -3
  300. data/test/unit/bio/util/test_contingency_table.rb +5 -3
  301. data/test/unit/bio/util/test_restriction_enzyme.rb +4 -2
  302. data/test/unit/bio/util/test_sirna.rb +6 -4
  303. metadata +147 -2
@@ -9,10 +9,12 @@
9
9
  # $Id:$
10
10
  #
11
11
 
12
+ # loading helper routine for testing bioruby
12
13
  require 'pathname'
13
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
14
- $:.unshift(libpath) unless $:.include?(libpath)
14
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
15
+ 'bioruby_test_helper.rb')).cleanpath.to_s
15
16
 
17
+ # libraries needed for the tests
16
18
  require 'test/unit'
17
19
  require 'digest/sha1'
18
20
  require 'bio/db/gff'
@@ -1,19 +1,21 @@
1
1
  #
2
- # test/unit/bio/db/test_rebase.rb - Unit test for Bio::Lasergene
2
+ # test/unit/bio/db/test_lasergene.rb - Unit test for Bio::Lasergene
3
3
  #
4
4
  # Author:: Trevor Wennblom <mailto:trevor@corevx.com>
5
5
  # Copyright:: Copyright (c) 2007 Center for Biomedical Research Informatics, University of Minnesota (http://cbri.umn.edu)
6
6
  # License:: The Ruby License
7
7
  #
8
- # $Id: test_lasergene.rb,v 1.2 2007/04/05 23:35:43 trevor Exp $
8
+ # $Id:$
9
9
  #
10
10
 
11
+ # loading helper routine for testing bioruby
11
12
  require 'pathname'
12
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
13
- $:.unshift(libpath) unless $:.include?(libpath)
13
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
14
+ 'bioruby_test_helper.rb')).cleanpath.to_s
14
15
 
16
+ # libraries needed for the tests
15
17
  require 'test/unit'
16
- require 'bio'
18
+ require 'bio/sequence'
17
19
  require 'bio/db/lasergene'
18
20
 
19
21
  module Bio #:nodoc:
@@ -5,10 +5,12 @@
5
5
  # License:: The Ruby License
6
6
  #
7
7
 
8
+ # loading helper routine for testing bioruby
8
9
  require 'pathname'
9
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
10
- $:.unshift(libpath) unless $:.include?(libpath)
10
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
11
+ 'bioruby_test_helper.rb')).cleanpath.to_s
11
12
 
13
+ # libraries needed for the tests
12
14
  require 'test/unit'
13
15
  require 'bio/db/medline'
14
16
 
@@ -6,16 +6,16 @@
6
6
  # Naohisa Goto <ng@bioruby.org>
7
7
  # License:: The Ruby License
8
8
  #
9
- # $Id: test_newick.rb,v 1.6 2007/12/12 16:06:22 ngoto Exp $
9
+ # $Id:$
10
10
  #
11
11
 
12
- require 'test/unit'
13
-
12
+ # loading helper routine for testing bioruby
14
13
  require 'pathname'
15
- libpath = Pathname.new(File.join(File.dirname(__FILE__), [".."] * 4, "lib")).cleanpath.to_s
16
- $:.unshift(libpath) unless $:.include?(libpath)
14
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
15
+ 'bioruby_test_helper.rb')).cleanpath.to_s
17
16
 
18
- require 'bio'
17
+ # libraries needed for the tests
18
+ require 'test/unit'
19
19
  require 'bio/tree'
20
20
  require 'bio/db/newick'
21
21
 
@@ -12,10 +12,12 @@
12
12
  # This file contains unit tests for Bio::Nexus.
13
13
  #
14
14
 
15
+ # loading helper routine for testing bioruby
15
16
  require 'pathname'
16
- libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
17
- $:.unshift(libpath) unless $:.include?(libpath)
17
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
18
+ 'bioruby_test_helper.rb')).cleanpath.to_s
18
19
 
20
+ # libraries needed for the tests
19
21
  require 'test/unit'
20
22
  require 'bio/db/nexus'
21
23
 
@@ -0,0 +1,769 @@
1
+ #
2
+ # = test/unit/bio/db/test_phyloxml.rb - Unit test for Bio::PhyloXML::Parser
3
+ #
4
+ # Copyright:: Copyright (C) 2009
5
+ # Diana Jaunzeikare <latvianlinuxgirl@gmail.com>
6
+ # License:: The Ruby License
7
+ #
8
+
9
+ # loading helper routine for testing bioruby
10
+ require 'pathname'
11
+ load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
12
+ 'bioruby_test_helper.rb')).cleanpath.to_s
13
+
14
+ # libraries needed for the tests
15
+ require 'test/unit'
16
+
17
+ begin
18
+ require 'libxml'
19
+ rescue LoadError
20
+ end
21
+
22
+ if defined?(LibXML) then
23
+ require 'bio/db/phyloxml/phyloxml_parser'
24
+ end
25
+
26
+ module Bio
27
+ class TestPhyloXML_Check_LibXML < Test::Unit::TestCase
28
+ def test_libxml
29
+ assert(defined?(LibXML),
30
+ "Error: libxml-ruby library is not present. Please install libxml-ruby library. It is needed for Bio::PhyloXML module. Unit test for PhyloXML will not be performed.")
31
+ end
32
+ end #class TestPhyloXML_LibXMLCheck
33
+ end #module Bio
34
+
35
+ module Bio
36
+
37
+ module TestPhyloXMLData
38
+
39
+ PHYLOXML_TEST_DATA = Pathname.new(File.join(BioRubyTestDataPath, 'phyloxml')).cleanpath.to_s
40
+
41
+ def self.example_xml
42
+ File.join PHYLOXML_TEST_DATA, 'phyloxml_examples.xml'
43
+ #If you want to test the output of writer, then do this:
44
+ #File.join PHYLOXML_TEST_DATA, 'phyloxml_examples_test.xml'
45
+ # But make sure you run ruby test/unit/bio/db/test_phyloxml_writer.rb before
46
+ end
47
+
48
+ def self.made_up_xml
49
+ File.join PHYLOXML_TEST_DATA, 'made_up.xml'
50
+ #If you want to test the output of writer, then do this:
51
+ #File.join PHYLOXML_TEST_DATA, 'made_up_test.xml'
52
+ # But make sure you run ruby test/unit/bio/db/test_phyloxml_writer.rb before
53
+ end
54
+
55
+ def self.metazoa_xml
56
+ File.join PHYLOXML_TEST_DATA, 'ncbi_taxonomy_metazoa.xml'
57
+ end
58
+
59
+ def self.mollusca_xml
60
+ File.join PHYLOXML_TEST_DATA, 'ncbi_taxonomy_mollusca.xml'
61
+ end
62
+
63
+ def self.life_xml
64
+ File.join PHYLOXML_TEST_DATA, 'tol_life_on_earth_1.xml'
65
+ end
66
+
67
+ def self.dollo_xml
68
+ File.join PHYLOXML_TEST_DATA, 'o_tol_332_d_dollo.xml'
69
+ end
70
+
71
+ def self.mollusca_short_xml
72
+ File.join PHYLOXML_TEST_DATA, 'ncbi_taxonomy_mollusca_short.xml'
73
+ end
74
+
75
+ end #end module TestPhyloXMLData
76
+
77
+
78
+
79
+ class TestPhyloXML_class_methods < Test::Unit::TestCase
80
+
81
+ def test_open
82
+ filename = TestPhyloXMLData.example_xml
83
+ assert_instance_of(Bio::PhyloXML::Parser,
84
+ phyloxml = Bio::PhyloXML::Parser.open(filename))
85
+ common_test_next_tree(phyloxml)
86
+ end
87
+
88
+ def test_new
89
+ str = File.read(TestPhyloXMLData.example_xml)
90
+ assert_instance_of(Bio::PhyloXML::Parser,
91
+ phyloxml = Bio::PhyloXML::Parser.new(str))
92
+ common_test_next_tree(phyloxml)
93
+ end
94
+
95
+ def test_for_io
96
+ io = File.open(TestPhyloXMLData.example_xml)
97
+ assert_instance_of(Bio::PhyloXML::Parser,
98
+ phyloxml = Bio::PhyloXML::Parser.for_io(io))
99
+ common_test_next_tree(phyloxml)
100
+ io.close
101
+ end
102
+
103
+ def common_test_next_tree(phyloxml)
104
+ tree = phyloxml.next_tree
105
+ tree_arr = []
106
+ while tree != nil do
107
+ tree_arr[tree_arr.length] = tree.name
108
+ tree = phyloxml.next_tree
109
+ end
110
+ assert_equal(13, tree_arr.length)
111
+ end
112
+ private :common_test_next_tree
113
+
114
+ end #class TestPhyloXML_class_methods
115
+
116
+
117
+
118
+ class TestPhyloXML_private_methods < Test::Unit::TestCase
119
+ def setup
120
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
121
+ end
122
+
123
+ def teardown
124
+ @phyloxml.close
125
+ end
126
+
127
+ def test__validate
128
+ assert_nothing_raised {
129
+ @phyloxml.instance_eval {
130
+ _validate(:file, TestPhyloXMLData.example_xml)
131
+ }
132
+ }
133
+ end
134
+
135
+ def test__validate_string
136
+ assert_nothing_raised {
137
+ @phyloxml.instance_eval {
138
+ _validate(:string, '<?xml version="1.0"?><phyloxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.phyloxml.org http://www.phyloxml.org/1.10/phyloxml.xsd" xmlns="http://www.phyloxml.org"/>')
139
+ }
140
+ }
141
+ end
142
+
143
+ def test__validate_validation_error
144
+ libxml_set_handler_quiet
145
+ assert_raise(RuntimeError) {
146
+ @phyloxml.instance_eval {
147
+ _validate(:string, '<a>test</a>')
148
+ }
149
+ }
150
+ libxml_set_handler_verbose
151
+ end
152
+
153
+ def test__schema
154
+ s = @phyloxml.instance_eval { _schema }
155
+ assert_instance_of(LibXML::XML::Schema, s)
156
+ end
157
+
158
+ def test__secure_filename
159
+ assert_equal('http:/bioruby.org/test.xml',
160
+ @phyloxml.instance_eval {
161
+ _secure_filename('http://bioruby.org/test.xml')
162
+ })
163
+ end
164
+
165
+ def test__secure_filename_unchanged
166
+ assert_equal('test/test.xml',
167
+ @phyloxml.instance_eval {
168
+ _secure_filename('test/test.xml')
169
+ })
170
+ end
171
+
172
+ def test_ClosedPhyloXMLParser
173
+ cp = Bio::PhyloXML::Parser::ClosedPhyloXMLParser.new
174
+ assert_raise(LibXML::XML::Error) { cp.next_tree }
175
+ end
176
+
177
+ private
178
+
179
+ def libxml_set_handler_quiet
180
+ # Sets quiet handler.
181
+ # Note that there are no way to get current handler.
182
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
183
+ end
184
+
185
+ def libxml_set_handler_verbose
186
+ # Sets verbose handler (default LibXML error handler).
187
+ # Note that there are no way to get current handler.
188
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
189
+ end
190
+ end #class TestPhyloXML_private_methods
191
+
192
+
193
+
194
+ class TestPhyloXML_close < Test::Unit::TestCase
195
+ def phyloxml_open
196
+ Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
197
+ end
198
+ private :phyloxml_open
199
+
200
+ def test_close
201
+ phyloxml = phyloxml_open
202
+ phyloxml.next_tree
203
+ assert_nil(phyloxml.close)
204
+ end
205
+
206
+ def test_close_after_close
207
+ phyloxml = phyloxml_open
208
+ phyloxml.close
209
+ assert_raise(LibXML::XML::Error) { phyloxml.close }
210
+ end
211
+
212
+ def test_next_tree_after_close
213
+ phyloxml = phyloxml_open
214
+ phyloxml.close
215
+ assert_raise(LibXML::XML::Error) { phyloxml.next_tree }
216
+ end
217
+
218
+ def test_close_does_not_affect_io
219
+ io = File.open(TestPhyloXMLData.example_xml)
220
+ phyloxml = Bio::PhyloXML::Parser.for_io(io)
221
+ phyloxml.next_tree
222
+ phyloxml.close
223
+ assert(!io.closed?)
224
+ end
225
+ end #class TestPhyloXML_close
226
+
227
+
228
+
229
+ class TestPhyloXML1 < Test::Unit::TestCase
230
+
231
+ def setup
232
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
233
+ end
234
+
235
+ def teardown
236
+ @phyloxml.close
237
+ end
238
+
239
+ def test_initialize
240
+ assert_instance_of(Bio::PhyloXML::Parser, @phyloxml)
241
+ end
242
+
243
+ def test_next_tree()
244
+ tree = @phyloxml.next_tree
245
+ tree_arr = []
246
+ while tree != nil do
247
+
248
+ tree_arr[tree_arr.length] = tree.name
249
+ tree = @phyloxml.next_tree
250
+ end
251
+ assert_equal(13, tree_arr.length)
252
+ end
253
+
254
+ end #class TestPhyloXML1
255
+
256
+
257
+
258
+ class TestPhyloXML2 < Test::Unit::TestCase
259
+
260
+ #setup is called before and every time any function es executed.
261
+ def setup
262
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
263
+ @tree = @phyloxml.next_tree
264
+ end
265
+
266
+ def test_tree_name
267
+ assert_equal("example from Prof. Joe Felsenstein's book \"Inferring Phylogenies\"", @tree.name)
268
+ end
269
+
270
+ def test_tree_description
271
+ assert_equal("phyloXML allows to use either a \"branch_length\" attribute or element to indicate branch lengths.", @tree.description)
272
+ end
273
+
274
+ def test_branch_length_attribute
275
+ assert_equal(0.792, @tree.total_distance)
276
+ end
277
+
278
+ def test_rooted_atr
279
+ assert_equal(true, @tree.rooted)
280
+ end
281
+
282
+
283
+ def test_branch_length_tag
284
+ @tree = @phyloxml.next_tree
285
+ assert_equal(0.792, @tree.total_distance)
286
+ end
287
+
288
+ def test_bootstrap
289
+ #iterate throuch first 2 trees to get to the third
290
+ @tree = @phyloxml.next_tree
291
+ @tree = @phyloxml.next_tree
292
+ node = @tree.get_node_by_name("AB")
293
+ assert_equal('bootstrap', node.confidences[0].type)
294
+ assert_equal(89, node.confidences[0].value)
295
+ end
296
+
297
+ def test_to_biotreenode_bootstrap
298
+ #iterate throuch first 2 trees to get to the third
299
+ @tree = @phyloxml.next_tree
300
+ @tree = @phyloxml.next_tree
301
+ node = @tree.get_node_by_name("AB")
302
+ bionode = node.to_biotreenode
303
+ assert_equal(89, bionode.bootstrap)
304
+ end
305
+
306
+ def test_duplications
307
+ 4.times do
308
+ @tree = @phyloxml.next_tree
309
+ end
310
+ node = @tree.root
311
+ assert_equal(1, node.events.speciations)
312
+ end
313
+
314
+ def test_taxonomy_scientific_name
315
+ 3.times do
316
+ @tree = @phyloxml.next_tree
317
+ end
318
+ t = @tree.get_node_by_name('A').taxonomies[0]
319
+ assert_equal('E. coli', t.scientific_name)
320
+ assert_equal("J. G. Cooper, 1863", t.authority)
321
+ t = @tree.get_node_by_name('C').taxonomies[0]
322
+ assert_equal('C. elegans', t.scientific_name)
323
+ end
324
+
325
+ def test_taxonomy_id
326
+ 5.times do
327
+ @tree = @phyloxml.next_tree
328
+ end
329
+ leaves = @tree.leaves
330
+ codes = []
331
+ ids = []
332
+ #id_types = []
333
+ leaves.each { |node|
334
+ codes[codes.length] = node.taxonomies[0].code
335
+ ids[ids.length] = node.taxonomies[0].taxonomy_id
336
+ #id_types[id_types.length] = node.taxonomy.id_type
337
+ }
338
+ assert_equal(["CLOAB", "DICDI", "OCTVU"], codes.sort)
339
+ #@todo assert ids, id_types. or create new class for id.
340
+ end
341
+
342
+ def test_taxonomy2
343
+ 9.times do
344
+ @tree = @phyloxml.next_tree
345
+ end
346
+ taxonomy = @tree.root.taxonomies[0]
347
+ assert_equal("8556", taxonomy.taxonomy_id.value)
348
+ assert_equal("NCBI", taxonomy.taxonomy_id.provider)
349
+ assert_equal("Varanus", taxonomy.scientific_name)
350
+ assert_equal("genus", taxonomy.rank)
351
+ assert_equal("EMBL REPTILE DATABASE", taxonomy.uri.desc)
352
+ assert_equal("http://www.embl-heidelberg.de/~uetz/families/Varanidae.html", taxonomy.uri.uri)
353
+ end
354
+
355
+ def test_distribution_desc
356
+ 9.times do
357
+ @tree = @phyloxml.next_tree
358
+ end
359
+ leaves = @tree.leaves
360
+ descrs = []
361
+ leaves.each { |node|
362
+ descrs << node.distributions[0].desc
363
+ }
364
+ assert_equal(['Africa', 'Asia', 'Australia'], descrs.sort)
365
+ end
366
+
367
+ def test_distribution_point
368
+ 10.times do
369
+ @tree = @phyloxml.next_tree
370
+ end
371
+ point = @tree.get_node_by_name('A').distributions[0].points[0]
372
+ assert_equal("WGS84", point.geodetic_datum)
373
+ assert_equal(47.481277, point.lat)
374
+ assert_equal(8.769303, point.long)
375
+ assert_equal(472, point.alt)
376
+
377
+ point = @tree.get_node_by_name('B').distributions[0].points[0]
378
+ assert_equal("WGS84", point.geodetic_datum)
379
+ assert_equal(35.155904, point.lat)
380
+ assert_equal(136.915863, point.long)
381
+ assert_equal(10, point.alt)
382
+ end
383
+
384
+ def test_sequence
385
+ 3.times do
386
+ @tree = @phyloxml.next_tree
387
+ end
388
+ sequence_a = @tree.get_node_by_name('A').sequences[0]
389
+ assert_equal('alcohol dehydrogenase', sequence_a.annotations[0].desc)
390
+ assert_equal("probability", sequence_a.annotations[0].confidence.type)
391
+ assert_equal(0.99, sequence_a.annotations[0].confidence.value)
392
+ sequence_b = @tree.get_node_by_name('B').sequences[0]
393
+ assert_equal('alcohol dehydrogenase', sequence_b.annotations[0].desc)
394
+ assert_equal("probability", sequence_b.annotations[0].confidence.type)
395
+ assert_equal(0.91, sequence_b.annotations[0].confidence.value)
396
+ sequence_c = @tree.get_node_by_name('C').sequences[0]
397
+ assert_equal('alcohol dehydrogenase', sequence_c.annotations[0].desc)
398
+ assert_equal("probability", sequence_c.annotations[0].confidence.type)
399
+ assert_equal(0.67, sequence_c.annotations[0].confidence.value)
400
+
401
+ end
402
+
403
+ def test_sequence2
404
+ 4.times do
405
+ @tree = @phyloxml.next_tree
406
+ end
407
+ leaves = @tree.leaves
408
+ leaves.each { |node|
409
+ #just test one node for now
410
+ if node.sequences[0].id_source == 'x'
411
+ assert_equal('adhB', node.sequences[0].symbol)
412
+ assert_equal("ncbi", node.sequences[0].accession.source)
413
+ assert_equal('AAB80874', node.sequences[0].accession.value)
414
+ assert_equal('alcohol dehydrogenase', node.sequences[0].name)
415
+ end
416
+ if node.sequences[0].id_source == 'z'
417
+ assert_equal("InterPro:IPR002085",
418
+ node.sequences[0].annotations[0].ref)
419
+ end
420
+ }
421
+ end
422
+
423
+ def test_sequence3
424
+ 5.times do
425
+ @tree = @phyloxml.next_tree
426
+ end
427
+ @tree.leaves.each { |node|
428
+ if node.sequences[0].symbol == 'ADHX'
429
+ assert_equal('UniProtKB', node.sequences[0].accession.source)
430
+ assert_equal('P81431', node.sequences[0].accession.value)
431
+ assert_equal('Alcohol dehydrogenase class-3', node.sequences[0].name)
432
+ assert_equal(true, node.sequences[0].is_aligned)
433
+ assert_equal(true, node.sequences[0].is_aligned?)
434
+ assert_equal('TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD',
435
+ node.sequences[0].mol_seq)
436
+ assert_equal('EC:1.1.1.1', node.sequences[0].annotations[0].ref)
437
+ assert_equal('GO:0004022', node.sequences[0].annotations[1].ref)
438
+ end
439
+ }
440
+ end
441
+
442
+ def test_to_biosequence
443
+ 5.times do
444
+ @tree = @phyloxml.next_tree
445
+ end
446
+ @tree.leaves.each { |node|
447
+ if node.sequences[0].symbol =='ADHX'
448
+ seq = node.sequences[0].to_biosequence
449
+ assert_equal('Alcohol dehydrogenase class-3', seq.definition)
450
+ assert_equal('UniProtKB', seq.id_namespace)
451
+ assert_equal('P81431', seq.entry_id)
452
+ assert_equal('TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD',
453
+ seq.seq.to_s)
454
+ end
455
+ }
456
+ end
457
+
458
+ def test_extract_biosequence
459
+ 5.times do
460
+ @tree = @phyloxml.next_tree
461
+ end
462
+ @tree.leaves.each { |node|
463
+ if node.sequences[0].symbol == 'ADHX'
464
+ seq = node.extract_biosequence
465
+ assert_equal('Alcohol dehydrogenase class-3', seq.definition)
466
+ assert_equal('TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD',
467
+ seq.seq.to_s)
468
+ assert_equal('Octopus vulgaris', seq.classification[0])
469
+ end
470
+ }
471
+ end
472
+
473
+ def test_date
474
+ 11.times do
475
+ @tree = @phyloxml.next_tree
476
+ end
477
+ date_a = @tree.get_node_by_name('A').date
478
+ assert_equal('mya', date_a.unit)
479
+ assert_equal("Silurian", date_a.desc)
480
+ assert_equal(425, date_a.value)
481
+ date_b = @tree.get_node_by_name('B').date
482
+ assert_equal('mya', date_b.unit)
483
+ assert_equal("Devonian", date_b.desc)
484
+ assert_equal(320, date_b.value)
485
+ date_c = @tree.get_node_by_name('C').date
486
+ assert_equal('mya', date_c.unit)
487
+ assert_equal('Ediacaran', date_c.desc)
488
+ assert_equal(600, date_c.value)
489
+ assert_equal(570, date_c.minimum)
490
+ assert_equal(630, date_c.maximum)
491
+ end
492
+
493
+ def test_property
494
+ 7.times do
495
+ @tree = @phyloxml.next_tree
496
+ end
497
+ property = @tree.get_node_by_name('A').properties[0]
498
+ assert_equal('xsd:integer', property.datatype)
499
+ assert_equal('NOAA:depth', property.ref)
500
+ assert_equal('clade', property.applies_to)
501
+ assert_equal('METRIC:m', property.unit)
502
+ assert_equal(' 1200 ', property.value)
503
+ end
504
+
505
+ def test_uri
506
+ 9.times do
507
+ @tree = @phyloxml.next_tree
508
+ end
509
+ uri = @tree.root.taxonomies[0].uri
510
+ assert_equal("EMBL REPTILE DATABASE", uri.desc)
511
+ assert_equal("http://www.embl-heidelberg.de/~uetz/families/Varanidae.html", uri.uri)
512
+ end
513
+
514
+
515
+
516
+ end #class TestPhyloXML2
517
+
518
+ class TestPhyloXML3 < Test::Unit::TestCase
519
+
520
+ TEST_STRING =
521
+ """<phylogeny rooted=\"true\">
522
+ <name>same example, with support of type \"bootstrap\"</name>
523
+ <clade>
524
+ <clade branch_length=\"0.06\">
525
+ <name>AB</name>
526
+ <confidence type=\"bootstrap\">89</confidence>
527
+ <clade branch_length=\"0.102\">
528
+ <name>A</name>
529
+ </clade>
530
+ <clade branch_length=\"0.23\">
531
+ <name>B</name>
532
+ </clade>
533
+ </clade>
534
+ <clade branch_length=\"0.4\">
535
+ <name>C</name>
536
+ </clade>
537
+ </clade>
538
+ </phylogeny>"""
539
+
540
+ def setup
541
+ phyloxml = Bio::PhyloXML::Parser.new(TEST_STRING)
542
+ @tree = phyloxml.next_tree()
543
+
544
+ end
545
+
546
+ def test_children
547
+ node = @tree.get_node_by_name("AB")
548
+ # nodes = @tree.children(node).sort { |a,b| a.name <=> b.name }
549
+ node_names = []
550
+ @tree.children(node).each { |children|
551
+ node_names[node_names.length] = children.name
552
+ }
553
+ node_names.sort!
554
+ assert_equal(["A", "B"], node_names)
555
+ end
556
+
557
+
558
+ end # class
559
+
560
+ class TestPhyloXML4 < Test::Unit::TestCase
561
+
562
+ #test cases what pertain to tree
563
+
564
+ def test_clade_relation
565
+
566
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
567
+ 7.times do
568
+ @tree = @phyloxml.next_tree
569
+ end
570
+ cr = @tree.clade_relations[0]
571
+ assert_equal("b", cr.id_ref_0)
572
+ assert_equal("c", cr.id_ref_1)
573
+ assert_equal("network_connection", cr.type)
574
+ end
575
+
576
+ def test_sequence_realations
577
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
578
+ 5.times do
579
+ @tree = @phyloxml.next_tree
580
+ end
581
+
582
+ sr = @tree.sequence_relations[0]
583
+
584
+ assert_equal("x", sr.id_ref_0)
585
+ assert_equal("y", sr.id_ref_1)
586
+ assert_equal("paralogy", sr.type)
587
+ end
588
+
589
+
590
+ end
591
+
592
+ class TestPhyloXML5 < Test::Unit::TestCase
593
+
594
+ #testing file made_up.xml
595
+ def setup
596
+ @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.made_up_xml)
597
+ end
598
+
599
+ def test_phylogeny_confidence
600
+ tree = @phyloxml.next_tree()
601
+ assert_equal("bootstrap", tree.confidences[0].type)
602
+ assert_equal(89, tree.confidences[0].value)
603
+ assert_equal("probability", tree.confidences[1].type)
604
+ assert_equal(0.71, tree.confidences[1].value)
605
+ end
606
+
607
+ def test_to_biotreenode_probability
608
+ tree = @phyloxml.next_tree()
609
+ node = tree.get_node_by_name('c').to_biotreenode
610
+ assert_equal(nil, node.bootstrap)
611
+ end
612
+
613
+ def test_polygon
614
+ 2.times do
615
+ @tree = @phyloxml.next_tree
616
+ end
617
+ polygon = @tree.get_node_by_name('A').distributions[0].polygons[0]
618
+ assert_equal(3, polygon.points.length)
619
+ assert_equal(47.481277, polygon.points[0].lat)
620
+ assert_equal("m", polygon.points[0].alt_unit)
621
+ assert_equal(136.915863, polygon.points[1].long)
622
+ assert_equal(452, polygon.points[2].alt)
623
+ polygon = @tree.get_node_by_name('A').distributions[0].polygons[1]
624
+ #making sure can read in second polygon
625
+ assert_equal(3, polygon.points.length)
626
+ assert_equal(40.481277, polygon.points[0].lat)
627
+ end
628
+
629
+ def test_reference
630
+ 3.times do
631
+ @tree = @phyloxml.next_tree
632
+ end
633
+ references = @tree.get_node_by_name('A').references
634
+ assert_equal("10.1093/bioinformatics/btm619", references[0].doi)
635
+ assert_equal("Phyutility: a phyloinformatics tool for trees, alignments and molecular data", references[0].desc)
636
+ assert_equal("10.1186/1471-2105-9-S1-S23", references[1].doi)
637
+ end
638
+
639
+
640
+ def test_single_clade
641
+ 4.times do
642
+ @tree = @phyloxml.next_tree()
643
+ end
644
+ assert_equal("A", @tree.root.name)
645
+ end
646
+
647
+ def test_domain_architecture
648
+ 5.times {@tree = @phyloxml.next_tree()}
649
+ node = @tree.get_node_by_name("22_MOUSE")
650
+ assert_equal("22_MOUSE", node.name)
651
+ assert_equal("MOUSE", node.taxonomies[0].code)
652
+ domain_arch = node.sequences[0].domain_architecture
653
+ assert_equal(1249, domain_arch.length)
654
+ assert_equal(6, domain_arch.domains[0].from)
655
+ assert_equal(90, domain_arch.domains[0].to)
656
+ assert_in_delta(7.0E-26, domain_arch.domains[0].confidence, 1E-26)
657
+ assert_equal("CARD", domain_arch.domains[0].value)
658
+ assert_equal("x", domain_arch.domains[0].id)
659
+ assert_equal(733, domain_arch.domains[5].from)
660
+ assert_equal(771, domain_arch.domains[5].to)
661
+ assert_in_delta(4.7E-14, domain_arch.domains[5].confidence, 1E-15)
662
+ assert_equal("WD40", domain_arch.domains[5].value)
663
+ assert_equal(1168, domain_arch.domains.last.from)
664
+ assert_equal(1204, domain_arch.domains.last.to)
665
+ assert_equal(0.3, domain_arch.domains.last.confidence)
666
+ assert_equal("WD40", domain_arch.domains.last.value)
667
+ end
668
+
669
+ def test_clade_width
670
+ @tree = @phyloxml.next_tree
671
+ assert_equal(0.2, @tree.root.width)
672
+ end
673
+
674
+ def test_binary_characters
675
+ 6.times do
676
+ @tree = @phyloxml.next_tree
677
+ end
678
+ bc =@tree.get_node_by_name("cellular_organisms").binary_characters
679
+ assert_equal("parsimony inferred", bc.bc_type)
680
+ assert_equal(0, bc.lost_count)
681
+ assert_equal(0, bc.gained_count)
682
+ assert_equal([], bc.lost)
683
+
684
+ bc2 = @tree.get_node_by_name("Eukaryota").binary_characters
685
+ assert_equal(2, bc2.gained_count)
686
+ assert_equal(["Cofilin_ADF", "Gelsolin"], bc2.gained)
687
+ assert_equal(["Cofilin_ADF", "Gelsolin"], bc2.present)
688
+ end
689
+
690
+ def test_rerootable2
691
+ 6.times do
692
+ @tree = @phyloxml.next_tree
693
+ end
694
+ assert_equal(false, @tree.rerootable)
695
+ end
696
+
697
+ def test_phylogeny_attributes
698
+ @tree = @phyloxml.next_tree
699
+ assert_equal(true, @tree.rooted)
700
+ assert_equal(false, @tree.rerootable)
701
+ #@todo make this test pass
702
+ #assert_equal("1", @tree.branch_length_unit)
703
+
704
+ end
705
+
706
+ def test_taxonomy_synonym
707
+ 5.times do
708
+ @tree = @phyloxml.next_tree
709
+ end
710
+ node = @tree.get_node_by_name('22_MOUSE')
711
+ t = node.taxonomies[0]
712
+ assert_equal("murine", t.synonyms[0])
713
+ assert_equal("vermin", t.synonyms[1])
714
+
715
+ end
716
+
717
+ def test_annotation_property
718
+ 5.times do
719
+ @tree =@phyloxml.next_tree
720
+ end
721
+ node = @tree.get_node_by_name('22_MOUSE')
722
+ prop = node.sequences[0].annotations[0].properties[0]
723
+ assert_equal("1200", prop.value)
724
+ end
725
+
726
+ end
727
+ class TestPhyloXML5 < Test::Unit::TestCase
728
+
729
+ def test_each
730
+ phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
731
+ count = 0
732
+ phyloxml.each do |tree|
733
+ count +=1
734
+ end
735
+ assert_equal(13, count)
736
+ end
737
+
738
+ def test_other
739
+ phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
740
+ assert_equal(nil, phyloxml.other[0])
741
+ phyloxml.each do |tree|
742
+ #iterate through all trees, to get to the end
743
+ end
744
+ o = phyloxml.other[0]
745
+ assert_equal('align:alignment', o.element_name)
746
+ assert_equal('seq', o.children[0].element_name)
747
+ assert_equal('aggtcgcggcctgtggaagtcctctcct', o.children[1].value)
748
+ assert_equal("C", o.children[2].attributes["name"])
749
+
750
+ end
751
+
752
+ def test_array_behaviour
753
+ phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.example_xml)
754
+ tree = phyloxml[2]
755
+ assert_equal("same example, with support of type \"bootstrap\"",
756
+ tree.name)
757
+ end
758
+
759
+
760
+ # def test_get_tree_by_name
761
+ # @phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLData.made_up_xml)
762
+ # tree = @phyloxml.get_tree_by_name "testing confidence"
763
+ #
764
+ # end
765
+
766
+ end
767
+
768
+
769
+ end if defined?(LibXML) #end module Bio