Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
SILACAnalyzer.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: Lars Nilse $
32 // $Authors: Lars Nilse, Steffen Sass, Holger Plattfaut, Bastian Blank $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FILTERING_DATAREDUCTION_SILACANALYZER_H
36 #define OPENMS_FILTERING_DATAREDUCTION_SILACANALYZER_H
37 
38 //OpenMS includes
39 #include <OpenMS/config.h>
40 // #include <OpenMS/APPLICATIONS/TOPPBase.h>
47 #include <OpenMS/FORMAT/MzMLFile.h>
55 
60 
61 //Contrib includes
62 #include <boost/algorithm/string/split.hpp>
63 #include <boost/algorithm/string/classification.hpp>
64 
65 //std includes
66 #include <cmath>
67 #include <vector>
68 #include <algorithm>
69 #include <fstream>
70 #include <limits>
71 #include <locale>
72 #include <iomanip>
73 
74 namespace OpenMS
75 {
86  class OPENMS_DLLAPI SILACAnalyzer :
87  public ProgressLogger
88  {
89  private:
90 
91  // input and output files
97 
101 
102  // section "sample"
109 
110  // section "algorithm"
117 
118  // section "labels"
119  std::vector<std::vector<String> > SILAClabels; // list of SILAC labels, e.g. selected_labels="[Lys4,Arg6][Lys8,Arg10]" => SILAClabels[0][1]="Arg6"
120  std::vector<std::vector<DoubleReal> > massShifts; // list of mass shifts
121 
123 
125 
126  public:
128  allow_missing_peaks(true)
129  {
130  }
131 
140  // section "sample"
141  String selected_labels_,
142  UInt charge_min_,
143  UInt charge_max_,
144  Int missed_cleavages_,
145  UInt isotopes_per_peptide_min_,
146  UInt isotopes_per_peptide_max_,
147  // section "algorithm"
148  DoubleReal rt_threshold_,
149  DoubleReal rt_min_,
150  DoubleReal intensity_cutoff_,
151  DoubleReal intensity_correlation_,
152  DoubleReal model_deviation_,
153  bool allow_missing_peaks_,
154  // labels part
155  std::map<String, DoubleReal> label_identifiers)
156  {
157  selected_labels = selected_labels_;
158  charge_min = charge_min_;
159  charge_max = charge_max_;
160  missed_cleavages = missed_cleavages_;
161  isotopes_per_peptide_min = isotopes_per_peptide_min_;
162  isotopes_per_peptide_max = isotopes_per_peptide_max_;
163 
164  rt_threshold = rt_threshold_;
165  rt_min = rt_min_;
166  intensity_cutoff = intensity_cutoff_;
167  intensity_correlation = intensity_correlation_;
168  model_deviation = model_deviation_;
169  allow_missing_peaks = allow_missing_peaks_;
170 
171  calculateLabelsAndMassShifts(label_identifiers);
172  }
173 
183  void calculateLabelsAndMassShifts(std::map<String, DoubleReal> label_identifiers);
184 
186  {
187  PeakWidthEstimator::Result peak_width;
188  std::vector<std::vector<SILACPattern> > data;
189  MSQuantifications msq;
190  std::vector<Clustering *> cluster_data;
191 
192  peak_width = estimatePeakWidth(exp);
193  filterData(exp, peak_width, data);
194  clusterData(exp, peak_width, cluster_data, data);
195 
196  // write output to consensus map
197  for (std::vector<Clustering *>::const_iterator it = cluster_data.begin(); it != cluster_data.end(); ++it)
198  {
199  generateClusterConsensusByCluster(out_map, **it);
200  }
201  }
202 
206  PeakWidthEstimator::Result estimatePeakWidth(const MSExperiment<Peak1D> & exp);
207 
211  void filterData(MSExperiment<Peak1D> & exp, const PeakWidthEstimator::Result & peak_width, std::vector<std::vector<SILACPattern> > & data);
212 
216  void clusterData(const MSExperiment<> &, const PeakWidthEstimator::Result &, std::vector<Clustering *> &, std::vector<std::vector<SILACPattern> > & data);
217 
218 
223  std::vector<std::vector<String> > & getSILAClabels()
224  {
225  return SILAClabels;
226  }
227 
231  std::vector<std::vector<DoubleReal> > & getMassShifts()
232  {
233  return massShifts;
234  }
235 
236  public:
237 
241  void generateClusterConsensusByCluster(ConsensusMap &, const Clustering &) const;
242 
246  void generateClusterConsensusByPattern(ConsensusMap &, const Clustering &, UInt & cluster_id) const;
247 
251  void generateClusterDebug(std::ostream & out, const Clustering & clustering, UInt & cluster_id) const;
252 
253  public:
257  void generateFilterConsensusByPattern(ConsensusMap &, const std::vector<SILACPattern> &) const;
258 
259  private:
260 
264  ConsensusFeature generateSingleConsensusByPattern(const SILACPattern &) const;
265 
266 
267  public:
268 
272  void generateClusterFeatureByCluster(FeatureMap<> &, const Clustering &) const;
273 
277  void readFilterConsensusByPattern(ConsensusMap &, std::vector<std::vector<SILACPattern> > &);
278 
279  static const String & selectColor(UInt nr);
280 
284  void readConsensus(const String & filename, ConsensusMap & in) const
285  {
286  ConsensusXMLFile c_file;
287  c_file.load(filename, in);
288  }
289 
293  void writeConsensus(const String & filename, ConsensusMap & out) const
294  {
295  out.sortByPosition();
297  out.setExperimentType("silac");
298 
299  ConsensusXMLFile c_file;
300  c_file.store(filename, out);
301  }
302 
306  void writeMzQuantML(const String & filename, MSQuantifications & msq) const
307  {
308  //~ TODO apply above to ConsensusMap befor putting into Msq
309  //~ out.sortByPosition();
310  //~ out.applyMemberFunction(&UniqueIdInterface::setUniqueId);
311  //~ out.setExperimentType("SILAC");
312 
313  MzQuantMLFile file;
314  file.store(filename, msq);
315  }
316 
320  void writeFeatures(const String & filename, FeatureMap<> & out) const
321  {
322  out.sortByPosition();
324 
325  FeatureXMLFile f_file;
326  f_file.store(filename, out);
327  }
328 
329  };
330 }
331 
332 #endif /* SILACANALYZER_H_ */
SILACClustering Clustering
Definition: SILACAnalyzer.h:122
A more convenient string class.
Definition: String.h:56
DoubleReal model_deviation
Definition: SILACAnalyzer.h:115
void store(const String &filename, const FeatureMap<> &feature_map)
stores the map feature_map in file with name filename.
String out
Definition: SILACAnalyzer.h:93
String selected_labels
Definition: SILACAnalyzer.h:103
void writeConsensus(const String &filename, ConsensusMap &out) const
Write consensusXML from ConsensusMap to file.
Definition: SILACAnalyzer.h:293
Algorithm to use for SILACAnalysis.
Definition: SILACAnalyzer.h:86
String out_features
Definition: SILACAnalyzer.h:95
Size setUniqueId()
Assigns a new, valid unique id. Always returns 1.
Definition: UniqueIdInterface.h:150
A container for consensus elements.
Definition: ConsensusMap.h:60
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features. The returned values are accumulated.
Definition: ConsensusMap.h:438
std::vector< std::vector< String > > & getSILAClabels()
Returns the list of SILAC labels, e.g. selected_labels=&quot;[Lys4,Arg6][Lys8,Arg10]&quot; =&gt; SILAClabels[0][1]...
Definition: SILACAnalyzer.h:223
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all features (including subordinates)...
Definition: FeatureMap.h:496
void setExperimentType(const String &experiment_type)
Mutable access to the experiment type.
Clustering implementation for SILAC stuff.
Definition: SILACClustering.h:52
UInt isotopes_per_peptide_min
Definition: SILACAnalyzer.h:107
std::vector< std::vector< DoubleReal > > & getMassShifts()
Returns the list of mass shifts calcualted.
Definition: SILACAnalyzer.h:231
void readConsensus(const String &filename, ConsensusMap &in) const
Read consensusXML from file to ConsensusMap.
Definition: SILACAnalyzer.h:284
void initialize(String selected_labels_, UInt charge_min_, UInt charge_max_, Int missed_cleavages_, UInt isotopes_per_peptide_min_, UInt isotopes_per_peptide_max_, DoubleReal rt_threshold_, DoubleReal rt_min_, DoubleReal intensity_cutoff_, DoubleReal intensity_correlation_, DoubleReal model_deviation_, bool allow_missing_peaks_, std::map< String, DoubleReal > label_identifiers)
Initializes the algorithm with parameters.
Definition: SILACAnalyzer.h:139
File adapter for MzQuantML files.
Definition: MzQuantMLFile.h:52
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLFile.h:59
void run_all(MSExperiment< Peak1D > &exp, ConsensusMap &out_map)
Definition: SILACAnalyzer.h:185
MSQuantifications msq
Definition: SILACAnalyzer.h:124
Definition: MSQuantifications.h:51
void sortByPosition()
Sort features by position. Lexicographical comparison (first RT then m/z) is done.
Definition: FeatureMap.h:310
Definition: PeakWidthEstimator.h:60
String out_filters
Definition: SILACAnalyzer.h:98
String out_debug
Definition: SILACAnalyzer.h:100
void writeMzQuantML(const String &filename, MSQuantifications &msq) const
Write MzQuantML from ConsensusMap to file.
Definition: SILACAnalyzer.h:306
DoubleReal rt_threshold
Definition: SILACAnalyzer.h:111
std::vector< std::vector< String > > SILAClabels
Definition: SILACAnalyzer.h:119
String out_mzq
Definition: SILACAnalyzer.h:96
void store(const String &filename, const MSQuantifications &cmsq) const
Stores a map in a MzQuantML file.
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:59
UInt charge_max
Definition: SILACAnalyzer.h:105
Int missed_cleavages
Definition: SILACAnalyzer.h:106
String in_filters
Definition: SILACAnalyzer.h:99
Base class for all classes that want to report their progess.
Definition: ProgressLogger.h:56
bool allow_missing_peaks
Definition: SILACAnalyzer.h:116
std::vector< std::vector< DoubleReal > > massShifts
Definition: SILACAnalyzer.h:120
UInt isotopes_per_peptide_max
Definition: SILACAnalyzer.h:108
DoubleReal intensity_cutoff
Definition: SILACAnalyzer.h:113
String out_clusters
Definition: SILACAnalyzer.h:94
A single SILAC pattern containing multiple found points.
Definition: SILACPattern.h:47
void sortByPosition()
Lexicographically sorts the peaks by their position (First RT then m/z).
void store(const String &filename, const ConsensusMap &consensus_map)
Stores a consensus map to file.
DoubleReal intensity_correlation
Definition: SILACAnalyzer.h:114
int Int
Signed integer type.
Definition: Types.h:100
void load(const String &filename, ConsensusMap &map)
Loads a consensus map from file and calls updateRanges.
DoubleReal rt_min
Definition: SILACAnalyzer.h:112
String in
Definition: SILACAnalyzer.h:92
SILACAnalyzer()
Definition: SILACAnalyzer.h:127
A 2-dimensional consensus feature.
Definition: ConsensusFeature.h:59
void writeFeatures(const String &filename, FeatureMap<> &out) const
Write featureXML from FeatureMap to file.
Definition: SILACAnalyzer.h:320
UInt charge_min
Definition: SILACAnalyzer.h:104

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