1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
25
// $Authors: Andreas Bertsch $
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-2013.
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.
30
// --------------------------------------------------------------------------
31
// $Maintainer: Hannes Roest $
32
// $Authors: Andreas Bertsch, Hannes Roest $
26
33
// --------------------------------------------------------------------------
28
35
#ifndef OPENMS_FORMAT_HANDLERS_TRAMLHANDLER_H
32
39
#include <OpenMS/FORMAT/ControlledVocabulary.h>
33
40
#include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h>
34
41
#include <OpenMS/METADATA/CVTermList.h>
42
#include <OpenMS/CONCEPT/ProgressLogger.h>
44
@brief XML handler for TraMLFile
46
@note Do not use this class. It is only needed in TraMLFile.
48
class OPENMS_DLLAPI TraMLHandler
50
@brief XML handler for TraMLFile
52
@note Do not use this class. It is only needed in TraMLFile.
54
class OPENMS_DLLAPI TraMLHandler :
59
typedef std::vector<ReactionMonitoringTransition::Product> ProductListType;
60
typedef std::vector<ReactionMonitoringTransition::Configuration> ConfigurationListType;
52
62
/**@name Constructors and destructor */
54
64
/// Constructor for a write-only handler
55
TraMLHandler(const TargetedExperiment& exp, const String& filename, const String& version, const ProgressLogger& logger);
65
TraMLHandler(const TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
57
67
/// Constructor for a read-only handler
58
TraMLHandler(TargetedExperiment& exp, const String& filename, const String& version, const ProgressLogger& logger);
68
TraMLHandler(TargetedExperiment & exp, const String & filename, const String & version, const ProgressLogger & logger);
61
71
virtual ~TraMLHandler();
66
virtual void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname);
69
virtual void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes);
72
virtual void characters(const XMLCh* const chars, const XMLSize_t length);
75
virtual void writeTo(std::ostream& os);
80
const ProgressLogger& logger_;
82
///Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
83
ControlledVocabulary cv_;
87
TargetedExperiment* exp_;
89
const TargetedExperiment* cexp_;
91
CVTermList actual_publication_;
93
CVTermList actual_contact_;
95
CVTermList actual_instrument_;
97
CVTermList actual_prediction_;
99
Software actual_software_;
101
TargetedExperiment::Protein actual_protein_;
103
TargetedExperiment::RetentionTime actual_rt_;
105
TargetedExperiment::Peptide actual_peptide_;
107
TargetedExperiment::Compound actual_compound_;
109
ReactionMonitoringTransition actual_transition_;
111
IncludeExcludeTarget actual_target_;
113
CVTermList actual_validation_;
115
CVTermList actual_interpretation_;
117
ReactionMonitoringTransition::Configuration actual_configuration_;
119
SourceFile actual_sourcefile_;
122
void handleCVParam_(const String& parent_parent_tag, const String& parent_tag, const CVTerm& cv_term);
124
/// Handles user terms
125
void handleUserParam_(const String& parent_parent_tag, const String& parent_tag, const String& name, const String& type, const String& value);
127
/// Writes user terms
128
void writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, UInt indent) const;
130
void writeUserParams_(std::ostream& os, const std::vector<MetaInfoInterface>& meta, UInt indent) const;
132
void writeCVParams_(std::ostream& os, const CVTermList& cv_terms, UInt indent) const;
135
/// Looks up a child CV term of @p parent_accession with the name @p name. If no such term is found, an empty term is returned.
136
ControlledVocabulary::CVTerm getChildWithName_(const String& parent_accession, const String& name) const;
138
/// Helper method that writes a source file
139
//void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
144
TraMLHandler(const TraMLHandler& rhs);
145
TraMLHandler& operator = (const TraMLHandler& rhs);
147
} // namespace Internal
76
virtual void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
79
virtual void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
82
virtual void characters(const XMLCh * const chars, const XMLSize_t length);
85
virtual void writeTo(std::ostream & os);
90
const ProgressLogger & logger_;
92
///Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
93
ControlledVocabulary cv_;
97
TargetedExperiment * exp_;
99
const TargetedExperiment * cexp_;
101
TargetedExperiment::Publication actual_publication_;
103
TargetedExperiment::Contact actual_contact_;
105
TargetedExperiment::Instrument actual_instrument_;
107
TargetedExperiment::Prediction actual_prediction_;
109
Software actual_software_;
111
TargetedExperiment::Protein actual_protein_;
113
TargetedExperiment::RetentionTime actual_rt_;
115
TargetedExperiment::Peptide actual_peptide_;
117
TargetedExperiment::Compound actual_compound_;
119
ReactionMonitoringTransition actual_transition_;
121
IncludeExcludeTarget actual_target_;
123
CVTermList actual_validation_;
125
CVTermList actual_interpretation_;
127
std::vector<ReactionMonitoringTransition::Product> actual_intermediate_products_;
129
ReactionMonitoringTransition::Product actual_product_;
131
ReactionMonitoringTransition::Configuration actual_configuration_;
133
SourceFile actual_sourcefile_;
136
void handleCVParam_(const String & parent_parent_tag, const String & parent_tag, const CVTerm & cv_term);
138
/// Handles user terms
139
void handleUserParam_(const String & parent_parent_tag, const String & parent_tag, const String & name, const String & type, const String & value);
141
/// Writes user terms
142
void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
144
void writeUserParams_(std::ostream & os, const std::vector<MetaInfoInterface> & meta, UInt indent) const;
146
void writeCVParams_(std::ostream & os, const CVTermList & cv_terms, UInt indent) const;
148
// subfunctions of write
149
void writeTarget_(std::ostream & os, const std::vector<IncludeExcludeTarget>::const_iterator & it) const;
151
void writeProduct_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Product>::const_iterator & prod_it) const;
153
void writeConfiguration_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Configuration>::const_iterator & cit) const;
155
/// Looks up a child CV term of @p parent_accession with the name @p name. If no such term is found, an empty term is returned.
156
ControlledVocabulary::CVTerm getChildWithName_(const String & parent_accession, const String & name) const;
158
/// Helper method that writes a source file
159
//void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
164
TraMLHandler(const TraMLHandler & rhs);
165
TraMLHandler & operator=(const TraMLHandler & rhs);
167
} // namespace Internal
148
168
} // namespace OpenMS