jandot-bio 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. data/bin/bioruby +44 -0
  2. data/bin/br_biofetch.rb +47 -0
  3. data/bin/br_bioflat.rb +282 -0
  4. data/bin/br_biogetseq.rb +45 -0
  5. data/bin/br_pmfetch.rb +421 -0
  6. data/doc/Changes-0.7.rd +369 -0
  7. data/doc/KEGG_API.rd +1843 -0
  8. data/doc/KEGG_API.rd.ja +1834 -0
  9. data/doc/Tutorial.rd +1296 -0
  10. data/doc/Tutorial.rd.ja +2640 -0
  11. data/etc/bioinformatics/seqdatabase.ini +210 -0
  12. data/lib/bio.rb +279 -0
  13. data/lib/bio/alignment.rb +2518 -0
  14. data/lib/bio/appl/bl2seq/report.rb +334 -0
  15. data/lib/bio/appl/blast.rb +351 -0
  16. data/lib/bio/appl/blast/format0.rb +1438 -0
  17. data/lib/bio/appl/blast/format8.rb +83 -0
  18. data/lib/bio/appl/blast/report.rb +516 -0
  19. data/lib/bio/appl/blast/rexml.rb +135 -0
  20. data/lib/bio/appl/blast/rpsblast.rb +176 -0
  21. data/lib/bio/appl/blast/wublast.rb +550 -0
  22. data/lib/bio/appl/blast/xmlparser.rb +228 -0
  23. data/lib/bio/appl/blat/report.rb +489 -0
  24. data/lib/bio/appl/clustalw.rb +219 -0
  25. data/lib/bio/appl/clustalw/report.rb +152 -0
  26. data/lib/bio/appl/emboss.rb +203 -0
  27. data/lib/bio/appl/fasta.rb +237 -0
  28. data/lib/bio/appl/fasta/format10.rb +325 -0
  29. data/lib/bio/appl/gcg/msf.rb +212 -0
  30. data/lib/bio/appl/gcg/seq.rb +195 -0
  31. data/lib/bio/appl/genscan/report.rb +552 -0
  32. data/lib/bio/appl/hmmer.rb +126 -0
  33. data/lib/bio/appl/hmmer/report.rb +683 -0
  34. data/lib/bio/appl/iprscan/report.rb +374 -0
  35. data/lib/bio/appl/mafft.rb +259 -0
  36. data/lib/bio/appl/mafft/report.rb +226 -0
  37. data/lib/bio/appl/muscle.rb +52 -0
  38. data/lib/bio/appl/phylip/alignment.rb +129 -0
  39. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  40. data/lib/bio/appl/probcons.rb +41 -0
  41. data/lib/bio/appl/psort.rb +548 -0
  42. data/lib/bio/appl/psort/report.rb +457 -0
  43. data/lib/bio/appl/pts1.rb +263 -0
  44. data/lib/bio/appl/sim4.rb +124 -0
  45. data/lib/bio/appl/sim4/report.rb +485 -0
  46. data/lib/bio/appl/sosui/report.rb +151 -0
  47. data/lib/bio/appl/spidey/report.rb +593 -0
  48. data/lib/bio/appl/targetp/report.rb +267 -0
  49. data/lib/bio/appl/tcoffee.rb +55 -0
  50. data/lib/bio/appl/tmhmm/report.rb +222 -0
  51. data/lib/bio/command.rb +337 -0
  52. data/lib/bio/data/aa.rb +349 -0
  53. data/lib/bio/data/codontable.rb +722 -0
  54. data/lib/bio/data/na.rb +223 -0
  55. data/lib/bio/db.rb +329 -0
  56. data/lib/bio/db/aaindex.rb +357 -0
  57. data/lib/bio/db/embl/common.rb +336 -0
  58. data/lib/bio/db/embl/embl.rb +402 -0
  59. data/lib/bio/db/embl/sptr.rb +1283 -0
  60. data/lib/bio/db/embl/swissprot.rb +42 -0
  61. data/lib/bio/db/embl/trembl.rb +41 -0
  62. data/lib/bio/db/embl/uniprot.rb +42 -0
  63. data/lib/bio/db/fantom.rb +599 -0
  64. data/lib/bio/db/fasta.rb +907 -0
  65. data/lib/bio/db/genbank/common.rb +290 -0
  66. data/lib/bio/db/genbank/ddbj.rb +22 -0
  67. data/lib/bio/db/genbank/genbank.rb +215 -0
  68. data/lib/bio/db/genbank/genpept.rb +60 -0
  69. data/lib/bio/db/genbank/refseq.rb +18 -0
  70. data/lib/bio/db/gff.rb +174 -0
  71. data/lib/bio/db/go.rb +481 -0
  72. data/lib/bio/db/kegg/brite.rb +41 -0
  73. data/lib/bio/db/kegg/compound.rb +131 -0
  74. data/lib/bio/db/kegg/drug.rb +98 -0
  75. data/lib/bio/db/kegg/enzyme.rb +148 -0
  76. data/lib/bio/db/kegg/expression.rb +155 -0
  77. data/lib/bio/db/kegg/genes.rb +263 -0
  78. data/lib/bio/db/kegg/genome.rb +241 -0
  79. data/lib/bio/db/kegg/glycan.rb +170 -0
  80. data/lib/bio/db/kegg/keggtab.rb +357 -0
  81. data/lib/bio/db/kegg/kgml.rb +256 -0
  82. data/lib/bio/db/kegg/orthology.rb +136 -0
  83. data/lib/bio/db/kegg/reaction.rb +82 -0
  84. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  85. data/lib/bio/db/lasergene.rb +209 -0
  86. data/lib/bio/db/litdb.rb +107 -0
  87. data/lib/bio/db/medline.rb +323 -0
  88. data/lib/bio/db/nbrf.rb +191 -0
  89. data/lib/bio/db/newick.rb +658 -0
  90. data/lib/bio/db/nexus.rb +1854 -0
  91. data/lib/bio/db/pdb.rb +29 -0
  92. data/lib/bio/db/pdb/atom.rb +77 -0
  93. data/lib/bio/db/pdb/chain.rb +210 -0
  94. data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
  95. data/lib/bio/db/pdb/model.rb +148 -0
  96. data/lib/bio/db/pdb/pdb.rb +1911 -0
  97. data/lib/bio/db/pdb/residue.rb +176 -0
  98. data/lib/bio/db/pdb/utils.rb +399 -0
  99. data/lib/bio/db/prosite.rb +597 -0
  100. data/lib/bio/db/rebase.rb +457 -0
  101. data/lib/bio/db/soft.rb +404 -0
  102. data/lib/bio/db/transfac.rb +375 -0
  103. data/lib/bio/feature.rb +226 -0
  104. data/lib/bio/io/das.rb +461 -0
  105. data/lib/bio/io/dbget.rb +194 -0
  106. data/lib/bio/io/ddbjxml.rb +581 -0
  107. data/lib/bio/io/ebisoap.rb +158 -0
  108. data/lib/bio/io/ensembl.rb +229 -0
  109. data/lib/bio/io/fastacmd.rb +163 -0
  110. data/lib/bio/io/fetch.rb +181 -0
  111. data/lib/bio/io/flatfile.rb +1309 -0
  112. data/lib/bio/io/flatfile/bdb.rb +253 -0
  113. data/lib/bio/io/flatfile/index.rb +1371 -0
  114. data/lib/bio/io/flatfile/indexer.rb +787 -0
  115. data/lib/bio/io/higet.rb +73 -0
  116. data/lib/bio/io/hinv.rb +442 -0
  117. data/lib/bio/io/keggapi.rb +805 -0
  118. data/lib/bio/io/ncbirest.rb +256 -0
  119. data/lib/bio/io/ncbisoap.rb +155 -0
  120. data/lib/bio/io/pubmed.rb +307 -0
  121. data/lib/bio/io/registry.rb +292 -0
  122. data/lib/bio/io/soapwsdl.rb +119 -0
  123. data/lib/bio/io/sql.rb +365 -0
  124. data/lib/bio/location.rb +772 -0
  125. data/lib/bio/map.rb +410 -0
  126. data/lib/bio/pathway.rb +854 -0
  127. data/lib/bio/reference.rb +623 -0
  128. data/lib/bio/sequence.rb +475 -0
  129. data/lib/bio/sequence/aa.rb +125 -0
  130. data/lib/bio/sequence/common.rb +333 -0
  131. data/lib/bio/sequence/compat.rb +123 -0
  132. data/lib/bio/sequence/format.rb +181 -0
  133. data/lib/bio/sequence/generic.rb +24 -0
  134. data/lib/bio/sequence/na.rb +491 -0
  135. data/lib/bio/shell.rb +44 -0
  136. data/lib/bio/shell/core.rb +578 -0
  137. data/lib/bio/shell/demo.rb +146 -0
  138. data/lib/bio/shell/interface.rb +218 -0
  139. data/lib/bio/shell/irb.rb +95 -0
  140. data/lib/bio/shell/object.rb +71 -0
  141. data/lib/bio/shell/plugin/blast.rb +42 -0
  142. data/lib/bio/shell/plugin/codon.rb +218 -0
  143. data/lib/bio/shell/plugin/das.rb +58 -0
  144. data/lib/bio/shell/plugin/emboss.rb +23 -0
  145. data/lib/bio/shell/plugin/entry.rb +105 -0
  146. data/lib/bio/shell/plugin/flatfile.rb +101 -0
  147. data/lib/bio/shell/plugin/keggapi.rb +181 -0
  148. data/lib/bio/shell/plugin/midi.rb +430 -0
  149. data/lib/bio/shell/plugin/obda.rb +45 -0
  150. data/lib/bio/shell/plugin/psort.rb +56 -0
  151. data/lib/bio/shell/plugin/seq.rb +247 -0
  152. data/lib/bio/shell/plugin/soap.rb +87 -0
  153. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
  154. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
  155. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
  156. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
  157. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
  158. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
  159. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  160. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  161. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  162. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
  163. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
  164. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
  165. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
  166. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
  167. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
  168. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
  169. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  170. data/lib/bio/shell/script.rb +25 -0
  171. data/lib/bio/shell/setup.rb +109 -0
  172. data/lib/bio/shell/web.rb +102 -0
  173. data/lib/bio/tree.rb +850 -0
  174. data/lib/bio/util/color_scheme.rb +191 -0
  175. data/lib/bio/util/color_scheme/buried.rb +59 -0
  176. data/lib/bio/util/color_scheme/helix.rb +59 -0
  177. data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
  178. data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
  179. data/lib/bio/util/color_scheme/strand.rb +59 -0
  180. data/lib/bio/util/color_scheme/taylor.rb +50 -0
  181. data/lib/bio/util/color_scheme/turn.rb +59 -0
  182. data/lib/bio/util/color_scheme/zappo.rb +50 -0
  183. data/lib/bio/util/contingency_table.rb +370 -0
  184. data/lib/bio/util/restriction_enzyme.rb +228 -0
  185. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  186. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  187. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  188. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  189. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  190. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  191. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  192. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  193. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  194. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  195. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  196. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  197. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  198. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  199. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  200. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  201. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  202. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  203. data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
  204. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  205. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  206. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  207. data/lib/bio/util/sirna.rb +288 -0
  208. data/sample/any2fasta.rb +59 -0
  209. data/sample/biofetch.rb +475 -0
  210. data/sample/color_scheme_na.rb +91 -0
  211. data/sample/dbget +37 -0
  212. data/sample/enzymes.rb +78 -0
  213. data/sample/fasta2tab.rb +99 -0
  214. data/sample/fastagrep.rb +72 -0
  215. data/sample/fastasort.rb +54 -0
  216. data/sample/fsplit.rb +51 -0
  217. data/sample/gb2fasta.rb +30 -0
  218. data/sample/gb2tab.rb +325 -0
  219. data/sample/gbtab2mysql.rb +161 -0
  220. data/sample/genes2nuc.rb +33 -0
  221. data/sample/genes2pep.rb +33 -0
  222. data/sample/genes2tab.rb +81 -0
  223. data/sample/genome2rb.rb +29 -0
  224. data/sample/genome2tab.rb +76 -0
  225. data/sample/goslim.rb +303 -0
  226. data/sample/gt2fasta.rb +47 -0
  227. data/sample/na2aa.rb +34 -0
  228. data/sample/pmfetch.rb +42 -0
  229. data/sample/pmsearch.rb +42 -0
  230. data/sample/psortplot_html.rb +214 -0
  231. data/sample/ssearch2tab.rb +96 -0
  232. data/sample/tdiary.rb +158 -0
  233. data/sample/tfastx2tab.rb +100 -0
  234. data/sample/vs-genes.rb +212 -0
  235. data/test/data/HMMER/hmmpfam.out +64 -0
  236. data/test/data/HMMER/hmmsearch.out +88 -0
  237. data/test/data/SOSUI/sample.report +11 -0
  238. data/test/data/TMHMM/sample.report +21 -0
  239. data/test/data/aaindex/DAYM780301 +30 -0
  240. data/test/data/aaindex/PRAM900102 +20 -0
  241. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  242. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  243. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  244. data/test/data/blast/b0002.faa +15 -0
  245. data/test/data/blast/b0002.faa.m0 +128 -0
  246. data/test/data/blast/b0002.faa.m7 +65 -0
  247. data/test/data/blast/b0002.faa.m8 +1 -0
  248. data/test/data/embl/AB090716.embl +65 -0
  249. data/test/data/embl/AB090716.embl.rel89 +63 -0
  250. data/test/data/fasta/example1.txt +75 -0
  251. data/test/data/fasta/example2.txt +21 -0
  252. data/test/data/genscan/sample.report +63 -0
  253. data/test/data/iprscan/merged.raw +32 -0
  254. data/test/data/iprscan/merged.txt +74 -0
  255. data/test/data/prosite/prosite.dat +2233 -0
  256. data/test/data/refseq/nm_126355.entret +64 -0
  257. data/test/data/soft/GDS100_partial.soft +92 -0
  258. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  259. data/test/data/uniprot/p53_human.uniprot +1456 -0
  260. data/test/functional/bio/io/test_ensembl.rb +186 -0
  261. data/test/functional/bio/io/test_soapwsdl.rb +52 -0
  262. data/test/runner.rb +14 -0
  263. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  264. data/test/unit/bio/appl/blast/test_report.rb +417 -0
  265. data/test/unit/bio/appl/blast/test_xmlparser.rb +388 -0
  266. data/test/unit/bio/appl/genscan/test_report.rb +182 -0
  267. data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
  268. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  269. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  270. data/test/unit/bio/appl/sosui/test_report.rb +81 -0
  271. data/test/unit/bio/appl/targetp/test_report.rb +146 -0
  272. data/test/unit/bio/appl/test_blast.rb +163 -0
  273. data/test/unit/bio/appl/test_fasta.rb +130 -0
  274. data/test/unit/bio/appl/test_pts1.rb +140 -0
  275. data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
  276. data/test/unit/bio/data/test_aa.rb +90 -0
  277. data/test/unit/bio/data/test_codontable.rb +107 -0
  278. data/test/unit/bio/data/test_na.rb +80 -0
  279. data/test/unit/bio/db/embl/test_common.rb +117 -0
  280. data/test/unit/bio/db/embl/test_embl.rb +214 -0
  281. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  282. data/test/unit/bio/db/embl/test_sptr.rb +1775 -0
  283. data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
  284. data/test/unit/bio/db/kegg/test_genes.rb +45 -0
  285. data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
  286. data/test/unit/bio/db/test_aaindex.rb +197 -0
  287. data/test/unit/bio/db/test_fasta.rb +250 -0
  288. data/test/unit/bio/db/test_gff.rb +127 -0
  289. data/test/unit/bio/db/test_lasergene.rb +95 -0
  290. data/test/unit/bio/db/test_newick.rb +293 -0
  291. data/test/unit/bio/db/test_nexus.rb +360 -0
  292. data/test/unit/bio/db/test_prosite.rb +1437 -0
  293. data/test/unit/bio/db/test_rebase.rb +101 -0
  294. data/test/unit/bio/db/test_soft.rb +138 -0
  295. data/test/unit/bio/io/test_ddbjxml.rb +75 -0
  296. data/test/unit/bio/io/test_ensembl.rb +109 -0
  297. data/test/unit/bio/io/test_fastacmd.rb +42 -0
  298. data/test/unit/bio/io/test_flatfile.rb +237 -0
  299. data/test/unit/bio/io/test_soapwsdl.rb +32 -0
  300. data/test/unit/bio/sequence/test_aa.rb +103 -0
  301. data/test/unit/bio/sequence/test_common.rb +174 -0
  302. data/test/unit/bio/sequence/test_compat.rb +69 -0
  303. data/test/unit/bio/sequence/test_na.rb +330 -0
  304. data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
  305. data/test/unit/bio/test_alignment.rb +1025 -0
  306. data/test/unit/bio/test_command.rb +288 -0
  307. data/test/unit/bio/test_db.rb +96 -0
  308. data/test/unit/bio/test_feature.rb +116 -0
  309. data/test/unit/bio/test_location.rb +39 -0
  310. data/test/unit/bio/test_map.rb +230 -0
  311. data/test/unit/bio/test_pathway.rb +473 -0
  312. data/test/unit/bio/test_reference.rb +224 -0
  313. data/test/unit/bio/test_sequence.rb +329 -0
  314. data/test/unit/bio/test_shell.rb +18 -0
  315. data/test/unit/bio/test_tree.rb +593 -0
  316. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  317. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  318. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  319. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
  320. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  321. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  322. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  323. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  324. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  325. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  326. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  327. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  328. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  329. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  330. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  331. data/test/unit/bio/util/test_color_scheme.rb +33 -0
  332. data/test/unit/bio/util/test_contingency_table.rb +94 -0
  333. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  334. data/test/unit/bio/util/test_sirna.rb +245 -0
  335. metadata +479 -0
