Class: Scaffolder::Region::Sequence

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

Overview

Class for inserting fasta sequence into the genome scaffold. The #raw_sequence method is also responsible for applying each of the sequence inserts to the original sequence. The following example specifies the insertion of a sequence identified by the fasta header ‘sequence1’. The example also outlines and insert to be added to the sequence in the region between 3 and 10.

- sequence:
    source: 'sequence1'
    inserts:
      -
        source: 'insert1'
        open: 3
        close: 10

Instance Method Summary collapse

Methods inherited from Scaffolder::Region

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

Instance Method Details

#inserts(inserts = nil) ⇒ Array

Array of inserts to add to this sequence. Each array entry may be either a Scaffolder::Region:Inserts or a corresponding to the attributes of an Insert. In the case of the latter each hash is used to generate a new Scaffolder::Region::Insert instance.

Parameters:

  • inserts (Array) (defaults to: nil)

    Accepts an array of either Scaffolder::Region::Insert or a hash of insert keyword data.

Returns:

  • (Array)

    Array of Scaffolder::Region::Insert



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/scaffolder/region/sequence.rb', line 31

def inserts(inserts=nil)
  if inserts.nil?
    @inserts || Array.new
  else
    @inserts = inserts.map do |insert|
      if insert.instance_of? Insert
        insert
      else
        Insert.generate(insert)
      end
    end
  end
end

#sequence_hookString

Adds each of the sequence inserts to the raw sequence. Updates the sequence length each time an insert is added to reflect the change.

Returns:

  • (String)

    original sequence with inserts added.

Raises:

  • (CoordinateError)

    if any insert open position is greater than the length of the original sequence

  • (CoordinateError)

    if any insert close position is less than one

  • (CoordinateError)

    if any insert open position is greater than the close position



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

def sequence_hook
  @updated_sequence ||= update_sequence_with_inserts
end

#sourceString

Fasta identifier for this sequence

Parameters:

  • (String)

Returns:

  • (String)


21
# File 'lib/scaffolder/region/sequence.rb', line 21

attribute :source