Class | Bio::Meme::Mast
In: | lib/bio/appl/meme/mast.rb lib/bio/appl/meme/mast/report.rb
Parent: | Object

## Description

Bio::Meme::Mast is a wrapper for searching a database using sequence motifs. The code will read options from a Hash and run the program. Parsing of the output is provided by Bio::Meme::Mast::Report. Before running, options[:mfile] and options[:d] must be set in the constructor or Mast.config(options = {})

## Usage

      mast = Mast.new('/path/to/mast')
      or with options
      mast = Mast.new('/path/to/mast', {:mfile => 'meme.out', :d => '/shared/db/nr'})

      report = Mast::Report.new(mast.run)
      report.each do |motif|
        puts motif.length
      end

### Methods

check_options config new run

### Included Modules

Bio::Command

### Classes and Modules

Class Bio::Meme::Mast::Report

### Constants

DEFAULT_OPTIONS | = | { # required :mfile => nil, :d => nil, # optional :stdin => nil, # may not work as expected :count => nil, :alphabet => nil, :stdout => true, :text => false, :sep => false, :norc => false, :dna => false, :comp => false, :rank => nil, :smax => nil, :ev => nil, :mt => nil, :w => false, :bfile => nil, :seqp => false, :mf => nil, :df => nil, :minseqs => nil, :mev => nil, :m => nil, :diag => nil, :best => false, :remcorr => false, :brief => false, :b => false, :nostatus => true, :hit_list => true, }

### Attributes

cmd | [R] | The command line String to be executed
options | [RW] | A Hash of options for Mast

### Public Class methods

new(mast_location, options = {})

Create a mast instance

      m = Mast.new('/usr/local/bin/mast')

Arguments:

- (required) mast_location: String

Raises: | ArgumentError if mast program is not found
Returns: | a Bio::Meme::Mast object

[Source]

         # File lib/bio/appl/meme/mast.rb, line 96
     96:     def initialize(mast_location, options = {})
     97:       unless File.exists?(mast_location)
     98:         raise ArgumentError.new("mast: command not found : #{mast_location}")
     99:       end
    100:       @binary = mast_location
    101:       options.empty? ? config(DEFAULT_OPTIONS) : config(options)
    102:     end

### Public Instance methods

check_options()

Checks if input/database files exist and options are valid

Raises: | ArgumentError if the motifs file does not exist
Raises: | ArgumentError if the database file does not exist
Raises: | ArgumentError if there is an invalid option

[Source]

         # File lib/bio/appl/meme/mast.rb, line 136
    136:     def check_options
    137:       @options.each_key do |k|
    138:         raise ArgumentError.new("Invalid option: #{k}") unless DEFAULT_OPTIONS.has_key?(k)
    139:       end
    140:       raise ArgumentError.new("Motif file not found: #{@options[:mfile]}") if @options[:mfile].nil? or !File.exists?(@options[:mfile])
    141:       raise ArgumentError.new("Database not found: #{@options[:d]}") if @options[:d].nil? or !File.exists?(@options[:d])
    142:     end

config(options)

Builds the command line string any options passed in will be merged with DEFAULT_OPTIONS Mast usage: mast <mfile> <opts> <flags>

      mast.config({:mfile => "meme.out", :d => "/path/to/fasta/db"})

Arguments:

- (required) options: Hash (see DEFAULT_OPTIONS)

Returns: | the command line string

[Source]

         # File lib/bio/appl/meme/mast.rb, line 114
    114:     def config(options)
    115:       @options = DEFAULT_OPTIONS.merge(options)
    116:       mfile, opts, flags = "", "", ""
    117:       @options.each_pair do |opt, val|
    118:         if val.nil? or val == false
    119:           next
    120:         elsif opt == :mfile
    121:           mfile = val
    122:         elsif val == true
    123:           flags << " -#{opt}"
    124:         else
    125:           opts << " -#{opt} #{val}"
    126:         end
    127:       end
    128:       @cmd = "#{@binary} #{mfile + opts + flags}"
    129:     end

run()

Run the mast program

Returns: | Bio::Meme::Mast::Report object

[Source]

         # File lib/bio/appl/meme/mast.rb, line 148
    148:     def run
    149:       check_options
    150:       call_command(@cmd) {|io| @output = io.read }
    151:       Report.new(@output)
    152:     end

[Validate]