Method: MS::Sequest::Srf::Sqt.commandline

Defined in:
lib/ms/sequest/srf/sqt.rb

.commandline(argv, progname = $0) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/ms/sequest/srf/sqt.rb', line 177

def self.commandline(argv, progname=$0)
  opt = {
    :filter => true
  }
  opts = OptionParser.new do |op|
    op.banner = "usage: #{progname} [OPTIONS] <file>.srf ..."
    op.separator "output: <file>.sqt ..."
    op.separator ""
    op.separator "options:"
    op.on("-d", "--db-info", "calculates num aa's and md5sum on db") {|v| opt[:db_info] = v }
    op.on("-p", "--db-path <String>", "If you need to specify the database path") {|v| opt[:new_db_path] = v }
    op.on("-u", "--db-update", "update the sqt file to reflect --db_path") {|v| opt[:db_update] = v }
    op.on("-n", "--no-filter", "by default, pephit must be within peptide_mass_tolerance",  "(defined in sequest.params) to be included.  Turns this off.") { opt[:filter] = false }
    op.on("-o", "--outfiles <first,...>", Array, "Comma list of output filenames") {|v| opt[:outfiles] = v }
    op.on("-r", "--round", "round floating point values reasonably") {|v| opt[:round] = v }
  end
  opts.parse!(argv)

  if argv.size == 0
    puts(opts) || exit
  end

  if opt[:outfiles] && (opt[:outfiles].size != argv.size)
    raise "if outfiles specified, outfiles must be same size as number of input files"
  end

  argv.each_with_index do |srf_file,i|
    outfile = 
      if opt[:outfiles]
        opt[:outfiles][i]
      else
        base = srf_file.chomp(File.extname(srf_file))
        base + '.sqt'
      end

    srf = MS::Sequest::Srf.new(srf_file, :link_protein_hits => false, :filter_by_precursor_mass_tolerance => opt.delete(:filter))
    srf.to_sqt(outfile, :db_info => opt[:db_info], :new_db_path => opt[:new_db_path], :update_db_path => opt[:db_update], :round => opt[:round])
  end
end