| OpenMS 2.5.0

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-2020.
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
37 #include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>
38 #include <OpenMS/FORMAT/ControlledVocabulary.h>
39 #include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h>
40 #include <OpenMS/METADATA/SourceFile.h>
41 #include <OpenMS/METADATA/CVTermList.h>
42 #include <OpenMS/CONCEPT/ProgressLogger.h>
43
44 #include <ostream>
45
46 namespace OpenMS
47 {
48 namespace Internal
49 {
50
56 class OPENMS_DLLAPI TraMLHandler :
57 public XMLHandler
58 {
59 public:
60
61 typedef std::vector<ReactionMonitoringTransition::Product> ProductListType;
62 typedef std::vector<ReactionMonitoringTransition::Configuration> ConfigurationListType;
63
66 TraMLHandler(const TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
68
70 TraMLHandler(TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
71
73 ~TraMLHandler() override;
75
76
77 // Docu in base class
78 void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
79
80 // Docu in base class
81 void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
82
83 // Docu in base class
84 void characters(const XMLCh * const chars, const XMLSize_t length) override;
85
86 //Docu in base class
87 void writeTo(std::ostream & os) override;
88
89 protected:
90
92 const ProgressLogger& logger_;
93
95 ControlledVocabulary cv_;
96
97 String tag_;
98
99 TargetedExperiment* exp_;
100
101 const TargetedExperiment* cexp_;
102
103 TargetedExperiment::Publication actual_publication_;
104
105 TargetedExperiment::Contact actual_contact_;
106
107 TargetedExperiment::Instrument actual_instrument_;
108
109 TargetedExperiment::Prediction actual_prediction_;
110
111 Software actual_software_;
112
113 TargetedExperiment::Protein actual_protein_;
114
115 TargetedExperiment::RetentionTime actual_rt_;
116
117 TargetedExperiment::Peptide actual_peptide_;
118
119 TargetedExperiment::Compound actual_compound_;
120
121 ReactionMonitoringTransition actual_transition_;
122
123 IncludeExcludeTarget actual_target_;
124
125 CVTermList actual_validation_;
126
127 TargetedExperiment::Interpretation actual_interpretation_;
128
129 std::vector<ReactionMonitoringTransition::Product> actual_intermediate_products_;
130
131 ReactionMonitoringTransition::Product actual_product_;
132
133 ReactionMonitoringTransition::Configuration actual_configuration_;
134
135 SourceFile actual_sourcefile_;
136
138 void handleCVParam_(const String & parent_parent_tag, const String & parent_tag, const CVTerm & cv_term);
139
141 void handleUserParam_(const String & parent_parent_tag, const String & parent_tag, const String & name, const String & type, const String & value);
142
144 void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
145
146 void writeUserParams_(std::ostream & os, const std::vector<MetaInfoInterface> & meta, UInt indent) const;
147
148 template <typename CVTList>
149 void writeCVParams_(std::ostream & os, const CVTList & cv_terms, UInt indent) const
150 {
151 for (Map<String, std::vector<CVTerm> >::const_iterator it = cv_terms.getCVTerms().begin();
152 it != cv_terms.getCVTerms().end(); ++it)
153 {
154 for (std::vector<CVTerm>::const_iterator cit = it->second.begin(); cit != it->second.end(); ++cit)
155 {
156 os << String(2 * indent, ' ') << "<cvParam cvRef=\"" << cit->getCVIdentifierRef() << "\" accession=\"" << cit->getAccession() << "\" name=\"" << cit->getName() << "\"";
157 if (cit->hasValue() && !cit->getValue().isEmpty() && !cit->getValue().toString().empty())
158 {
159 os << " value=\"" << cit->getValue().toString() << "\"";
160 }
161
162 if (cit->hasUnit())
163 {
164 os << " unitCvRef=\"" << cit->getUnit().cv_ref << "\" unitAccession=\"" << cit->getUnit().accession << "\" unitName=\"" << cit->getUnit().name << "\"";
165 }
166 os << "/>" << "\n";
167 }
168 }
169 }
170
171 // subfunctions of write
172 void writeTarget_(std::ostream & os, const std::vector<IncludeExcludeTarget>::const_iterator & it) const;
173
174 void writeRetentionTime_(std::ostream& os, const TargetedExperimentHelper::RetentionTime& rt) const;
175
176 void writeProduct_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Product>::const_iterator & prod_it) const;
177
178 void writeConfiguration_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Configuration>::const_iterator & cit) const;
179
181 ControlledVocabulary::CVTerm getChildWithName_(const String & parent_accession, const String & name) const;
182
184 //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
185
186 private:
187
188 TraMLHandler();
189 TraMLHandler(const TraMLHandler & rhs);
190 TraMLHandler & operator=(const TraMLHandler & rhs);
191 };
192 } // namespace Internal
193 } // namespace OpenMS
194
195
OpenMS::CVTermList
Representation of controlled vocabulary term list.
Definition: CVTermList.h:52
OpenMS::SourceFile
Description of a file location, used to store the origin of (meta) data.
Definition: SourceFile.h:46
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Internal::TraMLHandler::actual_rt_
TargetedExperiment::RetentionTime actual_rt_
Definition: TraMLHandler.h:115
OpenMS::Internal::TraMLHandler::logger_
const ProgressLogger & logger_
Progress logger.
Definition: TraMLHandler.h:92
OpenMS::Internal::TraMLHandler::actual_transition_
ReactionMonitoringTransition actual_transition_
Definition: TraMLHandler.h:121
OpenMS::Internal::TraMLHandler::tag_
String tag_
Definition: TraMLHandler.h:97
TargetedExperiment.h
XMLHandler.h
OpenMS::Internal::TraMLHandler::actual_configuration_
ReactionMonitoringTransition::Configuration actual_configuration_
Definition: TraMLHandler.h:133
OpenMS::Internal::TraMLHandler::actual_target_
IncludeExcludeTarget actual_target_
Definition: TraMLHandler.h:123
OpenMS::TargetedExperimentHelper::RetentionTime
This class stores a retention time structure that is used in TargetedExperiment (representing a TraML...
Definition: TargetedExperimentHelper.h:127
OpenMS::Internal::TraMLHandler::exp_
TargetedExperiment * exp_
Definition: TraMLHandler.h:99
OpenMS::Internal::TraMLHandler::actual_compound_
TargetedExperiment::Compound actual_compound_
Definition: TraMLHandler.h:119
OpenMS::Internal::TraMLHandler::cexp_
const TargetedExperiment * cexp_
Definition: TraMLHandler.h:101
OpenMS::Internal::TraMLHandler::actual_publication_
TargetedExperiment::Publication actual_publication_
Definition: TraMLHandler.h:103
OpenMS::Internal::TraMLHandler::actual_software_
Software actual_software_
Definition: TraMLHandler.h:111
OpenMS::TargetedExperimentHelper::Contact
Definition: TargetedExperimentHelper.h:444
OpenMS::Software
Description of the software used for processing.
Definition: Software.h:48
OpenMS::Internal::TraMLHandler::cv_
ControlledVocabulary cv_
Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
Definition: TraMLHandler.h:95
OpenMS::Internal::TraMLHandler::writeCVParams_
void writeCVParams_(std::ostream &os, const CVTList &cv_terms, UInt indent) const
Definition: TraMLHandler.h:149
OpenMS::Internal::TraMLHandler
XML handler for TraMLFile.
Definition: TraMLHandler.h:56
OpenMS::Internal::TraMLHandler::actual_peptide_
TargetedExperiment::Peptide actual_peptide_
Definition: TraMLHandler.h:117
OpenMS::TargetedExperimentHelper::Configuration
Definition: TargetedExperimentHelper.h:64
OpenMS::Internal::TraMLHandler::ProductListType
std::vector< ReactionMonitoringTransition::Product > ProductListType
Definition: TraMLHandler.h:61
ControlledVocabulary.h
OpenMS::CVTerm
Representation of controlled vocabulary term.
Definition: CVTerm.h:52
OpenMS::TargetedExperimentHelper::Compound
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:333
OpenMS::Internal::TraMLHandler::actual_validation_
CVTermList actual_validation_
Definition: TraMLHandler.h:125
OpenMS::TargetedExperimentHelper::Protein
Definition: TargetedExperimentHelper.h:98
ProgressLogger.h
OpenMS::Map
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:50
OpenMS::TargetedExperiment
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
OpenMS::Internal::TraMLHandler::actual_protein_
TargetedExperiment::Protein actual_protein_
Definition: TraMLHandler.h:113
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
OpenMS::Internal::TraMLHandler::actual_instrument_
TargetedExperiment::Instrument actual_instrument_
Definition: TraMLHandler.h:107
OpenMS::Internal::TraMLHandler::actual_contact_
TargetedExperiment::Contact actual_contact_
Definition: TraMLHandler.h:105
OpenMS::TargetedExperimentHelper::Instrument
Definition: TargetedExperimentHelper.h:478
OpenMS::ReactionMonitoringTransition
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56
CVTermList.h
OpenMS::Internal::TraMLHandler::actual_interpretation_
TargetedExperiment::Interpretation actual_interpretation_
Definition: TraMLHandler.h:127
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
SourceFile.h
OpenMS::Internal::TraMLHandler::actual_sourcefile_
SourceFile actual_sourcefile_
Definition: TraMLHandler.h:135
OpenMS::Internal::TraMLHandler::ConfigurationListType
std::vector< ReactionMonitoringTransition::Configuration > ConfigurationListType
Definition: TraMLHandler.h:62
OpenMS::TargetedExperimentHelper::Interpretation
Product ion interpretation.
Definition: TargetedExperimentHelper.h:520
OpenMS::Internal::TraMLHandler::actual_intermediate_products_
std::vector< ReactionMonitoringTransition::Product > actual_intermediate_products_
Definition: TraMLHandler.h:129
OpenMS::TargetedExperimentHelper::Publication
Definition: TargetedExperimentHelper.h:461
OpenMS::ControlledVocabulary::CVTerm
Representation of a CV term.
Definition: ControlledVocabulary.h:60
OpenMS::TargetedExperimentHelper::Peptide
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:370
OpenMS::IncludeExcludeTarget
This class stores a SRM/MRM transition.
Definition: IncludeExcludeTarget.h:52
OpenMS::Internal::TraMLHandler::actual_prediction_
TargetedExperiment::Prediction actual_prediction_
Definition: TraMLHandler.h:109
OpenMS::TargetedExperimentHelper::Prediction
Definition: TargetedExperimentHelper.h:495
OpenMS::Internal::TraMLHandler::actual_product_
ReactionMonitoringTransition::Product actual_product_
Definition: TraMLHandler.h:131
OpenMS::ControlledVocabulary
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:54
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:151
OpenMS::TargetedExperimentHelper::TraMLProduct
Represents a product ion.
Definition: TargetedExperimentHelper.h:588
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60