Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

MzTabFile.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Timo Sachsenberg $
00032 // $Authors: Timo Sachsenberg $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_FORMAT_MZTABFILE_H
00036 #define OPENMS_FORMAT_MZTABFILE_H
00037 
00038 #include <OpenMS/FORMAT/MzTab.h>
00039 #include <OpenMS/FORMAT/IdXMLFile.h>
00040 #include <OpenMS/FORMAT/SVOutStream.h>
00041 #include <OpenMS/FILTERING/ID/IDFilter.h>
00042 #include <OpenMS/CHEMISTRY/ModificationsDB.h>
00043 #include <OpenMS/FORMAT/SVOutStream.h>
00044 
00045 #include <boost/math/special_functions/fpclassify.hpp>
00046 
00047 #include <vector>
00048 #include <algorithm>
00049 
00050 namespace OpenMS
00051 {
00057   class OPENMS_DLLAPI MzTabFile
00058   {
00059 public:
00061     MzTabFile();
00063     ~MzTabFile();
00064 
00065     typedef std::map<std::pair<String, String>, std::vector<PeptideHit> > MapAccPepType;
00066 
00067     // (deprecated) TODO: use conversion to MzTab data structure and store function below
00068     void store(const String & filename, const std::vector<ProteinIdentification> & protein_ids, const std::vector<PeptideIdentification> & peptide_ids, String in, String document_id) const;
00069 
00070     // store MzTab file
00071     void store(const String & filename, const MzTab& mz_tab) const;
00072 
00073 protected:
00074     void generateMzTabMetaDataSection_(const MzTabMetaData& map, StringList& sl) const;
00075 
00076     void generateProteinHeader_(Int n_subsamples, const std::vector<String>& optional_protein_columns, StringList& sl) const;
00077 
00078     String generateMzTabProteinSectionRow_(const MzTabProteinSectionRow& row, const String& unit_id) const;
00079 
00080     void generateMzTabProteinSection_(const MzTabProteinSectionData& map, StringList& sl) const;
00081 
00082     void generateMzTabPeptideSection_(const MzTabPeptideSectionData& map, StringList& sl) const;
00083 
00084     void generateMzTabSmallMoleculeSection_(const MzTabSmallMoleculeSectionData & map, StringList& sl) const;
00085 
00086     String generateMzTabPeptideHeader_(Int n_subsamples, const std::vector<String>& optional_protein_columns) const;
00087 
00088     String generateMzTabPeptideSectionRow_(const MzTabPeptideSectionRow& row, const String& unit_id) const;
00089 
00090     String generateMzTabSmallMoleculeHeader_(Int n_subsamples, const std::vector<String>& optional_smallmolecule_columns) const;
00091 
00092     String generateMzTabSmallMoleculeSectionRow_(const MzTabSmallMoleculeSectionRow& row, const String& unit_id) const;
00093 
00094     static void sortPSM_(std::vector<PeptideIdentification>::iterator begin, std::vector<PeptideIdentification>::iterator end);
00095 
00096     static void keepFirstPSM_(std::vector<PeptideIdentification>::iterator begin, std::vector<PeptideIdentification>::iterator end);
00097 
00099     static void partitionIntoRuns(const std::vector<PeptideIdentification> & pep_ids,
00100                                   const std::vector<ProteinIdentification> & pro_ids,
00101                                   std::map<String, std::vector<PeptideIdentification> > & map_run_to_pepids,
00102                                   std::map<String, std::vector<ProteinIdentification> > & map_run_to_proids
00103                                   );
00104 
00105 
00107     static void createProteinToPeptideLinks(const std::map<String, std::vector<PeptideIdentification> > & map_run_to_pepids, MapAccPepType & map_run_accession_to_pephits);
00108 
00110     static String extractProteinAccession_(const PeptideHit & peptide_hit);
00111 
00113     static String extractPeptideModifications_(const PeptideHit & peptide_hit);
00114 
00116     static String mapSearchEngineToCvParam_(const String & openms_search_engine_name);
00117 
00118     static String mapSearchEngineScoreToCvParam_(const String & openms_search_engine_name, DoubleReal score, String score_type);
00119 
00120     static String extractNumPeptides(const String & common_identifier, const String & protein_accession,
00121                                      const MapAccPepType & map_run_accesion_to_peptides);
00122 
00123     // mzTab definition of distinct
00124     static String extractNumPeptidesDistinct(String common_identifier, String protein_accession,
00125                                              const MapAccPepType & map_run_accesion_to_peptides);
00126 
00127     // same as distinct but additional constraint of uniquenes (=maps to exactly one Protein)
00128     static String extractNumPeptidesUnambiguous(String common_identifier, String protein_accession,
00129                                                 const MapAccPepType & map_run_accesion_to_peptides);
00130 
00131     static std::map<String, Size> extractNumberOfSubSamples_(const std::map<String, std::vector<ProteinIdentification> > & map_run_to_proids);
00132 
00133     static void writePeptideHeader_(SVOutStream & output, std::map<String, Size> n_sub_samples);
00134 
00135     static void writeProteinHeader_(SVOutStream & output, std::map<String, Size> n_sub_samples);
00136 
00137     static void writeProteinData_(SVOutStream & output,
00138                                   const ProteinIdentification & prot_id,
00139                                   Size run_count,
00140                                   String input_filename,
00141                                   bool has_coverage,
00142                                   const MapAccPepType & map_run_accesion_to_peptides,
00143                                   const std::map<String, Size> & map_run_to_num_sub
00144                                   );
00145 
00146   };
00147 
00148 } // namespace OpenMS
00149 
00150 #endif // OPENMS_FORMAT_MZTABFILE_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:42 using doxygen 1.7.1