~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to include/OpenMS/FORMAT/HANDLERS/TraMLHandler.h

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2013-12-20 11:30:16 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131220113016-wre5g9bteeheq6he
Tags: 1.11.1-3
* remove version number from libbost development package names;
* ensure that AUTHORS is correctly shipped in all packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: C++; tab-width: 2; -*-
2
 
// vi: set ts=2:
3
 
//
4
 
// --------------------------------------------------------------------------
5
 
//                   OpenMS Mass Spectrometry Framework
6
 
// --------------------------------------------------------------------------
7
 
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
8
 
//
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.
13
 
//
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.
18
 
//
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
22
 
//
23
 
// --------------------------------------------------------------------------
24
 
// $Maintainer: $
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.
 
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 $
26
33
// --------------------------------------------------------------------------
27
34
 
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>
35
43
 
36
44
namespace OpenMS
37
45
{
38
 
        class ProgressLogger;
39
 
 
40
 
        namespace Internal
41
 
        {
42
 
 
43
 
                /**
44
 
                        @brief XML handler for TraMLFile
45
 
                        
46
 
                        @note Do not use this class. It is only needed in TraMLFile.
47
 
                */
48
 
                class OPENMS_DLLAPI TraMLHandler
49
 
                        : public XMLHandler
50
 
                {
51
 
                 public:
 
46
  namespace Internal
 
47
  {
 
48
 
 
49
    /**
 
50
      @brief XML handler for TraMLFile
 
51
 
 
52
      @note Do not use this class. It is only needed in TraMLFile.
 
53
    */
 
54
    class OPENMS_DLLAPI TraMLHandler :
 
55
      public XMLHandler
 
56
    {
 
57
public:
 
58
 
 
59
      typedef std::vector<ReactionMonitoringTransition::Product> ProductListType;
 
60
      typedef std::vector<ReactionMonitoringTransition::Configuration> ConfigurationListType;
 
61
 
52
62
      /**@name Constructors and destructor */
53
63
      //@{
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);
56
66
 
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);
59
69
 
60
70
      /// Destructor
61
71
      virtual ~TraMLHandler();
62
72
      //@}
63
73
 
64
74
 
65
 
                        // Docu in base class
66
 
      virtual void endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname);
67
 
                        
68
 
                        // Docu in base class
69
 
      virtual void startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes);
70
 
                        
71
 
                        // Docu in base class
72
 
      virtual void characters(const XMLCh* const chars, const XMLSize_t length);
73
 
                        
74
 
                        //Docu in base class
75
 
                        virtual void writeTo(std::ostream& os);
76
 
                        
77
 
                 protected:
78
 
      
79
 
                        /// Progress logger
80
 
                        const ProgressLogger& logger_;
81
 
                        
82
 
                        ///Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
83
 
                        ControlledVocabulary cv_;
84
 
                
85
 
                        String tag_;
86
 
 
87
 
                        TargetedExperiment* exp_;
88
 
 
89
 
                        const TargetedExperiment* cexp_;
90
 
 
91
 
                        CVTermList actual_publication_;
92
 
 
93
 
                        CVTermList actual_contact_;
94
 
 
95
 
                        CVTermList actual_instrument_;
96
 
 
97
 
                        CVTermList actual_prediction_;
98
 
                        
99
 
                        Software actual_software_;
100
 
 
101
 
                        TargetedExperiment::Protein actual_protein_;
102
 
 
103
 
                        TargetedExperiment::RetentionTime actual_rt_;
104
 
 
105
 
                        TargetedExperiment::Peptide actual_peptide_;
106
 
 
107
 
                        TargetedExperiment::Compound actual_compound_;
108
 
                        
109
 
                        ReactionMonitoringTransition actual_transition_;
110
 
 
111
 
                        IncludeExcludeTarget actual_target_;
112
 
 
113
 
                        CVTermList actual_validation_;
114
 
        
115
 
                        CVTermList actual_interpretation_;
116
 
                        
117
 
                        ReactionMonitoringTransition::Configuration actual_configuration_;
118
 
 
119
 
                        SourceFile actual_sourcefile_;
120
 
 
121
 
                        /// Handles CV terms
122
 
                        void handleCVParam_(const String& parent_parent_tag, const String& parent_tag, const CVTerm& cv_term);
123
 
 
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);
126
 
                        
127
 
                        /// Writes user terms
128
 
                        void writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, UInt indent) const;
