Class: Bio::Ipcress::Result

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

Overview

Ipcress single result (single primer pair match)

Attributes of this class should be largely obvious by inspecting the Ipcress output

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#experiment_nameObject

Returns the value of attribute experiment_name.



133
134
135
# File 'lib/bio/appl/ipcress.rb', line 133

def experiment_name
  @experiment_name
end

#forward_matching_sequenceObject

A String representing the matching part of the sequence



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

def forward_matching_sequence
  @forward_matching_sequence
end

#forward_mismatchesObject

Returns the value of attribute forward_mismatches.



149
150
151
# File 'lib/bio/appl/ipcress.rb', line 149

def forward_mismatches
  @forward_mismatches
end

#forward_primer_sequenceObject

A String representing the matching primer



141
142
143
# File 'lib/bio/appl/ipcress.rb', line 141

def forward_primer_sequence
  @forward_primer_sequence
end

#lengthObject

Returns the value of attribute length.



149
150
151
# File 'lib/bio/appl/ipcress.rb', line 149

def length
  @length
end

#matchesObject

Returns the value of attribute matches.



135
136
137
# File 'lib/bio/appl/ipcress.rb', line 135

def matches
  @matches
end

#primersObject

Returns the value of attribute primers.



135
136
137
# File 'lib/bio/appl/ipcress.rb', line 135

def primers
  @primers
end

#productObject

Returns the value of attribute product.



135
136
137
# File 'lib/bio/appl/ipcress.rb', line 135

def product
  @product
end

#result_typeObject

Returns the value of attribute result_type.



135
136
137
# File 'lib/bio/appl/ipcress.rb', line 135

def result_type
  @result_type
end

#reverse_matching_sequenceObject

A String representing the matching part of the sequence



147
148
149
# File 'lib/bio/appl/ipcress.rb', line 147

def reverse_matching_sequence
  @reverse_matching_sequence
end

#reverse_mismatchesObject

Returns the value of attribute reverse_mismatches.



149
150
151
# File 'lib/bio/appl/ipcress.rb', line 149

def reverse_mismatches
  @reverse_mismatches
end

#reverse_primer_sequenceObject

A String representing the matching primer



144
145
146
# File 'lib/bio/appl/ipcress.rb', line 144

def reverse_primer_sequence
  @reverse_primer_sequence
end

#startObject

Returns the value of attribute start.



149
150
151
# File 'lib/bio/appl/ipcress.rb', line 149

def start
  @start
end

#targetObject

Returns the value of attribute target.



135
136
137
# File 'lib/bio/appl/ipcress.rb', line 135

def target
  @target
end

Instance Method Details

#recalculate_mismatches_from_alignmentsObject

When there are wobbles in the primers, Ipcress always reports at least 1 mismatch (1 for all matching wobbles plus regular mismatches).

This method recalculates the mismatches by re-aligning the primers against the sequences that they hit in this Result.

Returns an array of 2 values corresponding to the number of mismatches in the forward and revcomp primers, respectively.

Assumes that there is only wobbles in the primers, not the sequence (Does ipcress itself assume this?)



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/bio/appl/ipcress.rb', line 162

def recalculate_mismatches_from_alignments
  calculate_mismatches = lambda do |seq, primer|
    mismatches = 0
    (0..(seq.length-1)).each do |position|
      regex = Bio::Sequence::NA.new(primer[position].downcase).to_re
      seqp = seq[position].downcase
      mismatches += 1 unless regex.match(seqp)
    end
    mismatches
  end
  
  return [
    calculate_mismatches.call(@forward_matching_sequence, @forward_primer_sequence),
    calculate_mismatches.call(@reverse_matching_sequence, @reverse_primer_sequence)
  ]
end