OpenMS  2.7.0
MascotInfile.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 #include <OpenMS/SYSTEM/File.h>
42 
43 #include <vector>
44 #include <fstream>
45 
46 namespace OpenMS
47 {
58  class OPENMS_DLLAPI MascotInfile :
59  public ProgressLogger
60  {
61 public:
62 
65 
67  virtual ~MascotInfile();
68 
70  void store(const String & filename, const PeakSpectrum & spec, double mz, double retention_time, String search_title);
71 
73  void store(const String & filename, const PeakMap & experiment, String search_title);
74 
81  template <typename MapType>
82  void load(const String & filename, MapType & exp)
83  {
84  exp.reset();
85  if (!File::exists(filename))
86  {
87  throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
88  }
89 
90  std::ifstream is(filename.c_str());
91  std::vector<std::pair<double, double> > spec;
92  UInt charge(0);
93  double pre_mz(0), pre_int(0), rt(-1);
94  String title;
95  while (getNextSpectrum_(is, spec, charge, pre_mz, pre_int, rt, title))
96  {
97  typename MapType::SpectrumType spectrum;
98  for (std::vector<std::pair<double, double> >::const_iterator it = spec.begin(); it != spec.end(); ++it)
99  {
100  typename MapType::PeakType p;
101  p.setPosition(it->first);
102  p.setIntensity(it->second);
103  spectrum.push_back(p);
104  }
105  spectrum.setMSLevel(2);
106  spectrum.getPrecursors().resize(1);
107  spectrum.getPrecursors()[0].setMZ(pre_mz);
108  spectrum.getPrecursors()[0].setIntensity(pre_int);
109  spectrum.getPrecursors()[0].setCharge(charge);
110  spectrum.setRT(rt);
111  if (title != "")
112  {
113  spectrum.setMetaValue("TITLE", title);
114  title = "";
115  }
116 
117  exp.addSpectrum(spectrum);
118 
119  // clean up
120  spec.clear();
121  charge = 0;
122  pre_mz = 0;
123  pre_int = 0;
124  }
125  }
126 
128  const String & getBoundary();
130  void setBoundary(const String & boundary);
131 
133  const String & getDB();
135  void setDB(const String & db);
136 
140  void setSearchType(const String & search_type);
141 
143  const String & getHits();
145  void setHits(const String & hits);
146 
148  const String & getCleavage();
150  void setCleavage(const String & cleavage);
151 
153  const String & getMassType();
155  void setMassType(const String & mass_type);
156 
158  const std::vector<String> & getModifications();
160  void setModifications(const std::vector<String> & mods);
161 
163  const std::vector<String> & getVariableModifications();
165  void setVariableModifications(const std::vector<String> & mods);
166 
170  void setInstrument(const String & instrument);
171 
175  void setMissedCleavages(UInt missed_cleavages);
176 
180  void setPrecursorMassTolerance(float precursor_mass_tolerance);
181 
185  void setPeakMassTolerance(float ion_mass_tolerance);
186 
188  const String & getTaxonomy();
190  void setTaxonomy(const String & taxonomy);
191 
195  void setFormVersion(const String & form_version);
196 
198  const String & getCharges();
200  void setCharges(std::vector<Int> & charges);
201 
202 protected:
204  double mz_;
205 
208 
211 
214 
217 
220 
223 
226 
228  std::vector<String> mods_;
229 
231  std::vector<String> variable_mods_;
232 
235 
238 
241 
244 
247 
250 
253 
256 
258  void writeParameterHeader_(const String & name, FILE * fp, bool line_break = true);
259 
261  void writeHeader_(FILE * fp);
262 
264  void writeSpectrum_(FILE * fp,
265  const String & filename,
266  const PeakSpectrum & peaks);
267 
269  void writeMSExperiment_(FILE * fp,
270  const String & filename,
271  const PeakMap & experiment);
272 
273  bool getNextSpectrum_(std::istream & is, std::vector<std::pair<double, double> > & spectrum, UInt & charge, double & precursor_mz, double & precursor_int, double & rt, String & title);
274  };
275 
276 } // namespace OpenMS
277 
File not found exception.
Definition: Exception.h:517
static bool exists(const String &file)
Method used to test if a file exists.
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
void reset()
Resets all internal values.
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
void setMSLevel(UInt ms_level)
Sets the MS level.
void setRT(double rt)
Sets the absolute retention time (in seconds)
Mascot input file adapter.
Definition: MascotInfile.h:60
std::vector< String > mods_
fixed Modifications
Definition: MascotInfile.h:228
const String & getHits()
returns the number of hits to report back
String instrument_
the used instrument
Definition: MascotInfile.h:234
void setSearchType(const String &search_type)
sets the search type (default: MIS). So far only MIS is supported! Valid types are "MIS" (MS/MS Ion S...
const String & getMassType()
returns the used mass type ("Monoisotopic" or "Average")
const String & getSearchType()
returns the search type
const std::vector< String > & getModifications()
returns a vector containing the fixed modifications (default: none)
String taxonomy_
taxonomy
Definition: MascotInfile.h:246
void setModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
const String & getInstrument()
returns the instrument type
void setMissedCleavages(UInt missed_cleavages)
sets the number of allowed missed cleavages (default: 1)
UInt getMissedCleavages()
returns the number of allowed missed cleavages
void setCharges(std::vector< Int > &charges)
sets the charges (default: 1+, 2+ and 3+)
void writeSpectrum_(FILE *fp, const String &filename, const PeakSpectrum &peaks)
writes the spectrum
String form_version_
form version
Definition: MascotInfile.h:249
String search_title_
the search title of the mascot search
Definition: MascotInfile.h:210
float precursor_mass_tolerance_
precursor mass tolerance in Da
Definition: MascotInfile.h:240
String db_
the DB to search in
Definition: MascotInfile.h:213
String boundary_
the boundary used for the MIME format
Definition: MascotInfile.h:252
float getPrecursorMassTolerance()
returns the precursor mass tolerance
String mass_type_
Monoisotopic/average mass.
Definition: MascotInfile.h:225
const String & getBoundary()
returns the boundary used for the MIME format
void writeMSExperiment_(FILE *fp, const String &filename, const PeakMap &experiment)
writes the MSExperiment
const std::vector< String > & getVariableModifications()
returns a vector containing the variable modifications (default: none)
void setCleavage(const String &cleavage)
sets the enzyme used for cleavage (default: Trypsin). See <mascot path>/config/enzymes for possible ...
const String & getCleavage()
returns the enzyme used for cleavage
const String & getCharges()
returns the charges
float getPeakMassTolerance()
returns the peak mass tolerance in Da
String cleavage_
Enzyme used for cleavage.
Definition: MascotInfile.h:222
UInt missed_cleavages_
number of missed cleavages
Definition: MascotInfile.h:237
void setVariableModifications(const std::vector< String > &mods)
sets the fixed modifications (default: none). See <mascot path>/config/mod_file for possible setting...
void writeHeader_(FILE *fp)
writes the full header
String hits_
number of hits to report
Definition: MascotInfile.h:219
void setPeakMassTolerance(float ion_mass_tolerance)
sets the peak mass tolerance in Da (default: 1.0)
bool getNextSpectrum_(std::istream &is, std::vector< std::pair< double, double > > &spectrum, UInt &charge, double &precursor_mz, double &precursor_int, double &rt, String &title)
void load(const String &filename, MapType &exp)
Definition: MascotInfile.h:82
const String & getTaxonomy()
returns the taxonomy
void setBoundary(const String &boundary)
sets the boundary used for the MIME format. By default a 22 character random string is used
std::vector< String > variable_mods_
variable Modifications
Definition: MascotInfile.h:231
void setTaxonomy(const String &taxonomy)
sets the taxonomy (default: All entries). See <mascot path>/config/taxonomy for possible settings.
void store(const String &filename, const PeakMap &experiment, String search_title)
stores the experiment data in a MascotInfile that can be used as input for MASCOT shell execution
double retention_time_
the retention time
Definition: MascotInfile.h:255
virtual ~MascotInfile()
constructor
float ion_mass_tolerance_
m/z tolerance of ions in Da
Definition: MascotInfile.h:243
void store(const String &filename, const PeakSpectrum &spec, double mz, double retention_time, String search_title)
stores the peak list in a MascotInfile that can be used as input for MASCOT shell execution
void setFormVersion(const String &form_version)
sets the Mascot form version (default: 1.01)
String search_type_
search type: MIS, SQ or PMF
Definition: MascotInfile.h:216
void setPrecursorMassTolerance(float precursor_mass_tolerance)
sets the precursor mass tolerance in Da (default: 2.0)
void setMassType(const String &mass_type)
sets the used mass type "Monoisotopic" or "Average" (default: Monoisotopic)
void setDB(const String &db)
sets the DB to use (default: MSDB). See <mascot path>/config/mascot.dat in "Databases" section for po...
const String & getFormVersion()
returns the Mascot form version
const String & getDB()
returns the DB to use
void writeParameterHeader_(const String &name, FILE *fp, bool line_break=true)
writes a parameter header
void setHits(const String &hits)
sets the number of hits to report back (default: 20)
double mz_
parent mass
Definition: MascotInfile.h:204
MascotInfile()
constructor
void setInstrument(const String &instrument)
sets the instrument type (Default: Default). Possible instruments: ESI-QUAD-TOF, MALDI-TOF-PSD,...
String charges_
charge states to use
Definition: MascotInfile.h:207
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:104
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:143
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
A more convenient string class.
Definition: String.h:61
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47