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

ResidueDB.h (Maintainer: Andreas Bertsch)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Andreas Bertsch $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_CHEMISTRY_RESIDUEDB_H
00028 #define OPENMS_CHEMISTRY_RESIDUEDB_H
00029 
00030 #include <OpenMS/DATASTRUCTURES/HashMap.h>
00031 
00032 #include <set>
00033 
00034 namespace OpenMS
00035 {
00036   // forward declarations
00037   class ResidueModification;
00038   class Residue;
00039 
00047   class ResidueDB
00048   {         
00049     public:
00050 
00054       typedef std::set<Residue*>::iterator ResidueIterator;
00055       typedef std::set<const Residue*>::const_iterator ResidueConstIterator;
00056       typedef std::set<ResidueModification*>::iterator ResidueModificationIterator;
00057       typedef std::set<const ResidueModification*>::const_iterator ResidueModificationConstIterator;
00059       
00063 
00064       ResidueDB();
00065 
00067       ResidueDB(const ResidueDB& residue_db);
00068       
00070       ResidueDB(const String& res_filename, const String& mod_filename) 
00071         throw(Exception::FileNotFound, Exception::ParseError);
00072       
00074       virtual ~ResidueDB();
00076       
00080 
00081       ResidueDB& operator = (const ResidueDB& aa);
00083       
00087 
00088       UInt getNumberOfResidues() const;
00089       
00091       UInt getNumberOfResidueModifications() const;
00092 
00094       const ResidueModification* getModification(const String& name) const;
00095 
00097       std::set<const ResidueModification*> getModifications(const Residue* residue) const;
00098 
00100       std::set<const ResidueModification*> getModifications(const String& res_name) const;
00101 
00103       const std::set<const ResidueModification*>& getModifications() const;
00104 
00106       const Residue* getResidue(const String& name) const;
00107 
00109       std::set<const Residue*> getResidues(const ResidueModification* modification) const;
00110 
00112       std::set<const Residue*> getResidues(const String& mod_name) const;
00113 
00115       const std::set<const Residue*>& getResidues() const;
00116 
00118       void setModifications(const String& filename) throw(Exception::FileNotFound, Exception::ParseError);
00119 
00121       void addResidueModification(ResidueModification modification);
00122 
00124       void setResidues(const String& filename) throw(Exception::FileNotFound, Exception::ParseError);
00125 
00127       void addResidue(const Residue& residue);
00129 
00133 
00134       bool hasResidueModification(const String& name) const;
00135 
00137       bool hasResidue(const String& name) const;
00138 
00140       bool operator == (const ResidueDB& rhs) const;
00141 
00143       bool operator != (const ResidueDB& rhs) const;
00145       
00149       inline ResidueIterator beginResidue() { return residues_.begin(); }
00150 
00151       inline ResidueIterator endResidue() { return residues_.end(); }
00152       
00153       inline ResidueConstIterator beginResidue() const { return const_residues_.begin(); }
00154 
00155       inline ResidueConstIterator endResidue() const { return const_residues_.end(); }
00156 
00157       inline ResidueModificationIterator beginResidueModification() { return modifications_.begin(); }
00158 
00159       inline ResidueModificationIterator endResidueModification() { return modifications_.end(); }
00160         
00161       inline ResidueModificationConstIterator beginResidueModification() const { return const_modifications_.begin(); }
00162 
00163       inline ResidueModificationConstIterator endResidueModification() const { return const_modifications_.end(); }
00165 
00166     protected:
00167 
00168       /*_ reads residues from the given file
00169       */
00170       void readResiduesFromFile_(const String& filename) throw(Exception::FileNotFound, Exception::ParseError);
00171 
00172       /*_ parses a residue, given the key/value pairs from i.e. an XML file
00173       */
00174       Residue* parseResidue_(HashMap<String, String>& values) throw();
00175 
00176       /*_ reads modifications from a file
00177       */
00178       void readResidueModificationsFromFile_(const String& filename) throw(Exception::FileNotFound, Exception::ParseError);
00179 
00180       /*_ deletes all sub-instances of the stored data like modifications and residues
00181       */
00182       void clear_();
00183 
00184       /*_ deletes all residues
00185       */
00186       void clearResidues_();
00187 
00188       /*_ deletes all modifications and also modified residues
00189       */
00190       void clearResidueModifications_();
00191 
00192       /*_ builds an index of residue names for fast access, synonyms are also considered
00193       */
00194       void buildResidueNames_();
00195 
00196       /*_ builds an index of modifications names for fast access, synonyms are also considered
00197       */
00198       void buildResidueModificationNames_();
00199 
00200       /*_ builds modified residues from a given modifications and residues
00201       */
00202       void buildModifiedResidues_();
00203 
00204       HashMap<String, Residue*> residue_names_;
00205 
00206       std::set<Residue*> residues_;
00207 
00208       std::set<const Residue*> const_residues_;
00209     
00210       HashMap<String, ResidueModification*> modification_names_;
00211       
00212       std::set<ResidueModification*> modifications_;
00213 
00214       std::set<const ResidueModification*> const_modifications_;
00215   };
00216 }
00217 #endif

Generated Tue Apr 1 15:36:37 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1