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

« back to all changes in this revision

Viewing changes to source/CHEMISTRY/Residue.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: Andreas Bertsch $
 
25
// $Authors: Andreas Bertsch $
 
26
// --------------------------------------------------------------------------
 
27
//
 
28
 
 
29
#include <OpenMS/CHEMISTRY/Residue.h>
 
30
#include <OpenMS/CHEMISTRY/ResidueModification.h>
 
31
#include <OpenMS/CHEMISTRY/ModificationsDB.h>
 
32
#include <cstdlib>
 
33
 
 
34
using namespace std;
 
35
 
 
36
namespace OpenMS
 
37
{
 
38
        // residue
 
39
        Residue::Residue()
 
40
                : name_("unknown"),
 
41
                        average_weight_(0.0f),
 
42
                        mono_weight_(0.0f),
 
43
                        is_modified_(false),
 
44
                        modification_(""),
 
45
                        loss_average_weight_(0.0f),
 
46
                        loss_mono_weight_(0.0f),
 
47
                        pka_(0.0),
 
48
                        pkb_(0.0),
 
49
                        pkc_(-1.0)
 
50
        {
 
51
        }
 
52
 
 
53
        Residue::Residue(       const String& name,
 
54
                                                                                const String& three_letter_code,
 
55
                                                                                const String& one_letter_code,
 
56
                                                                                const EmpiricalFormula& formula)
 
57
                :       name_(name),
 
58
                        three_letter_code_(three_letter_code),
 
59
                        one_letter_code_(one_letter_code),
 
60
                        formula_(formula),
 
61
                        average_weight_(0),
 
62
                        mono_weight_(0),
 
63
                        is_modified_(false),
 
64
                        modification_(""),
 
65
                        loss_average_weight_(0.0f),
 
66
                        loss_mono_weight_(0.0f),
 
67
                        pka_(0.0),
 
68
                        pkb_(0.0),
 
69
                        pkc_(-1.0),
 
70
                        gb_sc_(0.0),
 
71
                        gb_bb_l_(0.0),
 
72
                        gb_bb_r_(0.0)
 
73
        {
 
74
                if (formula_ != "")
 
75
                {
 
76
                        internal_formula_ = formula_ - getInternalToFull();
 
77
                }
 
78
        }
 
79
 
 
80
        Residue::Residue(const Residue& residue)
 
81
                : name_(residue.name_),
 
82
                        short_name_(residue.short_name_),
 
83
                        synonyms_(residue.synonyms_),
 
84
                        three_letter_code_(residue.three_letter_code_),
 
85
                        one_letter_code_(residue.one_letter_code_),
 
86
                        formula_(residue.formula_),
 
87
                        internal_formula_(residue.internal_formula_),
 
88
                        average_weight_(residue.average_weight_),
 
89
                        mono_weight_(residue.mono_weight_),
 
90
                        is_modified_(residue.is_modified_),
 
91
                        pre_mod_name_(residue.pre_mod_name_),
 
92
                        modification_(residue.modification_),
 
93
                        loss_names_(residue.loss_names_),
 
94
                        loss_formulas_(residue.loss_formulas_),
 
95
                        NTerm_loss_names_(residue.NTerm_loss_names_),
 
96
                        NTerm_loss_formulas_(residue.NTerm_loss_formulas_),
 
97
                        loss_average_weight_(residue.loss_average_weight_),
 
98
                        loss_mono_weight_(residue.loss_mono_weight_),
 
99
                        low_mass_ions_(residue.low_mass_ions_),
 
100
                        pka_(residue.pka_),
 
101
                        pkb_(residue.pkb_),
 
102
                        pkc_(residue.pkc_),
 
103
                        gb_sc_(residue.gb_sc_),
 
104
                        gb_bb_l_(residue.gb_bb_l_),
 
105
                        gb_bb_r_(residue.gb_bb_r_),
 
106
                        residue_sets_(residue.residue_sets_)
 
107
        {
 
108
        }
 
109
        
 
110
        Residue::~Residue()
 
111
        {
 
112
        }
 
113
 
 
114
        Residue& Residue::operator = (const Residue& residue)
 
115
        {
 
116
                if (this != &residue)
 
117
                {
 
118
                        name_ = residue.name_;
 
119
                        short_name_ = residue.short_name_;
 
120
                        synonyms_ = residue.synonyms_;
 
121
                        three_letter_code_ = residue.three_letter_code_;
 
122
                        one_letter_code_ = residue.one_letter_code_;
 
123
                        formula_ = residue.formula_;
 
124
                        internal_formula_ = residue.internal_formula_;
 
125
                        average_weight_ = residue.average_weight_;
 
126
                        mono_weight_ = residue.mono_weight_;
 
127
                        is_modified_ = residue.is_modified_;
 
128
                        pre_mod_name_ = residue.pre_mod_name_;
 
129
                        modification_ = residue.modification_;
 
130
                        loss_names_ = residue.loss_names_;
 
131
                        loss_formulas_ = residue.loss_formulas_;
 
132
                        NTerm_loss_names_ = residue.NTerm_loss_names_;
 
133
                        NTerm_loss_formulas_ = residue.NTerm_loss_formulas_;
 
134
                        loss_average_weight_ = residue.loss_average_weight_;
 
135
                        loss_mono_weight_ = residue.loss_mono_weight_;
 
136
                        low_mass_ions_ = residue.low_mass_ions_;
 
137
                        pka_ = residue.pka_;
 
138
                        pkb_ = residue.pkb_;
 
139
                        pkc_ = residue.pkc_;
 
140
                        gb_sc_ = residue.gb_sc_;
 
141
                        gb_bb_l_ = residue.gb_bb_l_;
 
142
                        gb_bb_r_ = residue.gb_bb_r_;
 
143
                        residue_sets_ = residue.residue_sets_;
 
144
                }
 
145
                return *this;
 
146
        }
 
147
 
 
148
        void Residue::setName(const String& name)
 
149
        {
 
150
                name_ = name;
 
151
        }
 
152
 
 
153
        const String& Residue::getName() const
 
154
        {
 
155
                return name_;
 
156
        }
 
157
 
 
158
        String Residue::getResidueTypeName(const Residue::ResidueType res_type)
 
159
        {
 
160
                String ion("-ion");
 
161
                switch (res_type)
 
162
                {
 
163
                case Residue::Full:
 
164
                        return "full";
 
165
                  case Residue::Internal:
 
166
                          return "internal";
 
167
                  case Residue::NTerminal:
 
168
                          return "N-terminal";
 
169
                  case Residue::CTerminal:
 
170
                          return "C-terminal";
 
171
                        case Residue::AIon:
 
172
                                return "a" + ion;
 
173
                        case Residue::BIon:
 
174
                                return "b" + ion;
 
175
                        case Residue::CIon:
 
176
                                return "c" + ion;
 
177
                        case Residue::CIonMinusOne:
 
178
                                return "c-1" + ion;
 
179
                        case Residue::CIonPlusOne:
 
180
                                return "c+1" + ion;
 
181
                        case Residue::CIonPlusTwo:
 
182
                                return "c+2" + ion;
 
183
                        case Residue::XIon:
 
184
                                return "x" + ion;
 
185
                        case Residue::YIon:
 
186
                                return "y" + ion;
 
187
                        case Residue::ZIon:
 
188
                                return "z" + ion;
 
189
                        case Residue::ZIonMinusOne:
 
190
                                return "z-1" + ion;
 
191
                        case Residue::ZIonPlusOne:
 
192
                                return "z+1" + ion;
 
193
                        case Residue::ZIonPlusTwo:
 
194
                                return "z+2" + ion;
 
195
                        default:
 
196
                                cerr << "Residue::getResidueTypeName: residue type has no name" << endl;
 
197
                }
 
198
                return "";
 
199
        }
 
200
 
 
201
        void Residue::setShortName(const String& short_name)
 
202
        {
 
203
                short_name_ = short_name;
 
204
        }
 
205
 
 
206
        const String& Residue::getShortName() const
 
207
        {
 
208
                return short_name_;
 
209
        }
 
210
 
 
211
        void Residue::setSynonyms(const set<String>& synonyms)
 
212
        {
 
213
                synonyms_ = synonyms;
 
214
        }
 
215
 
 
216
        void Residue::addSynonym(const String& synonym)
 
217
        {
 
218
                synonyms_.insert(synonym);
 
219
        }
 
220
        
 
221
        const set<String>& Residue::getSynonyms() const
 
222
        {
 
223
                return synonyms_;
 
224
        }
 
225
        
 
226
        void Residue::setThreeLetterCode(const String& three_letter_code)
 
227
        {
 
228
                three_letter_code_ = three_letter_code;
 
229
        }
 
230
 
 
231
        const String& Residue::getThreeLetterCode() const
 
232
        {
 
233
                return three_letter_code_;
 
234
        }
 
235
 
 
236
        void Residue::setOneLetterCode(const String& one_letter_code)
 
237
        {
 
238
                one_letter_code_ = one_letter_code;
 
239
        }
 
240
 
 
241
        const String& Residue::getOneLetterCode() const
 
242
        {
 
243
                return one_letter_code_;
 
244
        }
 
245
 
 
246
        DoubleReal Residue::getPka() const
 
247
        {
 
248
                return pka_;
 
249
        }
 
250
 
 
251
        DoubleReal Residue::getPkb() const
 
252
        {
 
253
                return pkb_;
 
254
        }
 
255
 
 
256
        DoubleReal Residue::getPkc() const
 
257
        {
 
258
                return pkc_;
 
259
        }
 
260
 
 
261
        DoubleReal Residue::getPiValue() const
 
262
        {
 
263
                DoubleReal temp1 = 0.0;
 
264
                DoubleReal temp2 = 0.0;
 
265
                DoubleReal temp3 = 0.0;
 
266
                DoubleReal pi = 0;
 
267
                
 
268
                temp1 = getPka();
 
269
                temp2 = getPkb();
 
270
                temp3 = getPkc();
 
271
                                
 
272
                if (temp3 >= 0 && temp3 < temp1)
 
273
                {                       
 
274
                        pi = (temp3 + temp2) / 2;
 
275
                }
 
276
                else if (temp3 >= temp2)
 
277
                {                       
 
278
                        pi = (temp1 + temp3) / 2;
 
279
                }
 
280
                else
 
281
                {
 
282
                        pi = (temp1 + temp2) / 2;
 
283
                }
 
284
                
 
285
                return pi;
 
286
        }
 
287
 
 
288
        void Residue::setPka(DoubleReal value)
 
289
        {
 
290
                pka_ = value;
 
291
        }
 
292
 
 
293
        void Residue::setPkb(DoubleReal value)
 
294
        {
 
295
                pkb_ = value;
 
296
        }
 
297
 
 
298
        void Residue::setPkc(DoubleReal value)
 
299
        {
 
300
                pkc_ = value;
 
301
        }
 
302
 
 
303
        void Residue::setLossFormulas(const vector<EmpiricalFormula>& loss_formulas)
 
304
        {
 
305
                loss_formulas_ = loss_formulas;
 
306
        }
 
307
 
 
308
        void Residue::addLossFormula(const EmpiricalFormula& loss_formula)
 
309
        {
 
310
                loss_formulas_.push_back(loss_formula);
 
311
        }
 
312
        
 
313
        const vector<EmpiricalFormula>& Residue::getLossFormulas() const
 
314
        {
 
315
                return loss_formulas_;
 
316
        }
 
317
 
 
318
        void Residue::addLossName(const String& name)
 
319
        {
 
320
                loss_names_.push_back(name);
 
321
        }
 
322
        
 
323
        void Residue::setLossNames(const vector<String>& names)
 
324
        {
 
325
                loss_names_ = names;
 
326
        }
 
327
 
 
328
        const vector<String>& Residue::getLossNames() const
 
329
        {
 
330
                return loss_names_;
 
331
        }
 
332
 
 
333
 
 
334
  void Residue::setNTermLossFormulas(const vector<EmpiricalFormula>& NTerm_loss_formulas)
 
335
  {
 
336
    NTerm_loss_formulas_ = NTerm_loss_formulas;
 
337
  }
 
338
 
 
339
  void Residue::addNTermLossFormula(const EmpiricalFormula& NTerm_loss_formula)
 
340
  {
 
341
    NTerm_loss_formulas_.push_back(NTerm_loss_formula);
 
342
  }
 
343
 
 
344
  const vector<EmpiricalFormula>& Residue::getNTermLossFormulas() const
 
345
  {
 
346
    return NTerm_loss_formulas_;
 
347
  }
 
348
 
 
349
  void Residue::addNTermLossName(const String& name)
 
350
  {
 
351
    NTerm_loss_names_.push_back(name);
 
352
  }
 
353
 
 
354
  void Residue::setNTermLossNames(const vector<String>& names)
 
355
  {
 
356
    NTerm_loss_names_ = names;
 
357
  }
 
358
 
 
359
  const vector<String>& Residue::getNTermLossNames() const
 
360
  {
 
361
    return NTerm_loss_names_;
 
362
  }
 
363
        
 
364
        
 
365
        void Residue::setFormula(const EmpiricalFormula& formula)
 
366
        {
 
367
                formula_ = formula; 
 
368
                internal_formula_ = formula_ - getInternalToFull();
 
369
        }
 
370
 
 
371
        EmpiricalFormula Residue::getFormula(ResidueType res_type) const
 
372
        {
 
373
                switch (res_type)
 
374
                {
 
375
                        case Full:
 
376
                                return formula_;
 
377
                        case Internal:
 
378
                                return internal_formula_;
 
379
                        case NTerminal:
 
380
                                return formula_ - getNTerminalToFull();
 
381
                        case CTerminal:
 
382
                                return formula_ - getCTerminalToFull();
 
383
                        case BIon:
 
384
                                return formula_ - getBIonToFull();
 
385
                        case AIon:
 
386
                                return formula_ - getAIonToFull();
 
387
                        case CIonMinusOne:
 
388
                                return formula_ - getCIonMinusOneToFull();
 
389
                        case CIon:
 
390
                                return formula_ - EmpiricalFormula("OH") + EmpiricalFormula("NH");
 
391
                        case XIon:
 
392
                                return formula_ + getXIonToFull();
 
393
                        case YIon:
 
394
                                return formula_ + getYIonToFull();
 
395
                        case ZIonMinusOne:
 
396
                                        return formula_ - getZIonMinusOneToFull();
 
397
                        case ZIon:
 
398
                                return formula_ - getZIonToFull();
 
399
                        case ZIonPlusOne:
 
400
                                return formula_ - getZIonPlusOneToFull();
 
401
                        case ZIonPlusTwo:
 
402
                                return formula_ - getZIonPlusTwoToFull();
 
403
                        default:
 
404
                                cerr << "Residue::getFormula: unknown ResidueType" << endl;
 
405
                                return formula_;
 
406
                }
 
407
        }
 
408
 
 
409
        void Residue::setAverageWeight(DoubleReal weight) 
 
410
        {
 
411
                average_weight_ = weight;
 
412
                return;
 
413
        }
 
414
 
 
415
        DoubleReal Residue::getAverageWeight(ResidueType res_type) const
 
416
        {
 
417
                switch (res_type)
 
418
                {
 
419
                        case Full:
 
420
                                return average_weight_;
 
421
                        case Internal:
 
422
                                return average_weight_ - getInternalToFullAverageWeight();
 
423
                        case NTerminal:
 
424
                                return average_weight_ - getNTerminalToFullAverageWeight();
 
425
                        case CTerminal:
 
426
                                return average_weight_ - getCTerminalToFullAverageWeight();
 
427
                        case BIon:
 
428
                                return average_weight_ - getBIonToFullAverageWeight();
 
429
                        case AIon:
 
430
                                return average_weight_ - getAIonToFullAverageWeight();
 
431
                        case CIonMinusOne:
 
432
                                return average_weight_ - getCIonMinusOneToFullAverageWeight();
 
433
                        case CIon:
 
434
                                return average_weight_ - EmpiricalFormula("OH").getAverageWeight() + EmpiricalFormula("NH").getAverageWeight();
 
435
                        case CIonPlusOne:
 
436
                                return average_weight_ - getCIonPlusOneToFullAverageWeight();
 
437
                        case CIonPlusTwo:
 
438
                                return average_weight_ - getCIonPlusTwoToFullAverageWeight();
 
439
                        case XIon:
 
440
                                return average_weight_ + getXIonToFullAverageWeight();
 
441
                        case YIon:
 
442
                                return average_weight_ + getYIonToFullAverageWeight();
 
443
                        case ZIonMinusOne:
 
444
                                return average_weight_ - getZIonMinusOneToFullAverageWeight();
 
445
                        case ZIon:
 
446
                                return average_weight_ - getZIonToFullAverageWeight();
 
447
                        case ZIonPlusOne:
 
448
                                return average_weight_ - getZIonPlusOneToFullAverageWeight();
 
449
                        case ZIonPlusTwo:
 
450
                                return average_weight_ - getZIonPlusTwoToFullAverageWeight();
 
451
                        default:
 
452
                                cerr << "Residue::getAverageWeight: unknown ResidueType" << endl;
 
453
                                return average_weight_;
 
454
                }
 
455
        }
 
456
 
 
457
        void Residue::setMonoWeight(DoubleReal weight)
 
458
        {
 
459
                mono_weight_ = weight;
 
460
                return;
 
461
        }
 
462
 
 
463
        DoubleReal Residue::getMonoWeight(ResidueType res_type) const
 
464
        {
 
465
                switch (res_type)
 
466
                {
 
467
                        case Full:
 
468
                                return mono_weight_;
 
469
                        case Internal:
 
470
                                return mono_weight_ - getInternalToFullMonoWeight();
 
471
                        case NTerminal:
 
472
                                return mono_weight_ - getNTerminalToFullMonoWeight();
 
473
                        case CTerminal:
 
474
                                return mono_weight_ - getCTerminalToFullMonoWeight();
 
475
                        case BIon:
 
476
                                return mono_weight_ - getBIonToFullMonoWeight();
 
477
                        case AIon:
 
478
                                return mono_weight_ - getAIonToFullMonoWeight();
 
479
                        case CIonMinusOne:
 
480
                                return mono_weight_ - getCIonMinusOneToFullMonoWeight();
 
481
                        case CIon:
 
482
                                return mono_weight_ - EmpiricalFormula("OH").getMonoWeight() + EmpiricalFormula("NH").getMonoWeight();
 
483
                        case CIonPlusOne:
 
484
                                return mono_weight_ - getCIonPlusOneToFullMonoWeight();
 
485
                        case CIonPlusTwo:
 
486
                                return mono_weight_ - getCIonPlusTwoToFullMonoWeight();
 
487
                        case XIon:
 
488
                                return mono_weight_ + getXIonToFullMonoWeight();
 
489
                        case YIon:
 
490
                                return mono_weight_ + getYIonToFullMonoWeight();
 
491
        case ZIonMinusOne:
 
492
        return mono_weight_ - getZIonMinusOneToFullMonoWeight();
 
493
                        case ZIon:
 
494
                                return mono_weight_ - getZIonToFullMonoWeight();
 
495
      case ZIonPlusOne:
 
496
        return mono_weight_ - getZIonPlusOneToFullMonoWeight();
 
497
      case ZIonPlusTwo:
 
498
        return mono_weight_ - getZIonPlusTwoToFullMonoWeight();
 
499
                        default:
 
500
                                cerr << "Residue::getMonoWeight: unknown ResidueType" << endl;
 
501
                                return mono_weight_;
 
502
                }
 
503
        }
 
504
 
 
505
        void Residue::setModification(const String& modification)
 
506
        {
 
507
                //modification_ = modification;
 
508
 
 
509
                ModificationsDB* mod_db = ModificationsDB::getInstance();
 
510
                ResidueModification mod = mod_db->getModification(one_letter_code_, modification, ResidueModification::ANYWHERE);
 
511
 
 
512
                modification_ = mod.getId();
 
513
                // update all the members
 
514
                if (mod.getAverageMass() != 0)
 
515
                {
 
516
                        average_weight_ = mod.getAverageMass();
 
517
                }
 
518
                if (mod.getMonoMass() != 0)
 
519
                {
 
520
                        mono_weight_ = mod.getMonoMass();
 
521
                }
 
522
 
 
523
                bool updated_formula(false);
 
524
                if (mod.getDiffFormula() != "")
 
525
                {
 
526
                        updated_formula = true;
 
527
                        setFormula(getFormula() + mod.getDiffFormula());
 
528
                }
 
529
                if (mod.getFormula() != "" && !updated_formula)
 
530
                {
 
531
                        updated_formula = true;
 
532
                        String formula = mod.getFormula();
 
533
                        formula.removeWhitespaces();
 
534
                        formula_ = formula;
 
535
                }
 
536
                
 
537
                if (updated_formula)
 
538
                {
 
539
                        average_weight_ = formula_.getAverageWeight();
 
540
                        mono_weight_ = formula_.getMonoWeight();
 
541
                }
 
542
                else
 
543
                {
 
544
                        if (mod.getAverageMass() != 0)
 
545
                        {
 
546
                                average_weight_ = mod.getAverageMass();
 
547
                        }
 
548
                        if (mod.getMonoMass() != 0)
 
549
                        {
 
550
                                mono_weight_ = mod.getMonoMass();
 
551
                        }
 
552
                }
 
553
        
 
554
                // neutral losses
 
555
                loss_formulas_.clear();
 
556
                loss_names_.clear();
 
557
                if (mod.hasNeutralLoss())
 
558
                {
 
559
                        loss_formulas_.push_back(mod.getNeutralLossDiffFormula());
 
560
                        loss_names_.push_back(mod.getNeutralLossDiffFormula().getString());
 
561
                }
 
562
 
 
563
                is_modified_ = true;
 
564
        }
 
565
        
 
566
        const String& Residue::getModification() const
 
567
        {
 
568
                return modification_;
 
569
        }
 
570
 
 
571
        void Residue::setLowMassIons(const vector<EmpiricalFormula>& low_mass_ions)
 
572
        {
 
573
                low_mass_ions_ = low_mass_ions;
 
574
        }
 
575
 
 
576
        const vector<EmpiricalFormula>& Residue::getLowMassIons() const
 
577
        {
 
578
                return low_mass_ions_;
 
579
        }
 
580
 
 
581
        DoubleReal Residue::getBackboneBasicityRight() const
 
582
        {
 
583
                return gb_bb_r_;
 
584
        }
 
585
 
 
586
        void Residue::setBackboneBasicityRight(DoubleReal gb_bb_r)
 
587
        {
 
588
                gb_bb_r_ = gb_bb_r;
 
589
        }
 
590
 
 
591
        DoubleReal Residue::getBackboneBasicityLeft() const
 
592
        {
 
593
                return gb_bb_l_;
 
594
        }
 
595
 
 
596
        void Residue::setBackboneBasicityLeft(DoubleReal gb_bb_l)
 
597
        {
 
598
                gb_bb_l_ = gb_bb_l;
 
599
        }
 
600
 
 
601
        DoubleReal Residue::getSideChainBasicity() const
 
602
        {
 
603
                return gb_sc_;
 
604
        }
 
605
 
 
606
        void Residue::setSideChainBasicity(DoubleReal gb_sc)
 
607
        {
 
608
                gb_sc_ = gb_sc;
 
609
        }
 
610
 
 
611
        void Residue::setResidueSets(const set<String>& residue_sets)
 
612
        {
 
613
                residue_sets_ = residue_sets;
 
614
        }
 
615
 
 
616
        const set<String>& Residue::getResidueSets() const
 
617
        {
 
618
                return residue_sets_;
 
619
        }
 
620
 
 
621
        void Residue::addResidueSet(const String& residue_set)
 
622
        {
 
623
                residue_sets_.insert(residue_set);
 
624
        }
 
625
 
 
626
        bool Residue::isModified() const
 
627
        {
 
628
                return is_modified_;
 
629
        }
 
630
        
 
631
        bool Residue::hasNeutralLoss() const
 
632
        {
 
633
    return ( !loss_formulas_.empty() );
 
634
        }
 
635
 
 
636
        bool Residue::hasNTermNeutralLosses() const
 
637
  {
 
638
    return ( !NTerm_loss_formulas_.empty() );
 
639
        }
 
640
        
 
641
        bool Residue::operator == (const Residue& residue) const
 
642
        {
 
643
                return (name_ == residue.name_ &&
 
644
                                                short_name_ == residue.short_name_ &&
 
645
                                                synonyms_ == residue.synonyms_ &&
 
646
                                                three_letter_code_ == residue.three_letter_code_ &&
 
647
                                                one_letter_code_ == residue.one_letter_code_ &&
 
648
                                                formula_ == residue.formula_ &&
 
649
                                                average_weight_ == residue.average_weight_ &&
 
650
                                                mono_weight_ == residue.mono_weight_ &&
 
651
                                                is_modified_ == residue.is_modified_ &&
 
652
                                                pre_mod_name_ == residue.pre_mod_name_ &&
 
653
                                                modification_ == residue.modification_ &&
 
654
                                                loss_names_ == residue.loss_names_ &&
 
655
                                                loss_formulas_ == residue.loss_formulas_ &&
 
656
                                                NTerm_loss_names_ == residue.NTerm_loss_names_ &&
 
657
                                                NTerm_loss_formulas_ == residue.NTerm_loss_formulas_ &&
 
658
                                                loss_average_weight_ == residue.loss_average_weight_ &&
 
659
                                                loss_mono_weight_ == residue.loss_mono_weight_ &&
 
660
                                                low_mass_ions_ == residue.low_mass_ions_ &&
 
661
                                                pka_ == residue.pka_ &&
 
662
                                                pkb_ == residue.pkb_ &&
 
663
                                                pkc_ == residue.pkc_ &&
 
664
                                                gb_sc_ == residue.gb_sc_ &&
 
665
                                                gb_bb_l_ == residue.gb_bb_l_ &&
 
666
                                                gb_bb_r_ == residue.gb_bb_r_ &&
 
667
                                                residue_sets_ == residue.residue_sets_);
 
668
        }
 
669
 
 
670
        bool Residue::operator == (char one_letter_code) const
 
671
        {
 
672
                return one_letter_code_[0] == one_letter_code;
 
673
        }
 
674
 
 
675
        bool Residue::operator != (char one_letter_code) const
 
676
        {
 
677
                return one_letter_code_[0] != one_letter_code;
 
678
        }
 
679
 
 
680
        bool Residue::operator != (const Residue& residue) const
 
681
        {
 
682
                return !(*this == residue);
 
683
        }
 
684
 
 
685
        bool Residue::isInResidueSet(const String& residue_set)
 
686
        {
 
687
                return residue_sets_.find(residue_set) != residue_sets_.end();
 
688
        }
 
689
 
 
690
        ostream& operator << (ostream& os, const Residue& residue) 
 
691
        {
 
692
                os << residue.name_ << " "
 
693
                         << residue.three_letter_code_ << " "
 
694
                         << residue.one_letter_code_ << " "
 
695
                         << residue.formula_;
 
696
                return os;
 
697
        }
 
698
 
 
699
}
 
700