Class: Scaffolder::Region::Insert

Inherits:
Scaffolder::Region show all
Defined in:
lib/scaffolder/region/insert.rb

Overview

Inserts are used to additional usually smaller sequences to larger sequences. The attributes in the sequence class are used to specify where the host sequence is ‘opened’ and ‘closed’ to add the insert. Either one of these two attributes may be ommitted. Omitting the ‘open’ attribute will cause the insert open position to be calculated based on the close minus the sequence length. The reverse is true if the close position is ommittted.

Instance Method Summary collapse

Methods inherited from Scaffolder::Region

[], attribute, #entry_type, generate, #raw_sequence, #reverse, #sequence, #sequence_hook, #start, #stop

Instance Method Details

#<=>(other) ⇒ Integer

Inserts are comparable by close position.

Parameters:

Returns:

  • (Integer)


47
48
49
# File 'lib/scaffolder/region/insert.rb', line 47

def <=>(other)
  self.close <=> other.close
end

#closeInteger

End position where insert is added. Default is open position plus the sequence length.

Parameters:

  • (Integer)

Returns:

  • (Integer)


31
32
# File 'lib/scaffolder/region/insert.rb', line 31

attribute :close,
:default => lambda{|s| s.open  + s.sequence_hook.length - 1 }

#openInteger

Open position where insert is added. Default is close position minus the sequence length.

Parameters:

  • (Integer)

Returns:

  • (Integer)


23
24
# File 'lib/scaffolder/region/insert.rb', line 23

attribute :open,
:default => lambda{|s| s.close - s.sequence_hook.length - 1 }

#positionRange

Insertion position as a Range

Returns:

  • (Range)

Raises:

  • (CoordinateError)

    if both the open and close positions are nil.



38
39
40
41
# File 'lib/scaffolder/region/insert.rb', line 38

def position
  raise CoordinateError if @close.nil? && @open.nil?
  open-1..close-1
end

#size_diffInteger

The difference in the insert sequence size and the insert location

Returns:

  • (Integer)


54
55
56
57
# File 'lib/scaffolder/region/insert.rb', line 54

def size_diff
  insert_size = (close - open) + 1
  sequence.length - insert_size
end

#sourceString

Fasta identifier for the insert sequence

Parameters:

  • (String)

Returns:

  • (String)


16
# File 'lib/scaffolder/region/insert.rb', line 16

attribute :source