Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
LCMS.h
Go to the documentation of this file.
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: Florian Zeller $
32 // $Authors: Lukas Mueller, Markus Mueller $
33 // --------------------------------------------------------------------------
34 //
36 //
37 // written by Lukas N Mueller, 30.3.05
38 // Lukas.Mueller@imsb.biol.ethz.ch
39 // Group of Prof. Ruedi Aebersold, IMSB, ETH Hoenggerberg, Zurich
40 //
41 // Ported to OpenMS by Florian Zeller, florian.zeller@bsse.ethz.ch
42 // December 2010
43 //
44 
45 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H
46 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H
47 
48 #include <string>
49 #include <vector>
50 #include <map>
51 
52 namespace OpenMS
53 {
54 
55  class OPENMS_DLLAPI LCMS
56  {
57 
59  // declaration of the private members:
60 
61 private:
62 
63  // name of the spectra:
64  std::string spec_name;
65 
66  // vector of object feature:
67  std::vector<SHFeature> feature_list;
68 
69  // a unique specrum id to identify a spectrum:
71 
72  // MASTER RUN ID:
73  int MASTER_ID;
74 
75  // the LC-MS raw data names and their IDs
76  std::map<int, std::string> raw_spec_names;
77 
78  // alignment error:
79  std::map<double, std::pair<double, double> > ALIGNMENT_ERROR;
80 
82  // declaration of the public members:
83 
84 public:
85 
87 // static double PEP_PROPHET_THERSHOLD;
88 
89  // class destructor
90  ~LCMS();
91 
92  // class constructor
93  LCMS(std::string);
94  LCMS();
95  // copy constructor
96  LCMS(const LCMS *);
97 
98  // copy constructor
99  LCMS(const LCMS &);
100 
101  // show the content of the spectra
102  void show_info();
103 
104  // copy constructor:
105  LCMS & operator=(const LCMS &);
106 
107  // sort the features according their parent mass:
108  void order_by_mass();
109 
110  // function to compare the feature mass:
111  float compare_feature_mass(const void *, const void *);
112 
113  // this structure provides the function to compare
114  // in the sorting algorithm:
115  struct OPERATOR_MZ
116  {
117  // provide the compare function for sort:
118  bool operator()(const SHFeature A, const SHFeature B) const
119  {
120  // check if they have same mass
121  if (A.MONO_MZ == B.MONO_MZ)
122  {
123  return A.TR < B.TR;
124  }
125  else
126  {
127  return A.MONO_MZ < B.MONO_MZ;
128  }
129  }
130 
131  };
132 
133  // this structure provides the function to compare
134  // in the sorting algorithm:
136  {
137  // provide the compare function for sort:
138  bool operator()(const SHFeature A, const SHFeature B) const
139  {
140  // check if they have same mass
141  if (A.feature_ID == B.feature_ID)
142  {
143  return true;
144  }
145  else
146  {
147  return false;
148  }
149  }
150 
151  };
152 
153  // tag the feature with the spectrum id:
155  {
156  std::vector<SHFeature>::iterator p = feature_list.begin();
157  while (p != feature_list.end())
158  {
159  (*p).set_spectrum_ID(get_spectrum_ID());
160  p++;
161  }
162  }
163 
164  // count the number of common peaks of a given number of LC-MS:
165  int get_nb_common_peaks(int);
166 
168  // start here all the get / set
169  // function to access the
170  // variables of the class
171 
172  // get the whole feature list:
174  { return feature_list.clear(); }
175  std::vector<SHFeature> get_feature_list()
176  { return feature_list; }
177  std::vector<SHFeature> * get_feature_list_reference()
178  { return &feature_list; }
180  { return feature_list.empty(); }
181 
182  // access end /start of list:
183  std::vector<SHFeature>::iterator get_feature_list_begin()
184  { return feature_list.begin(); }
185  std::vector<SHFeature>::iterator get_feature_list_end()
186  { return feature_list.end(); }
187 
188  // add a new feature to the list:
190  {
191 
192  if (IN->get_feature_ID() == -1)
193  {
194  IN->set_feature_ID((int) feature_list.size());
195  }
196  feature_list.push_back(*IN);
197  IN = NULL;
198  }
199 
200  // remove a feature from the LC/MS run by ID:
201  void remove_feature_by_ID(SHFeature *);
202  void remove_feature_by_ID(int);
203  // remove a feature from teh LC/MS run:
204  void remove_feature(SHFeature *);
205  void remove_feature(int i)
206  {
207  if (i < int(feature_list.size()))
208  {
209  feature_list.erase(feature_list.begin() + i);
210  }
211  }
212 
213  // remove a feature by iterator and return the iterator to the next element
214  std::vector<SHFeature>::iterator remove_feature_from_list(std::vector<SHFeature>::iterator IN)
215  { return feature_list.erase(IN); }
216 
217  // get number of feature added:
218  unsigned int get_nb_features()
219  { return (unsigned int) feature_list.size(); }
220 
221  std::string get_spec_name()
222  { return spec_name; }
223  void set_spec_name(std::string IN)
224  { spec_name = IN; }
225 
226  // set / get spectrum id:
228  { return spectrum_id; }
229  void set_spectrum_ID(int IN)
230  { spectrum_id = IN; }
231 
232  // set the id of all features
233  void setFeatureLCMSID();
234 
235  // search the list of feature for the one with input ID:
236  SHFeature * find_feature_by_ID(int);
237 
238  // access the raw data names:
239  void remove_raw_spec_name(int ID)
240  { raw_spec_names.erase(ID); }
241  void add_raw_spec_name(int ID, std::string name)
242  { raw_spec_names.insert(make_pair(ID, name)); }
244  { return raw_spec_names.empty(); }
245  std::map<int, std::string>::iterator get_raw_spec_name_start()
246  { return raw_spec_names.begin(); }
247  std::map<int, std::string>::iterator get_raw_spec_name_end()
248  { return raw_spec_names.end(); }
249  std::map<int, std::string> get_raw_spec_name_map()
250  { return raw_spec_names; }
252  { return (int) raw_spec_names.size(); }
253  std::string get_raw_spec_name(int ID)
254  {
255  std::map<int, std::string>::iterator p = raw_spec_names.find(ID);
256  if (p == raw_spec_names.end())
257  {
258  return "";
259  }
260  return (*p).second;
261  }
262 
263  // compare the LC/MS runs names
264  bool check_LCMS_name(std::string);
265 
266  // check if this LC/MS ID is present in the raw LC/MS runs
267  bool find_LC_MS_by_ID(int);
268 
269  // add the raw spectrum map:
270  void add_raw_spec_name_map(std::map<int, std::string> IN)
271  {
272  std::map<int, std::string>::iterator p = IN.begin();
273  while (p != IN.end())
274  {
275  int ID = (*p).first;
276  std::map<int, std::string>::iterator F = raw_spec_names.find(ID);
277  if (F != raw_spec_names.end())
278  {
279  ID += (int) raw_spec_names.size();
280  }
281  raw_spec_names.insert(make_pair(ID, (*p).second));
282  p++;
283  }
284  }
285 
286  // counts the number of ms features, which contain MS2 info:
288  {
289  int count = 0;
290  std::vector<SHFeature>::iterator P = get_feature_list_begin();
291  while (P != get_feature_list_end())
292  {
293  if ((*P).get_MS2_info())
294  count++;
295  P++;
296  }
297  return count;
298  }
299 
300  // counts the number of ms features, which contain MS2 info (no thresholding)
301  int get_nb_identified_features(double PepProb_T)
302  {
303  int count = 0;
304  std::vector<SHFeature>::iterator P = get_feature_list_begin();
305  while (P != get_feature_list_end())
306  {
307  if ((*P).get_MS2_info(PepProb_T))
308  count++;
309  P++;
310  }
311  return count;
312  }
313 
315  // access the alignment error:
316  // save an error:
317  void add_alignment_error(double TR, double ERROR_UP, double ERROR_DOWN)
318  {
319  std::pair<double, double> tmp(ERROR_UP, ERROR_DOWN);
320  ALIGNMENT_ERROR.insert(std::pair<double, std::pair<double, double> >(TR, tmp));
321  }
322 
323  // get alignment error at specific TR:
324  void get_alignment_error(double, double *, double *);
325 
326  // access MASTER run ID:
327  void set_MASTER_ID(int IN)
328  { MASTER_ID = IN; }
330  { return MASTER_ID; }
331  };
332 
333 }
334 
335 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H
Definition: LCMS.h:115
int get_spectrum_ID()
Definition: LCMS.h:227
bool check_feature_list_empty()
Definition: LCMS.h:179
void remove_feature(int i)
Definition: LCMS.h:205
void set_spectrum_ID(int IN)
Definition: LCMS.h:229
const double F
void add_raw_spec_name(int ID, std::string name)
Definition: LCMS.h:241
int get_nb_identified_features(double PepProb_T)
Definition: LCMS.h:301
#define NULL
Definition: IsotopeWaveletParallelFor.h:41
int get_nb_raw_specs()
Definition: LCMS.h:251
void remove_raw_spec_name(int ID)
Definition: LCMS.h:239
void add_alignment_error(double TR, double ERROR_UP, double ERROR_DOWN)
Definition: LCMS.h:317
std::vector< SHFeature >::iterator get_feature_list_begin()
Definition: LCMS.h:183
void set_MASTER_ID(int IN)
Definition: LCMS.h:327
std::vector< SHFeature > feature_list
Definition: LCMS.h:67
Definition: LCMS.h:55
int feature_ID
Definition: SHFeature.h:125
std::string get_spec_name()
Definition: LCMS.h:221
unsigned int get_nb_features()
Definition: LCMS.h:218
std::map< int, std::string > raw_spec_names
Definition: LCMS.h:76
int get_MASTER_ID()
Definition: LCMS.h:329
double MONO_MZ
Definition: SHFeature.h:121
std::map< int, std::string >::iterator get_raw_spec_name_end()
Definition: LCMS.h:247
bool check_raw_spec_name_empty()
Definition: LCMS.h:243
void set_feature_ID(int IN)
Definition: SHFeature.h:353
std::string spec_name
Definition: LCMS.h:64
void clear_feature_list()
Definition: LCMS.h:173
std::vector< SHFeature > get_feature_list()
Definition: LCMS.h:175
double TR
Definition: SHFeature.h:120
int spectrum_id
Definition: LCMS.h:70
void tag_peaks_with_spectrum_ID()
Definition: LCMS.h:154
std::vector< SHFeature >::iterator remove_feature_from_list(std::vector< SHFeature >::iterator IN)
Definition: LCMS.h:214
void set_spec_name(std::string IN)
Definition: LCMS.h:223
std::vector< SHFeature >::iterator get_feature_list_end()
Definition: LCMS.h:185
int get_feature_ID()
Definition: SHFeature.h:355
bool operator()(const SHFeature A, const SHFeature B) const
Definition: LCMS.h:138
std::map< int, std::string > get_raw_spec_name_map()
Definition: LCMS.h:249
void add_feature(SHFeature *IN)
Definition: LCMS.h:189
std::vector< SHFeature > * get_feature_list_reference()
Definition: LCMS.h:177
std::string get_raw_spec_name(int ID)
Definition: LCMS.h:253
int MASTER_ID
Definition: LCMS.h:73
Definition: SHFeature.h:51
int get_nb_identified_features()
Definition: LCMS.h:287
void add_raw_spec_name_map(std::map< int, std::string > IN)
Definition: LCMS.h:270
static double MINIMAL_PEP_PROPHET_THERSHOLD
Definition: LCMS.h:86
std::map< int, std::string >::iterator get_raw_spec_name_start()
Definition: LCMS.h:245
bool operator()(const SHFeature A, const SHFeature B) const
Definition: LCMS.h:118
std::map< double, std::pair< double, double > > ALIGNMENT_ERROR
Definition: LCMS.h:79

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:16 using doxygen 1.8.5