OpenMS
Loading...
Searching...
No Matches
TransitionTSVFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
21namespace OpenMS
22{
23
118 class OPENMS_DLLAPI TransitionTSVFile :
119 public ProgressLogger,
121 {
122
123protected:
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
192
194 void updateMembers_() override;
195
196private:
197
198 // Members
202
203 // Typedefs
204 typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
205 typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
206 typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
207
208 static const char* strarray_[];
209
210 static const std::vector<std::string> header_names_;
211
216
224 void getTSVHeader_(const std::string& line, char& delimiter, std::map<std::string, int>& header_dict) const;
225
233 void readUnstructuredTSVInput_(const char* filename, FileTypes::Type filetype, std::vector<TSVTransition>& transition_list);
234
236 void spectrastRTExtract(const String& str_inp, double & value, bool & spectrast_legacy);
237
239 bool spectrastAnnotationExtract(const String& str_inp, TSVTransition & mytransition);
240
244
260
265
278 void resolveMixedSequenceGroups_(std::vector<TSVTransition>& transition_list) const;
279
281 void createTransition_(std::vector<TSVTransition>::iterator& tr_it,
283
285 void createProtein_(String protein_name, const String& uniprot_id,
287
289 void interpretRetentionTime_(std::vector<TargetedExperiment::RetentionTime>& retention_times,
290 const OpenMS::DataValue& rt_value);
291
293 void createPeptide_(std::vector<TSVTransition>::const_iterator tr_it,
295
297 void createCompound_(std::vector<TSVTransition>::const_iterator tr_it,
299
301 void addModification_(std::vector<TargetedExperiment::Peptide::Modification>& mods,
302 int location,
303 const ResidueModification& rmod);
305
311 void writeTSVOutput_(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
312
313public:
314
316
318
322
329 void convertTargetedExperimentToTSV(const char* filename, OpenMS::TargetedExperiment& targeted_exp);
330
337 void convertLightTargetedExperimentToTSV(const char* filename, const OpenSwath::LightTargetedExperiment& targeted_exp);
338
346 void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenMS::TargetedExperiment& targeted_exp);
347
355 void convertTSVToTargetedExperiment(const char* filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment& targeted_exp);
356
359
360 };
361}
362
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition DataValue.h:34
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:34
Representation of a modification on an amino acid residue.
Definition ResidueModification.h:55
A more convenient string class.
Definition String.h:34
Represents a compound (small molecule)
Definition TargetedExperimentHelper.h:298
Represents a peptide (amino acid sequence)
Definition TargetedExperimentHelper.h:335
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:210
~TransitionTSVFile() override
Destructor.
bool override_group_label_check_
Definition TransitionTSVFile.h:200
TransitionTSVFile()
Constructor.
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:201
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:206
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:205
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 convertLightTargetedExperimentToTSV(const char *filename, const OpenSwath::LightTargetedExperiment &targeted_exp)
Write out a targeted experiment (Light structure) into a tsv file.
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:204
void streamTSVToLightTargetedExperiment_(const char *filename, FileTypes::Type filetype, OpenSwath::LightTargetedExperiment &exp)
Stream TSV directly to LightTargetedExperiment (memory-efficient)
String retentionTimeInterpretation_
Definition TransitionTSVFile.h:199
void updateMembers_() override
Synchronize members with param class.
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:75
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:356