-
Notifications
You must be signed in to change notification settings - Fork 0
/
MData.h
156 lines (133 loc) · 5.21 KB
/
MData.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
Copyright 2018, Michael R. Hoopmann, Institute for Systems Biology
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 _MDATA_H
#define _MDATA_H
#include "MDB.h"
#include "MIons.h"
#include "MLog.h"
#include "MParams.h"
#include "MPrecursor.h"
#include "MSpectrum.h"
#include "MSReader.h"
#include "NeoPepXMLParser.h"
#include <deque>
#include <iostream>
#include "CometDecoys.h"
#include "Threading.h"
#include "ThreadPool.h"
//=============================
// Structures for threading
//=============================
typedef struct mMS2struct{
MSToolkit::Spectrum* s;
MSpectrum* pls;
int state;
bool thread;
mMS2struct(MSToolkit::Spectrum* sp, mParams* params){
s = sp;
pls = new MSpectrum(*params);
state = 0;
thread = false;
}
~mMS2struct(){
delete s;
pls = NULL; //this needs to be deleted elsewhere
}
} mMS2struct;
class MData {
public:
MData();
MData(mParams* p);
~MData();
MSpectrum& operator[ ](const int& i);
MSpectrum& at(const int& i);
MSpectrum* getSpectrum(const int& i);
bool createDiag (FILE*& f);
NeoPepXMLParser* createPepXML(std::string& str, MDatabase& db);
bool createPercolator (FILE*& f, FILE*& f2);
bool createTXT (FILE*& f);
void diagSinglet ();
void exportPepXML (NeoPepXMLParser*& p, std::vector<mResults>& r);
void exportPercolator (FILE*& f, std::vector<mResults>& r);
void exportTXT (FILE*& f, std::vector<mResults>& r);
bool getBoundaries (double mass1, double mass2, std::vector<int>& index, bool* buffer);
bool getBoundaries2 (double mass, double prec, std::vector<int>& index, bool* buffer);
double getMaxMass ();
double getMinMass ();
void outputDiagnostics (FILE* f, MSpectrum& s, MDatabase& db);
bool outputResults (MDatabase& db);
void processPSM (MSpectrum& s, mScoreCard3& sc, mResults& r);
void processSpectrumInfo (MSpectrum& s, mResults& r);
bool readSpectra ();
void setAdductSites (std::string s);
void setLog (MLog* c);
void setParams (MParams* p);
void setVersion (const char* v);
int size ();
bool* getAdductSites ();
private:
//Data Members
bool* bScans;
char version[32];
std::vector<MSpectrum*> spec;
std::vector<mMass> massList;
static mParams* params;
MParams* parObj;
MIons aa;
static MLog* mlog;
int pepXMLindex;
//Common memory to be shared by all threads during spectral processing
static bool* memoryPool;
static double** tempRawData;
static double** tmpFastXcorrData;
static float** fastXcorrData;
static Mutex mutexMemoryPool;
static mPreprocessStruct** preProcess;
//Optimized file loading structures for spectral processing
static std::deque<MSToolkit::Spectrum*> dMS1;
static std::vector<MSToolkit::Spectrum*> vMS1Buffer;
static Mutex mutexLockMS1;
static CHardklor2** h;
static CHardklorSetting hs;
static Mutex* mutexHardklor;
static CAveragine** averagine;
static CMercury8** mercury;
static CModelLibrary* models;
static bool* bHardklor;
static int maxPrecursorMass;
bool adductSite[128];
//static void xCorrProc(MSpectrum* s);
//spectral processing functions
static void averageScansCentroid(std::vector<MSToolkit::Spectrum*>& s, MSToolkit::Spectrum& avg, double min, double max);
static int findPeak(MSToolkit::Spectrum* s, double mass);
static int findPeak(MSToolkit::Spectrum* s, double mass, double prec);
static void formatMS2(MSToolkit::Spectrum* s, MSpectrum* pls);
void initHardklor();
void memoryAllocate();
void memoryFree();
static void processMS2(mMS2struct* s);
static int processPrecursor(mMS2struct* s, int tIndex);
void releaseHardklor();
//Utilities
static void centroid(MSToolkit::Spectrum* s, void* out, double resolution, int instrument = 0, int type=0); //0=MSpectrum, 1=Spectrum
static void collapseSpectrum(MSpectrum& s);
static int compareInt (const void *p1, const void *p2);
static int compareMassList (const void *p1, const void *p2);
static int compareScanBinRev2(const void *p1, const void *p2);
static bool compareSpecPoint(const mSpecPoint& p1, const mSpecPoint& p2){ return p1.mass<p2.mass; }
static int getCharge(MSpectrum& s, int index, int next);
static double polynomialBestFit (std::vector<double>& x, std::vector<double>& y, std::vector<double>& coeff, int degree=2);
bool processPath (const char* in_path, char* out_path);
std::string processPeptide(mPeptide& pep, std::vector<mPepMod>& mod, int site, double massA, MDatabase& db);
};
#endif