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,228 @@
1
+ #
2
+ # = bio/appl/blast/xmlparser.rb - BLAST XML output (-m 7) parser by XMLParser
3
+ #
4
+ # Copyright:: Copyright (C) 2001
5
+ # Mitsuteru C. Nakao <n@bioruby.org>
6
+ # Copyright:: Copyright (C) 2003
7
+ # Toshiaki Katayama <k@bioruby.org>
8
+ # License:: The Ruby License
9
+ #
10
+ # $Id: xmlparser.rb,v 1.18 2008/05/12 13:11:45 ngoto Exp $
11
+ #
12
+ # == Description
13
+ #
14
+ # A parser for blast XML report (format 7) based on the XMLParser.
15
+ # This file is automatically loaded by bio/appl/blast/report.rb if
16
+ # the XMLParser installed.
17
+ #
18
+ # BioRuby provides two implements of the paser for the blast XML format report
19
+ # (format 7) based on the XMLParser and the REXML.
20
+ #
21
+
22
+ begin
23
+ require 'xmlparser'
24
+ rescue LoadError
25
+ end
26
+
27
+ module Bio
28
+ class Blast
29
+ class Report
30
+
31
+ private
32
+
33
+ def xmlparser_parse(xml)
34
+ parser = XMLParser.new
35
+ def parser.default; end
36
+
37
+ begin
38
+ tag_stack = Array.new
39
+ hash = Hash.new
40
+
41
+ parser.parse(xml) do |type, name, data|
42
+ case type
43
+ when XMLParser::START_ELEM
44
+ tag_stack.push(name)
45
+ hash.update(data)
46
+ case name
47
+ when 'Iteration'
48
+ iteration = Iteration.new
49
+ @iterations.push(iteration)
50
+ when 'Hit'
51
+ hit = Hit.new
52
+ hit.query_id = @query_id
53
+ hit.query_def = @query_def
54
+ hit.query_len = @query_len
55
+ @iterations.last.hits.push(hit)
56
+ when 'Hsp'
57
+ hsp = Hsp.new
58
+ @iterations.last.hits.last.hsps.push(hsp)
59
+ end
60
+ when XMLParser::END_ELEM
61
+ case name
62
+ when /^BlastOutput/
63
+ xmlparser_parse_program(name,hash)
64
+ hash = Hash.new
65
+ when /^Parameters$/
66
+ xmlparser_parse_parameters(hash)
67
+ hash = Hash.new
68
+ when /^Iteration/
69
+ xmlparser_parse_iteration(name, hash)
70
+ hash = Hash.new
71
+ when /^Hit/
72
+ xmlparser_parse_hit(name, hash)
73
+ hash = Hash.new
74
+ when /^Hsp$/
75
+ xmlparser_parse_hsp(hash)
76
+ hash = Hash.new
77
+ when /^Statistics$/
78
+ xmlparser_parse_statistics(hash)
79
+ hash = Hash.new
80
+ end
81
+ tag_stack.pop
82
+ when XMLParser::CDATA
83
+ if hash[tag_stack.last].nil?
84
+ hash[tag_stack.last] = data unless data.strip.empty?
85
+ else
86
+ hash[tag_stack.last].concat(data) if data
87
+ end
88
+ when XMLParser::PI
89
+ end
90
+ end
91
+ rescue XMLParserError
92
+ line = parser.line
93
+ column = parser.column
94
+ print "Parse error at #{line}(#{column}) : #{$!}\n"
95
+ end
96
+ end
97
+
98
+
99
+ def xmlparser_parse_program(tag, hash)
100
+ case tag
101
+ when 'BlastOutput_program'
102
+ @program = hash[tag]
103
+ when 'BlastOutput_version'
104
+ @version = hash[tag]
105
+ when 'BlastOutput_reference'
106
+ @reference = hash[tag]
107
+ when 'BlastOutput_db'
108
+ @db = hash[tag].strip
109
+ when 'BlastOutput_query-ID'
110
+ @query_id = hash[tag]
111
+ when 'BlastOutput_query-def'
112
+ @query_def = hash[tag]
113
+ when 'BlastOutput_query-len'
114
+ @query_len = hash[tag].to_i
115
+ end
116
+ end
117
+
118
+ # set parameter of the key as val
119
+ def xml_set_parameter(key, val)
120
+ #labels = {
121
+ # 'matrix' => 'Parameters_matrix',
122
+ # 'expect' => 'Parameters_expect',
123
+ # 'include' => 'Parameters_include',
124
+ # 'sc-match' => 'Parameters_sc-match',
125
+ # 'sc-mismatch' => 'Parameters_sc-mismatch',
126
+ # 'gap-open' => 'Parameters_gap-open',
127
+ # 'gap-extend' => 'Parameters_gap-extend',
128
+ # 'filter' => 'Parameters_filter',
129
+ # 'pattern' => 'Parameters_pattern',
130
+ # 'entrez-query' => 'Parameters_entrez-query',
131
+ #}
132
+ k = key.sub(/\AParameters\_/, '')
133
+ @parameters[k] =
134
+ case k
135
+ when 'expect', 'include'
136
+ val.to_f
137
+ when /\Agap\-/, /\Asc\-/
138
+ val.to_i
139
+ else
140
+ val
141
+ end
142
+ end
143
+
144
+ def xmlparser_parse_parameters(hash)
145
+ hash.each do |k, v|
146
+ xml_set_parameter(k, v)
147
+ end
148
+ end
149
+
150
+ def xmlparser_parse_iteration(tag, hash)
151
+ case tag
152
+ when 'Iteration_iter-num'
153
+ @iterations.last.num = hash[tag].to_i
154
+ when 'Iteration_message'
155
+ @iterations.last.message = hash[tag].to_s
156
+ end
157
+ end
158
+
159
+ def xmlparser_parse_hit(tag, hash)
160
+ hit = @iterations.last.hits.last
161
+ case tag
162
+ when 'Hit_num'
163
+ hit.num = hash[tag].to_i
164
+ when 'Hit_id'
165
+ hit.hit_id = hash[tag].clone
166
+ when 'Hit_def'
167
+ hit.definition = hash[tag].clone
168
+ when 'Hit_accession'
169
+ hit.accession = hash[tag].clone
170
+ when 'Hit_len'
171
+ hit.len = hash[tag].clone.to_i
172
+ end
173
+ end
174
+
175
+ def xmlparser_parse_hsp(hash)
176
+ hsp = @iterations.last.hits.last.hsps.last
177
+ hsp.num = hash['Hsp_num'].to_i
178
+ hsp.bit_score = hash['Hsp_bit-score'].to_f
179
+ hsp.score = hash['Hsp_score'].to_i
180
+ hsp.evalue = hash['Hsp_evalue'].to_f
181
+ hsp.query_from = hash['Hsp_query-from'].to_i
182
+ hsp.query_to = hash['Hsp_query-to'].to_i
183
+ hsp.hit_from = hash['Hsp_hit-from'].to_i
184
+ hsp.hit_to = hash['Hsp_hit-to'].to_i
185
+ hsp.pattern_from = hash['Hsp_pattern-from'].to_i
186
+ hsp.pattern_to = hash['Hsp_pattern-to'].to_i
187
+ hsp.query_frame = hash['Hsp_query-frame'].to_i
188
+ hsp.hit_frame = hash['Hsp_hit-frame'].to_i
189
+ hsp.identity = hash['Hsp_identity'].to_i
190
+ hsp.positive = hash['Hsp_positive'].to_i
191
+ hsp.gaps = hash['Hsp_gaps'].to_i
192
+ hsp.align_len = hash['Hsp_align-len'].to_i
193
+ hsp.density = hash['Hsp_density'].to_i
194
+ hsp.qseq = hash['Hsp_qseq']
195
+ hsp.hseq = hash['Hsp_hseq']
196
+ hsp.midline = hash['Hsp_midline']
197
+ end
198
+
199
+ def xmlparser_parse_statistics(hash)
200
+ labels = {
201
+ 'db-num' => 'Statistics_db-num',
202
+ 'db-len' => 'Statistics_db-len',
203
+ 'hsp-len' => 'Statistics_hsp-len',
204
+ 'eff-space' => 'Statistics_eff-space',
205
+ 'kappa' => 'Statistics_kappa',
206
+ 'lambda' => 'Statistics_lambda',
207
+ 'entropy' => 'Statistics_entropy'
208
+ }
209
+ labels.each do |k,v|
210
+ case k
211
+ when 'db-num', 'db-len', 'hsp-len'
212
+ @iterations.last.statistics[k] = hash[v].to_i
213
+ else
214
+ @iterations.last.statistics[k] = hash[v].to_f
215
+ end
216
+ end
217
+ end
218
+
219
+ end # class Report
220
+ end # class Blast
221
+ end # module Bio
222
+
223
+
224
+ =begin
225
+
226
+ This file is automatically loaded by bio/appl/blast/report.rb
227
+
228
+ =end
@@ -0,0 +1,489 @@
1
+ #
2
+ # = bio/appl/blat/report.rb - BLAT result parser
3
+ #
4
+ # Copyright:: Copyright (C) 2004 GOTO Naohisa <ng@bioruby.org>
5
+ # License:: The Ruby License
6
+ #
7
+ # $Id: report.rb,v 1.13 2007/04/05 23:35:39 trevor Exp $
8
+ #
9
+ # BLAT result parser (psl / pslx format).
10
+ #
11
+ # == Important Notes
12
+ #
13
+ # In BLAT results, the start position of a sequnece is numbered as 0.
14
+ # On the other hand, in many other homology search programs,
15
+ # the start position of a sequence is numbered as 1.
16
+ # To keep compatibility, the BLAT parser adds 1 to every position number.
17
+ #
18
+ # == References
19
+ #
20
+ # * Kent, W.J., BLAT--the BLAST-like alignment tool,
21
+ # Genome Research, 12, 656--664, 2002.
22
+ # http://www.genome.org/cgi/content/abstract/12/4/656
23
+ # * http://genome.ucsc.edu/goldenPath/help/blatSpec.html
24
+
25
+ require 'bio'
26
+
27
+ module Bio
28
+ class Blat
29
+
30
+ # Bio::Blat::Report is a BLAT report parser class.
31
+ # Its object may contain some Bio::Blat::Report::Hits objects.
32
+ #
33
+ # In BLAT results, the start position of a sequnece is numbered as 0.
34
+ # On the other hand, in many other homology search programs,
35
+ # the start position of a sequence is numbered as 1.
36
+ # To keep compatibility, the BLAT parser adds 1 to every position number
37
+ # except Bio::Blat::Report::Seqdesc and some Bio::Blat specific methods.
38
+ #
39
+ # Note that Bio::Blat::Report#query_def, #query_id, #query_len methods
40
+ # simply return first hit's query_*.
41
+ # If multiple query sequences are given, these values
42
+ # will be incorrect.
43
+ #
44
+ class Report #< DB
45
+ # Delimiter of each entry. Bio::FlatFile uses it.
46
+ # In Bio::Blat::Report, it it nil (1 entry 1 file).
47
+ DELIMITER = RS = nil # 1 file 1 entry
48
+
49
+ # Creates a new Bio::Blat::Report object from BLAT result text (String).
50
+ # You can use Bio::FlatFile to read a file.
51
+ # Currently, results created with options -out=psl (default) or
52
+ # -out=pslx are supported.
53
+ def initialize(text)
54
+ flag = false
55
+ head = []
56
+ @hits = []
57
+ text.each do |line|
58
+ if flag then
59
+ @hits << Hit.new(line)
60
+ else
61
+ # for headerless data
62
+ if /^\d/ =~ line then
63
+ flag = true
64
+ redo
65
+ end
66
+ line = line.chomp
67
+ if /\A\-+\s*\z/ =~ line
68
+ flag = true
69
+ else
70
+ head << line
71
+ end
72
+ end
73
+ end
74
+ @columns = parse_header(head)
75
+ end
76
+
77
+ # hits of the result.
78
+ # Returns an Array of Bio::Blat::Report::Hit objects.
79
+ attr_reader :hits
80
+
81
+ # Returns descriptions of columns.
82
+ # Returns an Array.
83
+ # This would be a Bio::Blat specific method.
84
+ attr_reader :columns
85
+
86
+ # Parses headers.
87
+ def parse_header(ary)
88
+ while x = ary.shift
89
+ if /psLayout version (\S+)/ =~ x then
90
+ @psl_version = $1
91
+ break
92
+ elsif !(x.strip.empty?)
93
+ ary.unshift(x)
94
+ break
95
+ end
96
+ end
97
+ a0 = ary.collect { |x| x.split(/\t/) }
98
+ k = []
99
+ a0.each do |x|
100
+ x.each_index do |i|
101
+ y = x[i].strip
102
+ k[i] = k[i].to_s + (y.sub!(/\-\z/, '') ? y : y + ' ')
103
+ end
104
+ end
105
+ k.each { |x| x.strip! }
106
+ k
107
+ end
108
+ private :parse_header
109
+
110
+ # version of the psl format (String or nil).
111
+ attr_reader :psl_version
112
+
113
+ # Bio::Blat::Report::SeqDesc stores sequence information of
114
+ # query or subject of the BLAT report.
115
+ # It also includes some hit information.
116
+ class SeqDesc
117
+ # Creates a new SeqDesc object.
118
+ # It is designed to be called internally from Bio::Blat::Report class.
119
+ # Users shall not use it directly.
120
+ def initialize(gap_count, gap_bases, name, size,
121
+ st, ed, starts, seqs)
122
+ @gap_count = gap_count.to_i
123
+ @gap_bases = gap_bases.to_i
124
+ @name = name
125
+ @size = size.to_i
126
+ @start = st.to_i
127
+ @end = ed.to_i
128
+ @starts = starts.collect { |x| x.to_i }
129
+ @seqs = seqs
130
+ end
131
+ # gap count
132
+ attr_reader :gap_count
133
+ # gap bases
134
+ attr_reader :gap_bases
135
+ # name of the sequence
136
+ attr_reader :name
137
+ # length of the sequence
138
+ attr_reader :size
139
+ # start position of the first segment
140
+ attr_reader :start
141
+ # end position of the final segment
142
+ attr_reader :end
143
+ # start positions of segments.
144
+ # Returns an array of numbers.
145
+ attr_reader :starts
146
+ # sequences of segments.
147
+ # Returns an array of String.
148
+ # Returns nil if there are no sequence data.
149
+ attr_reader :seqs
150
+ end #class SeqDesc
151
+
152
+ # Sequence segment pair of BLAT result.
153
+ # Similar to Bio::Blast::Report::Hsp but lacks many methods.
154
+ class SegmentPair
155
+ # Creates a new SegmentPair object.
156
+ # It is designed to be called internally from Bio::Blat::Report class.
157
+ # Users shall not use it directly.
158
+ def initialize(query_len, target_len, strand,
159
+ blksize, qstart, tstart, qseq, tseq,
160
+ protein_flag)
161
+ @blocksize = blksize
162
+ @qseq = qseq
163
+ @hseq = hseq
164
+ @hit_strand = 'plus'
165
+ w = (protein_flag ? 3 : 1) # 3 means query=protein target=dna
166
+ case strand
167
+ when '-'
168
+ # query is minus strand
169
+ @query_strand = 'minus'
170
+ # convert positions
171
+ @query_from = query_len - qstart
172
+ @query_to = query_len - qstart - blksize + 1
173
+ # To keep compatibility, with other homology search programs,
174
+ # we add 1 to each position number.
175
+ @hit_from = tstart + 1
176
+ @hit_to = tstart + blksize * w # - 1 + 1
177
+ when '+-'
178
+ # hit is minus strand
179
+ @query_strand = 'plus'
180
+ @hit_strand = 'minus'
181
+ # To keep compatibility, with other homology search programs,
182
+ # we add 1 to each position number.
183
+ @query_from = qstart + 1
184
+ @query_to = qstart + blksize # - 1 + 1
185
+ # convert positions
186
+ @hit_from = target_len - tstart
187
+ @hit_to = target_len - tstart - blksize * w + 1
188
+ else #when '+', '++'
189
+ @query_strand = 'plus'
190
+ # To keep compatibility with other homology search programs,
191
+ # we add 1 to each position number.
192
+ @query_from = qstart + 1
193
+ @query_to = qstart + blksize # - 1 + 1
194
+ @hit_from = tstart + 1
195
+ @hit_to = tstart + blksize * w # - 1 + 1
196
+ end
197
+ end
198
+ # Returns query start position.
199
+ # CAUTION: In Blat's raw result(psl format), first position is 0.
200
+ # To keep compatibility, the parser add 1 to the position.
201
+ attr_reader :query_from
202
+
203
+ # Returns query end position.
204
+ # CAUTION: In Blat's raw result(psl format), first position is 0.
205
+ # To keep compatibility, the parser add 1 to the position.
206
+ attr_reader :query_to
207
+
208
+ # Returns query sequence.
209
+ # If sequence data is not available, returns nil.
210
+ attr_reader :qseq
211
+
212
+ # Returns strand information of the query.
213
+ # Returns 'plus' or 'minus'.
214
+ attr_reader :query_strand
215
+
216
+ # Returns target (subject, hit) start position.
217
+ # CAUTION: In Blat's raw result(psl format), first position is 0.
218
+ # To keep compatibility, the parser add 1 to the position.
219
+ attr_reader :hit_from
220
+
221
+ # Returns target (subject, hit) end position.
222
+ # CAUTION: In Blat's raw result(psl format), first position is 0.
223
+ # To keep compatibility, the parser add 1 to the position.
224
+ attr_reader :hit_to
225
+
226
+ # Returns the target (subject, hit) sequence.
227
+ # If sequence data is not available, returns nil.
228
+ attr_reader :hseq
229
+
230
+ # Returns strand information of the target (subject, hit).
231
+ # Returns 'plus' or 'minus'.
232
+ attr_reader :hit_strand
233
+
234
+ # Returns block size (length) of the segment pair.
235
+ # This would be a Bio::Blat specific method.
236
+ attr_reader :blocksize
237
+
238
+ # Returns alignment length of the segment pair.
239
+ # Returns nil if no alignment data are available.
240
+ def align_len
241
+ @qseq ? @qseq.size : nil
242
+ end
243
+ end #class SegmentPair
244
+
245
+ # Hit class for the BLAT result parser.
246
+ # Similar to Bio::Blast::Report::Hit but lacks many methods.
247
+ # Its object may contain some Bio::Blat::Report::SegmentPair objects.
248
+ class Hit
249
+ # Creates a new Hit object from a piece of BLAT result text.
250
+ # It is designed to be called internally from Bio::Blat::Report object.
251
+ # Users shall not use it directly.
252
+ def initialize(str)
253
+ @data = str.chomp.split(/\t/)
254
+ end
255
+
256
+ # Raw data of the hit.
257
+ # (Note that it doesn't add 1 to position numbers.)
258
+ attr_reader :data
259
+
260
+ # split comma-separeted text
261
+ def split_comma(str)
262
+ str.to_s.sub(/\s*\,+\s*\z/, '').split(/\s*\,\s*/)
263
+ end
264
+ private :split_comma
265
+
266
+ # Returns sequence informations of the query.
267
+ # Returns a Bio::Blat::Report::SeqDesc object.
268
+ # This would be Bio::Blat specific method.
269
+ def query
270
+ unless defined?(@query)
271
+ d = @data
272
+ @query = SeqDesc.new(d[4], d[5], d[9], d[10], d[11], d[12],
273
+ split_comma(d[19]), split_comma(d[21]))
274
+ end
275
+ @query
276
+ end
277
+
278
+ # Returns sequence informations of the target(hit).
279
+ # Returns a Bio::Blat::Report::SeqDesc object.
280
+ # This would be Bio::Blat specific method.
281
+ def target
282
+ unless defined?(@target)
283
+ d = @data
284
+ @target = SeqDesc.new(d[6], d[7], d[13], d[14], d[15], d[16],
285
+ split_comma(d[20]), split_comma(d[22]))
286
+ end
287
+ @target
288
+ end
289
+
290
+ # Match nucleotides.
291
+ def match; @data[0].to_i; end
292
+ # Mismatch nucleotides.
293
+ def mismatch; @data[1].to_i; end
294
+
295
+ # "rep. match".
296
+ # Number of bases that match but are part of repeats.
297
+ # Note that current version of BLAT always set 0.
298
+ def rep_match; @data[2].to_i; end
299
+
300
+ # "N's". Number of 'N' bases.
301
+ def n_s; @data[3].to_i; end
302
+
303
+ # Returns strand information of the hit.
304
+ # Returns '+' or '-'.
305
+ # This would be a Bio::Blat specific method.
306
+ def strand; @data[8]; end
307
+
308
+ # Number of blocks(exons, segment pairs).
309
+ def block_count; @data[17].to_i; end
310
+
311
+ # Sizes of all blocks(exons, segment pairs).
312
+ # Returns an array of numbers.
313
+ def block_sizes
314
+ unless defined?(@block_sizes) then
315
+ @block_sizes = split_comma(@data[18]).collect { |x| x.to_i }
316
+ end
317
+ @block_sizes
318
+ end
319
+
320
+ # Returns blocks(exons, segment pairs) of the hit.
321
+ # Returns an array of Bio::Blat::Report::SegmentPair objects.
322
+ def blocks
323
+ unless defined?(@blocks)
324
+ bs = block_sizes
325
+ qst = query.starts
326
+ tst = target.starts
327
+ qseqs = query.seqs
328
+ tseqs = target.seqs
329
+ pflag = self.protein?
330
+ @blocks = (0...block_count).collect do |i|
331
+ SegmentPair.new(query.size, target.size, strand, bs[i],
332
+ qst[i], tst[i], qseqs[i], tseqs[i],
333
+ pflag)
334
+ end
335
+ end
336
+ @blocks
337
+ end
338
+ alias exons blocks
339
+
340
+ #--
341
+ # Bio::BLAST::*::Report::Hit compatible methods
342
+ #++
343
+ alias hsps blocks
344
+
345
+ # Returns the length of query sequence.
346
+ def query_len; query.size; end
347
+
348
+ # Returns the name of query sequence.
349
+ def query_def; query.name; end
350
+ alias query_id query_def
351
+
352
+ # Returns the length of the target(subject) sequence.
353
+ def target_len; target.size; end
354
+ alias len target_len
355
+
356
+ # Returns the name of the target(subject) sequence.
357
+ def target_def; target.name; end
358
+ alias target_id target_def
359
+ alias definition target_def
360
+
361
+ #Iterates over each block(exon, segment pair) of the hit.
362
+ # Yields a Bio::Blat::Report::SegmentPair object.
363
+ def each(&x) #:yields: segmentpair
364
+ exons.each(&x)
365
+ end
366
+
367
+ #--
368
+ # methods described in the BLAT FAQ at the UCSC genome browser.
369
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4)
370
+ #++
371
+
372
+ # Calculates the pslCalcMilliBad value defined in the
373
+ # BLAT FAQ (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
374
+ #
375
+ # The algorithm is taken from the BLAT FAQ
376
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
377
+ def milli_bad
378
+ w = (self.protein? ? 3 : 1)
379
+ qalen = w * (self.query.end - self.query.start)
380
+ talen = self.target.end - self.target.start
381
+ alen = (if qalen < talen then qalen; else talen; end)
382
+ return 0 if alen <= 0
383
+ d = qalen - talen
384
+ d = 0 if d < 0
385
+ total = w * (self.match + self.rep_match + self.mismatch)
386
+ return 0 if total == 0
387
+ return (1000 * (self.mismatch * w + self.query.gap_count +
388
+ (3 * Math.log(1 + d)).round) / total)
389
+ end
390
+
391
+ # Calculates the percent identity compatible with the BLAT web server
392
+ # as described in the BLAT FAQ
393
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
394
+ #
395
+ # The algorithm is taken from the BLAT FAQ
396
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
397
+ def percent_identity
398
+ 100.0 - self.milli_bad * 0.1
399
+ end
400
+
401
+ # When the output data comes from the protein query, returns true.
402
+ # Otherwise (nucleotide query), returns false.
403
+ # It returns nil if this cannot be determined.
404
+ #
405
+ # The algorithm is taken from the BLAT FAQ
406
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
407
+ #
408
+ # Note: It seems that it returns true only when protein query
409
+ # with nucleotide database (blat options: -q=prot -t=dnax).
410
+ def protein?
411
+ return nil if self.block_sizes.empty?
412
+ case self.strand[1,1]
413
+ when '+'
414
+ if self.target.end == self.target.starts[-1] +
415
+ 3 * self.block_sizes[-1] then
416
+ true
417
+ else
418
+ false
419
+ end
420
+ when '-'
421
+ if self.target.start == self.target.size -
422
+ self.target.starts[-1] - 3 * self.block_sizes[-1] then
423
+ true
424
+ else
425
+ false
426
+ end
427
+ else
428
+ nil
429
+ end
430
+ end
431
+
432
+ # Calculates the score compatible with the BLAT web server
433
+ # as described in the BLAT FAQ
434
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
435
+ #
436
+ # The algorithm is taken from the BLAT FAQ
437
+ # (http://genome.ucsc.edu/FAQ/FAQblat#blat4).
438
+ def score
439
+ w = (self.protein? ? 3 : 1)
440
+ w * (self.match + (self.rep_match >> 1)) -
441
+ w * self.mismatch - self.query.gap_count - self.target.gap_count
442
+ end
443
+ end #class Hit
444
+
445
+ #--
446
+ #Bio::BLAST::*::Report compatible methods
447
+ #++
448
+
449
+ # Returns number of hits.
450
+ # Same as hits.size.
451
+ def num_hits; @hits.size; end
452
+
453
+ # Iterates over each Bio::Blat::Report::Hit object.
454
+ # Same as hits.each.
455
+ def each_hit(&x) #:yields: hit
456
+ @hits.each(&x)
457
+ end
458
+ alias each each_hit
459
+
460
+ # Returns the name of query sequence.
461
+ # CAUTION: query_* methods simply return first hit's query_*.
462
+ # If multiple query sequences are given, these values
463
+ # will be incorrect.
464
+ def query_def; (x = @hits.first) ? x.query_def : nil; end
465
+
466
+ # Returns the length of query sequence.
467
+ # CAUTION: query_* methods simply return first hit's query_*.
468
+ # If multiple query sequences are given, these values
469
+ # will be incorrect.
470
+ def query_len; (x = @hits.first) ? x.query_len : nil; end
471
+ alias query_id query_def
472
+ end #class Report
473
+
474
+ end #class Blat
475
+ end #module Bio
476
+
477
+ =begin
478
+
479
+ = Bio::Blat::Report
480
+
481
+ BLAT result parser. (psl / pslx format)
482
+
483
+ = References
484
+
485
+ * ((<URL:http://www.genome.org/cgi/content/abstract/12/4/656>))
486
+ Kent, W.J., BLAT--the BLAST-like alignment tool,
487
+ Genome Research, 12, 656--664, 2002.
488
+
489
+ =end