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 
80  class OPENMS_DLLAPI TransitionTSVFile :
81  public ProgressLogger,
82  public DefaultParamHandler
83  {
84 
85 protected:
93  {
94  double precursor;
95  double product;
96  double rt_calibrated;
98  double CE;
101  bool decoy;
115  double drift_time;
122  std::vector<String> peptidoforms;
123 
125  precursor(-1),
126  product(-1),
127  rt_calibrated(-1),
128  CE(-1),
129  library_intensity(-1),
130  decoy(false),
131  fragment_charge("NA"),
132  fragment_nr(-1),
133  fragment_mzdelta(-1),
134  drift_time(-1),
135  fragment_modification(0),
136  detecting_transition(true),
137  identifying_transition(false),
138  quantifying_transition(true)
139  {}
140 
141  // By convention, if there is no (metabolic) compound name, it is a peptide
142  bool isPeptide()
143  {
144  return CompoundName.empty();
145  }
146  };
147 
155  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenMS::TargetedExperiment& exp);
156 
164  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenSwath::LightTargetedExperiment& exp);
165 
175 
177 
179  void updateMembers_() override;
180 
181 private:
186 
188  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
189  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
190  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
191 
192  static const char* strarray_[];
193 
194  static const std::vector<std::string> header_names_;
195 
204  void getTSVHeader_(const std::string& line, char& delimiter, std::vector<std::string> header, std::map<std::string, int>& header_dict);
205 
213  void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
214 
215  void spectrastRTExtract(const String str_inp, double & value, bool & spectrast_legacy);
216 
217  bool spectrastAnnotationExtract(const String str_inp, TSVTransition & mytransition);
218 
221  void cleanupTransitions_(TSVTransition& mytransition);
222 
235  void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list);
236 
238  void createTransition_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::ReactionMonitoringTransition& rm_trans);
239 
241  void createProtein_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Protein& protein);
242 
244  void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times, const OpenMS::DataValue rt_value);
245 
247  void createPeptide_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Peptide& peptide);
248 
250  void createCompound_(std::vector<TSVTransition>::iterator& tr_it, OpenMS::TargetedExperiment::Compound& compound);
251 
252  void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
253  int location, const ResidueModification& rmod);
255 
261  void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
262 
263 public:
264 
268 
270  ~TransitionTSVFile() override;
272 
279  void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
280 
288  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
289 
297  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
298 
300  void validateTargetedExperiment(const OpenMS::TargetedExperiment& targeted_exp);
301 
302  };
303 }
304 
Type
Actual file types enum.
Definition: FileTypes.h:58
bool detecting_transition
Definition: TransitionTSVFile.h:119
String SMILES
Definition: TransitionTSVFile.h:107
String fragment_charge
Definition: TransitionTSVFile.h:112
String fragment_type
Definition: TransitionTSVFile.h:117
A more convenient string class.
Definition: String.h:57
String precursor_charge
Definition: TransitionTSVFile.h:109
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Typedefs.
Definition: TransitionTSVFile.h:188
String transition_name
Definition: TransitionTSVFile.h:97
String Annotation
Definition: TransitionTSVFile.h:104
Representation of a modification.
Definition: ResidueModification.h:76
double fragment_mzdelta
Definition: TransitionTSVFile.h:114
String CompoundName
Definition: TransitionTSVFile.h:106
String uniprot_id
Definition: TransitionTSVFile.h:118
int fragment_modification
Definition: TransitionTSVFile.h:116
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
String peptide_group_label
Definition: TransitionTSVFile.h:110
int fragment_nr
Definition: TransitionTSVFile.h:113
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
double product
Definition: TransitionTSVFile.h:95
double rt_calibrated
Definition: TransitionTSVFile.h:96
String FullPeptideName
Definition: TransitionTSVFile.h:105
Internal structure to represent a transition.
Definition: TransitionTSVFile.h:92
String PeptideSequence
Definition: TransitionTSVFile.h:102
bool isPeptide()
Definition: TransitionTSVFile.h:142
TSVTransition()
Definition: TransitionTSVFile.h:124
double drift_time
Definition: TransitionTSVFile.h:115
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: TransitionTSVFile.h:189
double library_intensity
Definition: TransitionTSVFile.h:99
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: TransitionTSVFile.h:190
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:399
bool decoy
Definition: TransitionTSVFile.h:101
bool force_invalid_mods_
Definition: TransitionTSVFile.h:185
String label_type
Definition: TransitionTSVFile.h:111
String ProteinName
Definition: TransitionTSVFile.h:103
This class can convert TraML and TSV files into each other.
Definition: TransitionTSVFile.h:80
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:61
bool identifying_transition
Definition: TransitionTSVFile.h:120
String SumFormula
Definition: TransitionTSVFile.h:108
bool quantifying_transition
Definition: TransitionTSVFile.h:121
Definition: TargetedExperimentHelper.h:111
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
String retentionTimeInterpretation_
Members.
Definition: TransitionTSVFile.h:183
String group_id
Definition: TransitionTSVFile.h:100
double CE
Definition: TransitionTSVFile.h:98
static const std::vector< std::string > header_names_
Definition: TransitionTSVFile.h:194
std::vector< String > peptidoforms
Definition: TransitionTSVFile.h:122
Definition: TransitionExperiment.h:206
bool override_group_label_check_
Definition: TransitionTSVFile.h:184
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:94