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
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
# File lib/bio/appl/meme/mast.rb 96 def initialize(mast_location, options = {}) 97 unless File.exist?(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
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
# File lib/bio/appl/meme/mast.rb 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.exist?(@options[:mfile]) 141 raise ArgumentError.new("Database not found: #{@options[:d]}") if @options[:d].nil? or !File.exist?(@options[:d]) 142 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
# File lib/bio/appl/meme/mast.rb 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 the mast program
- Returns
-
Bio::Meme::Mast::Report
object
# File lib/bio/appl/meme/mast.rb 148 def run 149 check_options 150 call_command(@cmd) {|io| @output = io.read } 151 Report.new(@output) 152 end