class Bio::Meme::Mast
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 and options 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
Constants
- DEFAULT_OPTIONS
Attributes
The command line String to be executed
A Hash of options for Mast
Public Class Methods
Source
# File lib/bio/appl/meme/mast.rb 97 def initialize(mast_location, options = {}) 98 unless File.exist?(mast_location) 99 raise ArgumentError.new("mast: command not found : #{mast_location}") 100 end 101 @binary = mast_location 102 options.empty? ? config(DEFAULT_OPTIONS) : config(options) 103 end
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
Public Instance Methods
Source
# File lib/bio/appl/meme/mast.rb 137 def check_options 138 @options.each_key do |k| 139 raise ArgumentError.new("Invalid option: #{k}") unless DEFAULT_OPTIONS.has_key?(k) 140 end 141 raise ArgumentError.new("Motif file not found: #{@options[:mfile]}") if @options[:mfile].nil? or !File.exist?(@options[:mfile]) 142 raise ArgumentError.new("Database not found: #{@options[:d]}") if @options[:d].nil? or !File.exist?(@options[:d]) 143 end
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 115 def config(options) 116 @options = DEFAULT_OPTIONS.merge(options) 117 mfile, opts, flags = String.new, String.new, String.new 118 @options.each_pair do |opt, val| 119 if val.nil? or val == false 120 next 121 elsif opt == :mfile 122 mfile = val 123 elsif val == true 124 flags << " -#{opt}" 125 else 126 opts << " -#{opt} #{val}" 127 end 128 end 129 @cmd = "#{@binary} #{mfile + opts + flags}" 130 end
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 149 def run 150 check_options 151 call_command(@cmd) {|io| @output = io.read } 152 Report.new(@output) 153 end
Run the mast program
- Returns
-
Bio::Meme::Mast::Report
object