Class: Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gene-matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_sequence, limit = 0.6) ⇒ Matcher

Returns a new instance of Matcher.



8
9
10
11
12
13
# File 'lib/gene-matcher.rb', line 8

def initialize(input_sequence, limit = 0.6)
  @limit = limit
  @reserve_target_sequence = false
  @input_sequence = input_sequence
  @alignments = []
end

Instance Attribute Details

#alignmentsObject (readonly)

Returns the value of attribute alignments.



6
7
8
# File 'lib/gene-matcher.rb', line 6

def alignments
  @alignments
end

#input_sequenceObject

Returns the value of attribute input_sequence.



5
6
7
# File 'lib/gene-matcher.rb', line 5

def input_sequence
  @input_sequence
end

#limitObject

Returns the value of attribute limit.



5
6
7
# File 'lib/gene-matcher.rb', line 5

def limit
  @limit
end

#reserve_target_sequenceObject

Returns the value of attribute reserve_target_sequence.



5
6
7
# File 'lib/gene-matcher.rb', line 5

def reserve_target_sequence
  @reserve_target_sequence
end

Instance Method Details

#scan(target_sequence, source = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/gene-matcher.rb', line 15

def scan(target_sequence,source = {})
  sw = SmithWaterman.instance
  a = sw.alignment(target_sequence, @input_sequence)
  puts "#{a.score} / #{a.alignment_count} = #{a.score / a.alignment_count}" if ENV["DEBUG"]
  return if a.alignment_count == 0
  return if a.score / a.alignment_count < @limit
  a.source = {}.merge(source)
  a.source[:target_sequence] = target_sequence if @reserve_target_sequence
  @alignments += [a]
end