OpenMS  3.0.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-2022.
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 
144  class OPENMS_DLLAPI TransitionTSVFile :
145  public ProgressLogger,
146  public DefaultParamHandler
147  {
148 
149 protected:
157  {
158  double precursor = -1;
159  double product = -1;
160  double rt_calibrated = -1;
161  String transition_name = "";
162  double CE = -1;
163  double library_intensity = -1;
164  String group_id = "";
165  bool decoy = false;
167  std::vector<String> ProteinName;
178  String fragment_charge = "NA";
179  int fragment_nr = -1;
180  double fragment_mzdelta = -1;
181  double drift_time = -1;
182  int fragment_modification = 0;
184  std::vector<String> uniprot_id;
185  bool detecting_transition = true;
186  bool identifying_transition = false;
187  bool quantifying_transition = true;
188  std::vector<String> peptidoforms;
189 
192  bool isPeptide() const
193  {
194  return CompoundName.empty() || CompoundName == "NA";
195  }
196  };
197 
205 
213  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenMS::TargetedExperiment& exp);
214 
222  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenSwath::LightTargetedExperiment& exp);
223 
227 
229  void updateMembers_() override;
230 
231 private:
232 
233  // Members
237 
238  // Typedefs
239  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
240  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
241  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
242 
243  static const char* strarray_[];
244 
245  static const std::vector<std::string> header_names_;
246 
251 
259  void getTSVHeader_(const std::string& line, char& delimiter, std::map<std::string, int>& header_dict) const;
260 
268  void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
269 
271  void spectrastRTExtract(const String& str_inp, double & value, bool & spectrast_legacy);
272 
274  bool spectrastAnnotationExtract(const String& str_inp, TSVTransition & mytransition);
275 
278  void cleanupTransitions_(TSVTransition& mytransition);
280 
285 
298  void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list) const;
299 
301  void createTransition_(std::vector<TSVTransition>::iterator& tr_it,
303 
305  void createProtein_(String protein_name, const String& uniprot_id,
307 
309  void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times,
310  const OpenMS::DataValue& rt_value);
311 
313  void createPeptide_(std::vector<TSVTransition>::const_iterator tr_it,
315 
317  void createCompound_(std::vector<TSVTransition>::const_iterator tr_it,
319 
321  void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
322  int location,
323  const ResidueModification& rmod);
325 
331  void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
332 
333 public:
334 
338 
340  ~TransitionTSVFile() override;
342 
349  void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
350 
358  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
359 
367  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
368 
370  void validateTargetedExperiment(const OpenMS::TargetedExperiment& targeted_exp);
371 
372  };
373 }
374 
Type
Actual file types enum.
Definition: FileTypes.h:56
String SMILES
SMILES identifier (for metabolomics)
Definition: TransitionTSVFile.h:172
String fragment_type
Fragment type (e.g. "y" for a y7 ion)
Definition: TransitionTSVFile.h:183
std::vector< String > uniprot_id
List of UniProt identifiers of associated proteins.
Definition: TransitionTSVFile.h:184
A more convenient string class.
Definition: String.h:58
String precursor_charge
Precursor charge state.
Definition: TransitionTSVFile.h:175
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: TransitionTSVFile.h:239
String Annotation
Fragment ion annotation.
Definition: TransitionTSVFile.h:169
Representation of a modification on an amino acid residue.
Definition: ResidueModification.h:78
String CompoundName
Compound name (for metabolomics)
Definition: TransitionTSVFile.h:171
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
String Adducts
Adducts (for metabolomics)
Definition: TransitionTSVFile.h:174
String peptide_group_label
Peptide group identifier (grouping isotopically labelled peptides)
Definition: TransitionTSVFile.h:176
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:58
String GeneName
Gene identifier.
Definition: TransitionTSVFile.h:168
String FullPeptideName
Full peptide sequence with UniMod modifications.
Definition: TransitionTSVFile.h:170
Internal structure to represent a transition.
Definition: TransitionTSVFile.h:156
String PeptideSequence
Peptide sequence (only AA sequence)
Definition: TransitionTSVFile.h:166
std::vector< String > ProteinName
List of protein identifiers.
Definition: TransitionTSVFile.h:167
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: TransitionTSVFile.h:240
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: TransitionTSVFile.h:241
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:321
bool isPeptide() const
Definition: TransitionTSVFile.h:192
bool force_invalid_mods_
Definition: TransitionTSVFile.h:236
String label_type
Type of label that was used (e.g. "heavy" or "light")
Definition: TransitionTSVFile.h:177
This class supports reading and writing of OpenSWATH transition lists.
Definition: TransitionTSVFile.h:144
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
String SumFormula
Molecular formula (for metabolomics)
Definition: TransitionTSVFile.h:173
Definition: TargetedExperimentHelper.h:98
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
String retentionTimeInterpretation_
Definition: TransitionTSVFile.h:234
static const std::vector< std::string > header_names_
Definition: TransitionTSVFile.h:245
std::vector< String > peptidoforms
List of peptidoforms.
Definition: TransitionTSVFile.h:188
Definition: TransitionExperiment.h:218
bool override_group_label_check_
Definition: TransitionTSVFile.h:235
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:358
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:56