Class: Bio::DB::Primer3::SNP
- Inherits:
-
Object
- Object
- Bio::DB::Primer3::SNP
- Defined in:
- lib/bio/db/primer3.rb
Instance Attribute Summary collapse
-
#chromosome ⇒ Object
Returns the value of attribute chromosome.
-
#gene ⇒ Object
Returns the value of attribute gene.
-
#hit_count ⇒ Object
Returns the value of attribute hit_count.
-
#line_1 ⇒ Object
Returns the value of attribute line_1.
-
#line_2 ⇒ Object
Returns the value of attribute line_2.
-
#original ⇒ Object
Returns the value of attribute original.
-
#position ⇒ Object
Returns the value of attribute position.
-
#primer3_errors ⇒ Object
Returns the value of attribute primer3_errors.
-
#primer3_line_1 ⇒ Object
Returns the value of attribute primer3_line_1.
-
#primer3_line_2 ⇒ Object
Returns the value of attribute primer3_line_2.
-
#primers_line_1 ⇒ Object
Returns the value of attribute primers_line_1.
-
#primers_line_2 ⇒ Object
Returns the value of attribute primers_line_2.
-
#regions ⇒ Object
Returns the value of attribute regions.
-
#repetitive ⇒ Object
Returns the value of attribute repetitive.
-
#snp ⇒ Object
Returns the value of attribute snp.
-
#snp_from ⇒ Object
Returns the value of attribute snp_from.
-
#snp_type ⇒ Object
Returns the value of attribute snp_type.
-
#template_length ⇒ Object
Returns the value of attribute template_length.
-
#used_contigs ⇒ Object
Returns the value of attribute used_contigs.
Class Method Summary collapse
Instance Method Summary collapse
- #add_record(primer3record) ⇒ Object
- #common_primer ⇒ Object
- #find_left_primer_temp(primer) ⇒ Object
- #find_primer_pair_first ⇒ Object
- #find_primer_pair_second ⇒ Object
- #first_primer ⇒ Object
- #first_product ⇒ Object
- #found_primers? ⇒ Boolean
-
#initialize ⇒ SNP
constructor
A new instance of SNP.
- #line_1_name ⇒ Object
- #line_2_name ⇒ Object
- #orientation ⇒ Object
- #print_primers ⇒ Object
- #product_size ⇒ Object
- #realigned_primers ⇒ Object
- #realigned_primers_fasta ⇒ Object
- #second_primer ⇒ Object
- #second_product ⇒ Object
- #to_s ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize ⇒ SNP
Returns a new instance of SNP.
73 74 75 76 77 78 |
# 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 |
Instance Attribute Details
#chromosome ⇒ Object
Returns the value of attribute chromosome.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def chromosome @chromosome end |
#gene ⇒ Object
Returns the value of attribute gene.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def gene @gene end |
#hit_count ⇒ Object
Returns the value of attribute hit_count.
66 67 68 |
# File 'lib/bio/db/primer3.rb', line 66 def hit_count @hit_count end |
#line_1 ⇒ Object
Returns the value of attribute line_1.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def line_1 @line_1 end |
#line_2 ⇒ Object
Returns the value of attribute line_2.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def line_2 @line_2 end |
#original ⇒ Object
Returns the value of attribute original.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def original @original end |
#position ⇒ Object
Returns the value of attribute position.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def position @position end |
#primer3_errors ⇒ Object
Returns the value of attribute primer3_errors.
64 65 66 |
# File 'lib/bio/db/primer3.rb', line 64 def primer3_errors @primer3_errors end |
#primer3_line_1 ⇒ Object
Returns the value of attribute primer3_line_1.
59 60 61 |
# File 'lib/bio/db/primer3.rb', line 59 def primer3_line_1 @primer3_line_1 end |
#primer3_line_2 ⇒ Object
Returns the value of attribute primer3_line_2.
59 60 61 |
# File 'lib/bio/db/primer3.rb', line 59 def primer3_line_2 @primer3_line_2 end |
#primers_line_1 ⇒ Object
Returns the value of attribute primers_line_1.
60 61 62 |
# File 'lib/bio/db/primer3.rb', line 60 def primers_line_1 @primers_line_1 end |
#primers_line_2 ⇒ Object
Returns the value of attribute primers_line_2.
60 61 62 |
# File 'lib/bio/db/primer3.rb', line 60 def primers_line_2 @primers_line_2 end |
#regions ⇒ Object
Returns the value of attribute regions.
63 64 65 |
# File 'lib/bio/db/primer3.rb', line 63 def regions @regions end |
#repetitive ⇒ Object
Returns the value of attribute repetitive.
65 66 67 |
# File 'lib/bio/db/primer3.rb', line 65 def repetitive @repetitive end |
#snp ⇒ Object
Returns the value of attribute snp.
58 59 60 |
# File 'lib/bio/db/primer3.rb', line 58 def snp @snp end |
#snp_from ⇒ Object
Returns the value of attribute snp_from.
62 63 64 |
# File 'lib/bio/db/primer3.rb', line 62 def snp_from @snp_from end |
#snp_type ⇒ Object
Returns the value of attribute snp_type.
67 68 69 |
# File 'lib/bio/db/primer3.rb', line 67 def snp_type @snp_type end |
#template_length ⇒ Object
Returns the value of attribute template_length.
59 60 61 |
# File 'lib/bio/db/primer3.rb', line 59 def template_length @template_length end |
#used_contigs ⇒ Object
Returns the value of attribute used_contigs.
61 62 63 |
# File 'lib/bio/db/primer3.rb', line 61 def used_contigs @used_contigs end |
Class Method Details
Instance Method Details
#add_record(primer3record) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# 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 ⇒ Object
272 273 274 275 |
# 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) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# 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 ⇒ Object
99 100 101 102 103 104 105 |
# 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 ⇒ Object
107 108 109 110 111 112 113 |
# 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 ⇒ Object
262 263 264 265 |
# 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 ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 |
# 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? ⇒ Boolean
258 259 260 |
# File 'lib/bio/db/primer3.rb', line 258 def found_primers? return self.values[7] && self.values[7] != nil end |
#line_1_name ⇒ Object
69 70 71 |
# File 'lib/bio/db/primer3.rb', line 69 def line_1_name "#{gene}:#{position}#{original}>#{snp} #{line_1}}" end |
#line_2_name ⇒ Object
80 81 82 |
# File 'lib/bio/db/primer3.rb', line 80 def line_2_name "#{gene}:#{position}#{original}>#{snp} #{line_2}}" end |
#orientation ⇒ Object
282 283 284 285 |
# 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 ⇒ Object
251 252 253 254 255 256 |
# 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 ⇒ Object
277 278 279 280 |
# 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 ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# 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 = ['--maxiterate', '1000', '--localpair', '--quiet'] mafft = Bio::MAFFT.new( "mafft" , ) #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 ⇒ Object
312 313 314 315 316 317 318 |
# 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 ⇒ Object
267 268 269 270 |
# 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 ⇒ Object
300 301 302 303 304 305 306 307 308 309 |
# 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 ⇒ Object
84 85 86 |
# File 'lib/bio/db/primer3.rb', line 84 def to_s "#{gene}:#{original}#{position}#{snp}:#{snp_from.chromosome}" end |
#values ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# 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 =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 < @values[] = primer3_errors.to_a.join("|") else @values << nil end return @values end |