Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fix: fixed ScanError when bit score is in exponential notation

* Bug fix: fixed ScanError when bit score is in exponential notation
  such as 1.234e+5.
* Regular expressions for numerics including exponential notations
  are changed to get correct values.
  • Loading branch information...
commit 9256ce8e0c25d9097db2267829b294e9a8b38823 1 parent 88b2fb2
@ngoto ngoto authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/bio/appl/blast/format0.rb
View
20 lib/bio/appl/blast/format0.rb
@@ -345,7 +345,7 @@ def parse_colon_separated_params(hash, ary)
sc = StringScanner.new(str)
sc.skip(/\s*/)
while sc.rest?
- if sc.match?(/Number of sequences better than +([e\-\.\d]+) *\: *(.+)/) then
+ if sc.match?(/Number of sequences better than +([e\+\-\.\d]+) *\: *(.+)/) then
ev = sc[1]
ev = '1' + ev if ev[0] == ?e
@expect = ev.to_f
@@ -369,7 +369,7 @@ def parse_params
parse_colon_separated_params(@hash, @f0params)
#p @hash
if val = @hash['Matrix'] then
- if /blastn *matrix *\: *([e\-\.\d]+) +([e\-\.\d]+)/ =~ val then
+ if /blastn *matrix *\: *([e\+\-\.\d]+) +([e\+\-\.\d]+)/ =~ val then
@matrix = 'blastn'
@sc_match = $1.to_i
@sc_mismatch = $2.to_i
@@ -378,10 +378,10 @@ def parse_params
end
end
if val = @hash['Gap Penalties'] then
- if /Existence\: *([e\-\.\d]+)/ =~ val then
+ if /Existence\: *([e\+\-\.\d]+)/ =~ val then
@gap_open = $1.to_i
end
- if /Extension\: *([e\-\.\d]+)/ =~ val then
+ if /Extension\: *([e\+\-\.\d]+)/ =~ val then
@gap_extend = $1.to_i
end
end
@@ -716,7 +716,7 @@ def parse_stat
sc.skip(/ */)
end
sc.skip(/\s*/)
- while r = sc.scan(/[e\.\-\d]+/)
+ while r = sc.scan(/[e\+\-\.\d]+/)
#p r
h[s0.shift] = r
sc.skip(/ */)
@@ -973,11 +973,11 @@ def parse_score
sc = StringScanner.new(@f0score)
while sc.rest?
sc.skip(/\s*/)
- if sc.skip(/Expect(?:\(\d+\))? *\= *([e\-\.\d]+)/) then
+ if sc.skip(/Expect(?:\(\d+\))? *\= *([e\+\-\.\d]+)/) then
ev = sc[1].to_s
ev = '1' + ev if ev[0] == ?e
@evalue = ev.to_f
- elsif sc.skip(/Score *\= *([e\-\.\d]+) *bits *\( *([e\-\.\d]+) *\)/) then
+ elsif sc.skip(/Score *\= *([e\+\-\.\d]+) *bits *\( *([e\+\-\.\d]+) *\)/) then
bs = sc[1]
bs = '1' + bs if bs[0] == ?e
@bit_score = bs.to_f
@@ -1021,19 +1021,19 @@ def parse_score
if sc[2] then
@hit_frame = sc[3].to_i
end
- elsif sc.skip(/Score *\= *([e\-\.\d]+) +\(([e\-\.\d]+) *bits *\)/) then
+ elsif sc.skip(/Score *\= *([e\+\-\.\d]+) +\(([e\+\-\.\d]+) *bits *\)/) then
#WU-BLAST
@score = sc[1].to_i
bs = sc[2]
bs = '1' + bs if bs[0] == ?e
@bit_score = bs.to_f
- elsif sc.skip(/P *\= * ([e\-\.\d]+)/) then
+ elsif sc.skip(/P *\= * ([e\+\-\.\d]+)/) then
#WU-BLAST
@p_sum_n = nil
pv = sc[1]
pv = '1' + pv if pv[0] == ?e
@pvalue = pv.to_f
- elsif sc.skip(/Sum +P *\( *(\d+) *\) *\= *([e\-\.\d]+)/) then
+ elsif sc.skip(/Sum +P *\( *(\d+) *\) *\= *([e\+\-\.\d]+)/) then
#WU-BLAST
@p_sum_n = sc[1].to_i
pv = sc[2]
Please sign in to comment.
Something went wrong with that request. Please try again.