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: Andreas Bertsch, Timo Sachsenberg $ 00033 // -------------------------------------------------------------------------- 00034 // 00035 00036 #ifndef OPENMS_CHEMISTRY_ELEMENTDB_H 00037 #define OPENMS_CHEMISTRY_ELEMENTDB_H 00038 00039 #include <OpenMS/DATASTRUCTURES/String.h> 00040 #include <OpenMS/DATASTRUCTURES/Map.h> 00041 #include <OpenMS/CHEMISTRY/IsotopeDistribution.h> 00042 00043 namespace OpenMS 00044 { 00045 class Element; 00046 00070 class OPENMS_DLLAPI ElementDB 00071 { 00072 public: 00073 00077 00078 inline static const ElementDB * getInstance() 00079 { 00080 static ElementDB * db_ = 0; 00081 if (db_ == 0) 00082 { 00083 db_ = new ElementDB; 00084 } 00085 return db_; 00086 } 00087 00089 const Map<String, const Element *> & getNames() const; 00090 00092 const Map<String, const Element *> & getSymbols() const; 00093 00095 const Map<UInt, const Element *> & getAtomicNumbers() const; 00096 00101 const Element * getElement(const String & name) const; 00102 00104 const Element * getElement(UInt atomic_number) const; 00105 00107 Element * getElement(const String & name); 00108 00110 Element * getElement(UInt atomic_number); 00111 00113 00117 00118 bool hasElement(const String & name) const; 00119 00121 bool hasElement(UInt atomic_number) const; 00123 00124 protected: 00125 00126 /*_ parses a Histogram given as a OpenMS String and return the distribution 00127 00128 @throw throws exception ParseError 00129 */ 00130 IsotopeDistribution parseIsotopeDistribution_(const Map<UInt, double> & distribution); 00131 00132 /*_ calculates the average weight based on isotope abundance and mass 00133 */ 00134 double calculateAvgWeight_(const Map<UInt, double> & Z_to_abundance, const Map<UInt, double> & Z_to_mass); 00135 00136 /*_ calculates the mono weight based on the smallest isotope mass 00137 */ 00138 double calculateMonoWeight_(const Map<UInt, double> & Z_to_mass); 00139 00140 /*_ read elements from a XML file, formated as a Param file. 00141 00142 @throw throws ParseError if the file cannot be parsed 00143 @throw throws FileNotFound if the file could not be found 00144 */ 00145 void readFromFile_(const String & file_name); 00146 00147 /*_ resets all containers 00148 */ 00149 void clear_(); 00150 00151 Map<String, const Element *> names_; 00152 00153 Map<String, const Element *> symbols_; 00154 00155 Map<UInt, const Element *> atomic_numbers_; 00156 00157 private: 00158 00159 ElementDB(); 00160 00161 ElementDB(const ElementDB & db); 00162 00163 ElementDB & operator=(const ElementDB & db); 00164 00165 virtual ~ElementDB(); 00166 }; 00167 00168 } // namespace OpenMS 00169 #endif
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:38 using doxygen 1.7.1 |