OpenMS  2.6.0
PepXMLFile.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: Chris Bielow, Hendrik Weisser $
32 // $Authors: Chris Bielow, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 #include <OpenMS/FORMAT/XMLFile.h>
45 
46 #include <vector>
47 #include <map>
48 #include <set>
49 
50 
51 namespace OpenMS
52 {
63  class OPENMS_DLLAPI PepXMLFile :
64  protected Internal::XMLHandler,
65  public Internal::XMLFile
66  {
67 public:
68 
70  PepXMLFile();
71 
73  ~PepXMLFile() override;
74 
87  void load(const String& filename,
88  std::vector<ProteinIdentification>& proteins,
89  std::vector<PeptideIdentification>& peptides,
90  const String& experiment_name,
91  const SpectrumMetaDataLookup& lookup);
92 
99  void load(const String& filename,
100  std::vector<ProteinIdentification>& proteins,
101  std::vector<PeptideIdentification>& peptides,
102  const String& experiment_name = "");
103 
109  void store(const String& filename, std::vector<ProteinIdentification>& protein_ids,
110  std::vector<PeptideIdentification>& peptide_ids, const String& mz_file = "",
111  const String& mz_name = "", bool peptideprophet_analyzed = false, double rt_tolerance = 0.01);
112 
120  void keepNativeSpectrumName(bool keep)
121  {
122  keep_native_name_ = keep;
123  }
124 
125 protected:
126 
128  void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) override;
129 
131  void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
132 
133 private:
134 
136  void makeScanMap_();
137 
139  void readRTMZCharge_(const xercesc::Attributes& attributes);
140 
142  {
143  private:
144 
146  double massdiff_;
147  double mass_;
151  bool is_protein_terminus_; // "true" if protein terminus, "false" if peptide terminus
153  std::vector<String> errors_;
155 
156  public:
157  AminoAcidModification() = delete;
158 
164  const String& aminoacid, const String& massdiff, const String& mass,
165  String variable, const String& description, String terminus, const String& protein_terminus);
166 
167  AminoAcidModification(const AminoAcidModification& rhs) = default;
168 
169  virtual ~AminoAcidModification() = default;
170 
171  AminoAcidModification& operator=(const AminoAcidModification& rhs) = default;
172 
173  String toUnimodLikeString() const;
174 
175  const String& getDescription() const;
176 
177  bool isVariable() const;
178 
179  const ResidueModification* getRegisteredMod() const;
180 
181  double getMassDiff() const;
182 
183  double getMass() const;
184 
185  const String& getTerminus() const;
186 
187  const String& getAminoAcid() const;
188 
189  const std::vector<String>& getErrors() const;
190  };
191 
193  std::vector<ProteinIdentification>* proteins_;
194 
196  std::vector<PeptideIdentification>* peptides_;
197 
200 
203 
206 
212 
214  bool use_precursor_data_{};
215 
217  std::map<Size, Size> scan_map_;
218 
221 
224 
227 
230 
232  bool search_summary_{};
233 
235  bool wrong_experiment_{};
236 
238  bool seen_experiment_{};
239 
241  bool checked_base_name_{};
242 
244  bool has_decoys_{};
245 
248 
251 
253  std::vector<std::vector<ProteinIdentification>::iterator> current_proteins_;
254 
257 
261 
264 
267 
270 
273 
275  double rt_{}, mz_{};
276 
278  Int charge_{};
279 
281  UInt search_id_{};
282 
285 
288 
290  double hydrogen_mass_{};
291 
293  std::vector<std::pair<const ResidueModification*, Size> > current_modifications_;
294 
296  std::vector<AminoAcidModification> fixed_modifications_;
297 
299  std::vector<AminoAcidModification> variable_modifications_;
300 
302 
303  static const double mod_tol_;
304  static const double xtandem_artificial_mod_tol_;
305 
308  bool lookupAddFromHeader_(double modification_mass,
309  Size modification_position,
310  std::vector<AminoAcidModification> const& header_mods);
311  };
312 
313 } // namespace OpenMS
OpenMS::PepXMLFile::native_spectrum_name_
String native_spectrum_name_
Several optional attributes of spectrum_query.
Definition: PepXMLFile.h:208
OpenMS::PepXMLFile::swath_assay_
String swath_assay_
Definition: PepXMLFile.h:210
XMLFile.h
OpenMS::PepXMLFile::AminoAcidModification::registered_mod_
const ResidueModification * registered_mod_
Definition: PepXMLFile.h:154
OpenMS::PepXMLFile::analysis_summary_
bool analysis_summary_
Are we currently in an "analysis_summary" element (should be skipped)?
Definition: PepXMLFile.h:223
OpenMS::ResidueModification
Representation of a modification.
Definition: ResidueModification.h:76
OpenMS::PepXMLFile::prot_id_
String prot_id_
Identifier linking PeptideIdentifications and ProteinIdentifications.
Definition: PepXMLFile.h:284
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:151
OpenMS::PepXMLFile::enzyme_cuttingsite_
String enzyme_cuttingsite_
Definition: PepXMLFile.h:260
OpenMS::Element
Representation of an element.
Definition: Element.h:53
OpenMS::PepXMLFile::AminoAcidModification::is_variable_
bool is_variable_
Definition: PepXMLFile.h:148
OpenMS::PeptideHit::PepXMLAnalysisResult
Analysis Result (containing search engine / prophet results)
Definition: PeptideHit.h:211
OpenMS::PepXMLFile::scan_map_
std::map< Size, Size > scan_map_
Mapping between scan number in the pepXML file and index in the corresponding MSExperiment.
Definition: PepXMLFile.h:217
OpenMS::PepXMLFile::current_proteins_
std::vector< std::vector< ProteinIdentification >::iterator > current_proteins_
References to currently active ProteinIdentifications.
Definition: PepXMLFile.h:253
OpenMS::PepXMLFile::mod_tol_
static const double mod_tol_
Definition: PepXMLFile.h:303
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::PepXMLFile::AminoAcidModification::is_protein_terminus_
bool is_protein_terminus_
Definition: PepXMLFile.h:151
OpenMS::PepXMLFile::hydrogen_
Element hydrogen_
Hydrogen data (for mass types)
Definition: PepXMLFile.h:220
OpenMS::PepXMLFile::keepNativeSpectrumName
void keepNativeSpectrumName(bool keep)
Whether we should keep the native spectrum name of the pepXML.
Definition: PepXMLFile.h:120
OpenMS::PepXMLFile::enzyme_
String enzyme_
Enzyme name associated with the current identification run.
Definition: PepXMLFile.h:259
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::PepXMLFile::peptide_hit_
PeptideHit peptide_hit_
PeptideHit instance currently being processed.
Definition: PepXMLFile.h:269
OpenMS::PepXMLFile::xtandem_artificial_mod_tol_
static const double xtandem_artificial_mod_tol_
Definition: PepXMLFile.h:304
OpenMS::PepXMLFile::AminoAcidModification
Definition: PepXMLFile.h:141
OpenMS::PepXMLFile::current_peptide_
PeptideIdentification current_peptide_
PeptideIdentification instance currently being processed.
Definition: PepXMLFile.h:263
XMLHandler.h
SpectrumMetaDataLookup.h
ResidueDB.h
OpenMS::PepXMLFile::AminoAcidModification::terminus_
String terminus_
Definition: PepXMLFile.h:150
OpenMS::PepXMLFile::date_
DateTime date_
Date the pepXML file was generated.
Definition: PepXMLFile.h:287
Element.h
OpenMS::PepXMLFile::params_
ProteinIdentification::SearchParameters params_
Search parameters of the current identification run.
Definition: PepXMLFile.h:256
OpenMS::PepXMLFile::proteins_
std::vector< ProteinIdentification > * proteins_
Pointer to the list of identified proteins.
Definition: PepXMLFile.h:193
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::PepXMLFile::search_engine_
String search_engine_
Set name of search engine.
Definition: PepXMLFile.h:205
OpenMS::PepXMLFile::lookup_
const SpectrumMetaDataLookup * lookup_
Pointer to wrapper for looking up spectrum meta data.
Definition: PepXMLFile.h:199
OpenMS::PepXMLFile::variable_modifications_
std::vector< AminoAcidModification > variable_modifications_
Variable aminoacid modifications.
Definition: PepXMLFile.h:299
OpenMS::ResidueModification::TermSpecificity
TermSpecificity
Position where the modification is allowed to occur.
Definition: ResidueModification.h:95
int
OpenMS::PepXMLFile::AminoAcidModification::description_
String description_
Definition: PepXMLFile.h:149
OpenMS::PepXMLFile::AminoAcidModification::massdiff_
double massdiff_
Definition: PepXMLFile.h:146
OpenMS::PepXMLFile::AminoAcidModification::errors_
std::vector< String > errors_
Definition: PepXMLFile.h:153
OpenMS::PepXMLFile::decoy_prefix_
String decoy_prefix_
In case it has decoys, what is the prefix?
Definition: PepXMLFile.h:247
ProteinIdentification.h
OpenMS::PepXMLFile::search_score_summary_
bool search_score_summary_
Are we currently in an "search_score_summary" element (should be skipped)?
Definition: PepXMLFile.h:229
OpenMS::PepXMLFile::status_
String status_
Definition: PepXMLFile.h:211
OpenMS::PepXMLFile::AminoAcidModification::term_spec_
ResidueModification::TermSpecificity term_spec_
Definition: PepXMLFile.h:152
OpenMS::PepXMLFile::keep_native_name_
bool keep_native_name_
Whether we should keep the native spectrum name of the pepXML.
Definition: PepXMLFile.h:226
OpenMS::PepXMLFile::AminoAcidModification::mass_
double mass_
Definition: PepXMLFile.h:147
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::PepXMLFile::fixed_modifications_
std::vector< AminoAcidModification > fixed_modifications_
Fixed aminoacid modifications.
Definition: PepXMLFile.h:296
OpenMS::SpectrumMetaDataLookup
Helper class for looking up spectrum meta data.
Definition: SpectrumMetaDataLookup.h:142
OpenMS::PeptideIdentification
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:62
OpenMS::PepXMLFile::exp_name_
String exp_name_
Name of the associated experiment (filename of the data file, extension will be removed)
Definition: PepXMLFile.h:202
AASequence.h
OpenMS::PepXMLFile::current_base_name_
String current_base_name_
current base name
Definition: PepXMLFile.h:250
OpenMS::PepXMLFile::current_analysis_result_
PeptideHit::PepXMLAnalysisResult current_analysis_result_
Analysis result instance currently being processed.
Definition: PepXMLFile.h:266
OpenMS::PepXMLFile::experiment_label_
String experiment_label_
Definition: PepXMLFile.h:209
OpenMS::PepXMLFile::AminoAcidModification::aminoacid_
String aminoacid_
Definition: PepXMLFile.h:145
OpenMS::Internal::XMLFile
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:48
OpenMS::PepXMLFile::current_sequence_
String current_sequence_
Sequence of the current peptide hit.
Definition: PepXMLFile.h:272
OpenMS::PepXMLFile
Used to load and store PepXML files.
Definition: PepXMLFile.h:63
PeptideIdentification.h
OpenMS::ProteinIdentification::SearchParameters
Search parameters of the DB search.
Definition: ProteinIdentification.h:258
OpenMS::PepXMLFile::current_modifications_
std::vector< std::pair< const ResidueModification *, Size > > current_modifications_
The modifications of the current peptide hit (position is 1-based)
Definition: PepXMLFile.h:293
OpenMS::DateTime
DateTime Class.
Definition: DateTime.h:54
OpenMS::PepXMLFile::peptides_
std::vector< PeptideIdentification > * peptides_
Pointer to the list of identified peptides.
Definition: PepXMLFile.h:196
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:55