OpenMS
MzIdentMLHandler.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- 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 
22 
23 #include <vector>
24 #include <map>
25 
26 namespace OpenMS
27 {
28  class ProgressLogger;
29 
30  namespace Internal
31  {
32 
42  class OPENMS_DLLAPI MzIdentMLHandler :
43  public XMLHandler
44  {
45 public:
49  MzIdentMLHandler(const Identification& id, const String& filename, const String& version, const ProgressLogger& logger);
51  MzIdentMLHandler(const std::vector<ProteinIdentification>& pro_id, const std::vector<PeptideIdentification>& pep_id, const String& filename, const String& version, const ProgressLogger& logger);
52 
54  MzIdentMLHandler(Identification& id, const String& filename, const String& version, const ProgressLogger& logger);
56  MzIdentMLHandler(std::vector<ProteinIdentification>& pro_id, std::vector<PeptideIdentification>& pep_id, const String& filename, const String& version, const ProgressLogger& logger);
57 
59  ~MzIdentMLHandler() override;
61 
62 
63  // Docu in base class
64  void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) override;
65 
66  // Docu in base class
67  void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
68 
69  // Docu in base class
70  void characters(const XMLCh* const chars, const XMLSize_t length) override;
71 
72  //Docu in base class
73  void writeTo(std::ostream& os) override;
74 
75 protected:
78 
83 
84  //~ PeakMap* ms_exp_;
85 
88 
92  std::vector<ProteinIdentification>* pro_id_;
94  std::vector<PeptideIdentification>* pep_id_;
95 
97  const std::vector<ProteinIdentification>* cpro_id_;
98  const std::vector<PeptideIdentification>* cpep_id_;
99 
102 
105 
107  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="" */);
108 
110  void handleUserParam_(const String& parent_parent_tag, const String& parent_tag, const String& name, const String& type, const String& value);
111 
113  void writeMetaInfos_(String& s, const MetaInfoInterface& meta, UInt indent) const;
114 
116  ControlledVocabulary::CVTerm getChildWithName_(const String& parent_accession, const String& name) const;
117 
119  //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
120 
122  void writeEnzyme_(String& s, const DigestionEnzymeProtein& enzy, UInt miss, UInt indent) const;
123 
125  void writeModParam_(String& s, const std::vector<String>& mod_names, bool fixed, UInt indent) const;
126 
128  void writeFragmentAnnotations_(String& s, const std::vector<PeptideHit::PeakAnnotation>& annotations, UInt indent, bool is_ppxl) const;
129 
131  String trimOpenMSfileURI(const String& file) const;
132 
134  void writePeptideHit(const PeptideHit& hit,
135  std::vector<PeptideIdentification>::const_iterator& it,
136  std::map<String, String>& pep_ids,
137  const String& cv_ns, std::set<String>& sen_set,
138  std::map<String, String>& sen_ids,
139  std::map<String, std::vector<String> >& pep_evis,
140  std::map<String, double>& pp_identifier_2_thresh,
141  String& sidres);
142 
145  std::vector<PeptideIdentification>::const_iterator& it,
146  const String& ppxl_linkid, std::map<String, String>& pep_ids,
147  const String& cv_ns, std::set<String>& sen_set,
148  std::map<String, String>& sen_ids,
149  std::map<String, std::vector<String> >& pep_evis,
150  std::map<String, double>& pp_identifier_2_thresh,
151  double ppxl_crosslink_mass,
152  std::map<String, String>& ppxl_specref_2_element,
153  String& sid, bool alpha_peptide);
154 
155 private:
159  std::map<String, AASequence> pep_sequences_;
160  std::map<String, String> pp_identifier_2_sil_;
161  std::map<String, String> sil_2_sdb_;
162  std::map<String, String> sil_2_sdat_;
163  std::map<String, String> ph_2_sdat_;
164  std::map<String, String> sil_2_sip_;
168 
169  };
170  } // namespace Internal
171 } // namespace OpenMS
Representation of a peptide/protein sequence.
Definition: AASequence.h:86
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:29
Representation of a digestion enzyme for proteins (protease)
Definition: DigestionEnzymeProtein.h:24
Represents a object which can store the information of an analysisXML instance.
Definition: IdentificationHit.h:24
Represents a object which can store the information of an analysisXML instance.
Definition: Identification.h:28
XML STREAM handler for MzIdentMLFile.
Definition: MzIdentMLHandler.h:44
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:96
ProteinHit actual_protein_
Definition: MzIdentMLHandler.h:167
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:161
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:164
MzIdentMLHandler(const MzIdentMLHandler &rhs)
IdentificationHit current_id_hit_
IdentificationHit Item.
Definition: MzIdentMLHandler.h:104
const std::vector< ProteinIdentification > * cpro_id_
Definition: MzIdentMLHandler.h:97
const ProgressLogger & logger_
Progress logger.
Definition: MzIdentMLHandler.h:77
ControlledVocabulary cv_
Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
Definition: MzIdentMLHandler.h:80
String tag_
XML tag parse element.
Definition: MzIdentMLHandler.h:87
std::map< String, String > ph_2_sdat_
mapping identification runs (mapping PeptideIdentifications and ProteinIdentifications via ....
Definition: MzIdentMLHandler.h:163
MzIdentMLHandler(Identification &id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler.
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:101
MzIdentMLHandler & operator=(const MzIdentMLHandler &rhs)
std::vector< ProteinIdentification > * pro_id_
internal Identification Item for proteins
Definition: MzIdentMLHandler.h:92
std::map< String, AASequence > pep_sequences_
Definition: MzIdentMLHandler.h:159
Identification * id_
Identification Item.
Definition: MzIdentMLHandler.h:90
std::vector< PeptideIdentification > * pep_id_
Identification Item for peptides.
Definition: MzIdentMLHandler.h:94
MzIdentMLHandler(const std::vector< ProteinIdentification > &pro_id, const std::vector< PeptideIdentification > &pep_id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler for internal identification structures.
ControlledVocabulary unimod_
Controlled vocabulary for modifications (unimod from OpenMS/share/OpenMS/CV/unimod....
Definition: MzIdentMLHandler.h:82
void writeXLMSPeptideHit(const PeptideHit &hit, std::vector< PeptideIdentification >::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.
std::map< String, String > pp_identifier_2_sil_
mapping peptide/proteinidentification identifier_ to spectrumidentificationlist
Definition: MzIdentMLHandler.h:160
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:162
AASequence actual_peptide_
Definition: MzIdentMLHandler.h:165
~MzIdentMLHandler() override
Destructor.
MzIdentMLHandler(const Identification &id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler.
const std::vector< PeptideIdentification > * cpep_id_
Definition: MzIdentMLHandler.h:98
void writeMetaInfos_(String &s, const MetaInfoInterface &meta, UInt indent) const
Writes user terms.
Int current_mod_location_
Definition: MzIdentMLHandler.h:166
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 writePeptideHit(const PeptideHit &hit, std::vector< PeptideIdentification >::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.
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)
MzIdentMLHandler(std::vector< ProteinIdentification > &pro_id, std::vector< PeptideIdentification > &pep_id, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler for internal identification structures.
Base class for XML handlers.
Definition: XMLHandler.h:300
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Representation of a peptide hit.
Definition: PeptideHit.h:31
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Representation of a protein hit.
Definition: ProteinHit.h:34
Represents a object which can store the information of an analysisXML instance.
Definition: SpectrumIdentification.h:25
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Representation of a CV term.
Definition: ControlledVocabulary.h:35