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

« back to all changes in this revision

Viewing changes to include/OpenMS/ANALYSIS/DECHARGING/FeatureDeconvolution.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
 
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.
22
29
//
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Chris Bielow $
38
45
namespace OpenMS
39
46
{
40
47
 
41
 
        class Compomer;
42
 
        
43
 
  /** 
 
48
  class Compomer;
 
49
 
 
50
  /**
44
51
    @brief An algorithm to decharge features (i.e. as found by FeatureFinder).
45
52
 
46
 
    @htmlinclude OpenMS_FeatureDeconvolution.parameters 
47
 
    
 
53
    @htmlinclude OpenMS_FeatureDeconvolution.parameters
 
54
 
48
55
    @ingroup Analysis
49
56
  */
50
 
  
51
 
  class OPENMS_DLLAPI FeatureDeconvolution : public DefaultParamHandler
 
57
 
 
58
  class OPENMS_DLLAPI FeatureDeconvolution :
 
59
    public DefaultParamHandler
52
60
  {
53
 
    public:
54
 
    
55
 
                        enum CHARGEMODE {QFROMFEATURE=1,QHEURISTIC,QALL};
56
 
                        
57
 
      typedef FeatureMap<> FeatureMapType;
58
 
      typedef Feature FeatureType;
59
 
      typedef DPosition<2> ClusterPointType;
60
 
                        typedef FeatureMapType::FeatureType::CoordinateType CoordinateType;
61
 
                        typedef ILPDCWrapper::PairsType PairsType;
62
 
                        
63
 
      /** @name Constructors and Destructor s
64
 
      */
65
 
      //@{
66
 
      /// default constructor
67
 
      FeatureDeconvolution();
68
 
      
69
 
      /// Copy constructor
70
 
      FeatureDeconvolution(const FeatureDeconvolution& source);
71
 
      
72
 
      /// Assignment operator
73
 
      FeatureDeconvolution& operator=(const FeatureDeconvolution& source);        
74
 
 
75
 
      /// destructor
76
 
      virtual ~FeatureDeconvolution();
77
 
      //@}    
78
 
 
79
 
      /**
80
 
                                 @brief Compute a zero-charge feature map from a set of charged features
81
 
                                 
82
 
                                 Find putative ChargePairs, then score them and hand over to ILP.
83
 
 
84
 
                                 @param fm_in  Input feature-map
85
 
                                 @param fm_out Output feature-map (sorted by position and augmented with user params)
86
 
                                 @param cons_map   [out] Output of grouped features belonging to a charge group
87
 
                                 @param cons_map_p [out] Output of paired features connected by an edge
88
 
                        */
89
 
      void compute(const FeatureMapType &fm_in, FeatureMapType &fm_out, ConsensusMap &cons_map, ConsensusMap &cons_map_p);
90
 
 
91
 
    protected:
92
 
 
93
 
      void updateMembers_();
94
 
      
95
 
                        /**
96
 
                                @brief 1-sided Compomer for a feature
97
 
                                
98
 
                                Holds information on an explicit (with H+) 1-sided Compomer of a feature.
99
 
                        **/
100
 
                        struct CmpInfo_;
101
 
 
102
 
      /*
103
 
        @brief test for obviously wrong parameter settings and warn
104
 
 
105
 
        Currently supports the following scenarios:
106
 
         * If the lower charge bound is too high, consensus features with gapped, even charges will occur (e.g. 30,32,34), instead of the true (15,16,17)
107
 
           When more than 5% of the cf's look like this, we report it.
108
 
 
109
 
      */
110
 
      void checkSolution_(const ConsensusMap &cons_map) const;
111
 
 
112
 
                        /// test if "simple" edges have alternative
113
 
                        /// (more difficult explanation) supported by neighboring edges
114
 
                        /// e.g. (.)   -> (H+) might be augmented to
115
 
                        ///      (Na+) -> (H+Na+)
116
 
                        void inferMoreEdges_(PairsType& edges, Map<Size, std::set<CmpInfo_> >& feature_adducts);
117
 
 
118
 
                        /// A function mostly for debugging 
119
 
                        void printEdgesOfConnectedFeatures_(Size idx_1, Size idx_2, const PairsType& feature_relation);
120
 
                        
121
 
                        /**
122
 
                                @brief returns true if the intensity filter was passed or switched off
123
 
                                
124
 
                                Filter for adding an edge only when the two features connected by it, fulfill the
125
 
                                intensity criterion.
126
 
                                
127
 
                        **/
128
 
                        inline bool intensityFilterPassed_(const Int q1, const Int q2, const Compomer& cmp,const FeatureType& f1,const FeatureType& f2);
129
 
 
130
 
                        /**
131
 
                                @brief determines if we should test a putative feature charge
132
 
                                
133
 
                                Answer query given the internal status of @em q_try.
134
 
                                Features with q<=0 always return true.
135
 
                                
136
 
                        **/
137
 
                        bool chargeTestworthy_(const Int feature_charge, const Int putative_charge, const bool other_unchanged) const;
138
 
 
139
 
      /// List of adducts used to explain mass differences
140
 
      MassExplainer::AdductsType potential_adducts_;
141
 
      /// labeling table
142
 
      Map<Size, String> map_label_;
143
 
      /// labeling table inverse
144
 
      Map<String, Size> map_label_inverse_;
145
 
                        /// status of intensity filter for edges
146
 
                        bool enable_intensity_filter_;
147
 
                        /// status of charge discovery
148
 
                        CHARGEMODE q_try_;
149
 
      /// amount of debug information displayed
150
 
      Int verbose_level_;
 
61
public:
 
62
 
 
63
    enum CHARGEMODE {QFROMFEATURE = 1, QHEURISTIC, QALL};
 
64
 
 
65
    typedef FeatureMap<> FeatureMapType;
 
66
    typedef Feature FeatureType;
 
67
    typedef DPosition<2> ClusterPointType;
 
68
    typedef FeatureMapType::FeatureType::CoordinateType CoordinateType;
 
69
    typedef ILPDCWrapper::PairsType PairsType;
 
70
 
 
71
    /** @name Constructors and Destructor s
 
72
    */
 
73
    //@{
 
74
    /// default constructor
 
75
    FeatureDeconvolution();
 
76
 
 
77
    /// Copy constructor
 
78
    FeatureDeconvolution(const FeatureDeconvolution & source);
 
79
 
 
80
    /// Assignment operator
 
81
    FeatureDeconvolution & operator=(const FeatureDeconvolution & source);
 
82
 
 
83
    /// destructor
 
84
    virtual ~FeatureDeconvolution();
 
85
    //@}
 
86
 
 
87
    /**
 
88
               @brief Compute a zero-charge feature map from a set of charged features
 
89
 
 
90
               Find putative ChargePairs, then score them and hand over to ILP.
 
91
 
 
92
               @param fm_in  Input feature-map
 
93
               @param fm_out Output feature-map (sorted by position and augmented with user params)
 
94
               @param cons_map   [out] Output of grouped features belonging to a charge group
 
95
               @param cons_map_p [out] Output of paired features connected by an edge
 
96
          */
 
97
    void compute(const FeatureMapType & fm_in, FeatureMapType & fm_out, ConsensusMap & cons_map, ConsensusMap & cons_map_p);
 
98
 
 
99
protected:
 
100
 
 
101
    void updateMembers_();
 
102
 
 
103
    /**
 
104
        @brief 1-sided Compomer for a feature
 
105
 
 
106
        Holds information on an explicit (with H+) 1-sided Compomer of a feature.
 
107
    **/
 
108
    struct CmpInfo_;
 
109
 
 
110
    /*
 
111
      @brief test for obviously wrong parameter settings and warn
 
112
 
 
113
      Currently supports the following scenarios:
 
114
       * If the lower charge bound is too high, consensus features with gapped, even charges will occur (e.g. 30,32,34), instead of the true (15,16,17)
 
115
         When more than 5% of the cf's look like this, we report it.
 
116
 
 
117
    */
 
118
    void checkSolution_(const ConsensusMap & cons_map) const;
 
119
 
 
120
    /// test if "simple" edges have alternative
 
121
    /// (more difficult explanation) supported by neighboring edges
 
122
    /// e.g. (.)   -> (H+) might be augmented to
 
123
    ///      (Na+) -> (H+Na+)
 
124
    void inferMoreEdges_(PairsType & edges, Map<Size, std::set<CmpInfo_> > & feature_adducts);
 
125
 
 
126
    /// A function mostly for debugging
 
127
    void printEdgesOfConnectedFeatures_(Size idx_1, Size idx_2, const PairsType & feature_relation);
 
128
 
 
129
    /**
 
130
        @brief returns true if the intensity filter was passed or switched off
 
131
 
 
132
        Filter for adding an edge only when the two features connected by it, fulfill the
 
133
        intensity criterion.
 
134
 
 
135
    **/
 
136
    inline bool intensityFilterPassed_(const Int q1, const Int q2, const Compomer & cmp, const FeatureType & f1, const FeatureType & f2);
 
137
 
 
138
    /**
 
139
        @brief determines if we should test a putative feature charge
 
140
 
 
141
        Answer query given the internal status of @em q_try.
 
142
        Features with q<=0 always return true.
 
143
 
 
144
    **/
 
145
    bool chargeTestworthy_(const Int feature_charge, const Int putative_charge, const bool other_unchanged) const;
 
146
 
 
147
    /// List of adducts used to explain mass differences
 
148
    MassExplainer::AdductsType potential_adducts_;
 
149
    /// labeling table
 
150
    Map<Size, String> map_label_;
 
151
    /// labeling table inverse
 
152
    Map<String, Size> map_label_inverse_;
 
153
    /// status of intensity filter for edges
 
154
    bool enable_intensity_filter_;
 
155
    /// status of charge discovery
 
156
    CHARGEMODE q_try_;
 
157
    /// amount of debug information displayed
 
158
    Int verbose_level_;
151
159
 
152
160
  };
153
161
} // namespace OpenMS
154
162
 
155
163
#endif // OPENMS_ANALYSIS_DECHARGING_FEATUREDECONVOLUTION_H
156