00001 /* $Id: SpectrumSet.hpp 104199 2007-05-18 15:55:21Z lewisg $ 00002 * =========================================================================== 00003 * 00004 * PUBLIC DOMAIN NOTICE 00005 * National Center for Biotechnology Information 00006 * 00007 * This software/database is a "United States Government Work" under the 00008 * terms of the United States Copyright Act. It was written as part of 00009 * the author's official duties as a United States Government employee and 00010 * thus cannot be copyrighted. This software/database is freely available 00011 * to the public for use. The National Library of Medicine and the U.S. 00012 * Government have not placed any restriction on its use or reproduction. 00013 * 00014 * and reliability of the software and data, the NLM 00015 * Although all reasonable efforts have been taken to ensure the accuracyand the U.S. 00016 * Government do not and cannot warrant the performance or results that 00017 * may be obtained by using this software or data. The NLM and the U.S. 00018 * Government disclaim all warranties, express or implied, including 00019 * warranties of performance, merchantability or fitness for any particular 00020 * purpose. 00021 * 00022 * Please cite the author in any work or product based on this material. 00023 * 00024 * =========================================================================== 00025 * 00026 * Author: Lewis Y. Geer 00027 * 00028 * File Description: 00029 * Code for loading in spectrum datasets 00030 * 00031 * Remark: 00032 * This code was originally generated by application DATATOOL 00033 * using specifications from the data definition file 00034 * 'omssa.asn'. 00035 */ 00036 00037 #ifndef SPECTRUMSET_HPP 00038 #define SPECTRUMSET_HPP 00039 00040 00041 // generated includes 00042 #include <objects/omssa/MSSpectrumset.hpp> 00043 #include <objects/omssa/MSSpectrumFileType.hpp> 00044 00045 #include <iostream> 00046 #include <deque> 00047 00048 #include <corelib/ncbistr.hpp> 00049 00050 // generated classes 00051 BEGIN_NCBI_SCOPE 00052 00053 BEGIN_objects_SCOPE // namespace ncbi::objects:: 00054 00055 // proton mass 00056 const double kProton = 1.00728; 00057 00058 //! struct for holding a single peak 00059 typedef struct _InputPeak 00060 { 00061 //! scaled m/z value for peak 00062 int mz; 00063 //! unscaled intensity 00064 float Intensity; 00065 } TInputPeak; 00066 00067 //! for holding a spectrum 00068 typedef deque < TInputPeak > TInputPeaks; 00069 00070 00071 00072 class CSpectrumSet : public CMSSpectrumset { 00073 // typedef CMSSpectrumset_Base Tparent; 00074 typedef CMSSpectrumset Tparent; 00075 00076 public: 00077 00078 // constructor 00079 CSpectrumSet(void); 00080 // destructor 00081 ~CSpectrumSet(void); 00082 00083 /// 00084 /// wrapper for various file loaders 00085 /// 00086 int LoadFile(const EMSSpectrumFileType FileType, CNcbiIstream& DTA, int Max = 0); 00087 00088 /// 00089 /// load in a single dta file 00090 /// 00091 int LoadDTA( 00092 CNcbiIstream& DTA // stream containing dta 00093 ); 00094 00095 /// 00096 /// load in multiple dta files with <dta> tag separators 00097 /// 00098 /// returns -1 if more than Max spectra read 00099 int LoadMultDTA( 00100 CNcbiIstream& DTA, // stream containing tag delimited dtas 00101 int Max = 0 // maximum number of dtas to read in, 0= no limit 00102 ); 00103 00104 /// 00105 /// load multiple dta's separated by a blank line 00106 /// 00107 /// returns -1 if more than Max spectra read 00108 int LoadMultBlankLineDTA( 00109 CNcbiIstream& DTA, // stream containing blank delimited dtas 00110 int Max = 0, // maximum number of dtas to read in, 0= no limit 00111 bool isPKL = false // pkl formatted? 00112 ); 00113 00114 /// 00115 /// load mgf file 00116 /// 00117 /// returns -1 if more than Max spectra read 00118 int LoadMGF( 00119 CNcbiIstream& DTA, // stream containing mgf file 00120 int Max = 0 // maximum number of dtas to read in, 0= no limit 00121 ); 00122 00123 protected: 00124 00125 /// 00126 /// Read in the header of a DTA file 00127 /// 00128 bool GetDTAHeader( 00129 CNcbiIstream& DTA, // input stream 00130 CRef <CMSSpectrum>& MySpectrum, // asn.1 container for spectra 00131 bool isPKL = false // pkl formatted? 00132 ); 00133 00134 //! Convert peak list to spectrum 00135 /*! 00136 \param InputPeaks list of the input m/z and intensity values 00137 \param MySpectrum the spectrum to receive the scaled input 00138 \return success 00139 */ 00140 bool Peaks2Spectrum(const TInputPeaks& InputPeaks, CRef <CMSSpectrum>& MySpectrum) const; 00141 00142 //!Read in the body of a dta like file 00143 /*! 00144 \param DTA input stream 00145 \param InputPeaks list of the input m/z and intensity values 00146 \return success 00147 */ 00148 bool GetDTABody( 00149 CNcbiIstream& DTA, // input stream 00150 TInputPeaks& InputPeaks // asn.1 container for spectra 00151 ); 00152 00153 /// 00154 /// Read in an ms/ms block in an mgf file 00155 /// 00156 int GetMGFBlock(CNcbiIstream& DTA, CRef <CMSSpectrum>& MySpectrum); 00157 00158 private: 00159 // Prohibit copy constructor and assignment operator 00160 CSpectrumSet(const CSpectrumSet& value); 00161 CSpectrumSet& operator=(const CSpectrumSet& value); 00162 00163 }; 00164 00165 00166 00167 /////////////////// CSpectrumSet inline methods 00168 00169 // constructor 00170 inline 00171 CSpectrumSet::CSpectrumSet(void) 00172 { 00173 } 00174 00175 00176 // destructor 00177 inline 00178 CSpectrumSet::~CSpectrumSet(void) 00179 { 00180 } 00181 00182 /////////////////// end of CSpectrumSet inline methods 00183 00184 00185 END_objects_SCOPE // namespace ncbi::objects:: 00186 00187 END_NCBI_SCOPE 00188 00189 #endif // SPECTRUMSET_HPP 00190 /* Original file checksum: lines: 85, chars: 2278, CRC32: c22a6458 */ 00191 00192