📄 mspeak.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: mspeak.hpp,v $ * PRODUCTION Revision 1000.3 2004/06/01 18:09:07 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.14 * PRODUCTION * =========================================================================== *//* $Id: mspeak.hpp,v 1000.3 2004/06/01 18:09:07 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the authors in any work or product based on this material. * * =========================================================================== * * Authors: Lewis Y. Geer * * File Description: * code to deal with spectra and m/z ladders * * =========================================================================== */#ifndef MSPEAK__HPP#define MSPEAK__HPP#include <corelib/ncbimisc.hpp>#include <objects/omssa/omssa__.hpp>#include <set>#include <iostream>#include <vector>#include <deque>#include <map>#include <string.h>#include "msms.hpp"#include "msladder.hpp"BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)BEGIN_SCOPE(omssa)///////////////////////////////////////////////////////////////////////////////// CMSHit:://// Used by CMSPeak class to hold hits//// forward declaration needed for CMSHitInfoclass CMSPeak;// class for recording ion peak typeclass NCBI_XOMSSA_EXPORT CMSHitInfo {public: char& SetCharge(void) { return Charge; } const char GetCharge(void) { return Charge; } char& SetIon(void) { return Ion; } const char GetIon(void) { return Ion; } short int& SetNumber(void) { return Number; } const short GetNumber(void) { return Number; } short int& SetMod(void) { return Mod; } const short GetMod(void) { return Mod; } unsigned& SetIntensity(void) { return Intensity; } const unsigned GetIntensity(void) { return Intensity; } private: char Charge, Ion; short Number, Mod; unsigned Intensity;};// typedef for holding hit informationtypedef AutoPtr <CMSHitInfo, ArrayDeleter<CMSHitInfo> > THitInfo;// class to contain preliminary hits. memory footprint must be kept small.class CMSHit {public: // tor's CMSHit(void); CMSHit(int StartIn, int StopIn, int IndexIn); CMSHit(int StartIn, int StopIn, int IndexIn, int MassIn, int HitsIn, int ChargeIn); ~CMSHit(); // getter-setters int GetStart(void); void SetStart(int StartIn); int GetStop(void); void SetStop(int StopIn); int GetSeqIndex(void); void SetSeqIndex(int IndexIn); int GetMass(void); void SetMass(int MassIn); int GetHits(void); void SetHits(int HitsIn); int GetCharge(void); void SetCharge(int ChargeIn); CMSHitInfo& SetHitInfo(int n); // return number of hits above threshold int GetHits(double Threshold, int MaxI); // make a record of the ions hit void RecordMatches(CLadder& BLadder, CLadder& YLadder, CLadder& B2Ladder, CLadder& Y2Ladder, CMSPeak *Peaks); // copy operator CMSHit& operator= (CMSHit& in);protected: // helper function for RecordMatches void RecordMatchesScan(CLadder& Ladder, int& iHitInfo, CMSPeak *Peaks, int Which);private: int Start, Stop; int Index, Mass; int Hits; // number of peaks hit int Charge; // the charge of the hit THitInfo HitInfo;};/////////////////// CMSHit inline methodsinline CMSHit::CMSHit(void): Hits(0){}inline CMSHit::CMSHit(int StartIn, int StopIn, int IndexIn): Start(StartIn), Stop(StopIn), Index(IndexIn), Hits(0){}inline CMSHit::CMSHit(int StartIn, int StopIn, int IndexIn, int MassIn, int HitsIn, int ChargeIn): Start(StartIn), Stop(StopIn), Index(IndexIn), Mass(MassIn), Hits(HitsIn), Charge(ChargeIn){}inline CMSHit::~CMSHit() { // delete [] HitInfo; }inline int CMSHit::GetStart(void) { return Start;}inline void CMSHit::SetStart(int StartIn) { Start = StartIn;}inline int CMSHit::GetStop(void) { return Stop; }inline void CMSHit::SetStop(int StopIn) { Stop = StopIn; }inline int CMSHit::GetSeqIndex(void) { return Index; }inline void CMSHit::SetSeqIndex(int IndexIn) { Index = IndexIn; }inline int CMSHit::GetMass(void) { return Mass; }inline void CMSHit::SetMass(int MassIn) { Mass = MassIn; }inline int CMSHit::GetHits(void) { return Hits;}inline void CMSHit::SetHits(int HitsIn) { Hits = HitsIn;}inline int CMSHit::GetCharge(void){ return Charge;}inline void CMSHit::SetCharge(int ChargeIn){ Charge = ChargeIn;}inline CMSHitInfo& CMSHit::SetHitInfo(int n){ return *(HitInfo.get() + n);}inline CMSHit& CMSHit::operator= (CMSHit& in) { Start = in.Start; Stop = in.Stop; Index = in.Index; Mass = in.Mass; Hits = in.Hits; Charge = in.Charge; HitInfo.reset(); if(in.HitInfo) { HitInfo.reset(new CMSHitInfo[Hits]); int i; for(i = 0; i < Hits; i++) SetHitInfo(i) = in.SetHitInfo(i); } return *this;}/////////////////// end of CMSHit inline methods///////////////////////////////////////////////////////////////////////////////// CMZI:://// Used by CMSPeak class to spectral data//// a class for holding an m/z value and intensityclass NCBI_XOMSSA_EXPORT CMZI {public: int MZ; unsigned Intensity; CMZI(void); CMZI(int MZIn, unsigned IntensityIn); CMZI(double MZIn, double IntensityIn);};/////////////////// CMZI inline methodsinline CMZI::CMZI(void) {}inline CMZI::CMZI(int MZIn, unsigned IntensityIn): MZ(MZIn), Intensity(IntensityIn) {}inline CMZI::CMZI(double MZIn, double IntensityIn){ MZ = static_cast <int> (MZIn * MSSCALE); Intensity = static_cast <unsigned> (IntensityIn);}/////////////////// end of CMZI inline methods///////////////////////////////////////////////////////////////////////////////// CMSPeak:://// Class used to hold spectra and convert to mass ladders//// for containing hits in mspeak class// first index is chargetypedef CMSHit * TMSHitList;// min number of peaks to be considered a hit#define MSHITMIN 6// min number of peaks to consider a spectra// two is absolute minimum in order to get m/z range#define MSPEAKMIN 5// size of histogram bin in Daltons#define MSBIN 100// culled for single charges#define MSCULLED1 1// culled for double charges#define MSCULLED2 2// original data#define MSORIGINAL 0// only the few most intense peaks#define MSTOPHITS 3// number of above cull states#define MSNUMDATA 4// the number of top hits to retain -- will be replaced by dynamic value#define MSNUMTOP 3// the maximum charge state that can be considered#define MSMAXCHARGE 4// the precursor charge state at which to begin considering 2+ product ionsconst int kConsiderMult = 3;// function object for cull iteratetypedef bool (*TMZIbool) (const CMZI&, const CMZI&, int tol);enum EChargeState { eChargeUnknown, // charge has not been computed eCharge1, eChargeNot1, // charge is not +1, but one of +2, +3 ... eCharge2, eCharge3, eCharge4, eCharge5 };// typedef for holding intensitytypedef AutoPtr <unsigned, ArrayDeleter<unsigned> > TIntensity;// class to hold experimental data and manipulateclass NCBI_XOMSSA_EXPORT CMSPeak {public: CMSPeak(void); CMSPeak(int HitListSize);private: // c'tor helper void xCMSPeak(void); // writes out dta format void xWrite(std::ostream& FileOut, CMZI *Temp, int Num);public: ~CMSPeak(void); void AddTotalMass(int massin, int tolin); void Sort(int Which = MSORIGINAL); // Read a spectrum set into a CMSPeak int Read(CMSSpectrum& Spectrum, double MSMSTolerance); // Write out a CMSPeak in dta format (useful for debugging) enum EFileType { eDTA, eASC, ePKL, ePKS, eSCIEX, eUnknown }; void Write(std::ostream& FileOut, EFileType FileType = eDTA, int Which = MSORIGINAL); // functions used in SmartCull // iterate thru peaks, deleting ones that pass the test void CullIterate(CMZI *Temp, int& TempLen, TMZIbool FCN); // cull precursors void CullPrecursor(CMZI *Temp, int& TempLen, double Precursor); // take out peaks below a threshold void CullBaseLine(double Threshold, CMZI *Temp, int& TempLen); // cull isotopes using the Markey Method void CullIsotope(CMZI *Temp, int& TempLen); // cull peaks that are water or ammonia loss // note that this only culls the water or ammonia loss if these peaks have a lesser // less intensity void CullH20NH3(CMZI *Temp, int& TempLen); // recursively culls the peaks void SmartCull(double Threshold, int Charge, int SingleWindow, // size of the charge 1 window in Da int DoubleWindow, // size of the charge 2 window in Da int SingleNum, // number of peaks allowed in charge 1 window int DoubleNum); // number of peaks allowed in charge 2 window // use smartcull on all charges void CullAll(double Threshold, int SingleWindow, int DoubleWindow, int SingleNum, int DoubleNum); // return the lowest culled peak and the highest culled peak less than the // precursor mass passed in void HighLow(int& High, int& Low, int& NumPeaks, int PrecursorMass, int Charge, double Threshold, int& NumLo, // number of peak below mh/2 int& NumHi // number of peaks above mh/2 and below mh ); // count number of AA intervals in spectum. int CountAAIntervals(CMassArray& MassArray, bool Nodup=true, int Which = MSCULLED1); // counts the number of peaks above % of maximum peak int AboveThresh(double Threshold, int Which = MSORIGINAL); // the number of peaks at and below the precursor ion int PercentBelow(void); // return the number of peaks in a range. range is in fractions of MH int CountRange(double StartFraction, double StopFraction); // takes the ratio, low/high, of two ranges in the spectrum double RangeRatio(double Start, double Middle, double Stop); // various charge functions, some depreciated void SetPlusOne(double PlusIn); // is the data charge +1? bool IsPlus1(double PercentBelowIn); // calculates charge based on threshold and sets charge value void SetComputedCharge(int MaxCharge); EChargeState GetComputedCharge(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -