Class: BioDSL::AlignSeqMothur

Inherits:
Object
  • Object
show all
Includes:
AuxHelper
Defined in:
lib/BioDSL/commands/align_seq_mothur.rb

Overview

Align sequences in the stream using Mothur.

This is a wrapper for the mothur command align.seqs(). Basically, it aligns sequences to a reference alignment.

Please refer to the manual:

www.mothur.org/wiki/Align.seqs

Mothur must be installed for align_seq_mothurs to work. Read more here:

www.mothur.org/

Usage

align_seq_mothur(<template_file: <file>>[, cpus: <uint>])

Options

  • template_file: <file> - File with template alignment in FASTA format.

  • cpus: <uint> - Number of CPU cores to use (default=1).

Examples

To align the entries in the FASTA file `test.fna` to the template alignment in the file `template.fna` do:

BD.new.
read_fasta(input: "test.fna").
align_seq_mothur(template_file: "template.fna").
run

Constant Summary

STATS =
%i(records_in records_out sequences_in sequences_out residues_in
residues_out)

Instance Method Summary collapse

Methods included from AuxHelper

#aux_exist

Constructor Details

#initialize(options) ⇒ AlignSeqMothur

Constructor for the AlignSeqMothur class.

Options Hash (options):

  • :template_file (String)

    Path to template file.

  • :cpus (Integer)

    Number of CPUs to use.



76
77
78
79
80
81
82
# File 'lib/BioDSL/commands/align_seq_mothur.rb', line 76

def initialize(options)
  @options = options

  aux_exist('mothur')
  check_options
  defaults
end

Instance Method Details

#lmbProc

Return a lambda for the align_seq_mothur command.



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/BioDSL/commands/align_seq_mothur.rb', line 87

def lmb
  lambda do |input, output, status|
    status_init(status, STATS)

    TmpDir.create('input.fna', 'input.align') do |tmp_in, tmp_out, tmp_dir|
      process_input(input, output, tmp_in)
      run_mothur(@options[:template_file], @options[:cpus], tmp_dir, tmp_in)
      process_output(output, tmp_out)
    end
  end
end