bio 1.6.0.pre.20181210 → 2.0.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +32 -34
- data/ChangeLog +1462 -8
- data/Gemfile +0 -2
- data/KNOWN_ISSUES.rdoc +4 -10
- data/LEGAL +0 -10
- data/README.rdoc +31 -80
- data/README_DEV.rdoc +5 -5
- data/RELEASE_NOTES.rdoc +171 -18
- data/Rakefile +0 -34
- data/appveyor.yml +15 -7
- data/bioruby.gemspec +13 -4
- data/bioruby.gemspec.erb +0 -1
- data/gemfiles/Gemfile.travis-rbx +0 -2
- data/gemfiles/Gemfile.travis-ruby1.8 +0 -2
- data/gemfiles/Gemfile.travis-ruby1.9 +0 -2
- data/gemfiles/Gemfile.windows +6 -0
- data/lib/bio/appl/blast/report.rb +40 -8
- data/lib/bio/appl/iprscan/report.rb +3 -3
- data/lib/bio/appl/sosui/report.rb +1 -1
- data/lib/bio/db/embl/uniprotkb.rb +1 -1
- data/lib/bio/db/gff.rb +3 -1
- data/lib/bio/db/go.rb +2 -2
- data/lib/bio/db/kegg/common.rb +14 -0
- data/lib/bio/db/kegg/genes.rb +26 -0
- data/lib/bio/db/kegg/pathway.rb +5 -11
- data/lib/bio/sequence/common.rb +112 -0
- data/lib/bio/sequence/format.rb +1 -0
- data/lib/bio/tree.rb +1 -1
- data/lib/bio/version.rb +3 -3
- data/sample/color_scheme_aa.rb +82 -0
- data/sample/color_scheme_na.rb +5 -6
- data/sample/fastq2html.cwl +23 -0
- data/sample/fastq2html.rb +94 -0
- data/sample/fastq2html.testdata.yaml +5 -0
- data/sample/na2aa.cwl +23 -0
- data/sample/na2aa.rb +11 -25
- data/sample/na2aa.testdata.yaml +7 -0
- data/sample/rev_comp.cwl +23 -0
- data/sample/rev_comp.rb +20 -0
- data/sample/rev_comp.testdata.yaml +7 -0
- data/test/network/bio/db/kegg/test_genes_hsa7422.rb +91 -0
- data/test/unit/bio/appl/blast/test_report.rb +4 -4
- data/test/unit/bio/db/test_gff.rb +5 -0
- data/test/unit/bio/sequence/test_ruby3.rb +462 -0
- metadata +17 -8
- data/lib/bio/appl/blast/xmlparser.rb +0 -236
- data/setup.rb +0 -1600
@@ -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
|