Class: SearchTool

Inherits:
Tool
  • Object
show all
Defined in:
lib/protk/search_tool.rb

Direct Known Subclasses

ProphetTool

Instance Attribute Summary

Attributes inherited from Tool

#option_parser, #options

Instance Method Summary collapse

Methods inherited from Tool

#check_options, #input_base_path, #jobid_prefix, #jobid_prefix=, #method_missing, #output_base_path, #run

Constructor Details

#initialize(option_support = []) ⇒ SearchTool

Initializes commandline options common to all search tools. Individual search tools can add their own options, but should use Capital letters to avoid conflicts



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/protk/search_tool.rb', line 21

def initialize(option_support=[])
  super(option_support)

  if (option_support.include? :database)          
    @options.database = "sphuman"
    @option_parser.on( '-d', '--database dbname', 'Specify the database to use for this search. Default=sphuman' ) do |dbname|
      options.database = dbname
    end

  end
  
  if ( option_support.include? :enzyme )
     @options.enzyme = "Trypsin"
     @option_parser.on('--enzyme enz', 'Enzyme') do |enz|
       @options.enzyme=enz
     end
  end

  if ( option_support.include? :modifications )
    @options.var_mods = ""
    @option_parser.on('--var-mods vm', 'Variable modifications' ) do |vm|
      @options.var_mods = vm
    end

    @options.fix_mods = ""
    @option_parser.on('--fix-mods fm', 'Fixed modifications' ) do |fm|
      @options.fix_mods = fm
    end
  end

  if ( option_support.include? :instrument )
    @options.instrument = "ESI-QUAD-TOF"
    @option_parser.on('--instrument instrument', 'Instrument') do |instrument|
     @options.instrument=instrument
   end
  end

  if ( option_support.include? :mass_tolerance_units )
    @options.fragment_tolu="Da"
    @option_parser.on('--fragment-ion-tol-units tolu', 'Fragment ion mass tolerance units (Da or mmu). Default=Da' ) do |tolu|
      @options.fragment_tolu = tolu
    end
      
    @options.precursor_tolu="ppm"
    @option_parser.on('--precursor-ion-tol-units tolu', 'Precursor ion mass tolerance units (ppm or Da). Default=ppm' ) do |tolu|
      @options.precursor_tolu = tolu
    end
  end

  if ( option_support.include? :mass_tolerance )
    @options.fragment_tol=0.65
    @option_parser.on( '-f', '--fragment-ion-tol tol', 'Fragment ion mass tolerance (unit dependent). Default=0.65' ) do |tol|
      @options.fragment_tol = tol
    end
    
    @options.precursor_tol=200
    @option_parser.on( '-p', '--precursor-ion-tol tol', 'Precursor ion mass tolerance in (ppm if precursor search type is monoisotopic or Da if it is average). Default=200' ) do |tol|
      @options.precursor_tol = tol.to_f
    end
  end
  
  if ( option_support.include? :precursor_search_type )
    @options.precursor_search_type="monoisotopic"
    @option_parser.on( '-a', '--search-type type', 'Use monoisotopic or average precursor masses. (monoisotopic or average)' ) do |type| 
      @options.precursor_search_type = type
    end
  end

  if ( option_support.include? :strict_monoisotopic_mass )
    @options.strict_monoisotopic_mass=false
    @option_parser.on( '-s', '--strict-monoisotopic-mass', 'Dont allow for misassignment of monoisotopic mass to another isotopic peak') do
      @options.strict_monoisotopic_mass=true
    end
  end

  if ( option_support.include? :missed_cleavages )
    @options.missed_cleavages=2
    @option_parser.on( '-v', '--num-missed-cleavages num', 'Number of missed cleavages allowed' ) do |num| 
      @options.missed_cleavages = num
    end
  end

  if ( option_support.include? :respect_precursor_charges )
    @options.respect_precursor_charges=false
    @option_parser.on( '-q', '--respect-charges','Dont respect charges in the input file. Instead impute them by trying various options') do 
      @options.respect_precursor_charges=true
    end
  end

  if ( option_support.include? :searched_ions )
      @options.searched_ions = ""
      @option_parser.on('--searched-ions si', 'Ion series to search (default=b,y)' ) do |si|
        @options.searched_ions = si
      end
  end

  if ( option_support.include? :num_peaks_for_multi_isotope_search )
      @options.num_peaks_for_multi_isotope_search="0"
      @option_parser.on("--num-peaks-for-multi-isotope-search np","Number of peaks to include in multi-isotope search") do |np|
        @options.num_peaks_for_multi_isotope_search=np
      end
  end

  if ( option_support.include? :glyco)
    @options.glyco = false
    @option_parser.on( '-g', '--glyco', 'Expect N-Glycosylation modifications as variable mod in a search or as a parameter when building statistical models' ) do 
      @options.glyco = true
    end
  end

  if ( option_support.include? :methionine_oxidation)
    @options.methionine_oxidation = false
    @option_parser.on( '-m', '--methionineo', 'Expect Oxidised Methionine modifications as variable mod in a search' ) do 
      @options.methionine_oxidation = true
    end
  end

  if ( option_support.include? :carbamidomethyl)
    @options.carbamidomethyl = false
    @option_parser.on( '-c', '--carbamidomethyl', 'Expect Carbamidomethyl C modifications as fixed mod in a search' ) do 
      @options.carbamidomethyl = true
    end
  end
  
  if ( option_support.include? :maldi)
    @options.maldi=false
    @option_parser.on( '-l', '--maldi', 'Run a search on MALDI data') do
      @options.maldi=true
    end
  end
    
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tool

Instance Method Details

#current_database(db_type, db = @options.database) ⇒ Object

Based on the database setting and global database path, find the most current version of the required database This function returns the name of the database with an extension appropriate to the database type



167
168
169
# File 'lib/protk/search_tool.rb', line 167

def current_database(db_type,db=@options.database)
  return Constants.new.current_database_for_name(db)
end

#jobid_from_filename(filename) ⇒ Object



155
156
157
158
159
160
161
162
# File 'lib/protk/search_tool.rb', line 155

def jobid_from_filename(filename)
  jobid="protk"
  jobnum_match=filename.match(/(.{1,10}).*?\./)
  if (jobnum_match!=nil)
    jobid="#{self.jobid_prefix}#{jobnum_match[1]}"
  end
  return jobid
end