@@ -0,0 +1,83 @@
1
+ #
2
+ # = bio/appl/blast/format8.rb - BLAST tab-delimited output (-m 8) parser
3
+ #
4
+ # Copyright:: Copyright (C) 2002, 2003, 2007 Toshiaki Katayama <k@bioruby.org>
5
+ # License:: The Ruby License
6
+ #
7
+ # $Id: format8.rb,v 1.8 2007/12/14 16:15:20 k Exp $
8
+ #
9
+ # == Note
10
+ #
11
+ # This file is automatically loaded by bio/appl/blast/report.rb
12
+ #
13
+
14
+ module Bio
15
+ class Blast
16
+ class Report
17
+
18
+ private
19
+
20
+ def tab_parse(data)
21
+ iteration = Iteration.new
22
+ @iterations.push(iteration)
23
+ @query_id = @query_def = data[/\S+/]
24
+
25
+ query_prev = ''
26
+ target_prev = ''
27
+ hit_num = 1
28
+ hsp_num = 1
29
+ hit = ''
30
+ data.each do |line|
31
+ ary = line.chomp.split("\t")
32
+ query_id, target_id, hsp = tab_parse_hsp(ary)
33
+ if query_prev != query_id or target_prev != target_id
34
+ hit = Hit.new
35
+ hit.num = hit_num
36
+ hit_num += 1
37
+ hit.query_id = hit.query_def = query_id
38
+ hit.accession = hit.definition = target_id
39
+ iteration.hits.push(hit)
40
+ hsp_num = 1
41
+ end
42
+ hsp.num = hsp_num
43
+ hsp_num += 1
44
+ hit.hsps.push(hsp)
45
+ query_prev = query_id
46
+ target_prev = target_id
47
+ end
48
+ end
49
+
50
+ def tab_parse_hsp(ary)
51
+ query_id, target_id,
52
+ percent_identity,
53
+ align_len,
54
+ mismatch_count,
55
+ gaps,
56
+ query_from,
57
+ query_to,
58
+ hit_from,
59
+ hit_to,
60
+ evalue,
61
+ bit_score = *ary
62
+
63
+ hsp = Hsp.new
64
+ hsp.align_len = align_len.to_i
65
+ hsp.gaps = gaps.to_i
66
+ hsp.query_from = query_from.to_i
67
+ hsp.query_to = query_to.to_i
68
+ hsp.hit_from = hit_from.to_i
69
+ hsp.hit_to = hit_to.to_i
70
+ hsp.evalue = evalue.strip.to_f
71
+ hsp.bit_score = bit_score.to_f
72
+
73
+ hsp.percent_identity = percent_identity.to_f
74
+ hsp.mismatch_count = mismatch_count.to_i
75
+
76
+ return query_id, target_id, hsp
77
+ end
78
+
79
+ end
80
+ end
81
+ end
82
+
83
+
@@ -0,0 +1,516 @@
1
+ #
2
+ # = bio/appl/blast/report.rb - BLAST Report class
3
+ #
4
+ # Copyright:: Copyright (C) 2003 Toshiaki Katayama <k@bioruby.org>
5
+ # License:: The Ruby License
6
+ #
7
+ # $Id: report.rb,v 1.11 2007/04/05 23:35:39 trevor Exp $
8
+ #
9
+
10
+ require 'bio/appl/blast'
11
+ require 'bio/appl/blast/xmlparser'
12
+ require 'bio/appl/blast/rexml'
13
+ require 'bio/appl/blast/format8'
14
+
15
+ module Bio
16
+ class Blast
17
+
18
+ # = Bio::Blast::Report
19
+ #
20
+ # Parsed results of the blast execution for Tab-delimited and XML output
21
+ # format. Tab-delimited reports are consists of
22
+ #
23
+ # Query id,
24
+ # Subject id,
25
+ # percent of identity,
26
+ # alignment length,
27
+ # number of mismatches (not including gaps),
28
+ # number of gap openings,
29
+ # start of alignment in query,
30
+ # end of alignment in query,
31
+ # start of alignment in subject,
32
+ # end of alignment in subject,
33
+ # expected value,
34
+ # bit score.
35
+ #
36
+ # according to the MEGABLAST document (README.mbl). As for XML output,
37
+ # see the following DTDs.
38
+ #
39
+ # * http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd
40
+ # * http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.mod
41
+ # * http://www.ncbi.nlm.nih.gov/dtd/NCBI_Entity.mod
42
+ #
43
+ class Report
44
+
45
+ # for Bio::FlatFile support (only for XML data)
46
+ DELIMITER = RS = "</BlastOutput>\n"
47
+
48
+ # Specify to use XMLParser to parse XML (-m 7) output.
49
+ def self.xmlparser(data)
50
+ self.new(data, :xmlparser)
51
+ end
52
+
53
+ # Specify to use REXML to parse XML (-m 7) output.
54
+ def self.rexml(data)
55
+ self.new(data, :rexml)
56
+ end
57
+
58
+ # Specify to use tab delimited output parser.
59
+ def self.tab(data)
60
+ self.new(data, :tab)
61
+ end
62
+
63
+ def auto_parse(data)
64
+ if /<?xml/.match(data[/.*/])
65
+ if defined?(XMLParser)
66
+ xmlparser_parse(data)
67
+ else
68
+ rexml_parse(data)
69
+ end
70
+ else
71
+ tab_parse(data)
72
+ end
73
+ end
74
+ private :auto_parse
75
+
76
+ # Passing a BLAST output from 'blastall -m 7' or '-m 8' as a String.
77
+ # Formats are auto detected.
78
+ def initialize(data, parser = nil)
79
+ @iterations = []
80
+ @parameters = {}
81
+ case parser
82
+ when :xmlparser # format 7
83
+ xmlparser_parse(data)
84
+ when :rexml # format 7
85
+ rexml_parse(data)
86
+ when :tab # format 8
87
+ tab_parse(data)
88
+ else
89
+ auto_parse(data)
90
+ end
91
+ end
92
+
93
+ # Returns an Array of Bio::Blast::Report::Iteration objects.
94
+ attr_reader :iterations
95
+
96
+ # Returns a Hash containing execution parameters. Valid keys are:
97
+ # 'matrix', 'expect', 'include', 'sc-match', 'sc-mismatch',
98
+ # 'gap-open', 'gap-extend', 'filter'
99
+ attr_reader :parameters
100
+
101
+ # Shortcut for BlastOutput values.
102
+ attr_reader :program, :version, :reference, :db, :query_id, :query_def, :query_len
103
+
104
+ # Matrix used (-M) : shortcuts for @parameters
105
+ def matrix; @parameters['matrix']; end
106
+ # Expectation threshold (-e) : shortcuts for @parameters
107
+ def expect; @parameters['expect'].to_i; end
108
+ # Inclusion threshold (-h) : shortcuts for @parameters
109
+ def inclusion; @parameters['include'].to_i; end
110
+ # Match score for NT (-r) : shortcuts for @parameters
111
+ def sc_match; @parameters['sc-match'].to_i; end
112
+ # Mismatch score for NT (-q) : shortcuts for @parameters
113
+ def sc_mismatch; @parameters['sc-mismatch'].to_i; end
114
+ # Gap opening cost (-G) : shortcuts for @parameters
115
+ def gap_open; @parameters['gap-open'].to_i; end
116
+ # Gap extension cost (-E) : shortcuts for @parameters
117
+ def gap_extend; @parameters['gap-extend'].to_i; end
118
+ # Filtering options (-F) : shortcuts for @parameters
119
+ def filter; @parameters['filter']; end
120
+ # PHI-BLAST pattern : shortcuts for @parameters
121
+ def pattern; @parameters['pattern']; end
122
+ # Limit of request to Entrez : shortcuts for @parameters
123
+ def entrez_query; @parameters['entrez-query']; end
124
+
125
+ # Iterates on each Bio::Blast::Report::Iteration object. (for blastpgp)
126
+ def each_iteration
127
+ @iterations.each do |x|
128
+ yield x
129
+ end
130
+ end
131
+
132
+ # Iterates on each Bio::Blast::Report::Hit object of the the last Iteration.
133
+ # Shortcut for the last iteration's hits (for blastall)
134
+ def each_hit
135
+ @iterations.last.each do |x|
136
+ yield x
137
+ end
138
+ end
139
+ alias each each_hit
140
+
141
+ # Returns a Array of Bio::Blast::Report::Hits of the last iteration.
142
+ # Shortcut for the last iteration's hits
143
+ def hits
144
+ @iterations.last.hits
145
+ end
146
+
147
+ # Returns a Hash containing execution statistics of the last iteration.
148
+ # Valid keys are:
149
+ # 'db-num', 'db-len', 'hsp-len', 'eff-space', 'kappa', 'lambda', 'entropy'
150
+ # Shortcut for the last iteration's statistics.
151
+ def statistics
152
+ @iterations.last.statistics
153
+ end
154
+
155
+ # Number of sequences in BLAST db
156
+ def db_num; statistics['db-num']; end
157
+ # Length of BLAST db
158
+ def db_len; statistics['db-len']; end
159
+ # Effective HSP length
160
+ def hsp_len; statistics['hsp-len']; end
161
+ # Effective search space
162
+ def eff_space; statistics['eff-space']; end
163
+ # Karlin-Altschul parameter K
164
+ def kappa; statistics['kappa']; end
165
+ # Karlin-Altschul parameter Lamba
166
+ def lambda; statistics['lambda']; end
167
+ # Karlin-Altschul parameter H
168
+ def entropy; statistics['entropy']; end
169
+
170
+ # Returns a String (or nil) containing execution message of the last
171
+ # iteration (typically "CONVERGED").
172
+ # Shortcut for the last iteration's message (for checking 'CONVERGED')
173
+ def message
174
+ @iterations.last.message
175
+ end
176
+
177
+
178
+ # Bio::Blast::Report::Iteration
179
+ class Iteration
180
+ def initialize
181
+ @message = nil
182
+ @statistics = {}
183
+ @num = 1
184
+ @hits = []
185
+ end
186
+ # Returns an Array of Bio::Blast::Report::Hit objects.
187
+ attr_reader :hits
188
+
189
+ # Returns a Hash containing execution statistics.
190
+ # Valid keys are:
191
+ # 'db-len', 'db-num', 'eff-space', 'entropy', 'hsp-len', 'kappa', 'lambda'
192
+ attr_reader :statistics
193
+
194
+ # Returns the number of iteration counts.
195
+ attr_accessor :num
196
+
197
+ # Returns a String (or nil) containing execution message (typically
198
+ # "CONVERGED").
199
+ attr_accessor :message
200
+
201
+ # Iterates on each Bio::Blast::Report::Hit object.
202
+ def each
203
+ @hits.each do |x|
204
+ yield x
205
+ end
206
+ end
207
+ end
208
+
209
+
210
+ # Bio::Blast::Report::Hit
211
+ class Hit
212
+ def initialize
213
+ @hsps = []
214
+ end
215
+
216
+ # Returns an Array of Bio::Blast::Report::Hsp objects.
217
+ attr_reader :hsps
218
+
219
+ # Hit number
220
+ attr_accessor :num
221
+ # SeqId of subject
222
+ attr_accessor :hit_id
223
+ # Length of subject
224
+ attr_accessor :len
225
+ # Definition line of subject
226
+ attr_accessor :definition
227
+ # Accession
228
+ attr_accessor :accession
229
+
230
+ # Iterates on each Hsp object.
231
+ def each
232
+ @hsps.each do |x|
233
+ yield x
234
+ end
235
+ end
236
+
237
+ # Compatible method with Bio::Fasta::Report::Hit class.
238
+ attr_accessor :query_id
239
+ # Compatible method with Bio::Fasta::Report::Hit class.
240
+ attr_accessor :query_def
241
+ # Compatible method with Bio::Fasta::Report::Hit class.
242
+ attr_accessor :query_len
243
+
244
+ # Compatible method with Bio::Fasta::Report::Hit class.
245
+ alias target_id accession
246
+ # Compatible method with Bio::Fasta::Report::Hit class.
247
+ alias target_def definition
248
+ # Compatible method with Bio::Fasta::Report::Hit class.
249
+ alias target_len len
250
+
251
+ # Shortcut methods for the best Hsp, some are also compatible with
252
+ # Bio::Fasta::Report::Hit class.
253
+ def evalue; @hsps.first.evalue; end
254
+ def bit_score; @hsps.first.bit_score; end
255
+ def identity; @hsps.first.identity; end
256
+ def percent_identity; @hsps.first.percent_identity; end
257
+ def overlap; @hsps.first.align_len; end
258
+
259
+ def query_seq; @hsps.first.qseq; end
260
+ def target_seq; @hsps.first.hseq; end
261
+ def midline; @hsps.first.midline; end
262
+
263
+ def query_start; @hsps.first.query_from; end
264
+ def query_end; @hsps.first.query_to; end
265
+ def target_start; @hsps.first.hit_from; end
266
+ def target_end; @hsps.first.hit_to; end
267
+ def lap_at
268
+ [ query_start, query_end, target_start, target_end ]
269
+ end
270
+ end
271
+
272
+
273
+ # Bio::Blast::Report::Hsp
274
+ class Hsp
275
+ def initialize
276
+ @hsp = {}
277
+ end
278
+ attr_reader :hsp
279
+
280
+ # HSP number
281
+ attr_accessor :num
282
+ # Score (in bits) of HSP
283
+ attr_accessor :bit_score
284
+ # Sscore of HSP
285
+ attr_accessor :score
286
+ # E-value of HSP
287
+ attr_accessor :evalue
288
+ # Start of HSP in query
289
+ attr_accessor :query_from
290
+ # End of HSP
291
+ attr_accessor :query_to
292
+ # Start of HSP in subject
293
+ attr_accessor :hit_from
294
+ # End of HSP
295
+ attr_accessor :hit_to
296
+ # Start of PHI-BLAST pattern
297
+ attr_accessor :pattern_from
298
+ # End of PHI-BLAST pattern
299
+ attr_accessor :pattern_to
300
+ # Translation frame of query
301
+ attr_accessor :query_frame
302
+ # Translation frame of subject
303
+ attr_accessor :hit_frame
304
+ # Number of identities in HSP
305
+ attr_accessor :identity
306
+ # Number of positives in HSP
307
+ attr_accessor :positive
308
+ # Number of gaps in HSP
309
+ attr_accessor :gaps
310
+ # Length of the alignment used
311
+ attr_accessor :align_len
312
+ # Score density
313
+ attr_accessor :density
314
+ # Alignment string for the query (with gaps)
315
+ attr_accessor :qseq
316
+ # Alignment string for subject (with gaps)
317
+ attr_accessor :hseq
318
+ # Formating middle line
319
+ attr_accessor :midline
320
+ # Available only for '-m 8' format outputs.
321
+ attr_accessor :percent_identity
322
+ # Available only for '-m 8' format outputs.
323
+ attr_accessor :mismatch_count
324
+ end
325
+
326
+ end # Report
327
+
328
+ end # Blast
329
+ end # Bio
330
+
331
+
332
+ if __FILE__ == $0
333
+
334
+ =begin
335
+
336
+ begin # p is suitable than pp for the following test script
337
+ require 'pp'
338
+ alias p pp
339
+ rescue
340
+ end
341
+
342
+ # for multiple xml reports (iterates on each Blast::Report)
343
+ Bio::Blast.reports(ARGF) do |rep|
344
+ rep.iterations.each do |itr|
345
+ itr.hits.each do |hit|
346
+ hit.hsps.each do |hsp|
347
+ end
348
+ end
349
+ end
350
+ end
351
+
352
+ # for multiple xml reports (returns Array of Blast::Report)
353
+ reps = Bio::Blast.reports(ARGF.read)
354
+
355
+ # for a single report (xml or tab) format auto detect, parser auto selected
356
+ rep = Bio::Blast::Report.new(ARGF.read)
357
+
358
+ # to use xmlparser explicitly for a report
359
+ rep = Bio::Blast::Report.xmlparser(ARGF.read)
360
+
361
+ # to use resml explicitly for a report
362
+ rep = Bio::Blast::Report.rexml(ARGF.read)
363
+
364
+ # to use a tab delimited report
365
+ rep = Bio::Blast::Report.tab(ARGF.read)
366
+
367
+ =end
368
+
369
+ Bio::Blast.reports(ARGF) do |rep| # for multiple xml reports
370
+
371
+ print "# === Bio::Tools::Blast::Report\n"
372
+ puts
373
+ print " rep.program #=> "; p rep.program
374
+ print " rep.version #=> "; p rep.version
375
+ print " rep.reference #=> "; p rep.reference
376
+ print " rep.db #=> "; p rep.db
377
+ print " rep.query_id #=> "; p rep.query_id
378
+ print " rep.query_def #=> "; p rep.query_def
379
+ print " rep.query_len #=> "; p rep.query_len
380
+ puts
381
+
382
+ print "# === Parameters\n"
383
+ puts
384
+ print " rep.parameters #=> "; p rep.parameters
385
+ puts
386
+ print " rep.matrix #=> "; p rep.matrix
387
+ print " rep.expect #=> "; p rep.expect
388
+ print " rep.inclusion #=> "; p rep.inclusion
389
+ print " rep.sc_match #=> "; p rep.sc_match
390
+ print " rep.sc_mismatch #=> "; p rep.sc_mismatch
391
+ print " rep.gap_open #=> "; p rep.gap_open
392
+ print " rep.gap_extend #=> "; p rep.gap_extend
393
+ print " rep.filter #=> "; p rep.filter
394
+ print " rep.pattern #=> "; p rep.pattern
395
+ print " rep.entrez_query #=> "; p rep.entrez_query
396
+ puts
397
+
398
+ print "# === Statistics (last iteration's)\n"
399
+ puts
400
+ print " rep.statistics #=> "; p rep.statistics
401
+ puts
402
+ print " rep.db_num #=> "; p rep.db_num
403
+ print " rep.db_len #=> "; p rep.db_len
404
+ print " rep.hsp_len #=> "; p rep.hsp_len
405
+ print " rep.eff_space #=> "; p rep.eff_space
406
+ print " rep.kappa #=> "; p rep.kappa
407
+ print " rep.lambda #=> "; p rep.lambda
408
+ print " rep.entropy #=> "; p rep.entropy
409
+ puts
410
+
411
+ print "# === Message (last iteration's)\n"
412
+ puts
413
+ print " rep.message #=> "; p rep.message
414
+ puts
415
+
416
+ print "# === Iterations\n"
417
+ puts
418
+ print " rep.itrerations.each do |itr|\n"
419
+ puts
420
+
421
+ rep.iterations.each do |itr|
422
+
423
+ print "# --- Bio::Blast::Report::Iteration\n"
424
+ puts
425
+
426
+ print " itr.num #=> "; p itr.num
427
+ print " itr.statistics #=> "; p itr.statistics
428
+ print " itr.message #=> "; p itr.message
429
+ print " itr.hits.size #=> "; p itr.hits.size
430
+ puts
431
+
432
+ print " itr.hits.each do |hit|\n"
433
+ puts
434
+
435
+ itr.hits.each do |hit|
436
+
437
+ print "# --- Bio::Blast::Report::Hit\n"
438
+ puts
439
+
440
+ print " hit.num #=> "; p hit.num
441
+ print " hit.hit_id #=> "; p hit.hit_id
442
+ print " hit.len #=> "; p hit.len
443
+ print " hit.definition #=> "; p hit.definition
444
+ print " hit.accession #=> "; p hit.accession
445
+
446
+ print " --- compatible/shortcut ---\n"
447
+ print " hit.query_id #=> "; p hit.query_id
448
+ print " hit.query_def #=> "; p hit.query_def
449
+ print " hit.query_len #=> "; p hit.query_len
450
+ print " hit.target_id #=> "; p hit.target_id
451
+ print " hit.target_def #=> "; p hit.target_def
452
+ print " hit.target_len #=> "; p hit.target_len
453
+
454
+ print " hit.evalue #=> "; p hit.evalue
455
+ print " hit.bit_score #=> "; p hit.bit_score
456
+ print " hit.identity #=> "; p hit.identity
457
+ print " hit.overlap #=> "; p hit.overlap
458
+
459
+ print " hit.query_seq #=> "; p hit.query_seq
460
+ print " hit.midline #=> "; p hit.midline
461
+ print " hit.target_seq #=> "; p hit.target_seq
462
+
463
+ print " hit.query_start #=> "; p hit.query_start
464
+ print " hit.query_end #=> "; p hit.query_end
465
+ print " hit.target_start #=> "; p hit.target_start
466
+ print " hit.target_end #=> "; p hit.target_end
467
+ print " hit.lap_at #=> "; p hit.lap_at
468
+ print " --- compatible/shortcut ---\n"
469
+
470
+ print " hit.hsps.size #=> "; p hit.hsps.size
471
+ puts
472
+
473
+ print " hit.hsps.each do |hsp|\n"
474
+ puts
475
+
476
+ hit.hsps.each do |hsp|
477
+
478
+ print "# --- Bio::Blast::Report::Hsp\n"
479
+ puts
480
+ print " hsp.num #=> "; p hsp.num
481
+ print " hsp.bit_score #=> "; p hsp.bit_score
482
+ print " hsp.score #=> "; p hsp.score
483
+ print " hsp.evalue #=> "; p hsp.evalue
484
+ print " hsp.identity #=> "; p hsp.identity
485
+ print " hsp.gaps #=> "; p hsp.gaps
486
+ print " hsp.positive #=> "; p hsp.positive
487
+ print " hsp.align_len #=> "; p hsp.align_len
488
+ print " hsp.density #=> "; p hsp.density
489
+
490
+ print " hsp.query_frame #=> "; p hsp.query_frame
491
+ print " hsp.query_from #=> "; p hsp.query_from
492
+ print " hsp.query_to #=> "; p hsp.query_to
493
+
494
+ print " hsp.hit_frame #=> "; p hsp.hit_frame
495
+ print " hsp.hit_from #=> "; p hsp.hit_from
496
+ print " hsp.hit_to #=> "; p hsp.hit_to
497
+
498
+ print " hsp.pattern_from#=> "; p hsp.pattern_from
499
+ print " hsp.pattern_to #=> "; p hsp.pattern_to
500
+
501
+ print " hsp.qseq #=> "; p hsp.qseq
502
+ print " hsp.midline #=> "; p hsp.midline
503
+ print " hsp.hseq #=> "; p hsp.hseq
504
+ puts
505
+ print " hsp.percent_identity #=> "; p hsp.percent_identity
506
+ print " hsp.mismatch_count #=> "; p hsp.mismatch_count
507
+ puts
508
+
509
+ end
510
+ end
511
+ end
512
+ end # for multiple xml reports
513
+
514
+ end
515
+
516
+