Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

LCMS.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Florian Zeller $
00032 // $Authors: Lukas Mueller, Markus Mueller $
00033 // --------------------------------------------------------------------------
00034 //
00036 //
00037 //  written by Lukas N Mueller, 30.3.05
00038 //  Lukas.Mueller@imsb.biol.ethz.ch
00039 //  Group of Prof. Ruedi Aebersold, IMSB, ETH Hoenggerberg, Zurich
00040 //
00041 //  Ported to OpenMS by Florian Zeller, florian.zeller@bsse.ethz.ch
00042 //  December 2010
00043 //
00044 
00045 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H
00046 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H
00047 
00048 #include <string>
00049 #include <vector>
00050 #include <map>
00051 
00052 namespace OpenMS
00053 {
00054 
00055   class OPENMS_DLLAPI LCMS
00056   {
00057 
00059     // declaration of the private members:
00060 
00061 private:
00062 
00063     // name of the spectra:
00064     std::string spec_name;
00065 
00066     // vector of object feature:
00067     std::vector<SHFeature> feature_list;
00068 
00069     // a unique specrum id to identify a spectrum:
00070     int spectrum_id;
00071 
00072     // MASTER RUN ID:
00073     int MASTER_ID;
00074 
00075     // the LC-MS raw data names and their IDs
00076     std::map<int, std::string> raw_spec_names;
00077 
00078     // alignment error:
00079     std::map<double, std::pair<double, double> > ALIGNMENT_ERROR;
00080 
00082     // declaration of the public members:
00083 
00084 public:
00085 
00086     static double MINIMAL_PEP_PROPHET_THERSHOLD;
00087 //  static double PEP_PROPHET_THERSHOLD;
00088 
00089     // class destructor
00090     ~LCMS();
00091 
00092     // class constructor
00093     LCMS(std::string);
00094     LCMS();
00095     // copy constructor
00096     LCMS(const LCMS *);
00097 
00098     // copy constructor
00099     LCMS(const LCMS &);
00100 
00101     // show the content of the spectra
00102     void show_info();
00103 
00104     // copy constructor:
00105     LCMS & operator=(const LCMS &);
00106 
00107     // sort the features according their parent mass:
00108     void order_by_mass();
00109 
00110     // function to compare the feature mass:
00111     float compare_feature_mass(const void *, const void *);
00112 
00113     // this structure provides the function to compare
00114     // in the sorting algorithm:
00115     struct OPERATOR_MZ
00116     {
00117       // provide the compare function for sort:
00118       bool operator()(const SHFeature A, const SHFeature B) const
00119       {
00120         // check if they have same mass
00121         if (A.MONO_MZ == B.MONO_MZ)
00122         {
00123           return A.TR < B.TR;
00124         }
00125         else
00126         {
00127           return A.MONO_MZ < B.MONO_MZ;
00128         }
00129       }
00130 
00131     };
00132 
00133     // this structure provides the function to compare
00134     // in the sorting algorithm:
00135     struct OPERATOR_FeatureCompare
00136     {
00137       // provide the compare function for sort:
00138       bool operator()(const SHFeature A, const SHFeature B) const
00139       {
00140         // check if they have same mass
00141         if (A.feature_ID == B.feature_ID)
00142         {
00143           return true;
00144         }
00145         else
00146         {
00147           return false;
00148         }
00149       }
00150 
00151     };
00152 
00153     // tag the feature with the spectrum id:
00154     void tag_peaks_with_spectrum_ID()
00155     {
00156       std::vector<SHFeature>::iterator p = feature_list.begin();
00157       while (p != feature_list.end())
00158       {
00159         (*p).set_spectrum_ID(get_spectrum_ID());
00160         p++;
00161       }
00162     }
00163 
00164     // count the number of common peaks of a given number of LC-MS:
00165     int get_nb_common_peaks(int);
00166 
00168     // start here all the get / set
00169     // function to access the
00170     // variables of the class
00171 
00172     // get the whole feature list:
00173     void clear_feature_list()
00174     {   return feature_list.clear(); }
00175     std::vector<SHFeature> get_feature_list()
00176     {   return feature_list; }
00177     std::vector<SHFeature> * get_feature_list_reference()
00178     {   return &feature_list; }
00179     bool check_feature_list_empty()
00180     {   return feature_list.empty(); }
00181 
00182     // access end /start of list:
00183     std::vector<SHFeature>::iterator get_feature_list_begin()
00184     {   return feature_list.begin(); }
00185     std::vector<SHFeature>::iterator get_feature_list_end()
00186     {   return feature_list.end(); }
00187 
00188     // add a new feature to the list:
00189     void add_feature(SHFeature * IN)
00190     {
00191 
00192       if (IN->get_feature_ID() == -1)
00193       {
00194         IN->set_feature_ID((int) feature_list.size());
00195       }
00196       feature_list.push_back(*IN);
00197       IN = NULL;
00198     }
00199 
00200     // remove a feature from the LC/MS run by ID:
00201     void remove_feature_by_ID(SHFeature *);
00202     void remove_feature_by_ID(int);
00203     // remove a feature from teh LC/MS run:
00204     void remove_feature(SHFeature *);
00205     void remove_feature(int i)
00206     {
00207       if (i < int(feature_list.size()))
00208       {
00209         feature_list.erase(feature_list.begin() + i);
00210       }
00211     }
00212 
00213     // remove a feature by iterator and return the iterator to the next element
00214     std::vector<SHFeature>::iterator remove_feature_from_list(std::vector<SHFeature>::iterator IN)
00215     {   return feature_list.erase(IN); }
00216 
00217     // get number of feature added:
00218     unsigned int get_nb_features()
00219     {   return (unsigned int) feature_list.size(); }
00220 
00221     std::string get_spec_name()
00222     {   return spec_name; }
00223     void set_spec_name(std::string IN)
00224     {   spec_name = IN; }
00225 
00226     // set / get spectrum id:
00227     int get_spectrum_ID()
00228     {   return spectrum_id; }
00229     void set_spectrum_ID(int IN)
00230     {   spectrum_id = IN; }
00231 
00232     // set the id of all features
00233     void setFeatureLCMSID();
00234 
00235     // search the list of feature for the one with input ID:
00236     SHFeature * find_feature_by_ID(int);
00237 
00238     // access the raw data names:
00239     void remove_raw_spec_name(int ID)
00240     {   raw_spec_names.erase(ID); }
00241     void add_raw_spec_name(int ID, std::string name)
00242     {   raw_spec_names.insert(make_pair(ID, name)); }
00243     bool check_raw_spec_name_empty()
00244     {   return raw_spec_names.empty(); }
00245     std::map<int, std::string>::iterator get_raw_spec_name_start()
00246     {   return raw_spec_names.begin(); }
00247     std::map<int, std::string>::iterator get_raw_spec_name_end()
00248     {   return raw_spec_names.end(); }
00249     std::map<int, std::string> get_raw_spec_name_map()
00250     {   return raw_spec_names; }
00251     int get_nb_raw_specs()
00252     {   return (int) raw_spec_names.size(); }
00253     std::string get_raw_spec_name(int ID)
00254     {
00255       std::map<int, std::string>::iterator p = raw_spec_names.find(ID);
00256       if (p == raw_spec_names.end())
00257       {
00258         return "";
00259       }
00260       return (*p).second;
00261     }
00262 
00263     // compare the LC/MS runs names
00264     bool check_LCMS_name(std::string);
00265 
00266     // check if this LC/MS ID is present in the raw LC/MS runs
00267     bool find_LC_MS_by_ID(int);
00268 
00269     // add the raw spectrum map:
00270     void add_raw_spec_name_map(std::map<int, std::string> IN)
00271     {
00272       std::map<int, std::string>::iterator p = IN.begin();
00273       while (p != IN.end())
00274       {
00275         int ID = (*p).first;
00276         std::map<int, std::string>::iterator F = raw_spec_names.find(ID);
00277         if (F != raw_spec_names.end())
00278         {
00279           ID += (int) raw_spec_names.size();
00280         }
00281         raw_spec_names.insert(make_pair(ID, (*p).second));
00282         p++;
00283       }
00284     }
00285 
00286     // counts the number of ms features, which contain MS2 info:
00287     int get_nb_identified_features()
00288     {
00289       int count = 0;
00290       std::vector<SHFeature>::iterator P = get_feature_list_begin();
00291       while (P != get_feature_list_end())
00292       {
00293         if ((*P).get_MS2_info())
00294           count++;
00295         P++;
00296       }
00297       return count;
00298     }
00299 
00300     // counts the number of ms features, which contain MS2 info (no thresholding)
00301     int get_nb_identified_features(double PepProb_T)
00302     {
00303       int count = 0;
00304       std::vector<SHFeature>::iterator P = get_feature_list_begin();
00305       while (P != get_feature_list_end())
00306       {
00307         if ((*P).get_MS2_info(PepProb_T))
00308           count++;
00309         P++;
00310       }
00311       return count;
00312     }
00313 
00315     // access the alignment error:
00316     // save an error:
00317     void add_alignment_error(double TR, double ERROR_UP, double ERROR_DOWN)
00318     {
00319       std::pair<double, double> tmp(ERROR_UP, ERROR_DOWN);
00320       ALIGNMENT_ERROR.insert(std::pair<double, std::pair<double, double> >(TR, tmp));
00321     }
00322 
00323     // get alignment error at specific TR:
00324     void get_alignment_error(double, double *, double *);
00325 
00326     // access MASTER run ID:
00327     void set_MASTER_ID(int IN)
00328     {   MASTER_ID = IN; }
00329     int get_MASTER_ID()
00330     {   return MASTER_ID; }
00331   };
00332 
00333 }
00334 
00335 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_SUPERHIRN_LCMS_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:40 using doxygen 1.7.1