| OpenMS 2.5.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-2020.
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
37 #include <OpenMS/KERNEL/MSExperiment.h>
38 #include <OpenMS/DATASTRUCTURES/String.h>
39 #include <OpenMS/SYSTEM/File.h>
40 #include <OpenMS/CONCEPT/ProgressLogger.h>
41 #include <OpenMS/KERNEL/StandardTypes.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
64 MascotInfile();
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
138 const String & getSearchType();
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
168 const String & getInstrument();
170 void setInstrument(const String & instrument);
171
173 UInt getMissedCleavages();
175 void setMissedCleavages(UInt missed_cleavages);
176
178 float getPrecursorMassTolerance();
180 void setPrecursorMassTolerance(float precursor_mass_tolerance);
181
183 float getPeakMassTolerance();
185 void setPeakMassTolerance(float ion_mass_tolerance);
186
188 const String & getTaxonomy();
190 void setTaxonomy(const String & taxonomy);
191
193 const String & getFormVersion();
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
207 String charges_;
208
210 String search_title_;
211
213 String db_;
214
216 String search_type_;
217
219 String hits_;
220
222 String cleavage_;
223
225 String mass_type_;
226
228 std::vector<String> mods_;
229
231 std::vector<String> variable_mods_;
232
234 String instrument_;
235
237 UInt missed_cleavages_;
238
240 float precursor_mass_tolerance_;
241
243 float ion_mass_tolerance_;
244
246 String taxonomy_;
247
249 String form_version_;
250
252 String boundary_;
253
255 double retention_time_;
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
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MSExperiment::addSpectrum
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
OpenMS::MascotInfile
Mascot input file adapter.
Definition: MascotInfile.h:58
OpenMS::MascotInfile::precursor_mass_tolerance_
float precursor_mass_tolerance_
precursor mass tolerance in Da
Definition: MascotInfile.h:240
OpenMS::MascotInfile::search_type_
String search_type_
search type: MIS, SQ or PMF
Definition: MascotInfile.h:216
OpenMS::Peak1D::setIntensity
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:112
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::MascotInfile::instrument_
String instrument_
the used instrument
Definition: MascotInfile.h:234
StandardTypes.h
OpenMS::MascotInfile::search_title_
String search_title_
the search title of the mascot search
Definition: MascotInfile.h:210
OpenMS::MascotInfile::boundary_
String boundary_
the boundary used for the MIME format
Definition: MascotInfile.h:252
OpenMS::MascotInfile::mz_
double mz_
parent mass
Definition: MascotInfile.h:204
OpenMS::Peak1D::setPosition
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:151
OpenMS::MSSpectrum::setRT
void setRT(double rt)
Sets the absolute retention time (in seconds)
OpenMS::Exception::FileNotFound
File not found exception.
Definition: Exception.h:523
OpenMS::SpectrumSettings::getPrecursors
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
OpenMS::MascotInfile::db_
String db_
the DB to search in
Definition: MascotInfile.h:213
OpenMS::MascotInfile::missed_cleavages_
UInt missed_cleavages_
number of missed cleavages
Definition: MascotInfile.h:237
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
OpenMS::File::exists
static bool exists(const String &file)
Method used to test if a file exists.
String.h
OpenMS::MascotInfile::hits_
String hits_
number of hits to report
Definition: MascotInfile.h:219
OpenMS::MascotInfile::taxonomy_
String taxonomy_
taxonomy
Definition: MascotInfile.h:246
ProgressLogger.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::MascotInfile::load
void load(const String &filename, MapType &exp)
Definition: MascotInfile.h:82
MSExperiment.h
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
OpenMS::MSExperiment::reset
void reset()
Resets all internal values.
OpenMS::MascotInfile::charges_
String charges_
charge states to use
Definition: MascotInfile.h:207
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::MascotInfile::mods_
std::vector< String > mods_
fixed Modifications
Definition: MascotInfile.h:228
OpenMS::MascotInfile::ion_mass_tolerance_
float ion_mass_tolerance_
m/z tolerance of ions in Da
Definition: MascotInfile.h:243
OpenMS::MascotInfile::retention_time_
double retention_time_
the retention time
Definition: MascotInfile.h:255
OpenMS::MascotInfile::variable_mods_
std::vector< String > variable_mods_
variable Modifications
Definition: MascotInfile.h:231
OpenMS::MSSpectrum::setMSLevel
void setMSLevel(UInt ms_level)
Sets the MS level.
File.h
OpenMS::MetaInfoInterface::setMetaValue
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
OpenMS::MascotInfile::cleavage_
String cleavage_
Enzyme used for cleavage.
Definition: MascotInfile.h:222
OpenMS::MascotInfile::mass_type_
String mass_type_
Monoisotopic/average mass.
Definition: MascotInfile.h:225
OpenMS::MascotInfile::form_version_
String form_version_
form version
Definition: MascotInfile.h:249