module Mspire::Ident::SearchGroup
Attributes
searches[RW]
an array of search objects
Public Class Methods
new(arg=nil, opts={}) { |self| ... }
click to toggle source
takes an array of filenames or a single search filename (with extension defined by ‘extendsion’) or an array of objects passes any arguments to the initializer for each search the optional block yields the object for further processing
# File lib/mspire/ident/search.rb, line 92 def initialize(arg=nil, opts={}) @peptide_hits = [] @reference_hash = {} @searches = [] if arg if arg.is_a?(String) && arg =~ /\.#{Regexp.escap(extension)}$/ from_file(arg) elsif arg.is_a?(Array) && arg.first.is_a?(String) from_filenames(arg) elsif arg.is_a?(Array) @searches = array else raise ArgumentError, "must be file, array of filenames, or array of objs" end @searches << search_class.new(file, opts) end yield(self) if block_given? end
Public Instance Methods
extension()
click to toggle source
the group’s file extension (with no leading period)
# File lib/mspire/ident/search.rb, line 58 def extension 'grp' end
from_file(file)
click to toggle source
# File lib/mspire/ident/search.rb, line 71 def from_file(file) from_filenames(to_paths(file)) end
from_filenames(filenames)
click to toggle source
# File lib/mspire/ident/search.rb, line 76 def from_filenames(filenames) filenames.each do |file| if !File.exist? file message = "File: #{file} does not exist!\n" message << "perhaps you need to modify the file with file paths" abort message end @searches << search_class.new(file) end end
search_class()
click to toggle source
# File lib/mspire/ident/search.rb, line 62 def search_class Search end
to_paths(file)
click to toggle source
a simple formatted file with paths to the search files
# File lib/mspire/ident/search.rb, line 67 def to_paths(file) IO.readlines(file).grep(/\w/).reject {|v| v =~ /^#/}.map {|v| v.chomp } end