OpenMS
TransitionTSVFile.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hannes Roest $
6 // $Authors: Hannes Roest $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
18 
19 #include <fstream>
20 
21 namespace OpenMS
22 {
23 
118  class OPENMS_DLLAPI TransitionTSVFile :
119  public ProgressLogger,
120  public DefaultParamHandler
121  {
122 
123 protected:
131  {
132  double precursor = -1;
133  double product = -1;
134  double rt_calibrated = -1;
135  String transition_name = "";
136  double CE = -1;
137  double library_intensity = -1;
138  String group_id = "";
139  bool decoy = false;
141  std::vector<String> ProteinName;
152  String fragment_charge = "NA";
153  int fragment_nr = -1;
154  double fragment_mzdelta = -1;
155  double drift_time = -1;
156  int fragment_modification = 0;
158  std::vector<String> uniprot_id;
159  bool detecting_transition = true;
160  bool identifying_transition = false;
161  bool quantifying_transition = true;
162  std::vector<String> peptidoforms;
163 
166  bool isPeptide() const
167  {
168  return CompoundName.empty() || CompoundName == "NA";
169  }
170  };
171 
179 
187  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenMS::TargetedExperiment& exp);
188 
196  void TSVToTargetedExperiment_(std::vector<TSVTransition>& transition_list, OpenSwath::LightTargetedExperiment& exp);
197 
201 
203  void updateMembers_() override;
204 
205 private:
206 
207  // Members
211 
212  // Typedefs
213  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
214  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
215  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
216 
217  static const char* strarray_[];
218 
219  static const std::vector<std::string> header_names_;
220 
225 
233  void getTSVHeader_(const std::string& line, char& delimiter, std::map<std::string, int>& header_dict) const;
234 
242  void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
243 
245  void spectrastRTExtract(const String& str_inp, double & value, bool & spectrast_legacy);
246 
248  bool spectrastAnnotationExtract(const String& str_inp, TSVTransition & mytransition);
249 
252  void cleanupTransitions_(TSVTransition& mytransition);
254 
259 
272  void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list) const;
273 
275  void createTransition_(std::vector<TSVTransition>::iterator& tr_it,
277 
279  void createProtein_(String protein_name, const String& uniprot_id,
281 
283  void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times,
284  const OpenMS::DataValue& rt_value);
285 
287  void createPeptide_(std::vector<TSVTransition>::const_iterator tr_it,
289 
291  void createCompound_(std::vector<TSVTransition>::const_iterator tr_it,
293 
295  void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
296  int location,
297  const ResidueModification& rmod);
299 
305  void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
306 
307 public:
308 
312 
314  ~TransitionTSVFile() override;
316 
323  void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
324 
332  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
333 
341  void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
342 
345 
346  };
347 }
348 
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:33
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
This class stores a SRM/MRM transition.
Definition: ReactionMonitoringTransition.h:32
Representation of a modification on an amino acid residue.
Definition: ResidueModification.h:53
A more convenient string class.
Definition: String.h:34
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:296
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:333
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:39
Definition: TransitionTSVFile.h:121
void interpretRetentionTime_(std::vector< TargetedExperiment::RetentionTime > &retention_times, const OpenMS::DataValue &rt_value)
Helper function to assign retention times to compounds and peptides.
void addModification_(std::vector< TargetedExperiment::Peptide::Modification > &mods, int location, const ResidueModification &rmod)
Add a modification at the specified location.
static const std::vector< std::string > header_names_
Definition: TransitionTSVFile.h:219
~TransitionTSVFile() override
Destructor.
bool override_group_label_check_
Definition: TransitionTSVFile.h:209
void createCompound_(std::vector< TSVTransition >::const_iterator tr_it, OpenMS::TargetedExperiment::Compound &compound)
Populate a new TargetedExperiment::Compound object (a metabolite) from a row in the csv.
void cleanupTransitions_(TSVTransition &mytransition)
Cleanup of the read fields (removing quotes etc.)
bool force_invalid_mods_
Definition: TransitionTSVFile.h:210
void convertTargetedExperimentToTSV(const char *filename, OpenMS::TargetedExperiment &targeted_exp)
Write out a targeted experiment (TraML structure) into a tsv file.
void createProtein_(String protein_name, const String &uniprot_id, OpenMS::TargetedExperiment::Protein &protein)
Populate a new TargetedExperiment::Protein object from a row in the csv.
TransitionTSVFile::TSVTransition convertTransition_(const ReactionMonitoringTransition *it, OpenMS::TargetedExperiment &targeted_exp)
Convert an OpenMS transition to a TSVTransition for output writing.
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: TransitionTSVFile.h:215
void readUnstructuredTSVInput_(const char *filename, FileTypes::Type filetype, std::vector< TSVTransition > &transition_list)
Read tab or comma separated input with columns defined by their column headers only.
void writeTSVOutput_(const char *filename, OpenMS::TargetedExperiment &targeted_exp)
Write a TargetedExperiment to a file.
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: TransitionTSVFile.h:214
void TSVToTargetedExperiment_(std::vector< TSVTransition > &transition_list, OpenMS::TargetedExperiment &exp)
Convert a list of TSVTransition to a TargetedExperiment.
void createPeptide_(std::vector< TSVTransition >::const_iterator tr_it, OpenMS::TargetedExperiment::Peptide &peptide)
Populate a new TargetedExperiment::Peptide object from a row in the csv.
void getTSVHeader_(const std::string &line, char &delimiter, std::map< std::string, int > &header_dict) const
Determine separator in a CSV file and check for correct headers.
void convertTSVToTargetedExperiment(const char *filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment &targeted_exp)
Read in a tsv file and construct a targeted experiment (Light transition structure)
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: TransitionTSVFile.h:213
String retentionTimeInterpretation_
Definition: TransitionTSVFile.h:208
void updateMembers_() override
Synchronize members with param class.
void TSVToTargetedExperiment_(std::vector< TSVTransition > &transition_list, OpenSwath::LightTargetedExperiment &exp)
Convert a list of TSVTransition to a LightTargetedExperiment.
void spectrastRTExtract(const String &str_inp, double &value, bool &spectrast_legacy)
Extract retention time from a SpectraST comment string.
void resolveMixedSequenceGroups_(std::vector< TSVTransition > &transition_list) const
Resolve cases where the same peptide label group has different sequences.
void convertTSVToTargetedExperiment(const char *filename, FileTypes::Type filetype, OpenMS::TargetedExperiment &targeted_exp)
Read in a tsv/mrm file and construct a targeted experiment (TraML structure)
bool spectrastAnnotationExtract(const String &str_inp, TSVTransition &mytransition)
Extract annotation from a SpectraST comment string.
void validateTargetedExperiment(const OpenMS::TargetedExperiment &targeted_exp)
Validate a TargetedExperiment (check that all ids are unique)
void createTransition_(std::vector< TSVTransition >::iterator &tr_it, OpenMS::ReactionMonitoringTransition &rm_trans)
Populate a new ReactionMonitoringTransition object from a row in the csv.
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Type
Actual file types enum.
Definition: FileTypes.h:31
Definition: TargetedExperimentHelper.h:73
Internal structure to represent a transition.
Definition: TransitionTSVFile.h:131
String FullPeptideName
Full peptide sequence with UniMod modifications.
Definition: TransitionTSVFile.h:144
String label_type
Type of label that was used (e.g. "heavy" or "light")
Definition: TransitionTSVFile.h:151
String PeptideSequence
Peptide sequence (only AA sequence)
Definition: TransitionTSVFile.h:140
std::vector< String > peptidoforms
List of peptidoforms.
Definition: TransitionTSVFile.h:162
std::vector< String > uniprot_id
List of UniProt identifiers of associated proteins.
Definition: TransitionTSVFile.h:158
bool isPeptide() const
Definition: TransitionTSVFile.h:166
String precursor_charge
Precursor charge state.
Definition: TransitionTSVFile.h:149
String CompoundName
Compound name (for metabolomics)
Definition: TransitionTSVFile.h:145
String SMILES
SMILES identifier (for metabolomics)
Definition: TransitionTSVFile.h:146
String peptide_group_label
Peptide group identifier (grouping isotopically labelled peptides)
Definition: TransitionTSVFile.h:150
String SumFormula
Molecular formula (for metabolomics)
Definition: TransitionTSVFile.h:147
String Adducts
Adducts (for metabolomics)
Definition: TransitionTSVFile.h:148
String fragment_type
Fragment type (e.g. "y" for a y7 ion)
Definition: TransitionTSVFile.h:157
String GeneName
Gene identifier.
Definition: TransitionTSVFile.h:142
std::vector< String > ProteinName
List of protein identifiers.
Definition: TransitionTSVFile.h:141
String Annotation
Fragment ion annotation.
Definition: TransitionTSVFile.h:143
Definition: TransitionExperiment.h:185