Class: Bio::RestrictionEnzyme::DoubleStranded::CutLocationPair

Inherits:
Array
  • Object
show all
Defined in:
lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb

Overview

Stores a single cut location pair in 0-based index notation for use with DoubleStranded enzyme sequences.

Direct Known Subclasses

CutLocationPairInEnzymeNotation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*pair) ⇒ CutLocationPair

CutLocationPair constructor.

Stores a single cut location pair in 0-based index notation for use with DoubleStranded enzyme sequences.

Example:

clp = CutLocationPair.new(3,2)
clp.primary                    # 3
clp.complement                 # 2

Arguments

  • pair: May be two values represented as an Array, a Range, or a combination of Integer and nil values. The first value represents a cut on the primary strand, the second represents a cut on the complement strand.

Returns

nothing



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb', line 40

def initialize( *pair )
  a = b = nil

  if pair[0].kind_of? Array
    a,b = init_with_array( pair[0] )

  # no idea why this barfs without the second half during test/runner.rb
  # are there two Range objects running around?
  elsif pair[0].kind_of? Range or (pair[0].class.to_s == 'Range')
  #elsif pair[0].kind_of? Range
    a,b = init_with_array( [pair[0].first, pair[0].last] )

  elsif pair[0].kind_of? Integer or pair[0].kind_of? NilClass
    a,b = init_with_array( [pair[0], pair[1]] )

  else
    raise ArgumentError, "#{pair[0].class} is an invalid class type to initalize CutLocationPair."
  end

  super( [a,b] )
  @primary = a
  @complement = b
  return
end

Instance Attribute Details

#complementObject (readonly)

Location of the cut on the complementary strand. Corresponds - or ‘pairs’ - to the primary cut. A value of nil is an explicit representation of ‘no cut’.



21
22
23
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb', line 21

def complement
  @complement
end

#primaryObject (readonly)

Location of the cut on the primary strand. Corresponds - or ‘pairs’ - to the complement cut. A value of nil is an explicit representation of ‘no cut’.



16
17
18
# File 'lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb', line 16

def primary
  @primary
end