Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 #ifndef OPENMS_FORMAT_MASCOTINFILE_H
36 #define OPENMS_FORMAT_MASCOTINFILE_H
37 
40 #include <OpenMS/SYSTEM/File.h>
43 
44 #include <vector>
45 #include <fstream>
46 
47 namespace OpenMS
48 {
59  class OPENMS_DLLAPI MascotInfile :
60  public ProgressLogger
61  {
62 public:
63 
65  MascotInfile();
66 
68  virtual ~MascotInfile();
69 
71  void store(const String & filename, const PeakSpectrum & spec, double mz, double retention_time, String search_title);
72 
74  void store(const String & filename, const PeakMap & experiment, String search_title);
75 
82  template <typename MapType>
83  void load(const String & filename, MapType & exp)
84  {
85  exp.reset();
86  if (!File::exists(filename))
87  {
88  throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
89  }
90 
91  std::ifstream is(filename.c_str());
92  std::vector<std::pair<double, double> > spec;
93  UInt charge(0);
94  double pre_mz(0), pre_int(0), rt(-1);
95  String title;
96  while (getNextSpectrum_(is, spec, charge, pre_mz, pre_int, rt, title))
97  {
98  typename MapType::SpectrumType spectrum;
99  for (std::vector<std::pair<double, double> >::const_iterator it = spec.begin(); it != spec.end(); ++it)
100  {
101  typename MapType::PeakType p;
102  p.setPosition(it->first);
103  p.setIntensity(it->second);
104  spectrum.push_back(p);
105  }
106  spectrum.setMSLevel(2);
107  spectrum.getPrecursors().resize(1);
108  spectrum.getPrecursors()[0].setMZ(pre_mz);
109  spectrum.getPrecursors()[0].setIntensity(pre_int);
110  spectrum.getPrecursors()[0].setCharge(charge);
111  spectrum.setRT(rt);
112  if (title != "")
113  {
114  spectrum.setMetaValue("TITLE", title);
115  title = "";
116  }
117 
118  exp.addSpectrum(spectrum);
119 
120  // clean up
121  spec.clear();
122  charge = 0;
123  pre_mz = 0;
124  pre_int = 0;
125  }
126  }
127 
129  const String & getBoundary();
131  void setBoundary(const String & boundary);
132 
134  const String & getDB();
136  void setDB(const String & db);
137 
139  const String & getSearchType();
141  void setSearchType(const String & search_type);
142 
144  const String & getHits();
146  void setHits(const String & hits);
147 
149  const String & getCleavage();
151  void setCleavage(const String & cleavage);
152 
154  const String & getMassType();
156  void setMassType(const String & mass_type);
157 
159  const std::vector<String> & getModifications();
161  void setModifications(const std::vector<String> & mods);
162 
164  const std::vector<String> & getVariableModifications();
166  void setVariableModifications(const std::vector<String> & mods);
167 
169  const String & getInstrument();
171  void setInstrument(const String & instrument);
172 
174  UInt getMissedCleavages();
176  void setMissedCleavages(UInt missed_cleavages);
177 
179  float getPrecursorMassTolerance();
181  void setPrecursorMassTolerance(float precursor_mass_tolerance);
182 
184  float getPeakMassTolerance();
186  void setPeakMassTolerance(float ion_mass_tolerance);
187 
189  const String & getTaxonomy();
191  void setTaxonomy(const String & taxonomy);
192 
194  const String & getFormVersion();
196  void setFormVersion(const String & form_version);
197 
199  const String & getCharges();
201  void setCharges(std::vector<Int> & charges);
202 
203 protected:
205  double mz_;
206 
209 
212 
215 
218 
221 
224 
227 
229  std::vector<String> mods_;
230 
232  std::vector<String> variable_mods_;
233 
236 
239 
242 
245 
248 
251 
254 
257 
259  void writeParameterHeader_(const String & name, FILE * fp, bool line_break = true);
260 
262  void writeHeader_(FILE * fp);
263 
265  void writeSpectrum_(FILE * fp,
266  const String & filename,
267  const PeakSpectrum & peaks);
268 
270  void writeMSExperiment_(FILE * fp,
271  const String & filename,
272  const PeakMap & experiment);
273 
274  bool getNextSpectrum_(std::istream & is, std::vector<std::pair<double, double> > & spectrum, UInt & charge, double & precursor_mz, double & precursor_int, double & rt, String & title);
275  };
276 
277 } // namespace OpenMS
278 
279 #endif // OPENMS_FORMAT_MASCOTINFILE_H
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
double mz_
parent mass
Definition: MascotInfile.h:205
A more convenient string class.
Definition: String.h:57
String search_title_
the search title of the mascot search
Definition: MascotInfile.h:211
void reset()
Resets all internal values.
Definition: MSExperiment.h:709
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
Definition: MSExperiment.h:831
void load(const String &filename, MapType &exp)
Definition: MascotInfile.h:83
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
String mass_type_
Monoisotopic/average mass.
Definition: MascotInfile.h:226
UInt missed_cleavages_
number of missed cleavages
Definition: MascotInfile.h:238
File not found exception.
Definition: Exception.h:524
String charges_
charge states to use
Definition: MascotInfile.h:208
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:111
String taxonomy_
taxonomy
Definition: MascotInfile.h:247
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
static bool exists(const String &file)
Method used to test if a file exists.
String db_
the DB to search in
Definition: MascotInfile.h:214
String instrument_
the used instrument
Definition: MascotInfile.h:235
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:150
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
float ion_mass_tolerance_
m/z tolerance of ions in Da
Definition: MascotInfile.h:244
void setMSLevel(UInt ms_level)
Sets the MS level.
void setRT(double rt)
Sets the absolute retention time (in seconds)
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
String form_version_
form version
Definition: MascotInfile.h:250
std::vector< String > variable_mods_
variable Modifications
Definition: MascotInfile.h:232
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
std::vector< String > mods_
fixed Modifications
Definition: MascotInfile.h:229
String search_type_
search type: MIS, SQ or PMF
Definition: MascotInfile.h:217
Mascot input file adapter.
Definition: MascotInfile.h:59
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
float precursor_mass_tolerance_
precursor mass tolerance in Da
Definition: MascotInfile.h:241
String cleavage_
Enzyme used for cleavage.
Definition: MascotInfile.h:223
String hits_
number of hits to report
Definition: MascotInfile.h:220
String boundary_
the boundary used for the MIME format
Definition: MascotInfile.h:253
double retention_time_
the retention time
Definition: MascotInfile.h:256

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:01 using doxygen 1.8.13