Class: Bio::Blast::Default::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/blast/format0.rb

Overview

Bio::Blast::Default::Report parses NCBI BLAST default output and stores information in the data. It may store some Bio::Blast::Default::Report::Iteration objects.

Defined Under Namespace

Classes: AlwaysNil, F0dbstat, HSP, Hit, Iteration

Constant Summary collapse

DELIMITER =

Delimiter of each entry. Bio::FlatFile uses it.

RS = "\nBLAST"
DELIMITER_OVERRUN =

(Integer) excess read size included in DELIMITER.

5

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arg) ⇒ Report

def

[View source]

53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bio/appl/blast/format0.rb', line 53

def initialize(str)
  str = str.sub(/\A\s+/, '')
  str.sub!(/\n(T?BLAST.*)/m, "\n") # remove trailing entries for sure
  @entry_overrun = $1
  @entry = str
  data = str.split(/(?:^[ \t]*\n)+/)

  format0_split_headers(data)
  @iterations = format0_split_search(data)
  format0_split_stat_params(data)
end

Instance Attribute Details

#db_lenObject (readonly)

number of letters in database


102
103
104
# File 'lib/bio/appl/blast/format0.rb', line 102

def db_len
  @db_len
end

#db_numObject (readonly)

number of sequences in database


98
99
100
# File 'lib/bio/appl/blast/format0.rb', line 98

def db_num
  @db_num
end

#eff_spaceObject (readonly)

effective length of the database


110
111
112
# File 'lib/bio/appl/blast/format0.rb', line 110

def eff_space
  @eff_space
end

#entry_overrunObject (readonly)

piece of next entry. Bio::FlatFile uses it.


65
66
67
# File 'lib/bio/appl/blast/format0.rb', line 65

def entry_overrun
  @entry_overrun
end

#expectObject (readonly)

e-value threshold specified when BLAST was executed


134
135
136
# File 'lib/bio/appl/blast/format0.rb', line 134

def expect
  @expect
end

#gap_extendObject (readonly)

gap extend penalty


130
131
132
# File 'lib/bio/appl/blast/format0.rb', line 130

def gap_extend
  @gap_extend
end

#gap_openObject (readonly)

gap open penalty


126
127
128
# File 'lib/bio/appl/blast/format0.rb', line 126

def gap_open
  @gap_open
end

#iterationsObject (readonly)

(PSI-BLAST) Returns iterations. It returns an array of Bio::Blast::Default::Report::Iteration class. Note that normal blastall result usually contains one iteration.


71
72
73
# File 'lib/bio/appl/blast/format0.rb', line 71

def iterations
  @iterations
end

#matrixObject (readonly)

name of the matrix


114
115
116
# File 'lib/bio/appl/blast/format0.rb', line 114

def matrix
  @matrix
end

#num_hitsObject (readonly)

number of hits. Note that this may differ from hits.size.


138
139
140
# File 'lib/bio/appl/blast/format0.rb', line 138

def num_hits
  @num_hits
end

#posted_dateObject (readonly)

posted date of the database


106
107
108
# File 'lib/bio/appl/blast/format0.rb', line 106

def posted_date
  @posted_date
end

#sc_matchObject (readonly)

match score of the matrix


118
119
120
# File 'lib/bio/appl/blast/format0.rb', line 118

def sc_match
  @sc_match
end

#sc_mismatchObject (readonly)

mismatch score of the matrix


122
123
124
# File 'lib/bio/appl/blast/format0.rb', line 122

def sc_mismatch
  @sc_mismatch
end

Class Method Details

.open(filename, *mode) ⇒ Object

Opens file by using Bio::FlatFile.open.

[View source]

48
49
50
# File 'lib/bio/appl/blast/format0.rb', line 48

def self.open(filename, *mode)
  Bio::FlatFile.open(self, filename, *mode)
end

Instance Method Details

#converged?Boolean

(PSI-BLAST) Same as iterations.last.converged?. Returns true if the last iteration is converged, otherwise, returns false.

Returns:

  • (Boolean)
[View source]

221
222
223
# File 'lib/bio/appl/blast/format0.rb', line 221

def converged?
  @iterations.last.converged?
end

#dbObject

Returns the name (filename or title) of the database.

[View source]

245
246
247
248
249
250
251
252
253
254
# File 'lib/bio/appl/blast/format0.rb', line 245

def db
  unless defined?(@db)
    if /Database *\: *(.*)/m =~ @f0database then
      a = $1.split(/^/)
      a.pop if a.size > 1
      @db = a.collect { |x| x.sub(/\s+\z/, '') }.join(' ')
    end
  end #unless
  @db
end

#each_hitObject Also known as: each

