OpenMS  2.4.0
TransitionTSVFile.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-2018.
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: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
44 
45 #include <fstream>
46 
47 namespace OpenMS
48 {
49 
142  class OPENMS_DLLAPI TransitionTSVFile :
143  public ProgressLogger,
144  public DefaultParamHandler
145  {
146 
147 protected:
155  {
156  double precursor;
157  double product;
160  double CE;
163  bool decoy;
177  double drift_time;
184  std::vector<String> peptidoforms;
185 
187  precursor(-1),
188  product(-1),
189  rt_calibrated(-1),
190  CE(-1),
191  library_intensity(-1),
192  decoy(false),
193  fragment_charge("NA"),
194  fragment_nr(-1),
195  fragment_mzdelta(-1),
196  drift_time(-1),
197  fragment_modification(0),
198  detecting_transition(true),
199  identifying_transition(false),
200  quantifying_transition(true)
201  {}
202 
203  // By convention, if there is no (metabolic) compound name, it is a peptide
204  bool isPeptide()
205  {
206  return CompoundName.empty();
207  }
208  };
209 
217  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenMS::TargetedExperiment& exp);
218 
226  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenSwath::LightTargetedExperiment& exp);
227 
237 
239 
241  void updateMembers_() override;
242 
243 private:
248 
250  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
251  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
252  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
253 
254  static const char* strarray_[];
255 
256  static const std::vector<std::string> header_names_;
257 
266  void getTSVHeader_(const std::string& line, char& delimiter, std::vector<std::string> header, std::map<std::string, int>& header_dict);
267 
275  void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
276 
277  void spectrastRTExtract(const String str_inp, double & value, bool & spectrast_legacy);
278 
279  bool spectrastAnnotationExtract(const String str_inp, TSVTransition & mytransition);
280 
283  void cleanupTransitions_(TSVTransition& mytransition);
284 
297  void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list);
298 
300  void createTransition_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::ReactionMonitoringTransition& rm_trans);
301 
303  void createProtein_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Protein& protein);
304 
306  void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times, const OpenMS::DataValue rt_value);
307 
309  void createPeptide_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Peptide& peptide);
310 
312  void createCompound_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Compound& compound);
313 
314  void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
315  int location, const ResidueModification& rmod);
317 
323  void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
324 
325 public:
326 
330 
332  ~TransitionTSVFile() override;
334 
341  void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
342 
350  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
351 
359  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
360 
362  void validateTargetedExperiment(const OpenMS::TargetedExperiment& targeted_exp);
363 
364  };
365 }
366 
Type
Actual file types enum.
Definition: FileTypes.h:58
bool detecting_transition
Definition: TransitionTSVFile.h:181
String SMILES
Definition: TransitionTSVFile.h:169
String fragment_charge
Definition: TransitionTSVFile.h:174
String fragment_type
Definition: TransitionTSVFile.h:179
A more convenient string class.
Definition: String.h:57
String precursor_charge
Definition: TransitionTSVFile.h:171
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Typedefs.
Definition: TransitionTSVFile.h:250
String transition_name
Definition: TransitionTSVFile.h:159
String Annotation
Definition: TransitionTSVFile.h:166
Representation of a modification.
Definition: ResidueModification.h:76
double fragment_mzdelta
Definition: TransitionTSVFile.h:176
String CompoundName
Definition: TransitionTSVFile.h:168
String uniprot_id
Definition: TransitionTSVFile.h:180
int fragment_modification
Definition: TransitionTSVFile.h:178
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
String peptide_group_label
Definition: TransitionTSVFile.h:172
int fragment_nr
Definition: TransitionTSVFile.h:175
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
double product
Definition: TransitionTSVFile.h:157
double rt_calibrated
Definition: TransitionTSVFile.h:158
String FullPeptideName
Definition: TransitionTSVFile.h:167
Internal structure to represent a transition.
Definition: TransitionTSVFile.h:154
String PeptideSequence
Definition: TransitionTSVFile.h:164
bool isPeptide()
Definition: TransitionTSVFile.h:204
TSVTransition()
Definition: TransitionTSVFile.h:186
double drift_time
Definition: TransitionTSVFile.h:177
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: TransitionTSVFile.h:251
double library_intensity
Definition: TransitionTSVFile.h:161
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: TransitionTSVFile.h:252
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:399
bool decoy
Definition: TransitionTSVFile.h:163
bool force_invalid_mods_
Definition: TransitionTSVFile.h:247
String label_type
Definition: TransitionTSVFile.h:173
String ProteinName
Definition: TransitionTSVFile.h:165
This class supports reading and writing of OpenSWATH transition lists.
Definition: TransitionTSVFile.h:142
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
bool identifying_transition
Definition: TransitionTSVFile.h:182
String SumFormula
Definition: TransitionTSVFile.h:170
bool quantifying_transition
Definition: TransitionTSVFile.h:183
Definition: TargetedExperimentHelper.h:111
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
String retentionTimeInterpretation_
Members.
Definition: TransitionTSVFile.h:245
String group_id
Definition: TransitionTSVFile.h:162
double CE
Definition: TransitionTSVFile.h:160
static const std::vector< std::string > header_names_
Definition: TransitionTSVFile.h:256
std::vector< String > peptidoforms
Definition: TransitionTSVFile.h:184
Definition: TransitionExperiment.h:206
bool override_group_label_check_
Definition: TransitionTSVFile.h:246
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:451
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56
double precursor
Definition: TransitionTSVFile.h:156