class BioDSL::ComplementSeq

Complment sequences in the stream.

complement_seq complements sequences in the stream. The sequence type - DNA or RNA - is guessed by inspected the first sequence in the stream.

complement_seq can be used together with reverse_seq to reverse- complement sequences.

Usage

complement_seq()

Options

Examples

Consider the following FASTQ entry in the file test.fq:

@M02529:88:000000000-AC0WY:1:1101:12879:1928 2:N:0:185
TTGTAAAACGACGGCCAGTG
+
>>>>>FFFFD@A?A0AE0FG

To complement the sequence do:

BD.new.read_fastq(input:"test.fq").complement_seq.dump.run

{:SEQ_NAME=>"M02529:88:000000000-AC0WY:1:1101:12879:1928 2:N:0:185",
 :SEQ=>"AACATTTTGCTGCCGGTCAC",
 :SEQ_LEN=>20,
 :SCORES=>">>>>>FFFFD@A?A0AE0FG"}

Constants

STATS

Public Class Methods

new(options) click to toggle source

Constructor for ComplementSeq.

@param options [Hash] Options hash.

# File lib/BioDSL/commands/complement_seq.rb, line 67
def initialize(options)
  @options = options
  @type    = nil

  check_options
end

Public Instance Methods

lmb() click to toggle source

Return the command lambda for ComplementSeq.

@return [Proc] Command lambda

# File lib/BioDSL/commands/complement_seq.rb, line 77
def lmb
  lambda do |input, output, status|
    status_init(status, STATS)

    input.each do |record|
      @status[:records_in] += 1

      complement(record) if record.key? :SEQ

      output << record

      @status[:records_out] += 1
    end
  end
end

Private Instance Methods

check_options() click to toggle source

Check options.

# File lib/BioDSL/commands/complement_seq.rb, line 96
def check_options
  options_allowed(@options, nil)
end
complement(record) click to toggle source

Complements sequence in record.

@param record [Hash] BioDSL record with sequence.

# File lib/BioDSL/commands/complement_seq.rb, line 103
def complement(record)
  entry = BioDSL::Seq.new_bp(record)
  @type = entry.type_guess unless @type
  entry.type = @type
  entry.complement!

  @status[:sequences_in] += 1
  @status[:sequences_out] += 1
  @status[:residues_in] += entry.length
  @status[:residues_out] += entry.length

  record.merge! entry.to_bp
end