Sha256: 706906ec32fabd09f5ed1028860e4a1c109f13cce7c37eea4537dd4af83cfc97

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

require 'yaml'
require 'digest/sha1'
require 'scaffolder'
require 'scaffolder/tool'

class Scaffolder::Tool::Sequence < Scaffolder::Tool

  def self.description
    "Generate the fasta output for the scaffold"
  end

  def execute
    s = sequence(scaffold)
    Bio::Sequence.new(s).output(:fasta,:header => header(s,@settings))
  end

  private

  def sequence(scaffold)
    sequence = scaffold.inject(String.new) do |string,entry|
      string << entry.sequence
    end
  end

  def header(sequence,opts={})
    header = String.new
    header << opts[:definition] + " " if opts[:definition]
    unless opts[:no] && opts[:no][:sequence] && opts[:no][:sequence][:hash]
      header << Digest::SHA1.hexdigest(sequence)
    end
    header
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scaffolder-tools-0.1.2 lib/scaffolder/tool/sequence.rb
scaffolder-tools-0.1.1 lib/scaffolder/tool/sequence.rb
scaffolder-tools-0.1.0 lib/scaffolder/tool/sequence.rb