NCBI C++ ToolKit
MSModSpecSet.cpp
Go to the documentation of this file.

Go to the repository for this file.

1 /* $Id: MSModSpecSet.cpp 44472 2010-01-16 15:38:33Z lewisg $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'omssa.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
40 
41 // generated includes
43 
44 
45 #define NCBI_USE_ERRCODE_X Objects_Omssa
46 
47 // generated classes
48 
50 
51 BEGIN_objects_SCOPE // namespace ncbi::objects::
52 
53 // destructor
55 {
56 }
57 
58 //! creates arrays for the existing set
60 {
61  int i;
62  for(i=0; i < eMSMod_max; ++i)
63  ModMass[i] = 0;
64 
65  Tdata::const_iterator iMods;
66  for(iMods = Get().begin(); iMods != Get().end(); ++iMods) {
67  int ModNum = (*iMods)->GetMod();
68  if(ModNum >= eMSMod_max){
69  ERR_POST_X(1, Warning <<
70  "CMSModSpecSet::CreateArrays modification number unknown");
71  continue;
72  }
73  // ignore unspecified mods
74  if((*iMods)->GetMonomass() == 0.0) {
75  continue;
76  }
77 
78  ModTypes[ModNum] = static_cast <EMSModType> ((*iMods)->GetType());
79  ModMass[ModNum] = MSSCALE2INT((*iMods)->GetMonomass());
80 
81  // set up neutral loss if specified
82  if((*iMods)->CanGetNeutralloss())
83  NeutralLoss[ModNum] = MSSCALE2INT
84  ((*iMods)->GetMonomass() -
85  (*iMods)->GetNeutralloss().GetMonomass());
86  else
87  NeutralLoss[ModNum] = ModMass[ModNum];
88 
89  strncpy(ModNames[ModNum], (*iMods)->GetName().c_str(), kMaxNameSize - 1);
90  // make sure name is null terminated
91  ModNames[ModNum][kMaxNameSize-1] = '\0';
92 
93  if ((*iMods)->CanGetPsi_ms()) {
94  strncpy(UnimodNames[ModNum], (*iMods)->GetPsi_ms().c_str(), kMaxNameSize - 1);
95  } else {
96  strncpy(UnimodNames[ModNum], (*iMods)->GetName().c_str(), kMaxNameSize - 1);
97  }
98 
99  // make sure name is null terminated
100  UnimodNames[ModNum][kMaxNameSize-1] = '\0';
101 
102  int iChars(0);
103  CMSModSpec::TResidues::const_iterator iRes;
104  // loop thru chars
105  for(iRes = (*iMods)->GetResidues().begin(); iRes != (*iMods)->GetResidues().end(); ++iRes) {
106  if (iChars >= kMaxAAs) {
107  ERR_POST_X(2, Warning <<
108  "CMSModSpecSet::CreateArrays too many AAs in mod " <<
109  ModNum);
110  break;
111  }
112  if(strchr(UniqueAA, (*iRes)[0]) != 0)
113  ModChar[ModNum][iChars] = strchr(UniqueAA, (*iRes)[0]) - UniqueAA;
114  else {
115  ERR_POST_X(3, Warning <<
116  "CMSModSpecSet::CreateArrays unknown AA " <<
117  (*iRes) << " specified for mod " << ModNum);
118  break;
119  }
120 
121  iChars++;
122  }
123  NumModChars[ModNum] = iChars;
124  }
125  isArrayed = true;
126 }
127 
128 //! concatenates in another CMSModSpecSet
130 {
131  CMSModSpecSet::Tdata::const_iterator i;
132  if(ModsIn.CanGet()) {
133  for(i = ModsIn.Get().begin(); i != ModsIn.Get().end(); ++i) {
134  Set().push_back(*i);
135  }
136  }
137 }
138 
139 
140 END_objects_SCOPE // namespace ncbi::objects::
141 
143 
144 #undef NCBI_USE_ERRCODE_X
145 
146 /* Original file checksum: lines: 65, chars: 1896, CRC32: ed716b4 */
const char *const UniqueAA
Definition: MSMod.hpp:58
#define MSSCALE2INT(x)
Definition: MSMod.hpp:64
@MSModSpecSet.hpp User-defined methods of the data storage class.
static const int kMaxNameSize
the maximum size of an modification friendly name
~CMSModSpecSet(void)
char ModChar[eMSMod_max][kMaxAAs]
the AA's affected
void Append(const CMSModSpecSet &ModsIn)
concatenates in another CMSModSpecSet
int NeutralLoss[eMSMod_max]
the integer scaled mass of the neutral loss
int NumModChars[eMSMod_max]
the number of AA's affected
EMSModType ModTypes[eMSMod_max]
categorizes existing mods as the types EMSModType
int ModMass[eMSMod_max]
the integer scaled mass of the mod
void CreateArrays(void)
creates arrays for the existing set
char ModNames[eMSMod_max][kMaxNameSize]
friendly names
bool isArrayed
Have the arrays been intialized?
static const int kMaxAAs
the maximum number of AA's a modification can affect
char UnimodNames[eMSMod_max][kMaxNameSize]
friendly names
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:548
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:104
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:101
Tdata & Set(void)
Assign a value to data member.
const Tdata & Get(void) const
Get the member data.
bool CanGet(void) const
Check if it is safe to call Get method.
EMSModType
enumerate modification types
Definition: MSModType_.hpp:64
@ eMSMod_max
maximum number of mods
Definition: MSMod_.hpp:296
Definition of all error codes used in objects libraries.
int i
Modified on Sat Nov 14 14:32:15 2026 by modify_doxy.py rev. 717554