Class: Bio::RestrictionEnzyme::Range::SequenceRange::Fragment

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb

Defined Under Namespace

Classes: DisplayFragment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(primary_bin, complement_bin) ⇒ Fragment

Returns a new instance of Fragment.



22
23
24
25
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 22

def initialize( primary_bin, complement_bin )
  @primary_bin = primary_bin
  @complement_bin = complement_bin
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



20
21
22
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 20

def size
  @size
end

Instance Method Details

#for_display(p_str = nil, c_str = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 29

def for_display(p_str=nil, c_str=nil)
  df = DisplayFragment.new
  df.primary = ''
  df.complement = ''

  both_bins = (@primary_bin + @complement_bin).sort.uniq
  both_bins.each do |item|
    @primary_bin.include?(item) ? df.primary << p_str[item] : df.primary << ' '
    @complement_bin.include?(item) ? df.complement << c_str[item] : df.complement << ' '
  end
  
  df.p_left  = @primary_bin.first
  df.p_right = @primary_bin.last
  df.c_left  = @complement_bin.first
  df.c_right = @complement_bin.last

  df
end