NCBI Home IEB Home C++ Toolkit docs C Toolkit source browser C Toolkit source browser (2) |
NCBI C++ Toolkit Cross ReferenceC++/src/algo/ms/omssa/mspeak.hpp |
source navigation diff markup identifier search freetext search file search |
1 /* $Id: mspeak.hpp 141656 2008-09-29 13:08:30Z lewisg $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the authors in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * Authors: Lewis Y. Geer, Douglas J. Slotta 27 * 28 * File Description: 29 * code to deal with spectra and m/z ladders 30 * 31 * =========================================================================== 32 */ 33 34 #ifndef MSPEAK__HPP 35 #define MSPEAK__HPP 36 37 #include <corelib/ncbimisc.hpp> 38 #include <objects/omssa/omssa__.hpp> 39 #include <util/rangemap.hpp> 40 #include <util/itree.hpp> 41 42 #include <set> 43 #include <iostream> 44 #include <vector> 45 #include <deque> 46 #include <map> 47 #include <string.h> 48 49 #include "msms.hpp" 50 #include "msladder.hpp" 51 #include "SpectrumSet.hpp" 52 #include "omssascore.hpp" 53 54 55 BEGIN_NCBI_SCOPE 56 BEGIN_SCOPE(objects) 57 BEGIN_SCOPE(omssa) 58 59 60 class CMSPeak; 61 62 /** enum that describes type of peak list */ 63 enum EMSPeakListTypes { 64 eMSPeakListOriginal, // original data (MSORIGINAL) 65 eMSPeakListTop, // top hits (MSTOPHITS) 66 eMSPeakListCharge1, // charge +1 (MSCULLED1) 67 eMSPeakListCharge2, // 68 eMSPeakListCharge3, // (MSCULLED2) 69 eMSPeakListCharge4, // 70 eMSPeakListCharge5, // 71 eMSPeakListCharge6, // 72 eMSPeakListCharge7, // 73 eMSPeakListCharge8, // 74 eMSPeakListCharge9, // 75 eMSPeakListCharge10, // 76 eMSPeakListCharge11, // 77 eMSPeakListCharge12, // 78 eMSPeakListCharge13, // 79 eMSPeakListCharge14, // 80 eMSPeakListCharge15, // 81 eMSPeakListCharge16, // 82 eMSPeakListCharge17, // 83 eMSPeakListCharge18, // 84 eMSPeakListCharge19, // 85 eMSPeakListCharge20, // 86 eMSPeakListCharge21, // 87 eMSPeakListCharge22, // 88 eMSPeakListCharge23, // 89 eMSPeakListCharge24, // 90 eMSPeakListCharge25, // 91 eMSPeakListCharge26, // 92 eMSPeakListCharge27, // 93 eMSPeakListCharge28, // 94 eMSPeakListCharge29, // 95 eMSPeakListCharge30, // 96 eMSPeakListChargeMax 97 }; 98 99 100 /** 101 * Class to hold mod information for a hit 102 */ 103 class NCBI_XOMSSA_EXPORT CMSModInfo { 104 public: 105 const int GetModEnum(void) const; 106 int& SetModEnum(void); 107 108 const int GetSite(void) const; 109 int& SetSite(void); 110 111 const int GetIsFixed(void) const; 112 int& SetIsFixed(void); 113 114 private: 115 // the mod type 116 int ModEnum; 117 // the position in the peptide 118 int Site; 119 // is it fixed 120 int IsFixed; 121 }; 122 123 124 /////////////////// CMSModInfo inline methods 125 126 inline 127 const int CMSModInfo::GetModEnum(void) const 128 { 129 return ModEnum; 130 } 131 132 inline 133 int& CMSModInfo::SetModEnum(void) 134 { 135 return ModEnum; 136 } 137 138 inline 139 const int CMSModInfo::GetSite(void) const 140 { 141 return Site; 142 } 143 144 inline 145 int& CMSModInfo::SetSite(void) 146 { 147 return Site; 148 } 149 150 151 inline 152 const int CMSModInfo::GetIsFixed(void) const 153 { 154 return IsFixed; 155 } 156 157 inline 158 int& CMSModInfo::SetIsFixed(void) 159 { 160 return IsFixed; 161 } 162 163 164 /////////////////// end CMSModInfo inline methods 165 166 167 168 /** typedef for holding hit information */ 169 typedef AutoPtr <CMSModInfo, ArrayDeleter<CMSModInfo> > TModInfo; 170 171 172 /** 173 * class to contain preliminary hits. memory footprint must be kept small. 174 */ 175 class NCBI_XOMSSA_EXPORT CMSHit: public CMSSpectrumMatch { 176 public: 177 // tor's 178 CMSHit(void); 179 CMSHit(int StartIn, int StopIn, int IndexIn); 180 CMSHit(int StartIn, int StopIn, int IndexIn, int MassIn, int HitsIn, 181 int ChargeIn); 182 183 /** get sequence start */ 184 const int GetStart(void) const; 185 186 /** set sequence start */ 187 int& SetStart(); 188 189 /** get sequence stop */ 190 const int GetStop(void) const; 191 192 /** set sequence stop */ 193 int& SetStop(void); 194 195 /** get blast oid */ 196 const int GetSeqIndex(void) const; 197 198 /** set blast oid */ 199 int& SetSeqIndex(void); 200 201 /** 202 * get modification info 203 * 204 * @param n array index 205 */ 206 const CMSModInfo& GetModInfo(int n) const; 207 208 /** 209 * set modification info 210 * 211 * @param n array index 212 */ 213 CMSModInfo& SetModInfo(int n); 214 215 /** 216 * get size of modification info array 217 */ 218 const int GetNumModInfo(void) const; 219 220 /** 221 * return number of hits above threshold 222 */ 223 int CountHits(double Threshold, int MaxI); 224 225 226 /** 227 * count hits into two categories: independent hits and hits that are dependent on others 228 * 229 * @param Independent count of independent hits 230 * @param Dependent count of dependent hits 231 */ 232 void CountHitsByType(int& Independent, 233 int& Dependent, 234 double Threshold, 235 int MaxI) const; 236 237 // for poisson test 238 /** 239 * return number of hits above threshold scaled by m/z positions 240 */ 241 int CountHits(double Threshold, int MaxI, int High); 242 243 /** 244 * Make a record of the hits to the mass ladders 245 * 246 * @param LadderContainer holds the theoretical ladders 247 * @param iMods index into LadderContainer 248 * @param Peaks the experimental spectrum 249 * @param ModMask the bit array of modifications 250 * @param ModList modification information 251 * @param NumMod number of modifications 252 * @param PepStart starting position of peptide 253 * @param Searchctermproduct search the c terminal ions 254 * @param Searchb1 search the first forward ion? 255 * @param TheoreticalMassIn the mass of the theoretical peptide 256 */ 257 void RecordMatches(CLadderContainer& LadderContainer, 258 int iMod, 259 CMSPeak *Peaks, 260 unsigned ModMask, 261 CMod ModList[], 262 int NumMod, 263 const char *PepStart, 264 int Searchctermproduct, 265 int Searchb1, 266 int TheoreticalMassIn 267 ); 268 269 270 /// 271 /// Count Modifications in Mask 272 /// 273 274 int CountMods(unsigned ModMask, int NumMod); 275 276 277 /** 278 * Record the modifications used in the hit 279 * Note that fixed aa modifications are *not* recorded 280 * as these are dealt with by modifying the aa mass 281 * and the positions are not recorded anywhere 282 */ 283 void RecordModInfo(unsigned ModMask, 284 CMod ModList[], 285 int NumMod, 286 const char *PepStart 287 ); 288 289 290 /** 291 * assignment operator 292 * does a copy 293 */ 294 295 CMSHit& operator= (CMSHit& in); 296 297 protected: 298 299 /** 300 * helper function for RecordHits that scans thru a single ladder 301 * 302 * @param Ladder the ladder to record 303 * @param iHitInfo the index of the hit 304 * @param Peaks the spectrum that is hit 305 * @param Which which noise reduced spectrum to examine 306 * @param NOffset the numbering offset for the ladder at n terminus 307 * @param COffset the numbering offset for the ladder at c terminus 308 */ 309 void RecordMatchesScan(CLadder& Ladder, 310 int& iHitInfo, 311 CMSPeak *Peaks, 312 EMSPeakListTypes Which, 313 int NOffset, 314 int COffset); 315 316 private: 317 318 // disallow copy 319 CMSHit(const CMSHit& in) {} 320 321 /** 322 * start and stop positions, inclusive, on sequence 323 */ 324 int Start, Stop; 325 326 /** 327 * blast ordinal 328 */ 329 int Index; 330 331 /** modification information array */ 332 TModInfo ModInfo; 333 334 /** size of ModInfo */ 335 int NumModInfo; 336 }; 337 338 339 /////////////////// CMSHit inline methods 340 341 inline 342 CMSHit::CMSHit(void) 343 { 344 SetHits() = 0; 345 } 346 347 inline 348 CMSHit::CMSHit(int StartIn, int StopIn, int IndexIn): 349 Start(StartIn), Stop(StopIn), Index(IndexIn) 350 { 351 SetHits() = 0; 352 } 353 354 inline 355 CMSHit::CMSHit(int StartIn, int StopIn, int IndexIn, int MassIn, int HitsIn, 356 int ChargeIn): 357 Start(StartIn), Stop(StopIn), Index(IndexIn) 358 { 359 SetHits() = HitsIn; 360 SetExpMass() = MassIn; 361 SetCharge() = ChargeIn; 362 } 363 364 inline 365 const int CMSHit::GetStart(void) const 366 { 367 return Start; 368 } 369 370 inline 371 int& CMSHit::SetStart(void) 372 { 373 return Start; 374 } 375 376 inline 377 const int CMSHit::GetStop(void) const 378 { 379 return Stop; 380 } 381 382 inline 383 int& CMSHit::SetStop(void) 384 { 385 return Stop; 386 } 387 388 inline 389 const int CMSHit::GetSeqIndex(void) const 390 { 391 return Index; 392 } 393 394 inline 395 int& CMSHit::SetSeqIndex(void) 396 { 397 return Index; 398 } 399 400 inline 401 CMSModInfo& CMSHit::SetModInfo(int n) 402 { 403 return *(ModInfo.get() + n); 404 } 405 406 inline 407 const CMSModInfo& CMSHit::GetModInfo(int n) const 408 { 409 return *(ModInfo.get() + n); 410 } 411 412 inline 413 const int CMSHit::GetNumModInfo(void) const 414 { 415 return NumModInfo; 416 } 417 418 inline 419 CMSHit& CMSHit::operator= (CMSHit& in) 420 { 421 // handle self assignment 422 if(this == &in) return *this; 423 424 CMSSpectrumMatch::operator= (in); 425 Start = in.Start; 426 Stop = in.Stop; 427 Index = in.Index; 428 NumModInfo = in.NumModInfo; 429 int i; 430 ModInfo.reset(); 431 if(in.ModInfo) { 432 ModInfo.reset(new CMSModInfo[NumModInfo]); 433 for(i = 0; i < NumModInfo; i++) 434 SetModInfo(i) = in.SetModInfo(i); 435 } 436 return *this; 437 } 438 439 /////////////////// end of CMSHit inline methods 440 441 442 443 ///////////////////////////////////////////////////////////////////////////// 444 // 445 // CMZI:: 446 // 447 // Used by CMSPeak class to spectral data 448 // 449 450 /** 451 * a class for holding an m/z value, intensity, and rank 452 */ 453 class NCBI_XOMSSA_EXPORT CMZI: public CMSBasicPeak { 454 public: 455 CMZI(void); 456 CMZI(int MZIn, unsigned IntensityIn); 457 CMZI(double MZIn, double IntensityIn); 458 459 /** get the peak rank */ 460 const TMSRank GetRank(void) const; 461 462 /** set the peak rank */ 463 TMSRank& SetRank(void); 464 465 private: 466 /** The intensity rank of the peak. 1 = most intense */ 467 TMSRank Rank; 468 }; 469 470 /////////////////// CMZI inline methods 471 472 inline 473 CMZI::CMZI(void) 474 {} 475 476 inline 477 CMZI::CMZI(int MZIn, unsigned IntensityIn) 478 { 479 SetMZ() = MZIn; 480 SetIntensity() = IntensityIn; 481 } 482 483 inline 484 CMZI::CMZI(double MZIn, double IntensityIn) 485 { 486 SetMZ() = MSSCALE2INT(MZIn); 487 SetIntensity() = static_cast <unsigned> (IntensityIn); 488 } 489 490 inline 491 const TMSRank CMZI::GetRank(void) const 492 { 493 return Rank; 494 } 495 496 inline 497 TMSRank& CMZI::SetRank(void) 498 { 499 return Rank; 500 } 501 502 /////////////////// end of CMZI inline methods 503 504 505 ///////////////////////////////////////////////////////////////////////////// 506 // 507 // CMSPeak:: 508 // 509 // Class used to hold spectra and convert to mass ladders 510 // 511 512 513 // for containing hits in mspeak class 514 // first index is charge 515 typedef CMSHit * TMSHitList; 516 517 // min number of peaks to be considered a hit 518 #define MSHITMIN 2 519 520 // min number of peaks to consider a spectra 521 // two is absolute minimum in order to get m/z range 522 #define MSPEAKMIN 5 523 524 // size of histogram bin in Daltons 525 #define MSBIN 100 526 527 // the maximum charge state that can be considered 528 //#define MSMAXCHARGE 10 529 530 /** 531 * function object for cull iterate 532 */ 533 typedef bool (*TMZIbool) (const CMZI&, const CMZI&, int tol); 534 535 enum EChargeState { 536 eChargeUnknown, // charge has not been computed 537 eCharge1, 538 eChargeNot1, // charge is not +1, but one of +2, +3 ... 539 eCharge2, 540 eCharge3, 541 eCharge4, 542 eCharge5 }; 543 544 // for statistical modelling 545 // #define MSSTATRUN 546 547 548 /** 549 * enumeration of peak sort order 550 */ 551 552 enum EMSPeakListSort { 553 eMSPeakListSortNone, 554 eMSPeakListSortMZ, 555 eMSPeakListSortIntensity 556 }; 557 558 /** 559 * class for holding a set of peaks 560 */ 561 562 563 class NCBI_XOMSSA_EXPORT CMSPeakList : public CObject { 564 public: 565 CMSPeakList(void); 566 567 CMZI * const GetMZI(void) const; 568 void SetMZI(CMZI *In); 569 570 const int GetNum(void) const; 571 int& SetNum(void); 572 573 const EMSPeakListSort GetSorted(void) const; 574 EMSPeakListSort& SetSorted(void); 575 576 /** 577 * fill out the arrays and set defaults 578 * 579 * @param Size size of the arrays 580 */ 581 void CreateLists(int Size); 582 583 /** 584 * sort the peak by sort type 585 * @param SortType which sort to perform 586 */ 587 void Sort(EMSPeakListSort SortType); 588 589 /** 590 * Rank the given spectrum by intensity. 591 * assumes the spectrum is sorted by intensity. 592 * highest intensity is given rank 1. 593 */ 594 void Rank(void); 595 596 private: 597 /** m/z values and intensities */ 598 AutoPtr <CMZI, ArrayDeleter<CMZI> > MZI; 599 600 /** number of CMZI */ 601 int Num; 602 /** have the CMZI been sorted? */ 603 EMSPeakListSort Sorted; 604 }; 605 606 inline 607 CMZI * const CMSPeakList::GetMZI(void) const 608 { 609 return MZI.get(); 610 } 611 612 inline 613 void CMSPeakList::SetMZI(CMZI *In) 614 { 615 MZI.reset(In); 616 } 617 618 inline 619 const int CMSPeakList::GetNum(void) const 620 { 621 return Num; 622 } 623 624 inline 625 int& CMSPeakList::SetNum(void) 626 { 627 return Num; 628 } 629 630 inline 631 const EMSPeakListSort CMSPeakList::GetSorted(void) const 632 { 633 return Sorted; 634 } 635 636 inline 637 EMSPeakListSort& CMSPeakList::SetSorted(void) 638 { 639 return Sorted; 640 } 641 642 643 /** 644 * class to hold spectral data 645 * for filtering and statistical characterization 646 */ 647 648 class NCBI_XOMSSA_EXPORT CMSPeak { 649 public: 650 651 /** 652 * CMSPeak ctor 653 */ 654 CMSPeak(void); 655 656 /** 657 * CMSPeak ctor 658 * 659 * @param HitListSize size of the hit list allowed 660 */ 661 CMSPeak(int HitListSize); 662 663 664 private: 665 666 /** 667 * shared c'tor code 668 */ 669 void xCMSPeak(void); 670 671 /** 672 * writes out dta format 673 * 674 * @param FileOut output for dta file 675 * @param Temp list of intensities and m/z 676 * @param Num number of peaks 677 */ 678 void xWrite(std::ostream& FileOut, const CMZI * const Temp, const int Num) const; 679 680 public: 681 682 ~CMSPeak(void); 683 684 /** 685 * Compare the ladder and peaks and return back rank statistics 686 * @param Ladder the ladder to compare 687 * @param Which which exp spectrum to use 688 * 689 */ 690 int CompareSortedRank(CLadder& Ladder, 691 EMSPeakListTypes Which, 692 vector<bool>& usedPeaks); 693 694 /** 695 * Read a spectrum set into a CMSPeak 696 * 697 * @param Spectrum the spectrum itself 698 * @param Settings search settings, e.g. experimental tolerances 699 */ 700 int Read(const CMSSpectrum& Spectrum, 701 const CMSSearchSettings& Settings); 702 703 /** 704 * Read and process a spectrum set into a CMSPeak 705 * 706 * @param Spectrum the spectrum itself 707 * @param Settings search settings, e.g. experimental tolerances 708 */ 709 void ReadAndProcess(const CMSSpectrum& Spectrum, 710 const CMSSearchSettings& Settings); 711 712 /** 713 * Write out a CMSPeak in dta format (useful for debugging) 714 * 715 * @param FileOut the file to write out to 716 * @param FileType file format to use 717 * @param Which which MZI set to use 718 */ 719 void Write(std::ostream& FileOut, const EMSSpectrumFileType FileType, 720 const EMSPeakListTypes Which) const; 721 722 // functions used in SmartCull 723 724 /** 725 * iterate thru peaks, deleting ones that pass the test 726 * 727 * @param Temp MZI values to use 728 * @param TempLen length of Temp 729 * @param FCN function to use to do the test 730 */ 731 void CullIterate(CMZI *Temp, int& TempLen, const TMZIbool FCN); 732 733 /** 734 * cull precursors 735 * 736 * @param Temp MZI values to use 737 * @param TempLen length of Temp 738 * @param scaled precursor value 739 * @param Charge precursor charge 740 * @param PrecursorCull charge reduced culling 741 */ 742 void CullPrecursor(CMZI *Temp, 743 int& TempLen, 744 const int Precursor, 745 const int Charge, 746 bool PrecursorCull); 747 748 /** 749 * take out peaks below a threshold 750 * 751 * @param Temp MZI values to use 752 * @param TempLen length of Temp 753 * @param Threshold fraction of highest intensity used to cull 754 */ 755 void CullBaseLine(const double Threshold, CMZI *Temp, int& TempLen); 756 757 /** 758 * cull isotopes using the Markey Method 759 * 760 * @param Temp MZI values to use 761 * @param TempLen length of Temp 762 */ 763 void CullIsotope(CMZI *Temp, int& TempLen); 764 765 /** 766 * cull peaks that are water or ammonia loss 767 * note that this only culls the water or ammonia loss if these peaks have a lesser 768 * less intensity 769 * 770 * @param Temp MZI values to use 771 * @param TempLen length of Temp 772 */ 773 void CullH20NH3(CMZI *Temp, int& TempLen); 774 775 /** 776 * recursively culls the peaks 777 * 778 * @param ConsiderMultProduct assume multiply charged products? 779 * @param Temp MZI values to use 780 * @param TempLen length of Temp 781 * @param Settings search settings, e.g. experimental tolerances 782 */ 783 void SmartCull(const CMSSearchSettings& Settings, 784 CMZI *Temp, 785 int& TempLen, 786 const bool ConsiderMultProduct 787 ); 788 789 /** 790 * use smartcull on all charge states 791 * 792 * @param Settings search settings, e.g. experimental tolerances 793 */ 794 void CullAll(const CMSSearchSettings& Settings); 795 796 /** 797 * Performs culling based on whether to consider multiply charged ions or not 798 * 799 * @param Settings search settings, e.g. experimental tolerances 800 */ 801 void CullChargeAndWhich(const CMSSearchSettings& Settings 802 ); 803 804 /** 805 * return the lowest culled peak and the highest culled peak less than the 806 * precursor mass passed in 807 * 808 * @param NumLo number of peak below mh/2 809 * @param NumHi number of peaks above mh/2 and below mh 810 */ 811 void HighLow(int& High, 812 int& Low, 813 int& NumPeaks, 814 const int PrecursorMass, 815 const int Charge, 816 const double Threshold, 817 int& NumLo, 818 int& NumHi 819 ); 820 821 /** 822 * count number of AA intervals in spectrum. 823 */ 824 const int CountAAIntervals(const CMassArray& MassArray, 825 const bool Nodup/*=true*/, 826 const EMSPeakListTypes Which /*= MSCULLED1*/) const; 827 828 /** 829 * counts the number of peaks above % of maximum peak 830 */ 831 const int AboveThresh(const double Threshold, 832 const EMSPeakListTypes Which) const; 833 834 /** 835 * the number of peaks at and below the precursor ion 836 */ 837 const int PercentBelow(void) const; 838 839 /** 840 * return the number of peaks in a range. range is in fractions of MH 841 */ 842 const int CountRange(const double StartFraction, 843 const double StopFraction) const; 844 845 /** 846 * return the number of peaks in a range 847 * 848 * @param Start inclusive start of range in integer m/z 849 * @param Stop exclusive stop of range in integer m/z 850 * @param MaxIntensity the minimum intensity that a peak can have for counting 851 * @param Which which noise filtered spectrum to use 852 */ 853 const int CountMZRange(const int StartIn, 854 const int StopIn, 855 const double MinIntensity, 856 const int Which) const; 857 858 859 /** 860 * takes the ratio, low/high, of two ranges in the spectrum 861 */ 862 const double RangeRatio(const double Start, 863 const double Middle, 864 const double Stop) const; 865 866 867 // various charge functions 868 869 870 void SetPlusOne(const double PlusIn); 871 872 /** 873 * is the data charge +1? 874 */ 875 const bool IsPlus1(const double PercentBelowIn) const; 876 877 /** 878 * calculates charge based on threshold and sets charge value 879 * 880 * @param ChargeHandle contains info on how to deal with charge 881 * @param Spectrum the spectrum 882 */ 883 void SetComputedCharge(const CMSChargeHandle& ChargeHandle, 884 const CMSSpectrum& Spectrum); 885 886 /** 887 * return the computed charge state 888 */ 889 const EChargeState GetComputedCharge(void) const; 890 891 /** 892 * return allowed computed charges 893 */ 894 int * GetCharges(void); 895 896 /** 897 * return number of allowed computed charges 898 */ 899 const int GetNumCharges(void) const; 900 901 /** 902 * compare peaks to ladder using ContainsFast 903 * 904 * @param Ladder the ladder to compare 905 * @param Which which experimental spectrum to use 906 */ 907 const int Compare(CLadder& Ladder, 908 const EMSPeakListTypes Which) const; 909 910 /** 911 * see if value is contained in peaks 912 * 913 * @param value the m/z to compare 914 * @param Which which experimental spectrum to use 915 */ 916 const bool Contains(const int value, 917 const EMSPeakListTypes Which) const; 918 919 920 /** 921 * see if value is contained in peaks using binary search 922 * 923 * @param value the m/z value to compare 924 * @param Which which experimental spectrum to use 925 */ 926 const bool ContainsFast(const int value, 927 const EMSPeakListTypes Which) const; 928 929 /** 930 * compares only the top hits 931 * 932 * @param Ladder ladder to compare to 933 */ 934 const bool CompareTop(CLadder& Ladder); 935 936 /** 937 * Get Maximum intensity 938 * 939 * @param Which which experimental spectrum to use 940 */ 941 const int GetMaxI(const EMSPeakListTypes Which) const; 942 943 /** 944 * returns the cull array index 945 * 946 * @param Which which experimental spectrum to use 947 */ 948 const EMSPeakListTypes GetWhich(const int Charge) const; 949 950 /** 951 * initializes arrays used to track hits 952 * 953 * @param Minhitin minimal number of hits for a match 954 */ 955 void InitHitList(const int Minhitin 956 ); 957 958 /** 959 * Get a hit list 960 * 961 * @param Index which hit list 962 */ 963 TMSHitList& GetHitList(const int Index); 964 965 /** 966 * Get minimum hit 967 * 968 */ 969 const int GetMinhit() const; 970 971 /** 972 * Set minimum hit 973 * 974 */ 975 int & SetMinhit(void); 976 977 /** 978 * Get size of hit list 979 * 980 * @param Index which hit list 981 */ 982 const int GetHitListIndex(const int Index) const; 983 984 985 /** 986 * add hit to hitlist. returns true and the added hit if successful 987 * 988 * @param in Hit to add 989 * @param out the added hit 990 */ 991 const bool AddHit(CMSHit& in, CMSHit*& out); 992 993 994 /** 995 * return number of peptides examine for each charge state 996 * 997 * @param ChargeIn charge state 998 */ 999 const int GetPeptidesExamined(const int ChargeIn) const; 1000 1001 /** 1002 * set the number of peptides examine for each charge state 1003 * 1004 * @param ChargeIn charge state 1005 */ 1006 int& SetPeptidesExamined(const int ChargeIn); 1007 1008 1009 // getter-setters 1010 1011 /** 1012 * get precursor m/z 1013 */ 1014 const int GetPrecursormz(void) const; 1015 1016 /** 1017 * calculates neutral mass 1018 * 1019 * @param PrecusorCharge the charge to assume 1020 */ 1021 const int CalcPrecursorMass(const int PrecursorCharge) const; 1022 1023 /** 1024 * gets min precursor charge to consider multiply charged product ions 1025 */ 1026 const int GetConsiderMult(void) const; 1027 1028 /** 1029 * return any errors in computing on peaks 1030 */ 1031 const EMSHitError GetError(void) const; 1032 1033 /** 1034 * set any errors in computing on peaks 1035 * 1036 * @param ErrorIn what was the error? 1037 */ 1038 void SetError(const EMSHitError ErrorIn); 1039 1040 /** 1041 * set the names of the spectrum 1042 */ 1043 CMSSpectrum::TIds& SetName(void); 1044 1045 /** 1046 * get the names of the spectrum 1047 */ 1048 const CMSSpectrum::TIds& GetName(void) const; 1049 1050 /** 1051 * set the spectrum number 1052 */ 1053 int& SetNumber(void); 1054 1055 /** 1056 * get the spectrum number 1057 */ 1058 const int GetNumber(void) const; 1059 1060 /** 1061 * set the product mass tolerance in Daltons. 1062 * 1063 * @param tolin unscaled mass tolerance 1064 */ 1065 void SetTolerance(const double tolin); 1066 1067 /** 1068 * get the product mass tolerance in Daltons. 1069 */ 1070 const int GetTol(void) const; 1071 1072 /** 1073 * set the precursor mass tolerance in Daltons. 1074 * 1075 * @param tolin precursor mass tolerance 1076 */ 1077 void SetPrecursorTol(double tolin); 1078 1079 /** 1080 * get the precursor mass tolerance in Daltons. 1081 */ 1082 const int GetPrecursorTol(void) const; 1083 1084 // functions for testing if peaks are h2o or nh3 losses 1085 1086 /** 1087 * check to see if TestMZ is Diff away from BigMZ 1088 * 1089 * @param BigMZ the major ion 1090 * @param TestMZ the minor ion 1091 * @param Diff distance between minor and major ions 1092 * @param tolin mass tolerance 1093 */ 1094 const bool IsAtMZ(const int BigMZ, 1095 const int TestMZ, 1096 const int Diff, 1097 const int tolin) const; 1098 1099 /** 1100 * see if TestMZ can be associated with BigMZ, e.g. water loss, etc. 1101 * 1102 * @param BigMZ the major ion 1103 * @param TestMZ the minor ion 1104 * @param tolin mass tolerance 1105 */ 1106 const bool IsMajorPeak(const int BigMZ, 1107 const int TestMZ, 1108 const int tolin) const; 1109 1110 /** 1111 * list of peaks, e.g. one for each charge 1112 */ 1113 typedef vector < CRef < CMSPeakList > > TPeakLists; 1114 1115 /** 1116 * get the peak lists 1117 */ 1118 const TPeakLists& GetPeakLists(void) const; 1119 1120 /** 1121 * set the peak lists 1122 */ 1123 TPeakLists& SetPeakLists(void); 1124 1125 private: 1126 /** lists of peaks filtered at different precursor charges, etc. */ 1127 TPeakLists PeakLists; 1128 int Precursormz; 1129 int Charges[eMSPeakListChargeMax - eMSPeakListCharge1]; // Computed allowed charges 1130 int NumCharges; // array size of Charges[] 1131 1132 //! product error tolerance of peptide 1133 int tol; 1134 //! precursor error tolerance 1135 int PrecursorTol; 1136 1137 double PlusOne; // value used to determine if spectra is +1 1138 EChargeState ComputedCharge; // algorithmically calculated 1139 int ConsiderMult; // at what precursor charge should multiply charged products be considered? 1140 int MaxCharge; // maximum precursor charge to consider 1141 int MinCharge; // minimum precursor charge to consider 1142 CAA AA; 1143 1144 CMSSpectrum::TIds Name; // name taken from spectrum 1145 int Number; // spectrum number taken from spectrum 1146 int Minhit; // minimum number of hit peaks to record hit 1147 1148 // list of hits 1149 TMSHitList HitList[eMSPeakListChargeMax - eMSPeakListCharge1]; 1150 int HitListSize; // max size of hit list 1151 int HitListIndex[eMSPeakListChargeMax - eMSPeakListCharge1]; // current size of HitList 1152 int LastHitNum[eMSPeakListChargeMax - eMSPeakListCharge1]; // the smallest hit currently in List 1153 int PeptidesExamined[eMSPeakListChargeMax - eMSPeakListCharge1]; // the number of peptides examined in search 1154 1155 EMSHitError Error; // errors that have occurred in processing 1156 1157 }; 1158 1159 1160 /////////////////// CMSPeak inline methods 1161 1162 inline 1163 const CMSPeak::TPeakLists& CMSPeak::GetPeakLists(void) const 1164 { 1165 return PeakLists; 1166 } 1167 1168 inline 1169 CMSPeak::TPeakLists& CMSPeak::SetPeakLists(void) 1170 { 1171 return PeakLists; 1172 } 1173 1174 inline 1175 void CMSPeak::SetPlusOne(const double PlusIn) 1176 { 1177 PlusOne = PlusIn; 1178 } 1179 1180 inline 1181 const EChargeState CMSPeak::GetComputedCharge(void) const 1182 { 1183 return ComputedCharge; 1184 } 1185 1186 inline 1187 TMSHitList& CMSPeak::GetHitList(const int Index) 1188 { 1189 return HitList[Index]; 1190 } 1191 1192 inline 1193 const int CMSPeak::GetHitListIndex(const int Index) const 1194 { 1195 return HitListIndex[Index]; 1196 } 1197 1198 inline 1199 const int CMSPeak::GetMinhit() const 1200 { 1201 return Minhit; 1202 } 1203 1204 inline 1205 int & CMSPeak::SetMinhit(void) 1206 { 1207 return Minhit; 1208 } 1209 1210 inline 1211 const int CMSPeak::GetPeptidesExamined(const int ChargeIn) const 1212 { 1213 return PeptidesExamined[ChargeIn - Charges[0]]; 1214 } 1215 1216 inline 1217 int& CMSPeak::SetPeptidesExamined(const int ChargeIn) 1218 { 1219 return PeptidesExamined[ChargeIn - Charges[0]]; 1220 } 1221 1222 inline 1223 const int CMSPeak::GetPrecursormz(void) const 1224 { 1225 return Precursormz; 1226 } 1227 1228 inline 1229 const int CMSPeak::CalcPrecursorMass(const int PrecursorCharge) const 1230 { 1231 return Precursormz * PrecursorCharge - MSSCALE2INT(PrecursorCharge * kProton); 1232 } 1233 1234 1235 inline 1236 const int CMSPeak::GetConsiderMult(void) const 1237 { 1238 return ConsiderMult; 1239 } 1240 1241 inline 1242 const EMSHitError CMSPeak::GetError(void) const 1243 { 1244 return Error; 1245 } 1246 1247 inline 1248 void CMSPeak::SetError(const EMSHitError ErrorIn) 1249 { 1250 Error = ErrorIn; 1251 } 1252 1253 inline 1254 CMSSpectrum::TIds& CMSPeak::SetName(void) 1255 { 1256 return Name; 1257 } 1258 1259 inline 1260 const CMSSpectrum::TIds& CMSPeak::GetName(void) const 1261 { 1262 return Name; 1263 } 1264 1265 inline 1266 int& CMSPeak::SetNumber(void) 1267 { 1268 return Number; 1269 } 1270 1271 inline 1272 const int CMSPeak::GetNumber(void) const 1273 { 1274 return Number; 1275 } 1276 1277 inline 1278 void CMSPeak::SetTolerance(const double tolin) 1279 { 1280 tol = MSSCALE2INT(tolin); 1281 } 1282 1283 inline 1284 const int CMSPeak::GetTol(void) const 1285 { 1286 return tol; 1287 } 1288 1289 inline 1290 void CMSPeak::SetPrecursorTol(double tolin) 1291 { 1292 PrecursorTol = MSSCALE2INT(tolin); 1293 } 1294 1295 inline 1296 const int CMSPeak::GetPrecursorTol(void) const 1297 { 1298 return PrecursorTol; 1299 } 1300 1301 // returns the cull array index 1302 inline 1303 const EMSPeakListTypes CMSPeak::GetWhich(const int Charge) const 1304 { 1305 return static_cast <EMSPeakListTypes> (eMSPeakListCharge1 + Charge - 1); 1306 } 1307 1308 inline 1309 int * CMSPeak::GetCharges(void) 1310 { 1311 return Charges; 1312 } 1313 1314 inline 1315 const int CMSPeak::GetNumCharges(void) const 1316 { 1317 return NumCharges; 1318 } 1319 1320 /////////////////// end of CMSPeak inline methods 1321 1322 1323 ///////////////////////////////////////////////////////////////////////////// 1324 // 1325 // CMSPeakSet:: 1326 // 1327 // Class used to hold sets of CMSPeak and access them quickly 1328 // 1329 1330 1331 typedef deque <CMSPeak *> TPeakSet; 1332 1333 class NCBI_XOMSSA_EXPORT _MassPeak: public CObject { 1334 public: 1335 int Mass, Peptol; 1336 int Charge; 1337 CMSPeak *Peak; 1338 }; 1339 1340 typedef _MassPeak TMassPeak; 1341 1342 1343 // range type for peptide mass +/- some tolerance 1344 typedef CRange<TSignedSeqPos> TMassRange; 1345 1346 class NCBI_XOMSSA_EXPORT CMSPeakSet: public CObject { 1347 public: 1348 // tor's 1349 CMSPeakSet(void); 1350 ~CMSPeakSet(); 1351 1352 void AddPeak(CMSPeak *PeakIn); 1353 1354 /** 1355 * put the pointers into an array sorted by mass 1356 * 1357 * @param Peptol the precursor mass tolerance 1358 * @param Zdep should the tolerance be charge dependent? 1359 * @return maximum m/z value 1360 */ 1361 int SortPeaks( 1362 int Peptol, 1363 int Zdep 1364 ); 1365 1366 TPeakSet& GetPeaks(void); 1367 CIntervalTree& SetIntervalTree(void); 1368 1369 private: 1370 TPeakSet PeakSet; // peak list for deletion 1371 CIntervalTree MassIntervals; 1372 }; 1373 1374 /////////////////// CMSPeakSet inline methods 1375 1376 inline CMSPeakSet::CMSPeakSet(void) 1377 {} 1378 1379 inline void CMSPeakSet::AddPeak(CMSPeak *PeakIn) 1380 { 1381 PeakSet.push_back(PeakIn); 1382 } 1383 1384 inline 1385 CIntervalTree& CMSPeakSet::SetIntervalTree(void) 1386 { 1387 return MassIntervals; 1388 } 1389 1390 inline 1391 TPeakSet& CMSPeakSet::GetPeaks(void) 1392 { 1393 return PeakSet; 1394 } 1395 1396 /////////////////// end of CMSPeakSet inline methods 1397 1398 END_SCOPE(omssa) 1399 END_SCOPE(objects) 1400 END_NCBI_SCOPE 1401 1402 #endif 1403 1404
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |