OpenMS  2.8.0
IdXMLFile.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 #include <OpenMS/FORMAT/XMLFile.h>
42 
43 #include <vector>
44 
45 namespace OpenMS
46 {
47  namespace Internal
48  {
49  class FeatureXMLHandler;
50  class ConsensusXMLHandler;
51  }
68  class OPENMS_DLLAPI IdXMLFile :
69  protected Internal::XMLHandler,
70  public Internal::XMLFile,
71  public ProgressLogger
72  {
73 public:
74  // both ConsensusXMLFile and FeatureXMLFile use some protected IdXML helper functions to parse identifications without code duplication
77 
80 
90  void load(const String& filename, std::vector<ProteinIdentification>& protein_ids, std::vector<PeptideIdentification>& peptide_ids);
91 
101  void load(const String& filename, std::vector<ProteinIdentification>& protein_ids, std::vector<PeptideIdentification>& peptide_ids, String& document_id);
102 
111  void store(const String& filename, const std::vector<ProteinIdentification>& protein_ids, const std::vector<PeptideIdentification>& peptide_ids, const String& document_id = "");
112 
113 
114 protected:
115  // Docu in base class
116  void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) override;
117 
118  // Docu in base class
119  void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
120 
124  void addProteinGroups_(MetaInfoInterface& meta, const std::vector<ProteinIdentification::ProteinGroup>& groups,
125  const String& group_name, const std::unordered_map<std::string, UInt>& accession_to_id, XMLHandler::ActionMode mode);
126 
128  void getProteinGroups_(std::vector<ProteinIdentification::ProteinGroup>& groups, const String& group_name);
129 
134  static std::ostream& createFlankingAAXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
135 
140  static std::ostream& createPositionXMLString_(const std::vector<PeptideEvidence> & pes, std::ostream& os);
141 
142 
146  static void writeFragmentAnnotations_(const String & tag_name, std::ostream & os,
147  const std::vector<PeptideHit::PeakAnnotation>& annotations, UInt indent);
148 
152  static void parseFragmentAnnotation_(const String& s, std::vector<PeptideHit::PeakAnnotation> & annotations);
153 
154 
156 
157  std::vector<ProteinIdentification>* prot_ids_;
160  std::vector<PeptideIdentification>* pep_ids_;
164  std::map<String, ProteinIdentification::SearchParameters> parameters_;
180  std::vector<PeptideEvidence> peptide_evidences_;
182  std::unordered_map<std::string, String> proteinid_to_accession_;
188  };
189 
190 } // namespace OpenMS
191 
Used to load and store idXML files.
Definition: IdXMLFile.h:72
static std::ostream & createPositionXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
std::vector< PeptideIdentification > * pep_ids_
Pointer to fill in peptide identifications.
Definition: IdXMLFile.h:160
MetaInfoInterface * last_meta_
Pointer to last read object with MetaInfoInterface.
Definition: IdXMLFile.h:162
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:166
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
ProteinIdentification prot_id_
Temporary protein ProteinIdentification.
Definition: IdXMLFile.h:170
std::unordered_map< std::string, String > proteinid_to_accession_
Map from protein id to accession.
Definition: IdXMLFile.h:182
PeptideHit::PepXMLAnalysisResult current_analysis_result_
Temporary analysis result instance.
Definition: IdXMLFile.h:178
ProteinHit prot_hit_
Temporary protein hit.
Definition: IdXMLFile.h:174
static std::ostream & createFlankingAAXMLString_(const std::vector< PeptideEvidence > &pes, std::ostream &os)
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids)
Loads the identifications of an idXML file without identifier.
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:176
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids, String &document_id)
Loads the identifications of an idXML file.
std::vector< PeptideEvidence > peptide_evidences_
Temporary peptide evidences.
Definition: IdXMLFile.h:180
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:186
PeptideIdentification pep_id_
Temporary peptide ProteinIdentification.
Definition: IdXMLFile.h:172
String * document_id_
Document identifier.
Definition: IdXMLFile.h:184
std::map< String, ProteinIdentification::SearchParameters > parameters_
Search parameters map (key is the "id")
Definition: IdXMLFile.h:164
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:168
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLHandler.h:66
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLHandler.h:74
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:49
Base class for XML handlers.
Definition: XMLHandler.h:325
ActionMode
Action to set the current mode (for error messages)
Definition: XMLHandler.h:342
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Analysis Result (containing search engine / prophet results)
Definition: PeptideHit.h:176
Representation of a peptide hit.
Definition: PeptideHit.h:57
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:65
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
Representation of a protein hit.
Definition: ProteinHit.h:60
Representation of a protein identification run.
Definition: ProteinIdentification.h:72
A more convenient string class.
Definition: String.h:60
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Search parameters of the DB search.
Definition: ProteinIdentification.h:260