bio 1.5.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +35 -36
  3. data/ChangeLog +911 -2554
  4. data/{gemfiles/Gemfile.travis-ruby2.2 → Gemfile} +0 -3
  5. data/KNOWN_ISSUES.rdoc +10 -13
  6. data/LEGAL +0 -10
  7. data/README.rdoc +40 -96
  8. data/README_DEV.rdoc +5 -5
  9. data/RELEASE_NOTES.rdoc +118 -234
  10. data/Rakefile +13 -43
  11. data/appveyor.yml +29 -0
  12. data/bioruby.gemspec +18 -81
  13. data/bioruby.gemspec.erb +8 -28
  14. data/doc/ChangeLog-1.5.0 +2919 -0
  15. data/doc/RELEASE_NOTES-1.5.0.rdoc +285 -0
  16. data/doc/Tutorial.rd +6 -108
  17. data/doc/Tutorial.rd.html +19 -98
  18. data/gemfiles/Gemfile.travis-jruby1.8 +3 -5
  19. data/gemfiles/Gemfile.travis-jruby1.9 +0 -3
  20. data/gemfiles/Gemfile.travis-rbx +0 -3
  21. data/gemfiles/Gemfile.travis-ruby1.8 +3 -5
  22. data/gemfiles/Gemfile.travis-ruby1.9 +0 -3
  23. data/gemfiles/Gemfile.windows +6 -0
  24. data/gemfiles/prepare-gemspec.rb +4 -0
  25. data/lib/bio.rb +0 -10
  26. data/lib/bio/appl/blast/genomenet.rb +4 -4
  27. data/lib/bio/appl/blast/report.rb +40 -8
  28. data/lib/bio/appl/fasta/format10.rb +2 -1
  29. data/lib/bio/command.rb +10 -0
  30. data/lib/bio/data/codontable.rb +99 -3
  31. data/lib/bio/db/aaindex.rb +74 -5
  32. data/lib/bio/db/gff.rb +3 -1
  33. data/lib/bio/db/kegg/common.rb +14 -0
  34. data/lib/bio/db/kegg/genes.rb +26 -0
  35. data/lib/bio/db/kegg/pathway.rb +5 -11
  36. data/lib/bio/db/soft.rb +2 -2
  37. data/lib/bio/io/flatfile/autodetection.rb +5 -0
  38. data/lib/bio/io/togows.rb +5 -5
  39. data/lib/bio/map.rb +4 -4
  40. data/lib/bio/sequence/format.rb +1 -0
  41. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +1 -1
  42. data/lib/bio/util/sirna.rb +2 -0
  43. data/lib/bio/version.rb +6 -8
  44. data/sample/color_scheme_aa.rb +82 -0
  45. data/sample/color_scheme_na.rb +5 -6
  46. data/sample/fastq2html.cwl +23 -0
  47. data/sample/fastq2html.rb +94 -0
  48. data/sample/fastq2html.testdata.yaml +5 -0
  49. data/sample/na2aa.cwl +23 -0
  50. data/sample/na2aa.rb +11 -25
  51. data/sample/na2aa.testdata.yaml +7 -0
  52. data/sample/rev_comp.cwl +23 -0
  53. data/sample/rev_comp.rb +20 -0
  54. data/sample/rev_comp.testdata.yaml +7 -0
  55. data/sample/test_restriction_enzyme_long.rb +1 -1
  56. data/test/network/bio/db/kegg/test_genes_hsa7422.rb +91 -0
  57. data/test/unit/bio/appl/blast/test_report.rb +4 -4
  58. data/test/unit/bio/data/test_codontable.rb +3 -0
  59. data/test/unit/bio/db/test_gff.rb +5 -0
  60. data/test/unit/bio/test_alignment.rb +2 -2
  61. metadata +20 -77
  62. data/bin/bioruby +0 -47
  63. data/bin/br_biofetch.rb +0 -71
  64. data/bin/br_bioflat.rb +0 -293
  65. data/bin/br_biogetseq.rb +0 -45
  66. data/bin/br_pmfetch.rb +0 -422
  67. data/lib/bio/appl/blast/xmlparser.rb +0 -236
  68. data/lib/bio/db/biosql/biosql_to_biosequence.rb +0 -78
  69. data/lib/bio/db/biosql/sequence.rb +0 -444
  70. data/lib/bio/db/phyloxml/phyloxml.xsd +0 -582
  71. data/lib/bio/db/phyloxml/phyloxml_elements.rb +0 -1197
  72. data/lib/bio/db/phyloxml/phyloxml_parser.rb +0 -1001
  73. data/lib/bio/db/phyloxml/phyloxml_writer.rb +0 -227
  74. data/lib/bio/io/biosql/ar-biosql.rb +0 -257
  75. data/lib/bio/io/biosql/biosql.rb +0 -39
  76. data/lib/bio/io/biosql/config/database.yml +0 -21
  77. data/lib/bio/io/sql.rb +0 -79
  78. data/lib/bio/shell.rb +0 -44
  79. data/lib/bio/shell/core.rb +0 -578
  80. data/lib/bio/shell/demo.rb +0 -146
  81. data/lib/bio/shell/interface.rb +0 -217
  82. data/lib/bio/shell/irb.rb +0 -94
  83. data/lib/bio/shell/object.rb +0 -71
  84. data/lib/bio/shell/plugin/blast.rb +0 -42
  85. data/lib/bio/shell/plugin/codon.rb +0 -218
  86. data/lib/bio/shell/plugin/das.rb +0 -58
  87. data/lib/bio/shell/plugin/emboss.rb +0 -23
  88. data/lib/bio/shell/plugin/entry.rb +0 -137
  89. data/lib/bio/shell/plugin/flatfile.rb +0 -101
  90. data/lib/bio/shell/plugin/midi.rb +0 -430
  91. data/lib/bio/shell/plugin/ncbirest.rb +0 -68
  92. data/lib/bio/shell/plugin/obda.rb +0 -45
  93. data/lib/bio/shell/plugin/psort.rb +0 -56
  94. data/lib/bio/shell/plugin/seq.rb +0 -248
  95. data/lib/bio/shell/plugin/togows.rb +0 -40
  96. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +0 -29
  97. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +0 -4
  98. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +0 -27
  99. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +0 -11
  100. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +0 -4
  101. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +0 -7
  102. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
  103. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
  104. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
  105. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +0 -368
  106. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +0 -47
  107. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +0 -144
  108. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +0 -47
  109. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +0 -8
  110. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +0 -10
  111. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +0 -26
  112. data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
  113. data/lib/bio/shell/script.rb +0 -25
  114. data/lib/bio/shell/setup.rb +0 -108
  115. data/lib/bio/shell/web.rb +0 -102
  116. data/sample/test_phyloxml_big.rb +0 -205
  117. data/setup.rb +0 -1600
  118. data/test/data/phyloxml/apaf.xml +0 -666
  119. data/test/data/phyloxml/bcl_2.xml +0 -2097
  120. data/test/data/phyloxml/made_up.xml +0 -144
  121. data/test/data/phyloxml/ncbi_taxonomy_mollusca_short.xml +0 -65
  122. data/test/data/phyloxml/phyloxml_examples.xml +0 -415
  123. data/test/unit/bio/db/biosql/tc_biosql.rb +0 -114
  124. data/test/unit/bio/db/biosql/ts_suite_biosql.rb +0 -8
  125. data/test/unit/bio/db/test_phyloxml.rb +0 -821
  126. data/test/unit/bio/db/test_phyloxml_writer.rb +0 -334
  127. data/test/unit/bio/shell/plugin/test_seq.rb +0 -187
  128. data/test/unit/bio/test_shell.rb +0 -20
