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.
536
537
538
539
540
541
542
543
544
|
# File 'lib/bio/db/primer3.rb', line 536
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
424
425
426
427
428
429
430
|
# File 'lib/bio/db/primer3.rb', line 424
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.
404
405
406
|
# File 'lib/bio/db/primer3.rb', line 404
def polymorphism
@polymorphism
end
|
#properties ⇒ Object
Returns the value of attribute properties.
404
405
406
|
# File 'lib/bio/db/primer3.rb', line 404
def properties
@properties
end
|
#scores ⇒ Object
Returns the value of attribute scores.
405
406
407
|
# File 'lib/bio/db/primer3.rb', line 405
def scores
@scores
end
|
Class Method Details
.parse_file(filename, scores: nil) ⇒ Object
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
660
661
662
|
# File 'lib/bio/db/primer3.rb', line 632
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
517
518
519
520
|
# File 'lib/bio/db/primer3.rb', line 517
def self.reverse_complement_string(sequenc_str)
complement = sequenc_str.tr('atgcrymkdhvbswnATGCRYMKDHVBSWN', 'tacgyrkmhdbvswnTACGYRKMHDBVSWN')
complement.reverse!
end
|
Instance Method Details
#<=>(anOther) ⇒ Object
453
454
455
|
# File 'lib/bio/db/primer3.rb', line 453
def <=>(anOther)
return anOther.score <=> score
end
|
#best_pair ⇒ Object
408
409
410
411
412
413
414
415
416
417
|
# File 'lib/bio/db/primer3.rb', line 408
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
589
590
591
592
593
|
# File 'lib/bio/db/primer3.rb', line 589
def chromosome
return @chromosome if @parsed
@chromosome
end
|
#exon? ⇒ Boolean
607
608
609
610
611
|
# File 'lib/bio/db/primer3.rb', line 607
def exon?
return @exon if @parsed
@exon
end
|
#find_left_tm(primer) ⇒ Object
432
433
434
435
436
437
438
439
440
441
442
443
|
# File 'lib/bio/db/primer3.rb', line 432
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
595
596
597
598
599
|
# File 'lib/bio/db/primer3.rb', line 595
def homoeologous?
return @homoeologous if @parsed
@homoeologous
end
|
#left_coordinates ⇒ Object
465
466
467
468
469
|
# File 'lib/bio/db/primer3.rb', line 465
def left_coordinates
@left_coordinates = best_pair.left.coordinates
@left_coordinates
end
|
#left_primer ⇒ Object
479
480
481
482
483
|
# File 'lib/bio/db/primer3.rb', line 479
def left_primer
@left_primer = best_pair.left.sequence
@left_primer
end
|
#left_primer_snp(snp) ⇒ Object
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
# File 'lib/bio/db/primer3.rb', line 485
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
510
511
512
513
514
515
|
# File 'lib/bio/db/primer3.rb', line 510
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
613
614
615
616
617
|
# File 'lib/bio/db/primer3.rb', line 613
def line
return @line if @parsed
@line
end
|
#orientation ⇒ Object
583
584
585
586
587
|
# File 'lib/bio/db/primer3.rb', line 583
def orientation
return @orientation if @parsed
@orientation
end
|
#parse_blocks ⇒ Object
623
624
625
626
627
628
629
630
|
# File 'lib/bio/db/primer3.rb', line 623
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
457
458
459
460
461
462
|
# File 'lib/bio/db/primer3.rb', line 457
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
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
579
580
581
|
# File 'lib/bio/db/primer3.rb', line 553
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
419
420
421
422
|
# File 'lib/bio/db/primer3.rb', line 419
def primer_error
return @properties[:primer_error] if @properties[:primer_error]
return nil
end
|
#product_length ⇒ Object
532
533
534
|
# File 'lib/bio/db/primer3.rb', line 532
def product_length
return best_pair.size
end
|
#right_coordinates ⇒ Object
471
472
473
474
475
476
477
|
# File 'lib/bio/db/primer3.rb', line 471
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
528
529
530
|
# File 'lib/bio/db/primer3.rb', line 528
def right_primer
return best_pair.right.sequence
end
|
#right_primer_delete ⇒ Object
522
523
524
525
526
|
# File 'lib/bio/db/primer3.rb', line 522
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
445
446
447
448
449
450
451
|
# File 'lib/bio/db/primer3.rb', line 445
def score
ret = 0
ret += @scores[type]
ret += @scores[:exon] if exon?
ret -= product_length
ret
end
|
#size ⇒ Object
619
620
621
|
# File 'lib/bio/db/primer3.rb', line 619
def size
@properties[:primer_pair_num_returned].to_i
end
|
#snp ⇒ Object
546
547
548
549
550
|
# File 'lib/bio/db/primer3.rb', line 546
def snp
return @snp if @snp
@snp
end
|
#type ⇒ Object
601
602
603
604
605
|
# File 'lib/bio/db/primer3.rb', line 601
def type
return @type if @parsed
@type
end
|