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

« back to all changes in this revision

Viewing changes to source/CHEMISTRY/WeightWrapper.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2012-11-12 15:58:12 UTC
  • Revision ID: package-import@ubuntu.com-20121112155812-vr15wtg9b50cuesg
Tags: upstream-1.9.0
ImportĀ upstreamĀ versionĀ 1.9.0

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: Chris Bielow $
 
25
// $Authors: Chris Bielow $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/CHEMISTRY/WeightWrapper.h>
 
29
 
 
30
namespace OpenMS{
 
31
        
 
32
        WeightWrapper::WeightWrapper()
 
33
        :weight_mode_(MONO)
 
34
        {
 
35
        }
 
36
 
 
37
        WeightWrapper::WeightWrapper(const WEIGHTMODE weight_mode)
 
38
        :weight_mode_(weight_mode)
 
39
        {
 
40
        }
 
41
 
 
42
        WeightWrapper::WeightWrapper(const WeightWrapper& source)
 
43
         : weight_mode_(source.weight_mode_) 
 
44
        {
 
45
        }
 
46
        
 
47
        WeightWrapper::~WeightWrapper()
 
48
        {
 
49
        }
 
50
        
 
51
        void WeightWrapper::setWeightMode(const WEIGHTMODE mode)
 
52
        {
 
53
                if (mode >= WeightWrapper::SIZE_OF_WEIGHTMODE) throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__, "setWeightMode() received illegal 'mode' value!");
 
54
                weight_mode_ = mode;
 
55
        }
 
56
 
 
57
        WeightWrapper::WEIGHTMODE WeightWrapper::getWeightMode() const
 
58
        {
 
59
                return weight_mode_;
 
60
        }
 
61
 
 
62
        DoubleReal WeightWrapper::getWeight(const AASequence& aa) const
 
63
        {
 
64
                if (weight_mode_==WeightWrapper::MONO) return aa.getMonoWeight();
 
65
                else return aa.getAverageWeight();
 
66
        }
 
67
        
 
68
        DoubleReal WeightWrapper::getWeight(const EmpiricalFormula& ef) const
 
69
        {
 
70
                if (weight_mode_==WeightWrapper::MONO) return ef.getMonoWeight();
 
71
                else return ef.getAverageWeight();
 
72
        }
 
73
        
 
74
 
 
75
        DoubleReal WeightWrapper::getWeight(const Residue& r, Residue::ResidueType res_type) const
 
76
        {
 
77
                if (weight_mode_==WeightWrapper::MONO) return r.getMonoWeight(res_type);
 
78
                else return r.getAverageWeight(res_type);
 
79
        }
 
80
 
 
81
}