129
 
 
130
 
                        void writeUserParams_(std::ostream& os, const std::vector<MetaInfoInterface>& meta, UInt indent) const;
131
 
 
132
 
                        void writeCVParams_(std::ostream& os, const CVTermList& cv_terms, UInt indent) const;
133
 
 
134
 
                        
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;
137
 
                        
138
 
                        /// Helper method that writes a source file
139
 
                        //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
140
 
 
141
 
                        private:
142
 
 
143
 
                                TraMLHandler();
144
 
                                TraMLHandler(const TraMLHandler& rhs);
145
 
                                TraMLHandler& operator = (const TraMLHandler& rhs);
146
 
                };
147
 
        } // namespace Internal
 
75
      // Docu in base class
 
76
      virtual void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
 
77
 
 
78
      // Docu in base class
 
79
      virtual void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
 
80
 
 
81
      // Docu in base class
 
82
      virtual void characters(const XMLCh * const chars, const XMLSize_t length);
 
83
 
 
84
      //Docu in base class
 
85
      virtual void writeTo(std::ostream & os);
 
86
 
 
87
protected:
 
88
 
 
89
      /// Progress logger
 
90
      const ProgressLogger & logger_;
 
91
 
 
92
      ///Controlled vocabulary (psi-ms from OpenMS/share/OpenMS/CV/psi-ms.obo)
 
93
      ControlledVocabulary cv_;
 
94
 
 
95
      String tag_;
 
96
 
 
97
      TargetedExperiment * exp_;
 
98
 
 
99
      const TargetedExperiment * cexp_;
 
100
 
 
101
      TargetedExperiment::Publication actual_publication_;
 
102
 
 
103
      TargetedExperiment::Contact actual_contact_;
 
104
 
 
105
      TargetedExperiment::Instrument actual_instrument_;
 
106
 
 
107
      TargetedExperiment::Prediction actual_prediction_;
 
108
 
 
109
      Software actual_software_;
 
110
 
 
111
      TargetedExperiment::Protein actual_protein_;
 
112
 
 
113
      TargetedExperiment::RetentionTime actual_rt_;
 
114
 
 
115
      TargetedExperiment::Peptide actual_peptide_;
 
116
 
 
117
      TargetedExperiment::Compound actual_compound_;
 
118
 
 
119
      ReactionMonitoringTransition actual_transition_;
 
120
 
 
121
      IncludeExcludeTarget actual_target_;
 
122
 
 
123
      CVTermList actual_validation_;
 
124
 
 
125
      CVTermList actual_interpretation_;
 
126
 
 
127
      std::vector<ReactionMonitoringTransition::Product> actual_intermediate_products_;
 
128
 
 
129
      ReactionMonitoringTransition::Product actual_product_;
 
130
 
 
131
      ReactionMonitoringTransition::Configuration actual_configuration_;
 
132
 
 
133
      SourceFile actual_sourcefile_;
 
134
 
 
135
      /// Handles CV terms
 
136
      void handleCVParam_(const String & parent_parent_tag, const String & parent_tag, const CVTerm & cv_term);
 
137
 
 
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);
 
140
 
 
141
      /// Writes user terms
 
142
      void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
 
143
 
 
144
      void writeUserParams_(std::ostream & os, const std::vector<MetaInfoInterface> & meta, UInt indent) const;
 
145
 
 
146
      void writeCVParams_(std::ostream & os, const CVTermList & cv_terms, UInt indent) const;
 
147
 
 
148
      // subfunctions of write
 
149
      void writeTarget_(std::ostream & os, const std::vector<IncludeExcludeTarget>::const_iterator & it) const;
 
150
 
 
151
      void writeProduct_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Product>::const_iterator & prod_it) const;
 
152
 
 
153
      void writeConfiguration_(std::ostream & os, const std::vector<ReactionMonitoringTransition::Configuration>::const_iterator & cit) const;
 
154
 
 
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;
 
157
 
 
158
      /// Helper method that writes a source file
 
159
      //void writeSourceFile_(std::ostream& os, const String& id, const SourceFile& software);
 
160
 
 
161
private:
 
162
 
 
163
      TraMLHandler();
 
164
      TraMLHandler(const TraMLHandler & rhs);
 
165
      TraMLHandler & operator=(const TraMLHandler & rhs);
 
166
    };
 
167
  } // namespace Internal
148
168
} // namespace OpenMS
149
169
 
150
170
#endif