Sha256: e1343e4870b38d78135ef9c3b409d70b7e25939b54ec1a3a79e357eea291e8be

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

# 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.
#
# @see Scaffolder::Region::Sequence Scaffolder::Region::Sequence for an
#   example on adding inserts to a sequence.
class Scaffolder::Region::Insert < Scaffolder::Region

  # Fasta identifier for the insert sequence
  #
  # @param [String]
  # @return [String]
  attribute :source

  # Open position where insert is added. Default is close position minus the
  # sequence length.
  #
  # @param [Integer]
  # @return [Integer]
  attribute :open,
    :default => lambda{|s| s.close - s.sequence_hook.length - 1 }

  # End position where insert is added. Default is open position plus the
  # sequence length.
  #
  # @param [Integer]
  # @return [Integer]
  attribute :close,
    :default => lambda{|s| s.open  + s.sequence_hook.length - 1 }

  # Insertion position as a Range
  #
  # @return [Range]
  # @raise [CoordinateError] if both the open and close positions are nil.
  def position
    raise CoordinateError if @close.nil? && @open.nil?
    open-1..close-1
  end

  # Inserts are comaprable by close position.
  #
  # @return [Integer]
  # @param [Scaffolder::Region::Insert]
  def <=>(other)
    self.close <=> other.close
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scaffolder-0.4.2 lib/scaffolder/region/insert.rb
scaffolder-0.4.1 lib/scaffolder/region/insert.rb
scaffolder-0.4.0 lib/scaffolder/region/insert.rb