Iterates over each hit of the last iteration. Same as iterations.last.each_hit. Yields a Bio::Blast::Default::Report::Hit object. This is very useful in most cases, e.g. for blastall results.

[View source]

196
197
198
199
200
# File 'lib/bio/appl/blast/format0.rb', line 196

def each_hit
  @iterations.last.each do |x|
    yield x
  end
end

#each_iterationObject

(PSI-BLAST) Iterates over each iteration. Same as iterations.each. Yields a Bio::Blast::Default::Report::Iteration object.

[View source]

186
187
188
189
190
# File 'lib/bio/appl/blast/format0.rb', line 186

def each_iteration
  @iterations.each do |x|
    yield x
  end
end

#entropyObject

Same as iterations.last.entropy.

[View source]

146
# File 'lib/bio/appl/blast/format0.rb', line 146

def entropy;        @iterations.last.entropy;        end

#gapped_entropyObject

Same as iterations.last.gapped_entropy.

[View source]

153
# File 'lib/bio/appl/blast/format0.rb', line 153

def gapped_entropy; @iterations.last.gapped_entropy; end

#gapped_kappaObject

Same as iterations.last.gapped_kappa.

[View source]

149
# File 'lib/bio/appl/blast/format0.rb', line 149

def gapped_kappa;   @iterations.last.gapped_kappa;   end

#gapped_lambdaObject

Same as iterations.last.gapped_lambda.

[View source]

151
# File 'lib/bio/appl/blast/format0.rb', line 151

def gapped_lambda;  @iterations.last.gapped_lambda;  end

#hitsObject

Same as iterations.last.hits. Returns the last iteration’s hits. Returns an array of Bio::Blast::Default::Report::Hit object. This is very useful in most cases, e.g. for blastall results.

[View source]

207
208
209
# File 'lib/bio/appl/blast/format0.rb', line 207

def hits
  @iterations.last.hits
end

#kappaObject

Same as iterations.last.kappa.

[View source]

142
# File 'lib/bio/appl/blast/format0.rb', line 142

def kappa;          @iterations.last.kappa;          end

#lambdaObject

Same as iterations.last.lambda.

[View source]

144
# File 'lib/bio/appl/blast/format0.rb', line 144

def lambda;         @iterations.last.lambda;         end

#messageObject

(PSI-BLAST) Same as iterations.last.message.

[View source]

213
214
215
# File 'lib/bio/appl/blast/format0.rb', line 213

def message
  @iterations.last.message
end

#patternObject

(PHI-BLAST) Same as iterations.first.pattern. Note that it returns the FIRST iteration’s value.

[View source]

173
# File 'lib/bio/appl/blast/format0.rb', line 173

def pattern; @iterations.first.pattern; end

#pattern_positionsObject

(PHI-BLAST) Same as iterations.first.pattern_positions. Note that it returns the FIRST iteration’s value.

[View source]

178
179
180
# File 'lib/bio/appl/blast/format0.rb', line 178

def pattern_positions
  @iterations.first.pattern_positions
end

#programObject

Returns program name.

[View source]

156
# File 'lib/bio/appl/blast/format0.rb', line 156

def program;        format0_parse_header; @program;        end

#query_defObject

Returns definition of the query.

[View source]

168
# File 'lib/bio/appl/blast/format0.rb', line 168

def query_def; format0_parse_query; @query_def; end

#query_lenObject

Returns length of the query.

[View source]

165
# File 'lib/bio/appl/blast/format0.rb', line 165

def query_len; format0_parse_query; @query_len; end

#referenceObject

Returns the bibliography reference of the BLAST software. Note that this method shows only the first reference. When you want to get additional references, you can use references method.

[View source]

229
230
231
# File 'lib/bio/appl/blast/format0.rb', line 229

def reference
  references[0]
end

#referencesObject

Returns the bibliography references of the BLAST software. Returns an array of strings.

[View source]

235
236
237
238
239
240
241
242
# File 'lib/bio/appl/blast/format0.rb', line 235

def references
  unless defined?(@references)
    @references = @f0references.collect do |x|
      x.to_s.gsub(/\s+/, ' ').strip
    end
  end #unless
  @references
end

#to_sObject

Returns whole entry as a string.

[View source]

74
# File 'lib/bio/appl/blast/format0.rb', line 74

def to_s; @entry; end

#versionObject

Returns version of the program.

[View source]

158
# File 'lib/bio/appl/blast/format0.rb', line 158

def version;        format0_parse_header; @version;        end

#version_dateObject

Returns released date of the program.

[View source]

162
# File 'lib/bio/appl/blast/format0.rb', line 162

def version_date;   format0_parse_header; @version_date;   end

#version_numberObject

Returns version number string of the program.

[View source]

160
# File 'lib/bio/appl/blast/format0.rb', line 160

def version_number; format0_parse_header; @version_number; end