OpenMS
Loading...
Searching...
No Matches
MzIdentMLHandler.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Mathias Walzer $
6// $Authors: Mathias Walzer, Andreas Bertsch $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
21
22#include <vector>
23#include <map>
24
25namespace OpenMS
26{
27 class ProgressLogger;
28
29 namespace Internal
30 {
31
37 class OPENMS_DLLAPI IdentificationHit :
39 {
40 public:
42
43
44 IdentificationHit() = default;
45
48
50 virtual ~IdentificationHit() = default;
51
53 IdentificationHit(IdentificationHit&&) noexcept = default;
54
56 IdentificationHit& operator=(const IdentificationHit&) = default;
57
59 IdentificationHit& operator=(IdentificationHit&&) noexcept = default;
61
63
64
65 bool operator==(const IdentificationHit& rhs) const noexcept;
66
68 bool operator!=(const IdentificationHit& rhs) const noexcept;
70
72
73
74 void setId(const std::string& id) noexcept;
75
77 const std::string& getId() const noexcept;
78
80 void setCharge(int charge) noexcept;
81
83 int getCharge() const noexcept;
84
86 void setCalculatedMassToCharge(double mz) noexcept;
87
89 double getCalculatedMassToCharge() const noexcept;
90
92 void setExperimentalMassToCharge(double mz) noexcept;
93
95 double getExperimentalMassToCharge() const noexcept;
96
98 void setName(const std::string& name) noexcept;
99
101 const std::string& getName() const noexcept;
102
104 void setPassThreshold(bool pass) noexcept;
105
107 bool getPassThreshold() const noexcept;
108
110 void setRank(int rank) noexcept;
111
113 int getRank() const noexcept;
115
116 private:
117 std::string id_;
118 int charge_ = 0;
119 double calculated_mass_to_charge_ = 0.0;
120 double experimental_mass_to_charge_ = 0.0;
121 std::string name_;
122 bool pass_threshold_ = true;
123 int rank_ = 0;
124 };
125
133 class OPENMS_DLLAPI SpectrumIdentification :
134 public MetaInfoInterface
135 {
136public:
137
139
140
153 bool operator==(const SpectrumIdentification & rhs) const;
155 bool operator!=(const SpectrumIdentification & rhs) const;
157
158 // @name Accessors
160
161 void setHits(const std::vector<IdentificationHit> & hits);
162
164 void addHit(const IdentificationHit & hit);
165
167 const std::vector<IdentificationHit> & getHits() const;
169
170protected:
171
173 std::vector<IdentificationHit> hits_;
174 };
175
183 class OPENMS_DLLAPI Identification :
184 public MetaInfoInterface
185 {
186 public:
187
189
190
192 Identification() = default;
194 Identification(const Identification & source) = default;
199
201 Identification & operator=(const Identification & source) = default;
204
206 bool operator==(const Identification & rhs) const;
208 bool operator!=(const Identification & rhs) const;
210
212
213
214 void setCreationDate(const DateTime & date);
215
217 const DateTime & getCreationDate() const;
218
220 void setSpectrumIdentifications(const std::vector<SpectrumIdentification> & ids);
221
224
226 const std::vector<SpectrumIdentification> & getSpectrumIdentifications() const;
228 protected:
231 std::vector<SpectrumIdentification> spectrum_identifications_;
232 };
233
243 class OPENMS_DLLAPI MzIdentMLHandler :
244 public XMLHandler
245 {
246public:
250 MzIdentMLHandler(const std::vector<ProteinIdentification>& pro_id, const PeptideIdentificationList& pep_id, const String& filename, const String& version, const ProgressLogger& logger);
251
253 MzIdentMLHandler(std::vector<ProteinIdentification>& pro_id, PeptideIdentificationList& pep_id, const String& filename, const String& version, const ProgressLogger& logger);
254
258
259
260 // Docu in base class
261 void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) override;
262
263 // Docu in base class
264 void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
265
266 // Docu in base class
267 void characters(const XMLCh* const chars, const XMLSize_t length) override;
268
269 //Docu in base class
270 void writeTo(std::ostream& os) override;
271
272protected:
275
280
281 //~ PeakMap* ms_exp_;
282
285
289 std::vector<ProteinIdentification>* pro_id_;
292
294 const std::vector<ProteinIdentification>* cpro_id_;
296
299
302
304 void handleCVParam_(const String& parent_parent_tag, const String& parent_tag, const String& accession, /* const String& name, */ /* const String& value, */ const xercesc::Attributes& attributes, const String& cv_ref /* , const String& unit_accession="" */);
305
307 void handleUserParam_(const String& parent_parent_tag, const String& parent_tag, const String& name, const String& type, const String& value);
308
310 void writeMetaInfos_(String& s, const MetaInfoInterface& meta, UInt indent) const;
311
313 ControlledVocabulary::CVTerm getChildWithName_(const String& parent_accession, const String& name) const;
314
316 //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
317
319 void writeEnzyme_(String& s, const DigestionEnzymeProtein& enzy, UInt miss, UInt indent) const;
320
322 void writeModParam_(String& s, const std::vector<String>& mod_names, bool fixed, UInt indent) const;
323
325 void writeFragmentAnnotations_(String& s, const std::vector<PeptideHit::PeakAnnotation>& annotations, UInt indent, bool is_ppxl) const;
326
329
333 std::map<String, String>& pep_ids,
334 const String& cv_ns, std::set<String>& sen_set,
335 std::map<String, String>& sen_ids,
336 std::map<String, std::vector<String> >& pep_evis,
337 std::map<String, double>& pp_identifier_2_thresh,
338 String& sidres);
339
343 const String& ppxl_linkid, std::map<String, String>& pep_ids,
344 const String& cv_ns, std::set<String>& sen_set,
345 std::map<String, String>& sen_ids,
346 std::map<String, std::vector<String> >& pep_evis,
347 std::map<String, double>& pp_identifier_2_thresh,
348 double ppxl_crosslink_mass,
349 std::map<String, String>& ppxl_specref_2_element,
350 String& sid, bool alpha_peptide);
351
352private:
356 std::map<String, AASequence> pep_sequences_;
357 std::map<String, String> pp_identifier_2_sil_;
358 std::map<String, String> sil_2_sdb_;
359 std::map<String, String> sil_2_sdat_;
360 std::map<String, String> ph_2_sdat_;
361 std::map<String, String> sil_2_sip_;
365
366 };
367 } // namespace Internal
368} // namespace OpenMS
char16_t XMLCh
Definition ClassTest.h:28
subpage TOPP_TargetedFileConverter Converts targeted feature or consensus feature files subpage TOPP_FileInfo Shows basic information about the file
Definition TOPP.doxygen:44
Representation of a peptide/protein sequence.
Definition AASequence.h:88
Definition ControlledVocabulary.h:29
DateTime Class.
Definition DateTime.h:35
Representation of a digestion enzyme for proteins (protease)
Definition DigestionEnzymeProtein.h:24
typename VecMember::const_iterator const_iterator
Definition ExposedVector.h:69
Represents a object which can store the information of an analysisXML instance.
Definition MzIdentMLHandler.h:39
virtual ~IdentificationHit()=default
Virtual destructor.
IdentificationHit(const IdentificationHit &)=default
Copy constructor.
IdentificationHit(IdentificationHit &&) noexcept=default
Move constructor.
IdentificationHit()=default
Default constructor.
Definition MzIdentMLHandler.h:185
void addSpectrumIdentification(const SpectrumIdentification &id)
adds a spectrum identification
DateTime creation_date_
Date and time the search was performed.
Definition MzIdentMLHandler.h:230
const DateTime & getCreationDate() const
returns the date and time the file was created
Identification(const Identification &source)=default
Copy constructor.
bool operator==(const Identification &rhs) const
Equality operator.
Identification(Identification &&)=default
Move constructor.
const std::vector< SpectrumIdentification > & getSpectrumIdentifications() const
returns the spectrum identifications stored
virtual ~Identification()
Destructor.
void setSpectrumIdentifications(const std::vector< SpectrumIdentification > &ids)
sets the spectrum identifications
Identification()=default
Default constructor.
Identification & operator=(const Identification &source)=default
Assignment operator.
Identification & operator=(Identification &&) &=default
Move assignment operator.
std::vector< SpectrumIdentification > spectrum_identifications_
Definition MzIdentMLHandler.h:231
void setCreationDate(const DateTime &date)
sets the date and time the file was written
String id_
Identifier.
Definition MzIdentMLHandler.h:229
bool operator!=(const Identification &rhs) const
Inequality operator.
XML STREAM handler for MzIdentMLFile.
Definition MzIdentMLHandler.h:245
ControlledVocabulary::CVTerm getChildWithName_(const String &parent_accession, const String &name) const
Looks up a child CV term of parent_accession with the name name. If no such term is found,...
const Identification * cid_
Definition MzIdentMLHandler.h:293
PeptideIdentificationList * pep_id_
Identification Item for peptides.
Definition MzIdentMLHandler.h:291
MzIdentMLHandler(const std::vector< ProteinIdentification > &pro_id, const PeptideIdentificationList &pep_id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler for internal identification structures.
ProteinHit actual_protein_
Definition MzIdentMLHandler.h:364
String trimOpenMSfileURI(const String &file) const
Convenience method to remove the [] from OpenMS internal file uri representation.
std::map< String, String > sil_2_sdb_
mapping spectrumidentificationlist to the search data bases
Definition MzIdentMLHandler.h:358
void writeXLMSPeptideHit(const PeptideHit &hit, PeptideIdentificationList::const_iterator &it, const String &ppxl_linkid, std::map< String, String > &pep_ids, const String &cv_ns, std::set< String > &sen_set, std::map< String, String > &sen_ids, std::map< String, std::vector< String > > &pep_evis, std::map< String, double > &pp_identifier_2_thresh, double ppxl_crosslink_mass, std::map< String, String > &ppxl_specref_2_element, String &sid, bool alpha_peptide)
Abstraction of PeptideHit loop for XL-MS data from OpenPepXL.
void writeTo(std::ostream &os) override
Writes the contents to a stream.
std::map< String, String > sil_2_sip_
mapping spectrumidentificationlist to the search protocol (where the params are at)
Definition MzIdentMLHandler.h:361
MzIdentMLHandler(const MzIdentMLHandler &rhs)
IdentificationHit current_id_hit_
IdentificationHit Item.
Definition MzIdentMLHandler.h:301
const std::vector< ProteinIdentification > * cpro_id_
Definition MzIdentMLHandler.h:294
const ProgressLogger & logger_
Progress logger.
Definition MzIdentMLHandler.h:274
ControlledVocabulary cv_
Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
Definition MzIdentMLHandler.h:277
String tag_
XML tag parse element.
Definition MzIdentMLHandler.h:284
std::map< String, String > ph_2_sdat_
mapping identification runs (mapping PeptideIdentifications and ProteinIdentifications via ....
Definition MzIdentMLHandler.h:360
void writeFragmentAnnotations_(String &s, const std::vector< PeptideHit::PeakAnnotation > &annotations, UInt indent, bool is_ppxl) const
Helper method that writes the FragmentAnnotations section of a spectrum identification.
SpectrumIdentification current_spectrum_id_
SpectrumIdentification Item.
Definition MzIdentMLHandler.h:298
void writePeptideHit(const PeptideHit &hit, PeptideIdentificationList::const_iterator &it, std::map< String, String > &pep_ids, const String &cv_ns, std::set< String > &sen_set, std::map< String, String > &sen_ids, std::map< String, std::vector< String > > &pep_evis, std::map< String, double > &pp_identifier_2_thresh, String &sidres)
Abstraction of PeptideHit loop for most PeptideHits.
MzIdentMLHandler(std::vector< ProteinIdentification > &pro_id, PeptideIdentificationList &pep_id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler for internal identification structures.
std::vector< ProteinIdentification > * pro_id_
internal Identification Item for proteins
Definition MzIdentMLHandler.h:289
std::map< String, AASequence > pep_sequences_
Definition MzIdentMLHandler.h:356
Identification * id_
Identification Item.
Definition MzIdentMLHandler.h:287
ControlledVocabulary unimod_
Controlled vocabulary for modifications (unimod from OpenMS/share/OpenMS/CV/unimod....
Definition MzIdentMLHandler.h:279
MzIdentMLHandler & operator=(const MzIdentMLHandler &rhs)
std::map< String, String > pp_identifier_2_sil_
mapping peptide/proteinidentification identifier_ to spectrumidentificationlist
Definition MzIdentMLHandler.h:357
void startElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname, const xercesc::Attributes &attributes) override
std::map< String, String > sil_2_sdat_
mapping spectrumidentificationlist to the search input
Definition MzIdentMLHandler.h:359
AASequence actual_peptide_
Definition MzIdentMLHandler.h:362
~MzIdentMLHandler() override
Destructor.
void writeMetaInfos_(String &s, const MetaInfoInterface &meta, UInt indent) const
Writes user terms.
Int current_mod_location_
Definition MzIdentMLHandler.h:363
void characters(const XMLCh *const chars, const XMLSize_t length) override
void endElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname) override
void writeEnzyme_(String &s, const DigestionEnzymeProtein &enzy, UInt miss, UInt indent) const
Helper method that writes a source file.
void handleUserParam_(const String &parent_parent_tag, const String &parent_tag, const String &name, const String &type, const String &value)
Handles user terms.
void handleCVParam_(const String &parent_parent_tag, const String &parent_tag, const String &accession, const xercesc::Attributes &attributes, const String &cv_ref)
Handles CV terms.
void writeModParam_(String &s, const std::vector< String > &mod_names, bool fixed, UInt indent) const
Helper method that writes the modification search params (fixed or variable)
const PeptideIdentificationList * cpep_id_
Definition MzIdentMLHandler.h:295
Definition MzIdentMLHandler.h:135
bool operator==(const SpectrumIdentification &rhs) const
Equality operator.
bool operator!=(const SpectrumIdentification &rhs) const
Inequality operator.
virtual ~SpectrumIdentification()
Destructor.
const std::vector< IdentificationHit > & getHits() const
returns the identification hits of this spectrum identification
SpectrumIdentification & operator=(const SpectrumIdentification &)=default
Assignment operator.
SpectrumIdentification & operator=(SpectrumIdentification &&) &=default
Move assignment operator.
std::vector< IdentificationHit > hits_
Single peptide hits.
Definition MzIdentMLHandler.h:173
void setHits(const std::vector< IdentificationHit > &hits)
sets the identification hits of this spectrum identification (corresponds to single peptide hit in th...
SpectrumIdentification()=default
Default constructor.
void addHit(const IdentificationHit &hit)
adds a single identification hit to the hits
SpectrumIdentification(SpectrumIdentification &&)=default
Move constructor.
String id_
Identifier.
Definition MzIdentMLHandler.h:172
SpectrumIdentification(const SpectrumIdentification &)=default
Copy constructor.
Base class for XML handlers.
Definition XMLHandler.h:328
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:36
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
Representation of a protein hit.
Definition ProteinHit.h:35
A more convenient string class.
Definition String.h:34
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
STL namespace.
Representation of a CV term.
Definition ControlledVocabulary.h:50