OpenMS  2.8.0
OSWFile.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-2021.
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: George Rosenberger $
32 // $Authors: George Rosenberger, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
42 
43 #include <array>
44 #include <map>
45 
46 namespace OpenMS
47 {
66  class OPENMS_DLLAPI OSWFile
67  {
68  public:
69 
71  static constexpr Size ALL_PROTEINS = -1;
72 
75  OSWFile(const String& filename);
76  OSWFile(const OSWFile& rhs) = default;
77  OSWFile& operator=(const OSWFile& rhs) = default;
78 
82  void read(OSWData& swath_result);
83 
88  void readMinimal(OSWData& swath_result);
89 
99  void readProtein(OSWData& swath_result, const Size index);
100 
102  enum class OSWLevel
103  {
104  MS1,
105  MS2,
106  TRANSITION,
107  SIZE_OF_OSWLEVEL
108  };
109  static const std::array<std::string, (Size)OSWLevel::SIZE_OF_OSWLEVEL> names_of_oswlevel;
110 
112  {
113  PercolatorFeature(double score, double qvalue, double pep)
114  : score(score), qvalue(qvalue), posterior_error_prob(pep)
115  {}
116  PercolatorFeature(const PercolatorFeature& rhs) = default;
117 
118  double score;
119  double qvalue;
121  };
122 
127  static void readToPIN(const std::string& filename, const OSWFile::OSWLevel osw_level, std::ostream& pin_output,
128  const double ipf_max_peakgroup_pep, const double ipf_max_transition_isotope_overlap, const double ipf_min_transition_sn);
129 
133  static void writeFromPercolator(const std::string& osw_filename, const OSWFile::OSWLevel osw_level, const std::map< std::string, PercolatorFeature >& features);
134 
137  UInt64 getRunID() const;
138 
139  protected:
144  void readTransitions_(OSWData& swath_result);
145 
153  void getFullProteins_(OSWData& swath_result, Size prot_index = ALL_PROTEINS);
154 
156  void readMeta_(OSWData& data);
157 
158  private:
162  };
163 
164 } // namespace OpenMS
165 
Holds all or partial information from an OSW file.
Definition: OSWData.h:305
This class serves for reading in and writing OpenSWATH OSW files.
Definition: OSWFile.h:67
void read(OSWData &swath_result)
void getFullProteins_(OSWData &swath_result, Size prot_index=ALL_PROTEINS)
fill one (prot_id) or all proteins into swath_result
void readTransitions_(OSWData &swath_result)
SqliteConnector conn_
SQL connection. Stays open as long as this object lives.
Definition: OSWFile.h:160
String filename_
sql file to open/write to
Definition: OSWFile.h:159
static void writeFromPercolator(const std::string &osw_filename, const OSWFile::OSWLevel osw_level, const std::map< std::string, PercolatorFeature > &features)
Updates an OpenSWATH OSW SQLite file with the MS1-, MS2- or transition-level results of Percolator.
bool has_SCOREMS2_
database contains pyProphet's score_MS2 table with qvalues
Definition: OSWFile.h:161
void readProtein(OSWData &swath_result, const Size index)
populates a protein at index index within swath_results with Peptides, unless the protein already has...
OSWFile(const String &filename)
OSWFile & operator=(const OSWFile &rhs)=default
OSWLevel
for Percolator data read/write operations
Definition: OSWFile.h:103
UInt64 getRunID() const
static void readToPIN(const std::string &filename, const OSWFile::OSWLevel osw_level, std::ostream &pin_output, const double ipf_max_peakgroup_pep, const double ipf_max_transition_isotope_overlap, const double ipf_min_transition_sn)
Reads an OSW SQLite file and returns the data on MS1-, MS2- or transition-level as ostream (e....
void readMinimal(OSWData &swath_result)
void readMeta_(OSWData &data)
set source file and sqMass run-ID
OSWFile(const OSWFile &rhs)=default
File adapter for Sqlite files.
Definition: SqliteConnector.h:57
A more convenient string class.
Definition: String.h:60
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: OSWFile.h:112
PercolatorFeature(double score, double qvalue, double pep)
Definition: OSWFile.h:113
double score
Definition: OSWFile.h:118
double qvalue
Definition: OSWFile.h:119
PercolatorFeature(const PercolatorFeature &rhs)=default
double posterior_error_prob
Definition: OSWFile.h:120