@@ -1,422 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # = pmfetch - PubMed client
4
- #
5
- # Copyright:: Copyright (C) 2004, 2005
6
- # Toshiaki Katayama <k@bioruby.org>
7
- # License:: The Ruby License
8
- #
9
- # $Id:$
10
- #
11
-
12
- require 'bio'
13
-
14
- PROG_VER = "Powered by BioRuby #{Bio::BIORUBY_VERSION_ID}"
15
- PROG_NAME = File.basename($0)
16
-
17
-
18
- require 'getoptlong'
19
-
20
-
21
- ### formatting
22
-
23
- class String
24
- def fill(fill_column = 80, prefix = '', separater = ' ')
25
- prefix = ' ' * prefix if prefix.is_a?(Integer)
26
- maxlen = fill_column - prefix.length
27
- raise "prefix is longer than fill_column" if maxlen <= 0
28
-
29
- cursor = pos = 0
30
- lines = []
31
- while cursor < self.length
32
- line = self[cursor, maxlen]
33
- pos = line.rindex(separater)
34
- pos = nil if line.length < maxlen
35
- if pos
36
- len = pos + separater.length
37
- lines << self[cursor, len]
38
- cursor += len
39
- else
40
- lines << self[cursor, maxlen]
41
- cursor += maxlen
42
- end
43
- end
44
- return lines.join("\n#{prefix}")
45
- end
46
- end
47
-
48
-
49
- module Bio
50
- class Reference
51
- def report
52
- if (num = @authors.size) > 10
53
- authors = "#{@authors[0]} et al. (#{num} authors)"
54
- elsif num > 4
55
- sep = ',' * (num - 1)
56
- authors = "#{@authors[0]}#{sep} #{@authors[-1]}"
57
- else
58
- authors = authors_join(' & ')
59
- end
60
- journal = "#{@journal} #{@year} #{@volume}(#{@issue}):#{@pages}"
61
-
62
- indent = 8
63
- prefix = ' ' * indent
64
- [
65
- "#{@pages[/\d+/]}".ljust(indent) + "#{@title}".fill(78, indent),
66
- authors,
67
- "#{journal} [PMID:#{@pubmed}]",
68
- ].join("\n#{prefix}")
69
- end
70
- end
71
- end
72
-
73
-
74
- class PMFetch
75
-
76
- class Examples < StandardError; end
77
- class Version < StandardError; end
78
- class Usage < StandardError; end
79
-
80
- ### default options
81
-
82
- def initialize
83
- @format = 'rd'
84
- @search_opts = {
85
- 'retmax' => 20,
86
- }
87
- @query = nil
88
- @query_opts = []
89
- @pmid_list_only = false
90
-
91
- pmfetch
92
- end
93
-
94
-
95
- ### main
96
-
97
- def pmfetch
98
- begin
99
- set_options
100
- parse_options
101
- check_query
102
- rescue PMFetch::Examples
103
- puts examples
104
- exit
105
- rescue PMFetch::Version
106
- puts version
107
- exit
108
- rescue PMFetch::Usage
109
- puts usage
110
- exit
111
- rescue GetoptLong::MissingArgument, GetoptLong::InvalidOption
112
- puts usage
113
- exit
114
- end
115
-
116
- list = pm_esearch
117
-
118
- if list.empty?
119
- ;
120
- elsif @pmid_list_only
121
- puts list
122
- else
123
- pm_efetch(list)
124
- end
125
- end
126
-
127
-
128
- ### help
129
-
130
- def usage
131
- %Q[
132
- Usage: #{PROG_NAME} [options...] "query string"
133
- or #{PROG_NAME} --query "query string" [other options...]
134
-
135
- Options:
136
- -q --query "genome AND virus" Query string for PubMed search
137
- -t --title "mobile elements" Title of the article to search
138
- -j --journal "genome res" Journal title to search
139
- -v --volume # Journal volume to search
140
- -i --issue # Journal issue to search
141
- -p --page # First page number of the article to search
142
- -a --author "Altschul SF" Author name to search
143
- -m --mesh "SARS virus" MeSH term to search
144
- -f --format bibtex Summary output format
145
- --pmidlist Output only a list of PubMed IDs
146
- -n --retmax # Number of articles to retrieve at the maximum
147
- -N --retstart # Starting number of the articles to retrieve
148
- -s --sort pub+date Sort method for the summary output
149
- --reldate # Search articles published within recent # days
150
- --mindate YYYY/MM/DD Search articles published after the date
151
- --maxdate YYYY/MM/DD Search articles published before the date
152
- --help Output this help, then exit
153
- --examples Output examples, then exit
154
- --version Output version number, then exit
155
-
156
- Formats:
157
- endnote, medline, bibitem, bibtex, report, rd,
158
- nature, science, genome_res, genome_biol, nar, current, trends, cell
159
-
160
- Sort:
161
- author, journal, pub+date, page
162
-
163
- See the following pages for the PubMed search options:
164
- http://www.ncbi.nlm.nih.gov/entrez/query/static/help/pmhelp.html
165
- http://www.ncbi.nlm.nih.gov/entrez/query/static/esearch_help.html
166
-
167
- #{version}
168
-
169
- ]
170
- end
171
-
172
- def version
173
- PROG_VER
174
- end
175
-
176
- def examples
177
- DATA.read.gsub('PMFetch', PROG_NAME)
178
- end
179
-
180
-
181
- private
182
-
183
-
184
- ### options
185
-
186
- def set_options
187
- @parser = GetoptLong.new
188
-
189
- @parser.set_options(
190
- [ '--query', '-q', GetoptLong::REQUIRED_ARGUMENT ],
191
- [ '--title', '-t', GetoptLong::REQUIRED_ARGUMENT ],
192
- [ '--journal', '-j', GetoptLong::REQUIRED_ARGUMENT ],
193
- [ '--volume', '-v', GetoptLong::REQUIRED_ARGUMENT ],
194
- [ '--issue', '-i', GetoptLong::REQUIRED_ARGUMENT ],
195
- [ '--page', '-p', GetoptLong::REQUIRED_ARGUMENT ],
196
- [ '--author', '-a', GetoptLong::REQUIRED_ARGUMENT ],
197
- [ '--mesh', '-m', GetoptLong::REQUIRED_ARGUMENT ],
198
- [ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ],
199
- [ '--pmidlist', GetoptLong::NO_ARGUMENT ],
200
- [ '--retmax', '-n', GetoptLong::REQUIRED_ARGUMENT ],
201
- [ '--retstart', '-N', GetoptLong::REQUIRED_ARGUMENT ],
202
- [ '--sort', '-s', GetoptLong::REQUIRED_ARGUMENT ],
203
- [ '--reldate', GetoptLong::REQUIRED_ARGUMENT ],
204
- [ '--mindate', GetoptLong::REQUIRED_ARGUMENT ],
205
- [ '--maxdate', GetoptLong::REQUIRED_ARGUMENT ],
206
- [ '--examples', GetoptLong::NO_ARGUMENT ],
207
- [ '--help', GetoptLong::NO_ARGUMENT ],
208
- [ '--version', GetoptLong::NO_ARGUMENT ]
209
- )
210
- end
211
-
212
- def parse_options
213
- @parser.each_option do |optname, optarg|
214
- case optname
215
- when /--query/
216
- @query = optarg
217
- when /--title/
218
- @query_opts << "#{optarg}[ti]"
219
- when /--journal/
220
- @query_opts << "#{optarg}[ta]"
221
- when /--volume/
222
- @query_opts << "#{optarg}[vi]"
223
- when /--issue/
224
- @query_opts << "#{optarg}[ip]"
225
- when /--page/
226
- @query_opts << "#{optarg}[pg]"
227
- when /--author/
228
- @query_opts << "#{optarg}[au]"
229
- when /--mesh/
230
- @query_opts << "#{optarg}[mh]"
231
- when /--format/
232
- @format = optarg
233
- when /--pmidlist/
234
- @pmid_list_only = true
235
- when /--examples/
236
- raise PMFetch::Examples
237
- when /--help/
238
- raise PMFetch::Usage
239
- when /--version/
240
- raise PMFetch::Version
241
- when /--sort/
242
- @sort = optarg
243
- @search_opts["sort"] = @sort unless @sort == "page"
244
- else
245
- optname.delete!('-')
246
- @search_opts[optname] = optarg
247
- end
248
- end
249
- end
250
-
251
-
252
- ### check query
253
-
254
- def check_query
255
- p @query if $DEBUG
256
- @query ||= ARGV.join(" ") unless ARGV.empty?
257
-
258
- p @query if $DEBUG
259
- @query_str = [ @query, @query_opts ].flatten.compact.join(" AND ")
260
-
261
- p @query_str if $DEBUG
262
- if @query_str.empty?
263
- raise PMFetch::Usage
264
- end
265
- end
266
-
267
-
268
- ### search
269
-
270
- def pm_esearch
271
- return Bio::PubMed.esearch(@query_str, @search_opts)
272
- end
273
-
274
- def pm_efetch(list)
275
- entries = Bio::PubMed.efetch(list)
276
-
277
- if @format == 'medline'
278
- medline_format(entries)
279
- else
280
- entries = parse_entries(entries)
281
- if @sort == 'page'
282
- entries = sort_entries(entries)
283
- end
284
- if @format == 'report'
285
- report_format(entries)
286
- else
287
- other_format(entries)
288
- end
289
- end
290
- end
291
-
292
-
293
- ### output
294
-
295
- def medline_format(entries)
296
- entries.each do |entry|
297
- puts entry
298
- puts '//'
299
- end
300
- end
301
-
302
- def parse_entries(entries)
303
- entries.map { |entry| Bio::MEDLINE.new(entry) }
304
- end
305
-
306
- def sort_entries(entries)
307
- if RUBY_VERSION > "1.8.0"
308
- entries.sort_by { |x|
309
- [ x.journal, x.volume.to_i, x.issue.to_i, x.pages.to_i ]
310
- }
311
- else
312
- entries.map { |x|
313
- [ x.journal, x.volume.to_i, x.issue.to_i, x.pages.to_i, x ]
314
- }.sort { |a, b|
315
- a[0..3] <=> b[0..3]
316
- }.map { |y|
317
- y.pop
318
- }
319
- end
320
- end
321
-
322
- def report_format(entries)
323
- entries.each do |entry|
324
- puts entry.reference.report
325
- puts
326
- end
327
- end
328
-
329
- def other_format(entries)
330
- entries.each do |entry|
331
- puts entry.reference.format(@format)
332
- puts
333
- end
334
- end
335
-
336
- end
337
-
338
-
339
- PMFetch.new
340
-
341
-
342
- __END__
343
-
344
- = Examples : PubMed search
345
-
346
- These four lines will do the same job.
347
-
348
- % PMFetch transcription factor
349
- % PMFetch "transcription factor"
350
- % PMFetch --query "transcription factor"
351
- % PMFetch -q "transcription factor"
352
-
353
-
354
- Retrieve max 100 artiecles (20 is a NCBI's default) at a time, use --retmax as
355
-
356
- % PMFetch -q "transcription factor" --retmax 100
357
-
358
- and, to retrieve next 100 articles, use --retstart as
359
-
360
- % PMFetch -q "transcription factor" --retmax 100 --retstart 100
361
-
362
-
363
- You can narrow the search target for an issue of the journal.
364
-
365
- % PMFetch --journal development --volume 131 --issue 3 transcription factor
366
-
367
-
368
- Short options are also available.
369
-
370
- % PMFetch -j development -v 131 -i 3 transcription factor
371
-
372
-
373
- Search articles indexed in PubMed within these 90 days.
374
-
375
- % PMFetch -q "transcription factor" --reldate 90
376
-
377
-
378
- Search articles indexed in PubMed during the period of 2001/04/01 to 2001/08/31
379
-
380
- % PMFetch -q "transcription factor" --mindate 2001/04/01 --maxdate 2001/08/31
381
-
382
-
383
- Output format can be changed by --format option.
384
-
385
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f report
386
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f rd
387
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f endnote
388
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f medline
389
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f bibitem
390
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f bibtex
391
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f nature
392
- % PMFetch -q "transcription factor" -j development -v 131 -i 3 -f science
393
-
394
-
395
- Generate title listings for the journal report meeting (don't forget
396
- to inclease the number of --retmax for fetching all titles).
397
-
398
- % PMFetch -f report -j development -v 131 -i 3 -n 100
399
-
400
-
401
- Search by author name.
402
-
403
- % PMFetch -a "Karlin S"
404
- % PMFetch -a "Koonin EV"
405
-
406
-
407
- Search by MeSH term.
408
-
409
- % PMFetch -m "computational biology"
410
- % PMFetch -m "SARS virus"
411
-
412
-
413
- Search by PubMed ID (PMID).
414
-
415
- % PMFetch 12345
416
-
417
-
418
- Output PMID only.
419
-
420
- % PMFetch --pmidlist tardigrada
421
-
422
-
@@ -1,236 +0,0 @@
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:$
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
-
157
- # for new BLAST XML format
158
- when 'Iteration_query-ID'
159
- @iterations.last.query_id = hash[tag].to_s
160
- when 'Iteration_query-def'
161
- @iterations.last.query_def = hash[tag].to_s
162
- when 'Iteration_query-len'
163
- @iterations.last.query_len = hash[tag].to_i
164
- end
165
- end
166
-
167
- def xmlparser_parse_hit(tag, hash)
168
- hit = @iterations.last.hits.last
169
- case tag
170
- when 'Hit_num'
171
- hit.num = hash[tag].to_i
172
- when 'Hit_id'
173
- hit.hit_id = hash[tag].clone
174
- when 'Hit_def'
175
- hit.definition = hash[tag].clone
176
- when 'Hit_accession'
177
- hit.accession = hash[tag].clone
178
- when 'Hit_len'
179
- hit.len = hash[tag].clone.to_i
180
- end
181
- end
182
-
183
- def xmlparser_parse_hsp(hash)
184
- hsp = @iterations.last.hits.last.hsps.last
185
- hsp.num = hash['Hsp_num'].to_i
186
- hsp.bit_score = hash['Hsp_bit-score'].to_f
187
- hsp.score = hash['Hsp_score'].to_i
188
- hsp.evalue = hash['Hsp_evalue'].to_f
189
- hsp.query_from = hash['Hsp_query-from'].to_i
190
- hsp.query_to = hash['Hsp_query-to'].to_i
191
- hsp.hit_from = hash['Hsp_hit-from'].to_i
192
- hsp.hit_to = hash['Hsp_hit-to'].to_i
193
- hsp.pattern_from = hash['Hsp_pattern-from'].to_i
194
- hsp.pattern_to = hash['Hsp_pattern-to'].to_i
195
- hsp.query_frame = hash['Hsp_query-frame'].to_i
196
- hsp.hit_frame = hash['Hsp_hit-frame'].to_i
197
- hsp.identity = hash['Hsp_identity'].to_i
198
- hsp.positive = hash['Hsp_positive'].to_i
199
- hsp.gaps = hash['Hsp_gaps'].to_i
200
- hsp.align_len = hash['Hsp_align-len'].to_i
201
- hsp.density = hash['Hsp_density'].to_i
202
- hsp.qseq = hash['Hsp_qseq']
203
- hsp.hseq = hash['Hsp_hseq']
204
- hsp.midline = hash['Hsp_midline']
205
- end
206
-
207
- def xmlparser_parse_statistics(hash)
208
- labels = {
209
- 'db-num' => 'Statistics_db-num',
210
- 'db-len' => 'Statistics_db-len',
211
- 'hsp-len' => 'Statistics_hsp-len',
212
- 'eff-space' => 'Statistics_eff-space',
213
- 'kappa' => 'Statistics_kappa',
214
- 'lambda' => 'Statistics_lambda',
215
- 'entropy' => 'Statistics_entropy'
216
- }
217
- labels.each do |k,v|
218
- case k
219
- when 'db-num', 'db-len', 'hsp-len'
220
- @iterations.last.statistics[k] = hash[v].to_i
221
- else
222
- @iterations.last.statistics[k] = hash[v].to_f
223
- end
224
- end
225
- end
226
-
227
- end # class Report
228
- end # class Blast
229
- end # module Bio
230
-
231
-
232
- =begin
233
-
234
- This file is automatically loaded by bio/appl/blast/report.rb
235
-
236
- =end