OpenMS
OSWFile.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: George Rosenberger $
6 // $Authors: George Rosenberger, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
16 
17 #include <array>
18 #include <map>
19 
20 namespace OpenMS
21 {
40  class OPENMS_DLLAPI OSWFile
41  {
42  public:
43 
45  static constexpr Size ALL_PROTEINS = -1;
46 
49  OSWFile(const String& filename);
50  OSWFile(const OSWFile& rhs) = default;
51  OSWFile& operator=(const OSWFile& rhs) = default;
52 
56  void read(OSWData& swath_result);
57 
62  void readMinimal(OSWData& swath_result);
63 
73  void readProtein(OSWData& swath_result, const Size index);
74 
76  enum class OSWLevel
77  {
78  MS1,
79  MS2,
80  TRANSITION,
81  SIZE_OF_OSWLEVEL
82  };
83  static const std::array<std::string, (Size)OSWLevel::SIZE_OF_OSWLEVEL> names_of_oswlevel;
84 
86  {
87  PercolatorFeature(double score, double qvalue, double pep)
88  : score(score), qvalue(qvalue), posterior_error_prob(pep)
89  {}
90  PercolatorFeature(const PercolatorFeature& rhs) = default;
91 
92  double score;
93  double qvalue;
95  };
96 
101  static void readToPIN(const std::string& filename, const OSWFile::OSWLevel osw_level, std::ostream& pin_output,
102  const double ipf_max_peakgroup_pep, const double ipf_max_transition_isotope_overlap, const double ipf_min_transition_sn);
103 
107  static void writeFromPercolator(const std::string& osw_filename, const OSWFile::OSWLevel osw_level, const std::map< std::string, PercolatorFeature >& features);
108 
111  UInt64 getRunID() const;
112 
113  protected:
118  void readTransitions_(OSWData& swath_result);
119 
127  void getFullProteins_(OSWData& swath_result, Size prot_index = ALL_PROTEINS);
128 
130  void readMeta_(OSWData& data);
131 
132  private:
136  };
137 
138 } // namespace OpenMS
139 
Holds all or partial information from an OSW file.
Definition: OSWData.h:279
This class serves for reading in and writing OpenSWATH OSW files.
Definition: OSWFile.h:41
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:134
String filename_
sql file to open/write to
Definition: OSWFile.h:133
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:135
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:77
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:31
A more convenient string class.
Definition: String.h:34
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Definition: OSWFile.h:86
PercolatorFeature(double score, double qvalue, double pep)
Definition: OSWFile.h:87
double score
Definition: OSWFile.h:92
double qvalue
Definition: OSWFile.h:93
PercolatorFeature(const PercolatorFeature &rhs)=default
double posterior_error_prob
Definition: OSWFile.h:94