OpenMS
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 
16 #include <OpenMS/FORMAT/XMLFile.h>
17 
18 #include <vector>
19 
20 namespace OpenMS
21 {
22  namespace Internal
23  {
24  class FeatureXMLHandler;
25  class ConsensusXMLHandler;
26  }
41  class OPENMS_DLLAPI IdXMLFile :
42  protected Internal::XMLHandler,
43  public Internal::XMLFile,
44  public ProgressLogger
45  {
46 public:
47  // both ConsensusXMLFile and FeatureXMLFile use some protected IdXML helper functions to parse identifications without code duplication
50 
53 
63  void load(const String& filename, std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids);
64 
74  void load(const String& filename, std::vector<ProteinIdentification>& protein_ids, PeptideIdentificationList& peptide_ids, String& document_id);
75 
84  void store(const String& filename, const std::vector<ProteinIdentification>& protein_ids, const PeptideIdentificationList& peptide_ids, const String& document_id = "");
85 
86 
87 protected:
88  // Docu in base class
89  void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) override;
90 
91  // Docu in base class
92  void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
93 
97  void addProteinGroups_(MetaInfoInterface& meta, const std::vector<ProteinIdentification::ProteinGroup>& groups,
98  const String& group_name, const std::unordered_map<std::string, UInt>& accession_to_id, XMLHandler::ActionMode mode);
99 
101  void getProteinGroups_(std::vector<ProteinIdentification::ProteinGroup>& groups, const String& group_name);
102 
107  static std::ostream& createFlankingAAXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
108 
113  static std::ostream& createPositionXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
114 
115 
119  static void writeFragmentAnnotations_(const String & tag_name, std::ostream & os,
120  const std::vector<PeptideHit::PeakAnnotation>& annotations, UInt indent);
121 
125  static void parseFragmentAnnotation_(const String& s, std::vector<PeptideHit::PeakAnnotation> & annotations);
126 
127 
129 
130  std::vector<ProteinIdentification>* prot_ids_;
137  std::map<String, ProteinIdentification::SearchParameters> parameters_;
153  std::vector<PeptideEvidence> peptide_evidences_;
155  std::unordered_map<std::string, String> proteinid_to_accession_;
161  };
162 
163 } // namespace OpenMS
164 
char16_t XMLCh
Definition: ClassTest.h:28
Used to load and store idXML files.
Definition: IdXMLFile.h:45
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids)
Loads the identifications of an idXML file without identifier.
static std::ostream & createPositionXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
MetaInfoInterface * last_meta_
Pointer to last read object with MetaInfoInterface.
Definition: IdXMLFile.h:135
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, String &document_id)
Loads the identifications of an idXML file.
void getProteinGroups_(std::vector< ProteinIdentification::ProteinGroup > &groups, const String &group_name)
Read and store ProteinGroup data.
ProteinIdentification::SearchParameters param_
Temporary search parameters variable.
Definition: IdXMLFile.h:139
ProteinIdentification prot_id_
Temporary protein ProteinIdentification.
Definition: IdXMLFile.h:143
std::unordered_map< std::string, String > proteinid_to_accession_
Map from protein id to accession.
Definition: IdXMLFile.h:155
PeptideHit::PepXMLAnalysisResult current_analysis_result_
Temporary analysis result instance.
Definition: IdXMLFile.h:151
ProteinHit prot_hit_
Temporary protein hit.
Definition: IdXMLFile.h:147
static std::ostream & createFlankingAAXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
void addProteinGroups_(MetaInfoInterface &meta, const std::vector< ProteinIdentification::ProteinGroup > &groups, const String &group_name, const std::unordered_map< std::string, UInt > &accession_to_id, XMLHandler::ActionMode mode)
static void parseFragmentAnnotation_(const String &s, std::vector< PeptideHit::PeakAnnotation > &annotations)
IdXMLFile()
Constructor.
PeptideHit pep_hit_
Temporary peptide hit.
Definition: IdXMLFile.h:149
std::vector< PeptideEvidence > peptide_evidences_
Temporary peptide evidences.
Definition: IdXMLFile.h:153
void startElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname, const xercesc::Attributes &attributes) override
bool prot_id_in_run_
true if a prot id is contained in the current run
Definition: IdXMLFile.h:159
PeptideIdentification pep_id_
Temporary peptide ProteinIdentification.
Definition: IdXMLFile.h:145
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
String * document_id_
Document identifier.
Definition: IdXMLFile.h:157
std::map< String, ProteinIdentification::SearchParameters > parameters_
Search parameters map (key is the "id")
Definition: IdXMLFile.h:137
void endElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname) override
static void writeFragmentAnnotations_(const String &tag_name, std::ostream &os, const std::vector< PeptideHit::PeakAnnotation > &annotations, UInt indent)
String id_
Temporary id.
Definition: IdXMLFile.h:141
PeptideIdentificationList * pep_ids_
Pointer to fill in peptide identifications.
Definition: IdXMLFile.h:133
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:45
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:23
Base class for XML handlers.
Definition: XMLHandler.h:328
ActionMode
Action to set the current mode (for error messages)
Definition: XMLHandler.h:345
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:168
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition: PeptideHit.h:50
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:63
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Representation of a protein hit.
Definition: ProteinHit.h:34
Representation of a protein identification run.
Definition: ProteinIdentification.h:51
A more convenient string class.
Definition: String.h:34
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:248