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.
533
534
535
536
537
538
539
540
541
|
# File 'lib/bio/db/primer3.rb', line 533
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
421
422
423
424
425
426
427
|
# File 'lib/bio/db/primer3.rb', line 421
def method_missing(method_name, *args)
return @properties[method_name] if @properties[method_name]
$stderr.puts "Missing #{method_name}"
$stderr.puts @properties.inspect
return "" raise NoMethodError.new()
end
|
Instance Attribute Details
#polymorphism ⇒ Object
Returns the value of attribute polymorphism.
401
402
403
|
# File 'lib/bio/db/primer3.rb', line 401
def polymorphism
@polymorphism
end
|
#properties ⇒ Object
Returns the value of attribute properties.
401
402
403
|
# File 'lib/bio/db/primer3.rb', line 401
def properties
@properties
end
|
#scores ⇒ Object
Returns the value of attribute scores.
402
403
404
|
# File 'lib/bio/db/primer3.rb', line 402
def scores
@scores
end
|
Class Method Details
.parse_file(filename, scores: nil) ⇒ Object
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
# File 'lib/bio/db/primer3.rb', line 629
def self.parse_file(filename, scores: nil)
File.open(filename) do | f |
record = Primer3Record.new
record.scores = scores if scores
f.each_line do | line |
line.chomp!
if line == "="
record.parse_blocks
yield record
record = Primer3Record.new
record.scores = scores if scores
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
|
.reverse_complement_string(sequenc_str) ⇒ Object
514
515
516
517
|
# File 'lib/bio/db/primer3.rb', line 514
def self.reverse_complement_string(sequenc_str)
complement = sequenc_str.tr('atgcrymkdhvbswnATGCRYMKDHVBSWN', 'tacgyrkmhdbvswnTACGYRKMHDBVSWN')
complement.reverse!
end
|
Instance Method Details
#<=>(anOther) ⇒ Object
450
451
452
|
# File 'lib/bio/db/primer3.rb', line 450
def <=>(anOther)
return anOther.score <=> score
end
|
#best_pair ⇒ Object
405
406
407
408
409
410
411
412
413
414
|
# File 'lib/bio/db/primer3.rb', line 405
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
586
587
588
589
590
|
# File 'lib/bio/db/primer3.rb', line 586
def chromosome
return @chromosome if @parsed
@chromosome
end
|
#exon? ⇒ Boolean
604
605
606
607
608
|
# File 'lib/bio/db/primer3.rb', line 604
def exon?
return @exon if @parsed
@exon
end
|
#find_left_tm(primer) ⇒ Object
429
430
431
432
433
434
435
436
437
438
439
440
|
# File 'lib/bio/db/primer3.rb', line 429
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
|
#homoeologous? ⇒ Boolean
592
593
594
595
596
|
# File 'lib/bio/db/primer3.rb', line 592
def homoeologous?
return @homoeologous if @parsed
@homoeologous
end
|
#left_coordinates ⇒ Object
462
463
464
465
466
|
# File 'lib/bio/db/primer3.rb', line 462
def left_coordinates
@left_coordinates = best_pair.left.coordinates
@left_coordinates
end
|
#left_primer ⇒ Object
476
477
478
479
480
|
# File 'lib/bio/db/primer3.rb', line 476
def left_primer
@left_primer = best_pair.left.sequence
@left_primer
end
|
#left_primer_snp(snp) ⇒ Object
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
# File 'lib/bio/db/primer3.rb', line 482
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 =Primer3Record.reverse_complement_string(snp.original )
base_snp = Primer3Record.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
507
508
509
510
511
512
|
# File 'lib/bio/db/primer3.rb', line 507
def left_primer_with_coordinates(coordinates, other_orientation)
seq = self.sequence_template
seq = Primer3Record.reverse_complement_string(seq) if self.orientation != other_orientation
seq[coordinates[0],coordinates[1]]
end
|
#line ⇒ Object
610
611
612
613
614
|
# File 'lib/bio/db/primer3.rb', line 610
def line
return @line if @parsed
@line
end
|
#orientation ⇒ Object
580
581
582
583
584
|
# File 'lib/bio/db/primer3.rb', line 580
def orientation
return @orientation if @parsed
@orientation
end
|
#parse_blocks ⇒ Object
620
621
622
623
624
625
626
627
|
# File 'lib/bio/db/primer3.rb', line 620
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
454
455
456
457
458
459
|
# File 'lib/bio/db/primer3.rb', line 454
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
# File 'lib/bio/db/primer3.rb', line 550
def
arr = self.sequence_id.split(" ")
@snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = arr
@type = @type.to_sym
if @in
@in = @in.to_sym == :exon
else
@exon = false
end
if @polymorphism.to_sym == :homoeologous
@homoeologous = true
else
@homoeologous = false
end
@parsed = true
@orientation = @orientation.to_sym
end
|
#primer_error ⇒ Object
416
417
418
419
|
# File 'lib/bio/db/primer3.rb', line 416
def primer_error
return @properties[:primer_error] if @properties[:primer_error]
return nil
end
|
#product_length ⇒ Object
529
530
531
|
# File 'lib/bio/db/primer3.rb', line 529
def product_length
return best_pair.size
end
|
#right_coordinates ⇒ Object
468
469
470
471
472
473
474
|
# File 'lib/bio/db/primer3.rb', line 468
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
525
526
527
|
# File 'lib/bio/db/primer3.rb', line 525
def right_primer
return best_pair.right.sequence
end
|
#right_primer_delete ⇒ Object
519
520
521
522
523
|
# File 'lib/bio/db/primer3.rb', line 519
def right_primer_delete
@right_primer = self.sequence_template[right_coordinates[0],right_coordinates[1]] unless @right_primer
@right_primer = Primer3Record.reverse_complement_string(@right_primer)
@right_primer
end
|
#score ⇒ Object
442
443
444
445
446
447
448
|
# File 'lib/bio/db/primer3.rb', line 442
def score
ret = 0
ret += @scores[type]
ret += @scores[:exon] if exon?
ret -= product_length
ret
end
|
#size ⇒ Object
616
617
618
|
# File 'lib/bio/db/primer3.rb', line 616
def size
@properties[:primer_pair_num_returned].to_i
end
|
#snp ⇒ Object
543
544
545
546
547
|
# File 'lib/bio/db/primer3.rb', line 543
def snp
return @snp if @snp
@snp
end
|
#type ⇒ Object
598
599
600
601
602
|
# File 'lib/bio/db/primer3.rb', line 598
def type
return @type if @parsed
@type
end
|