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.



14
15
16
17
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 14

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.



12
13
14
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 12

def size
  @size
end

Instance Method Details

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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb', line 21

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