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

QcMLFile.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: Mathias Walzer $
00032 // $Authors: Mathias Walzer $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_FORMAT_QCMLFILE_H
00036 #define OPENMS_FORMAT_QCMLFILE_H
00037 
00038 #include <OpenMS/CONCEPT/ProgressLogger.h>
00039 #include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>
00040 #include <OpenMS/FORMAT/XMLFile.h>
00041 #include <OpenMS/CONCEPT/UniqueIdGenerator.h>
00042 
00043 #include <vector>
00044 #include <map>
00045 #include <set>
00046 #include <algorithm>
00047 
00048 namespace OpenMS
00049 {
00057   class OPENMS_DLLAPI QcMLFile :
00058     public Internal::XMLHandler,
00059     public Internal::XMLFile,
00060     public ProgressLogger
00061   {
00062 public:
00064     struct OPENMS_DLLAPI QualityParameter
00065     {
00066       String name; 
00067       String id; 
00068       String value; 
00069       String cvRef; 
00070       String cvAcc; 
00071       String unitRef; 
00072       String unitAcc; 
00073       String flag; 
00074 
00076       QualityParameter();
00077 
00078       QualityParameter(const QualityParameter& rhs);
00079 
00080       QualityParameter& operator=(const QualityParameter& rhs);
00081       bool operator==(const QualityParameter& rhs) const;
00082       bool operator<(const QualityParameter& rhs) const;
00083       bool operator>(const QualityParameter& rhs) const;
00084 
00085       String toXMLString(UInt indentation_level) const;
00086     };
00087 
00089     struct OPENMS_DLLAPI Attachment
00090     {
00091       String name; 
00092       String value; 
00093       String cvRef; 
00094       String cvAcc; 
00095       String unitRef; 
00096       String unitAcc; 
00097       String binary; 
00098       String qualityRef; 
00099       std::vector<String> colTypes; 
00100       std::vector< std::vector<String> > tableRows; 
00101       //~ TODO -schema- coltypes with full definition (uintRef, unitAcc)
00102 
00104       Attachment();
00105 
00106       Attachment(const Attachment& rhs);
00107 
00108       Attachment& operator=(const Attachment& rhs);
00109       bool operator==(const Attachment& rhs) const;
00110       bool operator<(const Attachment& rhs) const;
00111       bool operator>(const Attachment& rhs) const;
00112 
00113       String toXMLString(UInt indentation_level) const;
00114       String toCSVString(String separator) const;
00115     };
00116 
00118     QcMLFile();
00120     ~QcMLFile();
00121 
00122     String map2cvs(const std::map< String, std::map<String, String> >& cvs_table, const String& separator) const;
00123     String exportIDstats(const String& filename) const;
00124 
00126     void addRunQualityParameter(String r, QualityParameter qp);
00128     void addRunAttachment(String r, Attachment at);
00130     void addSetQualityParameter(String r, QualityParameter qp);
00132     void addSetAttachment(String r, Attachment at);
00134     void removeAttachment(String r, std::vector<String>& ids, String at = "");
00136     void removeAttachment(String r, String at);
00138     void removeAllAttachments(String at);
00140     void removeQualityParameter(String r, std::vector<String>& ids);
00142     void merge(const QcMLFile & addendum, String setname = "");
00144     void/* std::vector<String>& */ collectSetParameter(const String setname, const String qp, std::vector<String>& ret);
00146     String exportAttachment(const String filename, const String qpname) const;
00148     void getRunNames (std::vector<String>& ids) const;
00150     bool existsRun(const String filename) const;
00152     bool existsSet(const String filename) const;
00154     void existsRunQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
00156     void existsSetQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
00158     void store(const String & filename) const;
00160     void load(const String & filename);
00161 
00162     //~ int siz; //debug
00163 
00164 protected:
00165     // Docu in base class
00166     virtual void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
00167 
00168     // Docu in base class
00169     virtual void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
00170 
00171     // Docu in base class
00172     virtual void characters(const XMLCh * const chars, const XMLSize_t length);
00173 
00174     std::map<String, std::vector< QualityParameter > > runQualityQPs_; //TODO run name attribute to schema of RunQuality
00175     std::map<String, std::vector< Attachment > > runQualityAts_;
00176     std::map<String, std::vector< QualityParameter > > setQualityQPs_;
00177     std::map<String, std::vector< Attachment > > setQualityAts_;
00178     std::map<String, std::set< String > > setQualityQPs_members_;
00179 
00180     String tag_;
00181     UInt progress_;
00182     QualityParameter qp_;
00183     Attachment at_;
00184     std::vector<String> row_;
00185     std::vector<String> header_;
00186     String name_;
00187     std::set<String> names_;
00188     std::vector<QualityParameter> qps_;
00189     std::vector<Attachment> ats_;
00190 
00191   };
00192 
00193 } // namespace OpenMS
00194 
00195 #endif // OPENMS_FORMAT_QCMLFILE_H

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