Class: Bio::Fasta::Report::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/fasta/format10.rb

Defined Under Namespace

Classes: Query, Target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Hit

Returns a new instance of Hit.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/bio/appl/fasta/format10.rb', line 111

def initialize(data)
  score, query, target = data.split(/\n>/)

  @definition, *score = score.split(/\n/)
  @score = {}

  pat = /;\s+([^:]+):\s+(.*)/

  score.each do |x|
    if pat.match(x)
      @score[$1] = $2
    end
  end

  @query = Query.new(query)
  @target = Target.new(target)
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



128
129
130
# File 'lib/bio/appl/fasta/format10.rb', line 128

def definition
  @definition
end

#queryObject (readonly)

Returns the value of attribute query.



128
129
130
# File 'lib/bio/appl/fasta/format10.rb', line 128

def query
  @query
end

#scoreObject (readonly)

Returns the value of attribute score.



128
129
130
# File 'lib/bio/appl/fasta/format10.rb', line 128

def score
  @score
end

#targetObject (readonly)

Returns the value of attribute target.



128
129
130
# File 'lib/bio/appl/fasta/format10.rb', line 128

def target
  @target
end

Instance Method Details

#bit_scoreObject

Bit score



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/bio/appl/fasta/format10.rb', line 144

def bit_score
  if @score['fa_bits']
    @score['fa_bits'].to_f
  elsif @score['sw_bits']
    @score['sw_bits'].to_f
  elsif @score['fx_bits']
    @score['fx_bits'].to_f
  elsif @score['tx_bits']
    @score['tx_bits'].to_f
  end
end

#directionObject



156
157
158
# File 'lib/bio/appl/fasta/format10.rb', line 156

def direction
  @score['fa_frame'] || @score['sw_frame'] || @score['fx_frame'] || @score['tx_frame']
end

#evalueObject

E-value score



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/bio/appl/fasta/format10.rb', line 131

def evalue
  if @score['fa_expect']
    @score['fa_expect'].to_f
  elsif @score['sw_expect']
    @score['sw_expect'].to_f
  elsif @score['fx_expect']
    @score['fx_expect'].to_f
  elsif @score['tx_expect']
    @score['tx_expect'].to_f
  end
end

#identityObject

percent identity



166
167
168
# File 'lib/bio/appl/fasta/format10.rb', line 166

def identity
  @score['sw_ident'].to_f
end

#lap_atObject



237
238
239
# File 'lib/bio/appl/fasta/format10.rb', line 237

def lap_at
  [ query_start, query_end, target_start, target_end ]
end

#overlapObject

overlap length



171
172
173
# File 'lib/bio/appl/fasta/format10.rb', line 171

def overlap
  @score['sw_overlap'].to_i
end

#query_defObject



185
186
187
# File 'lib/bio/appl/fasta/format10.rb', line 185

def query_def
  @query.definition
end

#query_endObject



225
226
227
# File 'lib/bio/appl/fasta/format10.rb', line 225

def query_end
  @query.stop
end

#query_idObject

Shortcuts for the methods of Bio::Fasta::Report::Hit::Query



177
178
179
# File 'lib/bio/appl/fasta/format10.rb', line 177

def query_id
  @query.entry_id
end

#query_lenObject



193
194
195
# File 'lib/bio/appl/fasta/format10.rb', line 193

def query_len
  @query.length
end

#query_seqObject



203
204
205
# File 'lib/bio/appl/fasta/format10.rb', line 203

def query_seq
  @query.sequence
end

#query_startObject

Information on matching region



221
222
223
# File 'lib/bio/appl/fasta/format10.rb', line 221

def query_start
  @query.start
end

#query_typeObject



211
212
213
# File 'lib/bio/appl/fasta/format10.rb', line 211

def query_type
  @query.moltype
end

#swObject

Smith-Waterman score



161
162
163
# File 'lib/bio/appl/fasta/format10.rb', line 161

def sw
  @score['sw_score'].to_i
end

#target_defObject



189
190
191
# File 'lib/bio/appl/fasta/format10.rb', line 189

def target_def
  @target.definition
end

#target_endObject



233
234
235
# File 'lib/bio/appl/fasta/format10.rb', line 233

def target_end
  @target.stop
end

#target_idObject



181
182
183
# File 'lib/bio/appl/fasta/format10.rb', line 181

def target_id
  @target.entry_id
end

#target_lenObject

Shortcuts for the methods of Bio::Fasta::Report::Hit::Target



199
200
201
# File 'lib/bio/appl/fasta/format10.rb', line 199

def target_len
  @target.length
end

#target_seqObject



207
208
209
# File 'lib/bio/appl/fasta/format10.rb', line 207

def target_seq
  @target.sequence
end

#target_startObject



229
230
231
# File 'lib/bio/appl/fasta/format10.rb', line 229

def target_start
  @target.start
end

#target_typeObject



215
216
217
# File 'lib/bio/appl/fasta/format10.rb', line 215

def target_type
  @target.moltype
end