~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to source/APPLICATIONS/TOPP/TMTAnalyzer.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2013-12-20 11:30:16 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131220113016-wre5g9bteeheq6he
Tags: 1.11.1-3
* remove version number from libbost development package names;
* ensure that AUTHORS is correctly shipped in all packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: Stephan Aiche $
 
32
// $Authors: Stephan Aiche $
 
33
// --------------------------------------------------------------------------
 
34
#include <OpenMS/KERNEL/MSExperiment.h>
 
35
#include <OpenMS/APPLICATIONS/TOPPBase.h>
 
36
#include <OpenMS/ANALYSIS/QUANTITATION/ItraqChannelExtractor.h>
 
37
#include <OpenMS/ANALYSIS/QUANTITATION/ItraqQuantifier.h>
 
38
#include <OpenMS/ANALYSIS/QUANTITATION/ItraqConstants.h>
 
39
#include <OpenMS/FORMAT/ConsensusXMLFile.h>
 
40
#include <OpenMS/FORMAT/MzMLFile.h>
 
41
#include <OpenMS/SYSTEM/File.h>
 
42
#include <OpenMS/FORMAT/MzQuantMLFile.h>
 
43
#include <OpenMS/METADATA/MSQuantifications.h>
 
44
 
 
45
using namespace OpenMS;
 
46
using namespace std;
 
47
 
 
48
// NOTE: This tool is a copy if ITRAQAnalyzer with the difference that it sets, the mode
 
49
//       automatically to TMT_SIXPLEX and ignores all iTRAQ-modes.
 
50
 
 
51
//-------------------------------------------------------------
 
52
//Doxygen docu
 
53
//-------------------------------------------------------------
 
54
 
 
55
/**
 
56
  @page TOPP_TMTAnalyzer TMTAnalyzer
 
57
 
 
58
  @brief Extracts and normalizes TMT information from an MS experiment.
 
59
 
 
60
<CENTER>
 
61
    <table>
 
62
        <tr>
 
63
            <td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. predecessor tools </td>
 
64
      <td VALIGN="middle" ROWSPAN=3> \f$ \longrightarrow \f$ TMTAnalyzer \f$ \longrightarrow \f$</td>
 
65
            <td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. successor tools </td>
 
66
        </tr>
 
67
        <tr>
 
68
            <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_FileConverter </td>
 
69
            <td VALIGN="middle" ALIGN = "center" ROWSPAN=2> @ref TOPP_IDMapper</td>
 
70
        </tr>
 
71
        <tr>
 
72
            <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_FileFilter </td>
 
73
        </tr>
 
74
    </table>
 
75
</CENTER>
 
76
 
 
77
  Extract the TMT reporter ion intensities (6plex) from raw MS2 data, does isotope corrections and
 
78
  stores the resulting quantitation as consensusXML, where each consensus centroid corresponds to
 
79
  one TMT MS2 scan (e.g., CID). The position of the centroid is the precursor position, its
 
80
  sub-elements are the channels (thus having m/z's of 126-131).
 
81
 
 
82
  Isotope correction is done using non-negative least squares (NNLS). See @ref TOPP_ITRAQAnalyzer
 
83
  for details.
 
84
 
 
85
  The correction matrices can be found (and changed) in the INI file. However, these matrices for
 
86
  TMT are now stable, and every kit delivered should have the same isotope
 
87
  correction values. Thus, there should be no need to change them, but feel free to compare the
 
88
  values in the INI file with your kit's Certificate.
 
89
 
 
90
  After this quantitation step, you might want to annotate the consensus elements with the
 
91
  respective identifications, obtained from an identification pipeline.
 
92
  Note that quantification is solely on peptide level at this stage. In order to obtain protein
 
93
  quantifications, you can try @ref TOPP_TextExporter to obtain a simple text format which you can
 
94
  feed to other software tools (e.g., R), or you can try @ref TOPP_ProteinQuantifier.
 
95
 
 
96
    <B>The command line parameters of this tool are:</B>
 
97
  @verbinclude TOPP_TMTAnalyzer.cli
 
98
    <B>INI file documentation of this tool:</B>
 
99
  @htmlinclude TOPP_TMTAnalyzer.html
 
100
*/
 
