OpenMS
Loading...
Searching...
No Matches
MzIdentMLDOMHandler.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$
7// --------------------------------------------------------------------------
8
9#pragma once
10
21
22
23#include <list>
24
25struct _xmlNode;
26typedef struct _xmlNode xmlNode;
27#include <map>
28#include <set>
29#include <stdexcept>
30#include <string>
31#include <vector>
32
33namespace OpenMS
34{
35 class ProgressLogger;
36
37 namespace Internal
38 {
50 class OPENMS_DLLAPI MzIdentMLDOMHandler
51 {
52public:
56 MzIdentMLDOMHandler(const std::vector<ProteinIdentification>& pro_id, const PeptideIdentificationList& pep_id, const std::string& version, const ProgressLogger& logger);
57
59 MzIdentMLDOMHandler(std::vector<ProteinIdentification>& pro_id, PeptideIdentificationList& pep_id, const std::string& version, const ProgressLogger& logger);
60
64
66 void readMzIdentMLFile(const std::string& mzid_file);
68 void writeMzIdentMLFile(const std::string& mzid_file);
69
70protected:
73
78
80 std::vector<ProteinIdentification>* pro_id_ = nullptr;
82 PeptideIdentificationList* pep_id_ = nullptr;
83
85 const std::vector<ProteinIdentification>* cpro_id_ = nullptr;
87 const PeptideIdentificationList* cpep_id_ = nullptr;
88
90 const std::string schema_version_;
91
93 ControlledVocabulary::CVTerm getChildWithName_(const std::string& parent_accession, const std::string& name) const;
94
97
100
102 std::pair<CVTermList, std::map<std::string, DataValue> > parseParamGroup_(const std::vector<xmlNode*>& paramGroup);
104 std::pair<std::string, DataValue> parseUserParam_(xmlNode* param);
105 void parseAnalysisSoftwareList_(const std::vector<xmlNode*>& analysisSoftwareElements);
106 void parseDBSequenceElements_(const std::vector<xmlNode*>& dbSequenceElements);
107 void parsePeptideElements_(const std::vector<xmlNode*>& peptideElements);
108 //AASequence parsePeptideSiblings_(const std::vector<xmlNode*>& peptideSiblings);
116 SignedSize inferModificationLocation_(xmlNode* modification_element, Size peptide_length) const;
117 void parsePeptideEvidenceElements_(const std::vector<xmlNode*>& peptideEvidenceElements);
118 void parseSpectrumIdentificationElements_(const std::vector<xmlNode*>& spectrumIdentificationElements);
119 void parseSpectrumIdentificationProtocolElements_(const std::vector<xmlNode*>& spectrumIdentificationProtocolElements);
120 void parseInputElements_(const std::vector<xmlNode*>& inputElements);
121 void parseSpectrumIdentificationListElements_(const std::vector<xmlNode*>& spectrumIdentificationListElements);
123 ProteinIdentification& runOfList_(const std::string& spectrum_identification_list_ref);
124 void parseSpectrumIdentificationItemSetXLMS(std::set<std::string>::const_iterator set_it, std::multimap<std::string, int> xl_val_map, xmlNode* element_res, const std::string& spectrumID);
125 void parseSpectrumIdentificationItemElement_(xmlNode* spectrumIdentificationItemElement, PeptideIdentification& spectrum_identification, std::string& spectrumIdentificationList_ref);
126 void parseProteinDetectionHypothesisElement_(xmlNode* proteinDetectionHypothesisElement, ProteinIdentification& protein_identification);
127 void parseProteinAmbiguityGroupElement_(xmlNode* proteinAmbiguityGroupElement, ProteinIdentification& protein_identification);
128 void parseProteinDetectionListElements_(const std::vector<xmlNode*>& proteinDetectionListElements);
129 static ProteinIdentification::SearchParameters findSearchParameters_(std::pair<CVTermList, std::map<std::string, DataValue> > as_params);
131
133 void buildCvList_(xmlNode* cvElements);
134 void buildAnalysisSoftwareList_(xmlNode* analysisSoftwareElements);
135 void buildSequenceCollection_(xmlNode* sequenceCollectionElements);
136 void buildAnalysisCollection_(xmlNode* analysisCollectionElements);
138 void buildInputDataCollection_(xmlNode* inputElements);
139 void buildEnclosedCV_(xmlNode* parentElement, const std::string& encel, const std::string& acc, const std::string& name, const std::string& cvref);
140 void buildAnalysisDataCollection_(xmlNode* analysisElements);
142
143
144private:
148
151 {
152 std::string name;
153 std::string version;
154 };
157 {
158 int start;
159 int stop;
160 char pre;
161 char post;
162 bool idec;
163 };
166 {
167 std::string sequence;
168 std::string database_ref;
169 std::string accession;
171 };
191 {
193 std::string enzyme;
195 std::map<std::string, DataValue> parameter_ups;
196// std::vector<ModificationParam> modification_parameter;
201 std::map<std::string, DataValue> threshold_ups;
202 };
205 {
206 std::string name;
207 std::string location;
208 std::string version;
210 };
211
212
213 std::unique_ptr<XMLHandler> xml_handler_ = nullptr;
214
215 //from AnalysisSoftware
216 std::string search_engine_;
218 //mapping from AnalysisSoftware
219 std::map<std::string, AnalysisSoftware> as_map_;
220
221 //mapping from DataCollection Inputs
222 std::map<std::string, std::string> sr_map_;
223 std::map<std::string, std::string> sd_map_;
224 std::map<std::string, DatabaseInput> db_map_;
225
226 //mapping from SpectrumIdentification - SpectrumIdentification will be the new IdentificationRuns
227 std::map<std::string, SpectrumIdentification> si_map_;
228 std::map<std::string, size_t> si_pro_map_;
229
230 //mapping from SpectrumIdentificationProtocol
231 std::map<std::string, SpectrumIdentificationProtocol> sp_map_;
232
233 //mapping from SequenceCollection
234 std::map<std::string, AASequence> pep_map_;
235 std::map<std::string, PeptideEvidence> pe_ev_map_;
236 std::map<std::string, std::string> pv_db_map_;
237 std::multimap<std::string, std::string> p_pv_map_;
238 std::map<std::string, DBSequence> db_sq_map_;
239
240 std::list<std::list<std::string> > hit_pev_;
241
242 bool xl_ms_search_ = false;
243 std::map<std::string, std::string> xl_id_donor_map_;
244 //std::map<std::string, std::string> xl_id_acceptor_map_; ///< mapping Peptide id -> crosslink acceptor value
245 std::map<std::string, std::string> xl_id_acceptor_map_;
246 std::map<std::string, SignedSize> xl_donor_pos_map_;
247 std::map<std::string, SignedSize> xl_acceptor_pos_map_;
248 std::map<std::string, double> xl_mass_map_;
249 std::map<std::string, std::string> xl_mod_map_;
250
252 std::set<std::string> q_score_child_terms_;
253 std::set<std::string> e_score_child_terms_;
254 std::set<std::string> specific_score_child_terms_;
255 };
256 } // namespace Internal
257} // namespace OpenMS
258
struct _xmlNode xmlNode
Definition MzIdentMLDOMHandler.h:26
Definition AASequence.h:96
Representation of controlled vocabulary term list.
Definition CVTermList.h:29
Representation of controlled vocabulary term.
Definition CVTerm.h:28
Definition ControlledVocabulary.h:31
DateTime Class.
Definition DateTime.h:31
XML DOM handler for MzIdentMLFile.
Definition MzIdentMLDOMHandler.h:51
ControlledVocabulary::CVTerm getChildWithName_(const std::string &parent_accession, const std::string &name) const
Looks up a child CV term of parent_accession with the name name. If no such term is found,...
void readMzIdentMLFile(const std::string &mzid_file)
Provides the functionality of reading a mzid with a handler object.
std::map< std::string, DataValue > threshold_ups
Definition MzIdentMLDOMHandler.h:201
MzIdentMLDOMHandler & operator=(const MzIdentMLDOMHandler &rhs)
std::map< std::string, PeptideEvidence > pe_ev_map_
mapping PeptideEvidence id -> PeptideEvidence
Definition MzIdentMLDOMHandler.h:235
static ProteinIdentification::SearchParameters findSearchParameters_(std::pair< CVTermList, std::map< std::string, DataValue > > as_params)
CVTermList parameter_cvs
Definition MzIdentMLDOMHandler.h:194
AASequence parsePeptideSiblings_(xmlNode *peptide)
std::map< std::string, DBSequence > db_sq_map_
mapping DBSequence id -> Sequence
Definition MzIdentMLDOMHandler.h:238
DateTime date
Definition MzIdentMLDOMHandler.h:209
void buildAnalysisSoftwareList_(xmlNode *analysisSoftwareElements)
void buildAnalysisProtocolCollection_(xmlNode *protocolElements)
void buildAnalysisDataCollection_(xmlNode *analysisElements)
std::map< std::string, std::string > sr_map_
mapping sourcefile id -> sourcefile location
Definition MzIdentMLDOMHandler.h:222
std::string spectrum_identification_list_ref
Definition MzIdentMLDOMHandler.h:178
std::pair< std::string, DataValue > parseUserParam_(xmlNode *param)
int start
Definition MzIdentMLDOMHandler.h:158
std::string spectrum_identification_protocol_ref
Definition MzIdentMLDOMHandler.h:177
void parseSpectrumIdentificationItemElement_(xmlNode *spectrumIdentificationItemElement, PeptideIdentification &spectrum_identification, std::string &spectrumIdentificationList_ref)
std::string residues
Definition MzIdentMLDOMHandler.h:185
std::map< std::string, SpectrumIdentificationProtocol > sp_map_
mapping SpectrumIdentificationProtocol id -> SpectrumIdentificationProtocol
Definition MzIdentMLDOMHandler.h:231
void parsePeptideEvidenceElements_(const std::vector< xmlNode * > &peptideEvidenceElements)
long double precursor_tolerance
Definition MzIdentMLDOMHandler.h:198
void parseProteinAmbiguityGroupElement_(xmlNode *proteinAmbiguityGroupElement, ProteinIdentification &protein_identification)
std::map< std::string, std::string > xl_mod_map_
mapping peptide id -> cross-linking reagent name
Definition MzIdentMLDOMHandler.h:249
const ProgressLogger & logger_
Progress logger.
Definition MzIdentMLDOMHandler.h:72
ControlledVocabulary cv_
Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
Definition MzIdentMLDOMHandler.h:75
std::map< std::string, SignedSize > xl_acceptor_pos_map_
mapping acceptor value -> cross-link modification location
Definition MzIdentMLDOMHandler.h:247
std::string search_engine_
Definition MzIdentMLDOMHandler.h:216
std::map< std::string, std::string > xl_id_acceptor_map_
mapping peptide id of acceptor peptide -> crosslink acceptor value
Definition MzIdentMLDOMHandler.h:245
void buildSequenceCollection_(xmlNode *sequenceCollectionElements)
std::string search_engine_version_
Definition MzIdentMLDOMHandler.h:217
long double mass_delta
Definition MzIdentMLDOMHandler.h:184
std::map< std::string, double > xl_mass_map_
mapping Peptide id -> cross-link mass
Definition MzIdentMLDOMHandler.h:248
CVTermList modification_param_cvs
Definition MzIdentMLDOMHandler.h:186
std::pair< CVTermList, std::map< std::string, DataValue > > parseParamGroup_(const std::vector< xmlNode * > &paramGroup)
First: CVparams, Second: userParams (independent of each other)
long double fragment_tolerance
Definition MzIdentMLDOMHandler.h:199
int stop
Definition MzIdentMLDOMHandler.h:159
std::map< std::string, std::string > pv_db_map_
mapping PeptideEvidence id -> DBSequence id
Definition MzIdentMLDOMHandler.h:236
std::map< std::string, AASequence > pep_map_
mapping Peptide id -> Sequence
Definition MzIdentMLDOMHandler.h:234
std::map< std::string, AnalysisSoftware > as_map_
mapping AnalysisSoftware id -> AnalysisSoftware
Definition MzIdentMLDOMHandler.h:219
std::string version
Definition MzIdentMLDOMHandler.h:153
std::map< std::string, SpectrumIdentification > si_map_
mapping SpectrumIdentification id -> SpectrumIdentification (id refs)
Definition MzIdentMLDOMHandler.h:227
void buildInputDataCollection_(xmlNode *inputElements)
bool idec
Definition MzIdentMLDOMHandler.h:162
ControlledVocabulary unimod_
Controlled vocabulary for modifications (unimod from OpenMS/share/OpenMS/CV/unimod....
Definition MzIdentMLDOMHandler.h:77
void buildAnalysisCollection_(xmlNode *analysisCollectionElements)
std::map< std::string, std::string > xl_id_donor_map_
mapping Peptide id -> crosslink donor value
Definition MzIdentMLDOMHandler.h:243
ProteinIdentification & runOfList_(const std::string &spectrum_identification_list_ref)
The protein identification run of a SpectrumIdentificationList; throws Exception::InvalidParameter if...
std::map< std::string, SignedSize > xl_donor_pos_map_
mapping donor value -> cross-link modification location
Definition MzIdentMLDOMHandler.h:246
std::map< std::string, DatabaseInput > db_map_
mapping database id -> DatabaseInput
Definition MzIdentMLDOMHandler.h:224
std::string sequence
Definition MzIdentMLDOMHandler.h:167
std::string name
Definition MzIdentMLDOMHandler.h:152
void writeMzIdentMLFile(const std::string &mzid_file)
Provides the functionality to write a mzid with a handler object.
CVTermList threshold_cvs
Definition MzIdentMLDOMHandler.h:200
void parseAnalysisSoftwareList_(const std::vector< xmlNode * > &analysisSoftwareElements)
void parseDBSequenceElements_(const std::vector< xmlNode * > &dbSequenceElements)
std::string database_ref
Definition MzIdentMLDOMHandler.h:168
CVTermList specificities
Definition MzIdentMLDOMHandler.h:187
MzIdentMLDOMHandler(std::vector< ProteinIdentification > &pro_id, PeptideIdentificationList &pep_id, const std::string &version, const ProgressLogger &logger)
Constructor for a read-only handler for internal identification structures.
void parseSpectrumIdentificationListElements_(const std::vector< xmlNode * > &spectrumIdentificationListElements)
void parseSpectrumIdentificationProtocolElements_(const std::vector< xmlNode * > &spectrumIdentificationProtocolElements)
void initScoreTermCaches_()
Precompute the CV child-term sets used per PSM (constant across a file); shared by both constructors.
char pre
Definition MzIdentMLDOMHandler.h:160
std::string spectra_data_ref
Definition MzIdentMLDOMHandler.h:175
void buildCvList_(xmlNode *cvElements)
std::string enzyme
Definition MzIdentMLDOMHandler.h:193
std::set< std::string > specific_score_child_terms_
Definition MzIdentMLDOMHandler.h:254
CVTermList cvs
Definition MzIdentMLDOMHandler.h:170
std::string location
Definition MzIdentMLDOMHandler.h:207
void parseProteinDetectionHypothesisElement_(xmlNode *proteinDetectionHypothesisElement, ProteinIdentification &protein_identification)
void parsePeptideElements_(const std::vector< xmlNode * > &peptideElements)
const std::string schema_version_
Internal version keeping.
Definition MzIdentMLDOMHandler.h:90
std::map< std::string, std::string > sd_map_
mapping spectradata id -> spectradata location
Definition MzIdentMLDOMHandler.h:223
MzIdentMLDOMHandler(const MzIdentMLDOMHandler &rhs)
void parseInputElements_(const std::vector< xmlNode * > &inputElements)
void parseSpectrumIdentificationItemSetXLMS(std::set< std::string >::const_iterator set_it, std::multimap< std::string, int > xl_val_map, xmlNode *element_res, const std::string &spectrumID)
CVTermList modification_parameter
Definition MzIdentMLDOMHandler.h:197
std::list< std::list< std::string > > hit_pev_
writing help only
Definition MzIdentMLDOMHandler.h:240
CVTerm parseCvParam_(xmlNode *param)
std::string accession
Definition MzIdentMLDOMHandler.h:169
SignedSize inferModificationLocation_(xmlNode *modification_element, Size peptide_length) const
std::set< std::string > e_score_child_terms_
Definition MzIdentMLDOMHandler.h:253
std::string fixed_mod
Definition MzIdentMLDOMHandler.h:183
std::map< std::string, DataValue > parameter_ups
Definition MzIdentMLDOMHandler.h:195
char post
Definition MzIdentMLDOMHandler.h:161
std::string search_database_ref
Definition MzIdentMLDOMHandler.h:176
MzIdentMLDOMHandler(const std::vector< ProteinIdentification > &pro_id, const PeptideIdentificationList &pep_id, const std::string &version, const ProgressLogger &logger)
Constructor for a write-only handler for internal identification structures.
std::map< std::string, size_t > si_pro_map_
mapping SpectrumIdentificationList id -> index to ProteinIdentification in pro_id_
Definition MzIdentMLDOMHandler.h:228
void buildEnclosedCV_(xmlNode *parentElement, const std::string &encel, const std::string &acc, const std::string &name, const std::string &cvref)
void parseProteinDetectionListElements_(const std::vector< xmlNode * > &proteinDetectionListElements)
std::set< std::string > q_score_child_terms_
cached CV child term sets (computed once, reused per PSM)
Definition MzIdentMLDOMHandler.h:252
void parseSpectrumIdentificationElements_(const std::vector< xmlNode * > &spectrumIdentificationElements)
std::multimap< std::string, std::string > p_pv_map_
mapping Peptide id -> PeptideEvidence id, multiple PeptideEvidences can have equivalent Peptides.
Definition MzIdentMLDOMHandler.h:237
virtual ~MzIdentMLDOMHandler()
Destructor.
Struct to hold the used analysis software for that file.
Definition MzIdentMLDOMHandler.h:151
Struct to hold the information from the DBSequence xml tag.
Definition MzIdentMLDOMHandler.h:166
Struct to hold the information from the DatabaseInput xml tag.
Definition MzIdentMLDOMHandler.h:205
Struct to hold the information from the ModificationParam xml tag.
Definition MzIdentMLDOMHandler.h:182
Struct to hold the PeptideEvidence information.
Definition MzIdentMLDOMHandler.h:157
Struct to hold the information from the SpectrumIdentification xml tag.
Definition MzIdentMLDOMHandler.h:174
Struct to hold the information from the SpectrumIdentificationProtocol xml tag.
Definition MzIdentMLDOMHandler.h:191
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Represents the set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition PeptideIdentification.h:66
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
Representation of a protein identification run.
Definition ProteinIdentification.h:55
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition Types.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Representation of a CV term.
Definition ControlledVocabulary.h:52
Search parameters of the DB search.
Definition ProteinIdentification.h:194