class Bio::DB::Primer3::SNP
Attributes
chromosome[RW]
gene[RW]
hit_count[RW]
line_1[RW]
line_2[RW]
original[RW]
position[RW]
primer3_errors[RW]
primer3_line_1[RW]
primer3_line_2[RW]
primers_line_1[RW]
primers_line_2[RW]
regions[RW]
repetitive[RW]
snp[RW]
snp_from[RW]
snp_type[RW]
template_length[RW]
used_contigs[RW]
Public Class Methods
new()
click to toggle source
# File lib/bio/db/primer3.rb, line 73 def initialize @primers_line_1 = SortedSet.new @primers_line_2 = SortedSet.new @regions = SortedSet.new @primer3_errors = Set.new end
parse(reg_str)
click to toggle source
# File lib/bio/db/primer3.rb, line 341 def self.parse(reg_str) reg_str.chomp! snp = SNP.new snp.gene, snp.original, snp.position, snp.snp = reg_str.split(",") snp.position = snp.position.to_i snp.original.upcase! snp.snp.upcase! snp end
parse_file(filename) { |snp| ... }
click to toggle source
# File lib/bio/db/primer3.rb, line 351 def self.parse_file(filename) File.open(filename) do | f | f.each_line do | line | snp = SNP.parse(line) if snp.position > 0 yield snp end end end end
Public Instance Methods
add_record(primer3record)
click to toggle source
# File lib/bio/db/primer3.rb, line 363 def add_record(primer3record) @primer3_errors = Set.new unless @primer3_errors @template_length = primer3record.sequence_template.size if primer3record.primer_error != nil primer3_errors << primer3record.primer_error return end case when primer3record.line == @line_1 @line_1_template = primer3record.sequence_template when primer3record.line == @line_2 @line_2_template = primer3record.sequence_template else raise Primer3Exception.new "#{primer3record.line} is not recognized (#{line_1}, #{line_2})" end if primer3record.primer_left_num_returned.to_i > 0 case when primer3record.line == @line_1 primers_line_1 << primer3record #puts primer3record.inspect @primer3_line_1 = primer3record if not @primer3_line_1 or @primer3_line_1 > primer3record when primer3record.line == @line_2 primers_line_2 << primer3record @primer3_line_2 = primer3record if not @primer3_line_2 or @primer3_line_2 > primer3record else raise Primer3Exception.new "#{primer3record.line} is not recognized (#{line_1}, #{line_2})" end else primer3_errors << "#{primer3record.line}(#{primer3record.orientation}):#{primer3record.primer_left_explain.gsub!(',',';')}" primer3_errors << "common(#{primer3record.orientation}#{primer3record.type}):#{primer3record.primer_right_explain.gsub!(',',';')}" primer3_errors << "pair(#{primer3record.orientation}#{primer3record.type}):#{primer3record.primer_pair_explain.gsub!(',',';')}" end end
common_primer()
click to toggle source
# File lib/bio/db/primer3.rb, line 272 def common_primer return self.values[9] if self.values[9] && self.values[9] != nil return "" end
find_left_primer_temp(primer)
click to toggle source
# File lib/bio/db/primer3.rb, line 88 def find_left_primer_temp(primer) primers_line_1.each do |pr| return pr.find_left_tm(primer) if pr.find_left_tm(primer) end primers_line_2.each do |pr| return pr.find_left_tm(primer) if pr.find_left_tm(primer) end return "NA" end
find_primer_pair_first()
click to toggle source
# File lib/bio/db/primer3.rb, line 99 def find_primer_pair_first primers_line_1.each do |pr| primer = pr.left_primer_snp(self) return pr if find_left_primer_temp(primer) != "NA" end nil end
find_primer_pair_second()
click to toggle source
# File lib/bio/db/primer3.rb, line 107 def find_primer_pair_second primers_line_2.each do |pr| primer = pr.left_primer_snp(self) return pr if find_left_primer_temp(primer) != "NA" end nil end
first_primer()
click to toggle source
# File lib/bio/db/primer3.rb, line 262 def first_primer return self.values[7] if self.values[7] && self.values[7] != nil return "" end
first_product()
click to toggle source
# File lib/bio/db/primer3.rb, line 288 def first_product left = first_primer right = common_primer nlen = product_size - left.size - right.size product = left + ('n' * nlen) + Primer3Record.reverse_complement_string(right) #puts "orientation: #{orientation}" product = Primer3Record.reverse_complement_string(product) if orientation == 'reverse' product end
found_primers?()
click to toggle source
# File lib/bio/db/primer3.rb, line 258 def found_primers? return self.values[7] && self.values[7] != nil end
line_1_name()
click to toggle source
# File lib/bio/db/primer3.rb, line 69 def line_1_name "#{gene}:#{position}#{original}>#{snp} #{line_1}}" end
line_2_name()
click to toggle source
# File lib/bio/db/primer3.rb, line 80 def line_2_name "#{gene}:#{position}#{original}>#{snp} #{line_2}}" end
orientation()
click to toggle source
# File lib/bio/db/primer3.rb, line 282 def orientation return self.values[11] if self.values[11]&& self.values[11] != nil return 'unknown' end
print_primers()
click to toggle source
# File lib/bio/db/primer3.rb, line 251 def print_primers to_print = values.dup to_print << @repetitive to_print << @hit_count to_print.join(",") end
product_size()
click to toggle source
# File lib/bio/db/primer3.rb, line 277 def product_size return self.values[16].to_i if self.values[16]&& self.values[16] != nil return 0 end
realigned_primers()
click to toggle source
# File lib/bio/db/primer3.rb, line 321 def realigned_primers return @realigned_primers if @realigned_primers sequences_to_align = Hash.new sequences_to_align["first_product"] = first_product sequences_to_align["second_product"] = second_product sequences_to_align.merge!(snp_from.surrounding_exon_sequences) if sequences_to_align.size == 1 @realigned_primers = sequences_to_align return @realigned_primers end options = ['--maxiterate', '1000', '--localpair', '--quiet'] mafft = Bio::MAFFT.new( "mafft" , options) #puts "Before MAFT:#{sequences_to_align.inspect}" report = mafft.query_align(sequences_to_align) @realigned_primers = report.alignment #puts "MAFFT: #{report.alignment.inspect}" @realigned_primers end
realigned_primers_fasta()
click to toggle source
# File lib/bio/db/primer3.rb, line 312 def realigned_primers_fasta ret_str = "" realigned_primers.each_pair do |name, seq| ret_str << ">#{self.to_s}-#{name}\n#{seq}\n" end ret_str end
second_primer()
click to toggle source
# File lib/bio/db/primer3.rb, line 267 def second_primer return self.values[8] if self.values[8] && self.values[8] != nil return "" end
second_product()
click to toggle source
# File lib/bio/db/primer3.rb, line 300 def second_product left = second_primer right = common_primer nlen = product_size - left.size - right.size product = left + ('n' * nlen) + Primer3Record.reverse_complement_string(right) product = Primer3Record.reverse_complement_string(product) if orientation == 'reverse' product end
to_s()
click to toggle source
# File lib/bio/db/primer3.rb, line 84 def to_s "#{gene}:#{original}#{position}#{snp}:#{snp_from.chromosome}" end
values()
click to toggle source
# File lib/bio/db/primer3.rb, line 115 def values return @values if @values left_start = 0 left_end = 0 right_start = 0 right_end = 0 total_columns_before_messages=17 #puts "Values in primer3" #puts snp_from.inspect @values = Array.new #@values << "#{gene},,#{template_length}," @values << gene @values << "#{original}#{position}#{snp}" @values << template_length @values << snp_from.chromosome @values << regions.size @values << regions.join("|") @values << snp_type if primer3_line_1 and primer3_line_2 #Block that searches both if both pairs have a TM primer_1 = primer3_line_1.left_primer_with_coordinates(primer3_line_2.left_coordinates, primer3_line_2.orientation) primer_1_tm = find_left_primer_temp(primer_1) primer_2 = primer3_line_2.left_primer_with_coordinates(primer3_line_1.left_coordinates, primer3_line_1.orientation) primer_2_tm = find_left_primer_temp(primer_2) if primer3_line_1 < primer3_line_2 and primer_2_tm != "NA" @values << primer3_line_1.left_primer @values << primer_2 @values << primer3_line_1.right_primer @values << primer3_line_1.type.to_s @values << primer3_line_1.orientation.to_s @values << primer3_line_1.best_pair.left.tm @values << primer_2_tm @values << primer3_line_1.best_pair.right.tm @values << "first" @values << primer3_line_1.best_pair.product_size elsif primer_1_tm != "NA" @values << primer_1 @values << primer3_line_2.left_primer @values << primer3_line_2.right_primer @values << primer3_line_2.type.to_s @values << primer3_line_2.orientation.to_s @values << primer_1_tm @values << primer3_line_2.best_pair.left.tm @values << primer3_line_2.best_pair.right.tm @values << "second" @values << primer3_line_2.best_pair.product_size else first_candidate = find_primer_pair_first second_candidate = find_primer_pair_second if first_candidate primer_2 = primer3_line_2.left_primer_with_coordinates(first_candidate.left_coordinates, first_candidate.orientation) primer_2_tm = find_left_primer_temp(primer_2) end if second_candidate #puts "input to search #{first_candidate.left_coordinates}" primer_1 = primer3_line_1.left_primer_with_coordinates(second_candidate.left_coordinates, second_candidate.orientation) primer_1_tm = find_left_primer_temp(primer_1) #puts "In the other funky if #{primer_2}" end if first_candidate and second_candidate and first_candidate < second_candidate #puts "A" @values << first_candidate.left_primer @values << primer_2 @values << first_candidate.right_primer @values << first_candidate.type.to_s @values << first_candidate.orientation.to_s @values << first_candidate.best_pair.left.tm @values << primer_2_tm @values << first_candidate.best_pair.right.tm @values << "first-" @values << first_candidate.best_pair.product_size elsif second_candidate #puts "B" @values << primer_1 @values << second_candidate.left_primer @values << second_candidate.right_primer @values << second_candidate.type.to_s @values << second_candidate.orientation.to_s @values << primer_1_tm @values << second_candidate.best_pair.left.tm @values << second_candidate.best_pair.right.tm @values << "second-" @values << second_candidate.best_pair.product_size elsif first_candidate #puts "C" @values << first_candidate.left_primer @values << primer_2 @values << first_candidate.right_primer @values << first_candidate.type.to_s @values << first_candidate.orientation.to_s @values << primer_2_tm @values << first_candidate.best_pair.left.tm @values << first_candidate.best_pair.right.tm @values << "first/" @values << first_candidate.best_pair.product_size end end elsif primer3_line_1 @values << primer3_line_1.left_primer @values << primer3_line_1.left_primer_snp(self) @values << primer3_line_1.right_primer @values << primer3_line_1.type.to_s @values << primer3_line_1.orientation.to_s @values << primer3_line_1.best_pair.left.tm @values << "NA" @values << primer3_line_1.best_pair.right.tm @values << "first+" @values << primer3_line_1.best_pair.product_size elsif primer3_line_2 @values << primer3_line_2.left_primer_snp(self) @values << primer3_line_2.left_primer @values << primer3_line_2.right_primer @values << primer3_line_2.type.to_s @values << primer3_line_2.orientation.to_s @values << "NA" @values << primer3_line_2.best_pair.left.tm @values << primer3_line_2.best_pair.right.tm @values << "second+" @values << primer3_line_2.best_pair.product_size end if @values.size < total_columns_before_messages @values[total_columns_before_messages] = primer3_errors.to_a.join("|") else @values << nil end return @values end