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 = -1;
157  double product = -1;
158  double rt_calibrated = -1;
159  String transition_name = "";
160  double CE = -1;
161  double library_intensity = -1;
162  String group_id = "";
163  bool decoy = false;
174  String fragment_charge = "NA";
175  int fragment_nr = -1;
176  double fragment_mzdelta = -1;
177  double drift_time = -1;
178  int fragment_modification = 0;
181  bool detecting_transition = true;
182  bool identifying_transition = false;
183  bool quantifying_transition = true;
184  std::vector<String> peptidoforms;
185 
188  bool isPeptide() const
189  {
190  return CompoundName.empty();
191  }
192  };
193 
201 
209  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenMS::TargetedExperiment& exp);
210 
218  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenSwath::LightTargetedExperiment& exp);
219 
223 
225  void updateMembers_() override;
226 
227 private:
228 
229  // Members
233 
234  // Typedefs
235  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
236  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
237  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
238 
239  static const char* strarray_[];
240 
241  static const std::vector<std::string> header_names_;
242 
247 
255  void getTSVHeader_(const std::string& line, char& delimiter, std::map<std::string, int>& header_dict) const;
256 
264  void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
265 
267  void spectrastRTExtract(const String str_inp, double & value, bool & spectrast_legacy);
268 
270  bool spectrastAnnotationExtract(const String str_inp, TSVTransition & mytransition);
271 
274  void cleanupTransitions_(TSVTransition& mytransition);
276 
281 
294  void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list) const;
295 
297  void createTransition_(std::vector<TSVTransition>::iterator& tr_it,
299 
301  void createProtein_(std::vector<TSVTransition>::iterator& tr_it,
303 
305  void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times,
306  const OpenMS::DataValue rt_value);
307 
309  void createPeptide_(std::vector<TSVTransition>::const_iterator tr_it,
311 
313  void createCompound_(std::vector<TSVTransition>::const_iterator tr_it,
315 
317  void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
318  int location,
319  const ResidueModification& rmod);
321 
327  void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
328 
329 public:
330 
334 
336  ~TransitionTSVFile() override;
338 
345  void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
346 
354  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
355 
363  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
364 
366  void validateTargetedExperiment(const OpenMS::TargetedExperiment& targeted_exp);
367 
368  };
369 }
370 
Type
Actual file types enum.
Definition: FileTypes.h:58
String SMILES
SMILES identifier (for metabolomics)
Definition: TransitionTSVFile.h:169
String fragment_type
Fragment type (e.g. "y" for a y7 ion)
Definition: TransitionTSVFile.h:179
A more convenient string class.
Definition: String.h:58
String precursor_charge
Precursor charge state.
Definition: TransitionTSVFile.h:171
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: TransitionTSVFile.h:235
String Annotation
Fragment ion annotation.
Definition: TransitionTSVFile.h:166
Representation of a modification.
Definition: ResidueModification.h:76
String CompoundName
Compound name (for metabolomics)
Definition: TransitionTSVFile.h:168
String uniprot_id
UniProt identifier of associated protein.
Definition: TransitionTSVFile.h:180
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
String peptide_group_label
Peptide group identifier (grouping isotopically labelled peptides)
Definition: TransitionTSVFile.h:172
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
String FullPeptideName
Full peptide sequence with UniMod modifications.
Definition: TransitionTSVFile.h:167
Internal structure to represent a transition.
Definition: TransitionTSVFile.h:154
String PeptideSequence
Peptide sequence (only AA sequence)
Definition: TransitionTSVFile.h:164
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: TransitionTSVFile.h:236
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: TransitionTSVFile.h:237
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:399
bool isPeptide() const
Definition: TransitionTSVFile.h:188
bool force_invalid_mods_
Definition: TransitionTSVFile.h:232
String label_type
Type of label that was used (e.g. "heavy" or "light")
Definition: TransitionTSVFile.h:173
String ProteinName
Protein identifier.
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
String SumFormula
Molecular formula (for metabolomics)
Definition: TransitionTSVFile.h:170
Definition: TargetedExperimentHelper.h:111
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
String retentionTimeInterpretation_
Definition: TransitionTSVFile.h:230
static const std::vector< std::string > header_names_
Definition: TransitionTSVFile.h:241
std::vector< String > peptidoforms
List of peptidoforms.
Definition: TransitionTSVFile.h:184
Definition: TransitionExperiment.h:206
bool override_group_label_check_
Definition: TransitionTSVFile.h:231
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:451
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56