Class: Bio::DB::Primer3::Primer3Record
- Inherits:
-
Object
- Object
- Bio::DB::Primer3::Primer3Record
show all
- Includes:
- Comparable
- Defined in:
- lib/bio/db/primer3.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Primer3Record.
438
439
440
441
442
443
444
445
446
|
# File 'lib/bio/db/primer3.rb', line 438
def initialize
@properties = Hash.new
@scores = Hash.new
@scores[:chromosome_specific] = 1000
@scores[:chromosome_semispecific] = 100
@scores[:chromosome_nonspecific] = 0
@scores[:exon] = 50
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
326
327
328
329
330
331
|
# File 'lib/bio/db/primer3.rb', line 326
def method_missing(method_name, *args)
return @properties[method_name] if @properties[method_name]
$stderr.puts "Missing #{method_name}"
$stderr.puts @properties.inspect
raise NoMethodError.new()
end
|
Instance Attribute Details
#polymorphism ⇒ Object
Returns the value of attribute polymorphism.
306
307
308
|
# File 'lib/bio/db/primer3.rb', line 306
def polymorphism
@polymorphism
end
|
#properties ⇒ Object
Returns the value of attribute properties.
306
307
308
|
# File 'lib/bio/db/primer3.rb', line 306
def properties
@properties
end
|
#socres ⇒ Object
Returns the value of attribute socres.
307
308
309
|
# File 'lib/bio/db/primer3.rb', line 307
def socres
@socres
end
|
Class Method Details
.parse_file(filename) ⇒ Object
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
# File 'lib/bio/db/primer3.rb', line 523
def self.parse_file(filename)
File.open(filename) do | f |
record = Primer3Record.new
f.each_line do | line |
line.chomp!
if line == "="
record.parse_blocks
yield record
record = Primer3Record.new
else
tokens = line.split("=")
i = 0
reg = ""
tokens.each do |tok|
if i > 0
if i > 1
reg << "="
end
reg << tok
end
i+=1
end
record.properties[tokens[0].downcase.to_sym] = reg
end
end
end
end
|
Instance Method Details
#<=>(anOther) ⇒ Object
354
355
356
|
# File 'lib/bio/db/primer3.rb', line 354
def <=>(anOther)
return anOther.score <=> score
end
|
#best_pair ⇒ Object
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/bio/db/primer3.rb', line 310
def best_pair
return @best_pair if @best_pair
@best_pair = nil
@primerPairs.each do | primer |
@best_pair = primer if @best_pair == nil
@best_pair = primer if primer.size < @best_pair.size
end
@best_pair
end
|
#chromosome ⇒ Object
480
481
482
483
484
|
# File 'lib/bio/db/primer3.rb', line 480
def chromosome
return @chromosome if @parsed
@chromosome
end
|
#exon? ⇒ Boolean
498
499
500
501
502
|
# File 'lib/bio/db/primer3.rb', line 498
def exon?
return @exon if @parsed
@exon
end
|
#find_left_tm(primer) ⇒ Object
333
334
335
336
337
338
339
340
341
342
343
344
|
# File 'lib/bio/db/primer3.rb', line 333
def find_left_tm(primer)
last = size - 1
(0..last).each do | i |
seq_prop = "primer_left_#{i}_sequence".to_sym
temp_property = "primer_left_#{i}_tm".to_sym
return @properties[temp_property] if @properties[seq_prop] == primer
end
return nil
end
|
#homeologous? ⇒ Boolean
486
487
488
489
490
|
# File 'lib/bio/db/primer3.rb', line 486
def homeologous?
return @homeologous if @parsed
@homeologous
end
|
#left_coordinates ⇒ Object
366
367
368
369
370
|
# File 'lib/bio/db/primer3.rb', line 366
def left_coordinates
@left_coordinates = best_pair.left.coordinates
@left_coordinates
end
|
#left_primer ⇒ Object
380
381
382
383
384
|
# File 'lib/bio/db/primer3.rb', line 380
def left_primer
@left_primer = best_pair.left.sequence
@left_primer
end
|
#left_primer_snp(snp) ⇒ Object
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
# File 'lib/bio/db/primer3.rb', line 386
def left_primer_snp(snp)
tmp_primer = String.new(left_primer)
if self.orientation == :forward
base_original = snp.original
base_snp = snp.snp
elsif self.orientation == :reverse
base_original = reverse_complement_string(snp.original )
base_snp = reverse_complement_string(snp.snp)
else
raise Primer3Exception.new "#{self.orientation} is not a valid orientation"
end
if tmp_primer[-1] == base_original
tmp_primer[-1] = base_snp
elsif tmp_primer[-1] == base_snp
tmp_primer[-1] = base_original
else
raise Primer3Exception.new "#{tmp_primer} doesnt end in a base in the SNP #{snp.to_s}"
end
return tmp_primer
end
|
#left_primer_with_coordinates(coordinates, other_orientation) ⇒ Object
410
411
412
413
414
415
416
417
|
# File 'lib/bio/db/primer3.rb', line 410
def left_primer_with_coordinates(coordinates, other_orientation)
seq = self.sequence_template
seq = reverse_complement_string(seq) if self.orientation != other_orientation
seq[coordinates[0],coordinates[1]]
end
|
#line ⇒ Object
504
505
506
507
508
|
# File 'lib/bio/db/primer3.rb', line 504
def line
return @line if @parsed
@line
end
|
#orientation ⇒ Object
474
475
476
477
478
|
# File 'lib/bio/db/primer3.rb', line 474
def orientation
return @orientation if @parsed
@orientation
end
|
#parse_blocks ⇒ Object
514
515
516
517
518
519
520
521
|
# File 'lib/bio/db/primer3.rb', line 514
def parse_blocks
total_blocks = size - 1
@primerPairs = Array.new
for i in 0..total_blocks
@primerPairs << PrimerPair.new(self, i)
end
end
|
#parse_coordinates(str) ⇒ Object
358
359
360
361
362
363
|
# File 'lib/bio/db/primer3.rb', line 358
def parse_coordinates(str)
coords = str.split(',')
coords[0] = coords[0].to_i
coords[1] = coords[1].to_i
coords
end
|
CL3339Contig1:T509C AvocetS chromosome_specific exon 4D forward
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
# File 'lib/bio/db/primer3.rb', line 455
def
@snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(" ")
@type = @type.to_sym
if @in
@in = @in.to_sym == :exon
else
@exon = false
end
if @polymorphism.to_sym == :homeologous
@homeologous = true
else
@homeologous = false
end
@parsed = true
@orientation = @orientation.to_sym
end
|
#primer_error ⇒ Object
321
322
323
324
|
# File 'lib/bio/db/primer3.rb', line 321
def primer_error
return @properties[:primer_error] if @properties[:primer_error]
return nil
end
|
#product_length ⇒ Object
434
435
436
|
# File 'lib/bio/db/primer3.rb', line 434
def product_length
return best_pair.size
end
|
#reverse_complement_string(sequenc_str) ⇒ Object
419
420
421
422
|
# File 'lib/bio/db/primer3.rb', line 419
def reverse_complement_string(sequenc_str)
complement = sequenc_str.tr('atgcrymkdhvbswnATGCRYMKDHVBSWN', 'tacgyrkmhdbvswnTACGYRKMHDBVSWN')
complement.reverse!
end
|
#right_coordinates ⇒ Object
372
373
374
375
376
377
378
|
# File 'lib/bio/db/primer3.rb', line 372
def right_coordinates
unless @right_coordinates
@right_coordinates = best_pair.right.coordinates
@right_coordinates[0] = @right_coordinates[0] - @right_coordinates[1] + 1
end
@right_coordinates
end
|
#right_primer ⇒ Object
430
431
432
|
# File 'lib/bio/db/primer3.rb', line 430
def right_primer
return best_pair.right.sequence
end
|
#right_primer_delete ⇒ Object
424
425
426
427
428
|
# File 'lib/bio/db/primer3.rb', line 424
def right_primer_delete
@right_primer = self.sequence_template[right_coordinates[0],right_coordinates[1]] unless @right_primer
@right_primer = reverse_complement_string(@right_primer)
@right_primer
end
|
#score ⇒ Object
346
347
348
349
350
351
352
|
# File 'lib/bio/db/primer3.rb', line 346
def score
ret = 0
ret += @scores[type]
ret += @scores[:exon] if exon?
ret -= product_length
ret
end
|
#size ⇒ Object
510
511
512
|
# File 'lib/bio/db/primer3.rb', line 510
def size
@properties[:primer_pair_num_returned].to_i
end
|
#snp ⇒ Object
448
449
450
451
452
|
# File 'lib/bio/db/primer3.rb', line 448
def snp
return @snp if @snp
@snp
end
|
#type ⇒ Object
492
493
494
495
496
|
# File 'lib/bio/db/primer3.rb', line 492
def type
return @type if @parsed
@type
end
|