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

InclusionExclusionList.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: Alexandra Zerck $
00032 // $Authors: Alexandra Zerck, Chris Bielow $
00033 // --------------------------------------------------------------------------
00034 //
00035 #ifndef OPENMS_ANALYSIS_TARGETED_INCLUSIONEXCLUSIONLIST_H
00036 #define OPENMS_ANALYSIS_TARGETED_INCLUSIONEXCLUSIONLIST_H
00037 
00038 #include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h>
00039 #include <OpenMS/FORMAT/FASTAFile.h>
00040 #include <OpenMS/KERNEL/FeatureMap.h>
00041 
00042 namespace OpenMS
00043 {
00050   class OPENMS_DLLAPI InclusionExclusionList :
00051     public DefaultParamHandler
00052   {
00053 protected:
00054     struct IEWindow
00055     {
00056       IEWindow(const DoubleReal RTmin, const DoubleReal RTmax, const DoubleReal MZ) :
00057         RTmin_(RTmin),
00058         RTmax_(RTmax),
00059         MZ_(MZ)
00060       {
00061       }
00062 
00063       DoubleReal RTmin_;
00064       DoubleReal RTmax_;
00065       DoubleReal MZ_;
00066     };
00067 
00075     class WindowDistance_
00076     {
00077 public:
00078       WindowDistance_(const DoubleReal rt_bridge, const DoubleReal mz_max, const bool mz_as_ppm) :
00079         rt_bridge_(rt_bridge),
00080         mz_max_(mz_max),
00081         mz_as_ppm_(mz_as_ppm)
00082       {
00083       }
00084 
00085       // measure of SIMILARITY (not distance, i.e. 1-distance)!!
00086       double operator()(const IEWindow & first, const IEWindow & second) const
00087       {
00088         // get MZ distance:
00089         DoubleReal d_mz = fabs(first.MZ_ - second.MZ_);
00090         if (mz_as_ppm_)
00091         {
00092           d_mz = d_mz / first.MZ_ * 1e6;
00093         }
00094         if (d_mz > mz_max_) {return 0; }
00095         // mz is close enough ...
00096 
00097         // is RT overlapping?
00098         if (first.RTmin_ <= second.RTmin_ && second.RTmin_ <= first.RTmax_) return 1;  // intersect #1
00099 
00100         if (first.RTmin_ <= second.RTmax_ && second.RTmax_ <= first.RTmax_) return 1;  // intersect #2
00101 
00102         if (second.RTmin_ <= first.RTmin_ && first.RTmax_ <= second.RTmax_) return 1;  // complete inclusion (only one case; the other is covered above)
00103 
00104         // when windows to not overlap at all:
00105         // ... are they at least close?
00106         if ((fabs(first.RTmin_ - second.RTmax_) <= rt_bridge_) ||
00107             (fabs(first.RTmax_ - second.RTmin_) <= rt_bridge_))
00108         {
00109           return 1;
00110         }
00111 
00112         // not overlapping...
00113         return 0;
00114       }
00115 
00116 protected:
00117 
00118       DoubleReal rt_bridge_; 
00119       DoubleReal mz_max_;    
00120       bool mz_as_ppm_;       
00121 
00122     }; // end of WindowDistance_
00123 
00124 
00125     typedef std::vector<IEWindow> WindowList;
00126 
00137     void mergeOverlappingWindows_(WindowList & list) const;
00138 
00139 
00149     void writeToFile_(const String & out_path, const WindowList & windows) const;
00150 
00151 public:
00155 
00156     InclusionExclusionList();
00157 
00158 
00160 
00161 //     void loadTargets(FeatureMap<>& map, std::vector<IncludeExcludeTarget>& targets,TargetedExperiment& exp);
00162 
00163 //     void loadTargets(std::vector<FASTAFile::FASTAEntry>& fasta_entries, std::vector<IncludeExcludeTarget>& targets,
00164 //                      TargetedExperiment& exp, Size missed_cleavages = 0);
00165 
00166 
00172     void writeTargets(const std::vector<FASTAFile::FASTAEntry> & fasta_entries,
00173                       const String & out_path,
00174                       const IntList & charges,
00175                       const String rt_model_path);
00176 
00182     void writeTargets(const FeatureMap<> & map,
00183                       const String & out_path);
00184 
00192     void writeTargets(const std::vector<PeptideIdentification> & pep_ids,
00193                       const String & out_path,
00194                       const IntList & charges);
00195 
00196   };
00197 
00198 
00199 }
00200 
00201 #endif

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