OpenMS
TraMLHandler.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-2023.
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: Hannes Roest $
32 // $Authors: Andreas Bertsch, Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 #include <iosfwd>
45 #include <map>
46 
47 namespace OpenMS
48 {
49  namespace Internal
50  {
51 
57  class OPENMS_DLLAPI TraMLHandler :
58  public XMLHandler
59  {
60 public:
61 
62  TraMLHandler() = delete;
63  TraMLHandler(const TraMLHandler & rhs) = delete;
64  TraMLHandler & operator=(const TraMLHandler & rhs) = delete;
65 
66  typedef std::vector<ReactionMonitoringTransition::Product> ProductListType;
67  typedef std::vector<ReactionMonitoringTransition::Configuration> ConfigurationListType;
68 
72  TraMLHandler(const TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
73 
75  TraMLHandler(TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
76 
78  ~TraMLHandler() override;
80 
81 
82  // Docu in base class
83  void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
84 
85  // Docu in base class
86  void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
87 
88  // Docu in base class
89  void characters(const XMLCh * const chars, const XMLSize_t length) override;
90 
91  //Docu in base class
92  void writeTo(std::ostream & os) override;
93 
94 protected:
95 
98 
101 
103 
105 
107 
109 
111 
113 
115 
117 
119 
121 
123 
125 
127 
129 
131 
133 
134  std::vector<ReactionMonitoringTransition::Product> actual_intermediate_products_;
135 
137 
139 
141 
143  void handleCVParam_(const String & parent_parent_tag, const String & parent_tag, const CVTerm & cv_term);
144 
146  void handleUserParam_(const String & parent_parent_tag, const String & parent_tag, const String & name, const String & type, const String & value);
147 
149  void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
150 
151  void writeUserParams_(std::ostream & os, const std::vector<MetaInfoInterface> & meta, UInt indent) const;
152 
153  void writeCVParams_(std::ostream & os, const CVTermList & cv_terms, UInt indent) const;
154  void writeCVParams_(std::ostream & os, const CVTermListInterface & cv_terms, UInt indent) const;
155 
156  void writeCVList_(std::ostream & os, const std::map<String, std::vector<CVTerm>> & cv_terms, UInt indent) const;
157 
158  // subfunctions of write
159  void writeTarget_(std::ostream & os, const std::vector<IncludeExcludeTarget>::const_iterator & it) const;
160 
161  void writeRetentionTime_(std::ostream& os, const TargetedExperimentHelper::RetentionTime& rt) const;
162 
163  void writeProduct_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Product>::const_iterator & prod_it) const;
164 
165  void writeConfiguration_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Configuration>::const_iterator & cit) const;
166 
168  ControlledVocabulary::CVTerm getChildWithName_(const String & parent_accession, const String & name) const;
169 
171  //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
172 
173  };
174  } // namespace Internal
175 } // namespace OpenMS
176 
177 
Interface to the controlled vocabulary term list.
Definition: CVTermListInterface.h:59
Representation of controlled vocabulary term list.
Definition: CVTermList.h:54
Representation of controlled vocabulary term.
Definition: CVTerm.h:53
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:55
This class stores a SRM/MRM transition.
Definition: IncludeExcludeTarget.h:54
XML handler for TraMLFile.
Definition: TraMLHandler.h:59
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,...
ReactionMonitoringTransition::Product actual_product_
Definition: TraMLHandler.h:136
std::vector< ReactionMonitoringTransition::Product > actual_intermediate_products_
Definition: TraMLHandler.h:134
std::vector< ReactionMonitoringTransition::Configuration > ConfigurationListType
Definition: TraMLHandler.h:67
void writeCVList_(std::ostream &os, const std::map< String, std::vector< CVTerm >> &cv_terms, UInt indent) const
TargetedExperiment::Peptide actual_peptide_
Definition: TraMLHandler.h:122
ReactionMonitoringTransition actual_transition_
Definition: TraMLHandler.h:126
TraMLHandler(const TargetedExperiment &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler.
TargetedExperiment::RetentionTime actual_rt_
Definition: TraMLHandler.h:120
TargetedExperiment::Interpretation actual_interpretation_
Definition: TraMLHandler.h:132
void writeTo(std::ostream &os) override
Writes the contents to a stream.
const TargetedExperiment * cexp_
Definition: TraMLHandler.h:106
TraMLHandler(TargetedExperiment &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler.
const ProgressLogger & logger_
Progress logger.
Definition: TraMLHandler.h:97
ControlledVocabulary cv_
Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
Definition: TraMLHandler.h:100
String tag_
Definition: TraMLHandler.h:102
void writeUserParam_(std::ostream &os, const MetaInfoInterface &meta, UInt indent) const
Writes user terms.
std::vector< ReactionMonitoringTransition::Product > ProductListType
Definition: TraMLHandler.h:66
CVTermList actual_validation_
Definition: TraMLHandler.h:130
TargetedExperiment::Contact actual_contact_
Definition: TraMLHandler.h:110
TargetedExperiment::Publication actual_publication_
Definition: TraMLHandler.h:108
SourceFile actual_sourcefile_
Definition: TraMLHandler.h:140
void writeUserParams_(std::ostream &os, const std::vector< MetaInfoInterface > &meta, UInt indent) const
ReactionMonitoringTransition::Configuration actual_configuration_
Definition: TraMLHandler.h:138
TargetedExperiment * exp_
Definition: TraMLHandler.h:104
void writeCVParams_(std::ostream &os, const CVTermList &cv_terms, UInt indent) const
~TraMLHandler() override
Destructor.
TargetedExperiment::Compound actual_compound_
Definition: TraMLHandler.h:124
void startElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname, const xercesc::Attributes &attributes) override
void writeCVParams_(std::ostream &os, const CVTermListInterface &cv_terms, UInt indent) const
TargetedExperiment::Instrument actual_instrument_
Definition: TraMLHandler.h:112
void writeRetentionTime_(std::ostream &os, const TargetedExperimentHelper::RetentionTime &rt) const
TraMLHandler(const TraMLHandler &rhs)=delete
void writeConfiguration_(std::ostream &os, const std::vector< ReactionMonitoringTransition::Configuration >::const_iterator &cit) const
void writeTarget_(std::ostream &os, const std::vector< IncludeExcludeTarget >::const_iterator &it) const
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 handleUserParam_(const String &parent_parent_tag, const String &parent_tag, const String &name, const String &type, const String &value)
Handles user terms.
void writeProduct_(std::ostream &os, const std::vector< ReactionMonitoringTransition::Product >::const_iterator &prod_it) const
TargetedExperiment::Prediction actual_prediction_
Definition: TraMLHandler.h:114
void handleCVParam_(const String &parent_parent_tag, const String &parent_tag, const CVTerm &cv_term)
Handles CV terms.
TraMLHandler & operator=(const TraMLHandler &rhs)=delete
Software actual_software_
Definition: TraMLHandler.h:116
TargetedExperiment::Protein actual_protein_
Definition: TraMLHandler.h:118
IncludeExcludeTarget actual_target_
Definition: TraMLHandler.h:128
Base class for XML handlers.
Definition: XMLHandler.h:326
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:58
Description of the software used for processing.
Definition: Software.h:50
Description of a file location, used to store the origin of (meta) data.
Definition: SourceFile.h:48
A more convenient string class.
Definition: String.h:60
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:323
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:360
This class stores a retention time structure that is used in TargetedExperiment (representing a TraML...
Definition: TargetedExperimentHelper.h:126
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:65
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
Representation of a CV term.
Definition: ControlledVocabulary.h:61
Definition: TargetedExperimentHelper.h:66
Definition: TargetedExperimentHelper.h:429
Definition: TargetedExperimentHelper.h:463
Product ion interpretation.
Definition: TargetedExperimentHelper.h:505
Definition: TargetedExperimentHelper.h:480
Definition: TargetedExperimentHelper.h:100
Definition: TargetedExperimentHelper.h:446
Represents a product ion.
Definition: TargetedExperimentHelper.h:573