forked from mhoopmann/hardklor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHardklor2.h
136 lines (116 loc) · 4.52 KB
/
CHardklor2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
Copyright 2007-2016, Michael R. Hoopmann, Institute for Systems Biology
Michael J. MacCoss, University of Washington
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _CHARDKLOR2_H
#define _CHARDKLOR2_H
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include "MSObject.h"
#include "MSReader.h"
#include "Spectrum.h"
#include "HardklorTypes.h"
#include "CAveragine.h"
#include "CMercury8.h"
#include "CHardklor.h"
#include "CModelLibrary.h"
#ifdef _MSC_VER
#include <Windows.h>
#include <profileapi.h>
#else
#include <sys/time.h>
#endif
class CHardklor2{
public:
//Constructors & Destructors:
CHardklor2(CAveragine *a, CMercury8 *m, CModelLibrary *lib);
~CHardklor2();
//Operators
hkMem& operator[](const int& index);
//Methods:
void Echo(bool b);
int GoHardklor(CHardklorSetting sett, MSToolkit::Spectrum* s=NULL);
void QuickCharge(MSToolkit::Spectrum& s, int index, std::vector<int>& v);
void SetResultsToMemory(bool b);
int Size();
protected:
private:
//Methods:
int BinarySearch(MSToolkit::Spectrum& s, double mz, bool floor);
double CalcFWHM(double mz,double res,int iType);
void Centroid(MSToolkit::Spectrum& s, MSToolkit::Spectrum& out);
bool CheckForPeak(std::vector<Result>& vMR, MSToolkit::Spectrum& s, int index);
int CompareData(const void*, const void*);
double LinReg(std::vector<float>& mer, std::vector<float>& obs);
bool MatchSubSpectrum(MSToolkit::Spectrum& s, int peakIndex, pepHit& pep);
double PeakMatcher(std::vector<Result>& vMR, MSToolkit::Spectrum& s, double lower, double upper, double deltaM, int matchIndex, int& matchCount, int& indexOverlap, std::vector<int>& vMatchIndex, std::vector<float>& vMatchIntensity);
double PeakMatcherB(std::vector<Result>& vMR, MSToolkit::Spectrum& s, double lower, double upper, double deltaM, int matchIndex, int& matchCount, std::vector<int>& vMatchIndex, std::vector<float>& vMatchIntensity);
void QuickHardklor(MSToolkit::Spectrum& s, std::vector<pepHit>& vPeps);
void RefineHits(std::vector<pepHit>& vPeps, MSToolkit::Spectrum& s);
void ResultToMem(pepHit& ph, MSToolkit::Spectrum& s);
void WritePepLine(pepHit& ph, MSToolkit::Spectrum& s, FILE* fptr, int format=0);
void WriteScanLine(MSToolkit::Spectrum& s, FILE* fptr, int format=0);
void SetIonFormula(pepHit& pep, const char* bestAveragine, double bestMass, double bestZeroMass, int bestCharge); // BSP edit, SKyline wants isotope envelope info
static int CompareBPI(const void *p1, const void *p2);
//Data Members:
CHardklorSetting cs;
CAveragine* averagine;
CMercury8* mercury;
CModelLibrary* models;
CPeriodicTable* PT;
MSToolkit::Spectrum mask;
hkMem hkm;
bool bEcho;
bool bShowPerformanceHints;
bool bMem;
int currentScanNumber;
//Vector for holding results in memory should that be needed
std::vector<hkMem> vResults;
//Temporary Data Members:
char bestCh[200];
double BestCorr;
int CorrMatches;
int ExtraPre;
int ExtraObs;
int SSIterations;
//For accurate timing of Hardklor
#ifdef _MSC_VER
__int64 startTime;
__int64 stopTime;
__int64 loadTime;
__int64 analysisTime;
__int64 timerFrequency;
__int64 tmpTime1;
__int64 tmpTime2;
#define getExactTime(a) QueryPerformanceCounter((LARGE_INTEGER*)&a)
#define getTimerFrequency(a) QueryPerformanceFrequency((LARGE_INTEGER*)&a)
#define toMicroSec(a) (a)
#define timeToSec(a,b) (a/b)
#else
timeval startTime;
timeval stopTime;
uint64_t loadTime;
uint64_t splitTime;
uint64_t analysisTime;
uint64_t tmpTime1;
uint64_t tmpTime2;
int timerFrequency;
#define getExactTime(a) gettimeofday(&a,NULL)
#define toMicroSec(a) a.tv_sec*1000000+a.tv_usec
#define getTimerFrequency(a) (a)=1
#define timeToSec(a,b) (a/1000000)
#endif
};
#endif