OpenMS
MQExporterHelper.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-2023.
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: Chris Bielow$
32 // $Authors: Virginia Rossow, Lenny Kovac, Hendrik Beschorner$
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <fstream>
40 #include <OpenMS/KERNEL/Feature.h>
44 
45 class OPENMS_DLLAPI MQExporterHelper
51 {
52 public:
53 
55  {
56  std::stringstream modifications;
57  char acetyl;
58  std::stringstream oxidation;
59  std::stringstream gene_names;
60  std::stringstream protein_names;
61  std::stringstream msms_mz;
62  std::stringstream mass_error_ppm;
63  std::stringstream mass_error_da;
64  std::stringstream uncalibrated_mass_error_ppm;
65  std::stringstream uncalibrated_mass_error_da;
66  std::stringstream uncalibrated_calibrated_mz_ppm;
67  std::stringstream uncalibrated_calibrated_mz_mda;
68  std::stringstream base_peak_fraction;
69 
70  // common columns in msms and evividence exporter
71  //file_ << "Sequence" << "\t"; maybe, relativ trivial
72  //file_ << "Length" << "\t";
73  //file_ << "Modifications" << "\t"; implementieren
74  // file_ << "Modified sequence" << "\t"; implementieren
75  //file_ << "Acetyl (Protein N-term)" << "\t"; implementieren
76  //file_ << "Oxidation (M)" << "\t"; implementieren
77  //file_ << "Missed cleavages" << "\t"; trivial
78  //file_ << "Proteins" << "\t"; trivial
79  //file_ << "Gene Names" << "\t"; // in progress, aber implementieren
80  //file_ << "Protein Names" << "\t"; // in progress, aber implementieren
81  //file_ << "Type" << "\t"; TODO different type
82  //file_ << "Raw file" << "\t"; trivial
83  //file_ << "MS/MS m/z" << "\t"; implementieren TODO is m/z in MSMS MS/MS m/z
84  //file_ << "Charge" << "\t"; trivial
85  //file_ << "m/z" << "\t"; trivial TODO
86  //file_ << "Mass" << "\t"; trivial
87  //file_ << "Mass Error [ppm]" << "\t"; vielleicht, beim einen halt noch calibrated dabei
88  //file_ << "Mass Error [Da]" << "\t"; vielleicht, beim einen halt noch calibrated dabei
89  //file_ << "Retention time" << "\t"; trivial
90  //file_ << "Fraction of total spectrum" << "\t"; trivial
91  //file_ << "Base peak fraction" << "\t"; trvial
92  //file_ << "PEP" << "\t"; trivial
93  //file_ << "MS/MS Scan Number" << "\t"; trivial
94  //file_ << "Score" << "\t"; trivial
95  //file_ << "Delta score" << "\t"; trivial
96  //file_ << "Reverse" << "\t";
97  //file_ << "id" << "\t"; ?
98  //file_ << "Protein group IDs" << "\n"; trivial
99 
100  explicit MQCommonOutputs(
101  const OpenMS::Feature& f,
102  const OpenMS::ConsensusMap& cmap,
103  const OpenMS::Size c_feature_number,
104  const std::multimap<OpenMS::String, std::pair<OpenMS::Size, OpenMS::Size>>& UIDs,
106  const OpenMS::MSExperiment& exp,
107  const std::map<OpenMS::String,OpenMS::String>& prot_mapper);
108  };
109 
115 static OpenMS::String extractGeneName(const OpenMS::String& prot_description);
116 
130  static OpenMS::Size proteinGroupID_(std::map<OpenMS::String, OpenMS::Size>& database,
131  const OpenMS::String& protein_accession);
132 
143  static std::map<OpenMS::Size, OpenMS::Size> makeFeatureUIDtoConsensusMapIndex_(const OpenMS::ConsensusMap& cmap);
144 
158  static bool hasValidPepID_(
159  const OpenMS::Feature& f,
160  const OpenMS::Size c_feature_number,
161  const std::multimap<OpenMS::String, std::pair<OpenMS::Size, OpenMS::Size>>& UIDs,
163 
175 
176 
183  static bool isValid(const std::string& filename_);
184 };
Helper class for common functions and NON trivial values needed for exporting MaxQuant outputs.
Definition: MQExporterHelper.h:51
static bool isValid(const std::string &filename_)
Checks if file is writable (i.e. the path in the ctor was not empty and could be created)
static OpenMS::String extractGeneName(const OpenMS::String &prot_description)
Extract a gene name from a protein description by looking for the substring 'GN='.
static std::map< OpenMS::Size, OpenMS::Size > makeFeatureUIDtoConsensusMapIndex_(const OpenMS::ConsensusMap &cmap)
Creates map that has the information which FeatureUID is mapped to which ConsensusFeature in Consensu...
static bool hasValidPepID_(const OpenMS::Feature &f, const OpenMS::Size c_feature_number, const std::multimap< OpenMS::String, std::pair< OpenMS::Size, OpenMS::Size >> &UIDs, const OpenMS::ProteinIdentification::Mapping &mp_f)
Checks if Feature has valid PeptideIdentifications.
static bool hasPeptideIdentifications_(const OpenMS::ConsensusFeature &cf)
Checks if ConsensusFeature has valid PeptideIdentifications.
static OpenMS::Size proteinGroupID_(std::map< OpenMS::String, OpenMS::Size > &database, const OpenMS::String &protein_accession)
Returns a unique ID (number) for each distinct protein accession, or creates a new ID by augmenting t...
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:71
A container for consensus elements.
Definition: ConsensusMap.h:92
An LC-MS feature.
Definition: Feature.h:72
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
A more convenient string class.
Definition: String.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Definition: MQExporterHelper.h:55
std::stringstream mass_error_ppm
Definition: MQExporterHelper.h:62
std::stringstream uncalibrated_mass_error_ppm
Definition: MQExporterHelper.h:64
std::stringstream modifications
Definition: MQExporterHelper.h:56
std::stringstream base_peak_fraction
Definition: MQExporterHelper.h:68
std::stringstream mass_error_da
Definition: MQExporterHelper.h:63
std::stringstream uncalibrated_calibrated_mz_mda
Definition: MQExporterHelper.h:67
std::stringstream gene_names
Definition: MQExporterHelper.h:59
std::stringstream uncalibrated_calibrated_mz_ppm
Definition: MQExporterHelper.h:66
std::stringstream uncalibrated_mass_error_da
Definition: MQExporterHelper.h:65
std::stringstream protein_names
Definition: MQExporterHelper.h:60
std::stringstream msms_mz
Definition: MQExporterHelper.h:61
std::stringstream oxidation
Definition: MQExporterHelper.h:58
char acetyl
Definition: MQExporterHelper.h:57
MQCommonOutputs(const OpenMS::Feature &f, const OpenMS::ConsensusMap &cmap, const OpenMS::Size c_feature_number, const std::multimap< OpenMS::String, std::pair< OpenMS::Size, OpenMS::Size >> &UIDs, const OpenMS::ProteinIdentification::Mapping &mp_f, const OpenMS::MSExperiment &exp, const std::map< OpenMS::String, OpenMS::String > &prot_mapper)
two way mapping from ms-run-path to protID|pepID-identifier
Definition: ProteinIdentification.h:83