OpenMS
Loading...
Searching...
No Matches
IdXMLFile.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: Timo Sachsenberg $
6// $Authors: Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <unordered_map>
12
19
20#include <functional>
21#include <iosfwd>
22#include <vector>
23
24namespace OpenMS
25{
26 namespace Internal
27 {
28 class FeatureXMLHandler;
29 class ConsensusXMLHandler;
30 }
45 class OPENMS_DLLAPI IdXMLFile :
46 protected Internal::XMLHandler,
47 public Internal::XMLFile,
48 public ProgressLogger
49 {
50public:
51 // both ConsensusXMLFile and FeatureXMLFile use some protected IdXML helper functions to parse identifications without code duplication
54
57
67 void load(const std::string& filename, std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids);
68
78 void load(const std::string& filename, std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids, std::string& document_id);
79
98 void store(const std::string& filename, const std::vector<ProteinIdentification>& protein_ids, const PeptideIdentificationList& peptide_ids, const std::string& document_id = "");
99
100
101protected:
103 void storeFile_(const std::string& filename, const std::vector<ProteinIdentification>& protein_ids, const PeptideIdentificationList& peptide_ids, const std::string& document_id);
104
105 // Docu in base class
106 void onEndElement(const char16_t* qname) override;
107
108 // Docu in base class
109 void onStartElement(const char16_t* qname, const Internal::XMLAttributes& attributes) override;
110
114 void addProteinGroups_(MetaInfoInterface& meta, const std::vector<ProteinIdentification::ProteinGroup>& groups,
115 const std::string& group_name, const std::unordered_map<std::string, UInt>& accession_to_id, XMLHandler::ActionMode mode);
116
118 void getProteinGroups_(std::vector<ProteinIdentification::ProteinGroup>& groups, const std::string& group_name);
119
124 static std::ostream& createFlankingAAXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
125
130 static std::ostream& createPositionXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
131
132
136 static void writeFragmentAnnotations_(const std::string & tag_name, std::ostream & os,
137 const std::vector<PeptideHit::PeakAnnotation>& annotations, UInt indent);
138
142 static void parseFragmentAnnotation_(const std::string& s, std::vector<PeptideHit::PeakAnnotation> & annotations);
143
154 static void formatBlock_(std::ostream& block_os, const std::function<void(std::ostream&)>& write);
155
156
158
159
160 std::vector<ProteinIdentification>* prot_ids_;
166 std::map<std::string, ProteinIdentification::SearchParameters> parameters_;
170 std::string id_;
182 std::vector<PeptideEvidence> peptide_evidences_;
184 std::unordered_map<std::string, std::string> proteinid_to_accession_;
186 std::unordered_map<std::string, std::string> proteinid_to_run_;
188 std::string* document_id_;
192 };
193
194} // namespace OpenMS
195
Used to load and store idXML files.
Definition IdXMLFile.h:49
static void writeFragmentAnnotations_(const std::string &tag_name, std::ostream &os, const std::vector< PeptideHit::PeakAnnotation > &annotations, UInt indent)
std::vector< ProteinIdentification > * prot_ids_
Pointer to fill in protein identifications.
Definition IdXMLFile.h:160
MetaInfoInterface * last_meta_
Pointer to last read object with MetaInfoInterface.
Definition IdXMLFile.h:164
std::map< std::string, ProteinIdentification::SearchParameters > parameters_
Search parameters map (key is the "id")
Definition IdXMLFile.h:166
static void parseFragmentAnnotation_(const std::string &s, std::vector< PeptideHit::PeakAnnotation > &annotations)
void storeFile_(const std::string &filename, const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const std::string &document_id)
store() after the checks that run before the file is opened
ProteinIdentification::SearchParameters param_
Temporary search parameters variable.
Definition IdXMLFile.h:168
std::unordered_map< std::string, std::string > proteinid_to_accession_
Map from protein id to accession.
Definition IdXMLFile.h:184
ProteinIdentification prot_id_
Temporary protein ProteinIdentification.
Definition IdXMLFile.h:172
static std::ostream & createFlankingAAXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
void onStartElement(const char16_t *qname, const Internal::XMLAttributes &attributes) override
Parsing method for opening tags.
PeptideHit::PepXMLAnalysisResult current_analysis_result_
Temporary analysis result instance.
Definition IdXMLFile.h:180
ProteinHit prot_hit_
Temporary protein hit.
Definition IdXMLFile.h:176
void store(const std::string &filename, const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const std::string &document_id="")
Stores the data in an idXML file.
std::unordered_map< std::string, std::string > proteinid_to_run_
the identifier of the run of each protein hit (by its id): a peptide hit may only reference the prote...
Definition IdXMLFile.h:186
void getProteinGroups_(std::vector< ProteinIdentification::ProteinGroup > &groups, const std::string &group_name)
Read and store ProteinGroup data.
IdXMLFile()
Constructor.
PeptideHit pep_hit_
Temporary peptide hit.
Definition IdXMLFile.h:178
void load(const std::string &filename, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids)
Loads the identifications of an idXML file without identifier.
std::string * document_id_
Document identifier.
Definition IdXMLFile.h:188
std::vector< PeptideEvidence > peptide_evidences_
Temporary peptide evidences.
Definition IdXMLFile.h:182
static std::ostream & createPositionXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
bool prot_id_in_run_
true if a prot id is contained in the current run
Definition IdXMLFile.h:190
void addProteinGroups_(MetaInfoInterface &meta, const std::vector< ProteinIdentification::ProteinGroup > &groups, const std::string &group_name, const std::unordered_map< std::string, UInt > &accession_to_id, XMLHandler::ActionMode mode)
static void formatBlock_(std::ostream &block_os, const std::function< void(std::ostream &)> &write)
Formats one block of the parallel peptide identification writer of store(): calls write on block_os.
PeptideIdentification pep_id_
Temporary peptide ProteinIdentification.
Definition IdXMLFile.h:174
void onEndElement(const char16_t *qname) override
Parsing method for closing tags.
std::string id_
Temporary id.
Definition IdXMLFile.h:170
PeptideIdentificationList * pep_ids_
Pointer to fill in peptide identifications.
Definition IdXMLFile.h:162
void load(const std::string &filename, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, std::string &document_id)
Loads the identifications of an idXML file.
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition ConsensusXMLHandler.h:41
This class provides Input/Output functionality for feature maps.
Definition FeatureXMLHandler.h:47
Non-owning attribute view for an XML start-element callback.
Definition XMLAttributes.h:29
Base class for loading and storing XML files via libxml2, with optional schema validation and transpa...
Definition XMLFile.h:40
Base class for XML handlers.
Definition XMLHandler.h:41
ActionMode
Action to set the current mode (for error messages)
Definition XMLHandler.h:58
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:35
Analysis Result (containing search engine / prophet results)
Definition PeptideHit.h:201
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
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:28
Representation of a protein hit.
Definition ProteinHit.h:34
Representation of a protein identification run.
Definition ProteinIdentification.h:55
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Search parameters of the DB search.
Definition ProteinIdentification.h:194