101
 
 
102
// We do not want this class to show up in the docu:
 
103
/// @cond TOPPCLASSES
 
104
 
 
105
class TOPPTMTAnalyzer :
 
106
  public TOPPBase
 
107
{
 
108
public:
 
109
  TOPPTMTAnalyzer() :
 
110
    TOPPBase("TMTAnalyzer", "Calculates TMT quantitative values for peptides", true, true)
 
111
  {
 
112
  }
 
113
 
 
114
protected:
 
115
  void registerOptionsAndFlags_()
 
116
  {
 
117
    registerInputFile_("in", "<file>", "", "input raw/picked data file ");
 
118
    setValidFormats_("in", StringList::create("mzML"));
 
119
    registerOutputFile_("out", "<file>", "", "output consensusXML file with quantitative information");
 
120
    setValidFormats_("out", StringList::create("consensusXML"));
 
121
 
 
122
    registerOutputFile_("out_mzq", "<file>", "", "Optional output file of MzQuantML.", false, true);
 
123
    setValidFormats_("out_mzq", StringList::create("mzq"));
 
124
 
 
125
    registerOutputFile_("out_stats", "<file>", "", "output statistics as tab-separated file (readable by R or Excel or ...)", false);
 
126
    setValidFormats_("out_stats", StringList::create("tsv"));
 
127
 
 
128
    addEmptyLine_();
 
129
 
 
130
    registerSubsection_("algorithm", "Algorithm parameters section");
 
131
  }
 
132
 
 
133
  Param getSubsectionDefaults_(const String & /*section*/) const
 
134
  {
 
135
    Param tmp;
 
136
    tmp.insert("Extraction:", ItraqChannelExtractor(ItraqQuantifier::TMT_SIXPLEX).getParameters());
 
137
    tmp.insert("Quantification:", ItraqQuantifier(ItraqQuantifier::TMT_SIXPLEX).getParameters());
 
138
    tmp.setValue("MetaInformation:Program", "OpenMS::TMTAnalyzer", "", StringList::create("advanced"));
 
139
    return tmp;
 
140
  }
 
141
 
 
142
  ExitCodes main_(int, const char **)
 
143
  {
 
144
    //-------------------------------------------------------------
 
145
    // parameter handling
 
146
    //-------------------------------------------------------------
 
147
    String in = getStringOption_("in");
 
148
    String out = getStringOption_("out");
 
149
    String out_stats = getStringOption_("out_stats");
 
150
    String out_mzq = getStringOption_("out_mzq");
 
151
 
 
152
    Int itraq_type = ItraqQuantifier::TMT_SIXPLEX;
 
153
    //-------------------------------------------------------------
 
154
    // loading input
 
155
    //-------------------------------------------------------------
 
156
 
 
157
    MzMLFile mz_data_file;
 
158
    MSExperiment<Peak1D> exp;
 
159
    mz_data_file.setLogType(log_type_);
 
160
    mz_data_file.load(in, exp);
 
161
 
 
162
    //-------------------------------------------------------------
 
163
    // calculations
 
164
    //-------------------------------------------------------------
 
165
    Param extract_param(getParam_().copy("algorithm:Extraction:", true));
 
166
    ItraqChannelExtractor itraq_ce(itraq_type, extract_param);
 
167
 
 
168
    ConsensusMap consensus_map_raw, consensus_map_quant;
 
169
    // extract raw signals
 
170
    itraq_ce.run(exp, consensus_map_raw);
 
171
 
 
172
    // do normalization
 
173
    Param quant_param(getParam_().copy("algorithm:Quantification:", true));
 
174
    ItraqQuantifier itraq_quant(itraq_type, quant_param);
 
175
 
 
176
    itraq_quant.run(consensus_map_raw, consensus_map_quant);
 
177
 
 
178
    // assign unique ID to output file (this might throw an exception.. but thats ok, as we want the program to quit then)
 
179
    if (getStringOption_("id_pool").trim().length() > 0) getDocumentIDTagger_().tag(consensus_map_quant);
 
180
 
 
181
    // annotate output file with MetaInformation
 
182
    Param metainfo_param(getParam_().copy("algorithm:MetaInformation:", true));
 
183
    for (Param::ParamIterator it = metainfo_param.begin(); it != metainfo_param.end(); ++it)
 
184
    {
 
185
      consensus_map_quant.setMetaValue(it->name, it->value);
 
186
    }
 
187
 
 
188
 
 
189
    //-------------------------------------------------------------
 
190
    // writing output
 
191
    //-------------------------------------------------------------
 
192
 
 
193
    //annotate output with data processing info
 
194
    addDataProcessing_(consensus_map_quant, getProcessingInfo_(DataProcessing::QUANTITATION));
 
195
 
 
196
    // add filename references
 
197
    for (ConsensusMap::FileDescriptions::iterator it = consensus_map_quant.getFileDescriptions().begin();
 
198
         it != consensus_map_quant.getFileDescriptions().end();
 
199
         ++it)
 
200
    {
 
201
      it->second.filename = in;
 
202
    }
 
203
 
 
204
    ConsensusXMLFile cm_file;
 
205
    cm_file.store(out, consensus_map_quant);
 
206
 
 
207
    if (!out_mzq.trim().empty())
 
208
    {
 
209
      MSQuantifications msq;
 
210
      std::vector<std::vector<std::pair<String, DoubleReal> > > labels;
 
211
      if (itraq_type == ItraqQuantifier::FOURPLEX)
 
212
      {
 
213
        for (Size i = 0; i < 4; ++i)
 
214
        {
 
215
          std::vector<std::pair<String, DoubleReal> > one_label;
 
216
          one_label.push_back(std::make_pair<String, DoubleReal>(String("Channel ") + String(ItraqConstants::CHANNELS_FOURPLEX[i][0]), DoubleReal(ItraqConstants::CHANNELS_FOURPLEX[i][0])));
 
217
          labels.push_back(one_label);
 
218
        }
 
219
      }
 
220
      else       //ItraqQuantifier::EIGHTPLEX
 
221
      {
 
222
        for (Size i = 0; i < 8; ++i)
 
223
        {
 
224
          std::vector<std::pair<String, DoubleReal> > one_label;
 
225
          one_label.push_back(std::make_pair<String, DoubleReal>(String("Channel ") + String(ItraqConstants::CHANNELS_FOURPLEX[i][0]), DoubleReal(ItraqConstants::CHANNELS_FOURPLEX[i][0])));
 
226
          labels.push_back(one_label);
 
227
        }
 
228
      }
 
229
      msq.registerExperiment(exp, labels);       //add assays
 
230
      msq.assignUIDs();
 
231
      MSQuantifications::QUANT_TYPES quant_type = MSQuantifications::MS2LABEL;
 
232
      msq.setAnalysisSummaryQuantType(quant_type);      //add analysis_summary_
 
233
 
 
234
      msq.addConsensusMap(consensus_map_quant);      //add ITRAQAnalyzer result
 
235
      //~ add AuditCollection - no such concept in TOPPTools yet
 
236
      MzQuantMLFile file;
 
237
      file.store(out_mzq, msq);
 
238
    }
 
239
 
 
240
    std::cout << itraq_quant.getStats();
 
241
    if (!out_stats.trim().empty())
 
242
    {
 
243
      ofstream f;
 
244
      f.open(out_stats.c_str(), ios_base::out);
 
245
      f << itraq_quant.getStats();
 
246
      f.close();
 
247
    }
 
248
 
 
249
    return EXECUTION_OK;
 
250
  }
 
251
 
 
252
};
 
253
 
 
254
int main(int argc, const char ** argv)
 
255
{
 
256
  TOPPTMTAnalyzer tool;
 
257
  return tool.main(argc, argv);
 
258
}
 
259
 
 
260
/// @endcond