CycloBranch
cMainThread.h
Go to the documentation of this file.
1
7#ifndef _CMAINTHREAD_H
8#define _CMAINTHREAD_H
9
10#include <iostream>
11#include <QThread>
12#include <QThreadPool>
13#include <QTime>
14#include <QMutex>
15
16#include "core/utilities.h"
17#include "core/cParameters.h"
18#include "core/cDeNovoGraph.h"
21
22using namespace std;
23
24
29
30
34class cMainThread : public QThread {
35
36 Q_OBJECT
37
38private:
39
40 bool enablelogwindow;
41 bool enablestdout;
42 bool terminatecomputation;
43 bool graphreaderisworking;
44
45 cDeNovoGraph graph;
46 cTheoreticalSpectrumList* listoftheoreticalspectra;
47 cParameters parameters;
48
49 QMutex mutex;
50
51 int paralleloutputstate;
52 int paralleloutputsize;
53
54 string getCurrentTime(QTime& time);
55
56 void singleThreadMS1(cMainThread* os, QTime& time, cTheoreticalSpectrum* testspectrum = 0, vector< vector< vector<int> > >* testhintsindexvector = 0, cTheoreticalSpectrumList* testlistoftheoreticalspectra = 0, vector< vector<cPeaksList> >* testunmatchedpeaksvector = 0);
57
58 void multiThreadMS1(cMainThread* os, QTime& time, cTheoreticalSpectrum* testspectrum = 0, vector< vector< vector<int> > >* testhintsindexvector = 0, cTheoreticalSpectrumList* testlistoftheoreticalspectra = 0, vector< vector<cPeaksList> >* testunmatchedpeaksvector = 0);
59
60 void initParallelOutputState(int size);
61
62 void serializeSpectrumPool(vector<cTheoreticalSpectrum*>& spectrumpool, cTheoreticalSpectrum& ts);
63
64 void serializeHintsIndexPool(vector< vector< vector<int> > >& hintsindexpool, vector< vector<int> >& hintsindex);
65
66 void serializeUnmatchedPeaksPool(int peaklistseriesvectorid, vector< vector<cPeaksList> >& unmatchedpeakspool, vector< vector<cPeaksList> >& unmatchedpeaks);
67
68 void serializeTheoreticalSpectrumListPool(int peaklistseriesvectorid, vector<cTheoreticalSpectrumList*>& theoreticalspectrumlistpool, cTheoreticalSpectrumList& theoreticalspectrumlist);
69
70 void printMatrix(cPeaksList& peaklist);
71
72 void printIonEstimations(cPeaksList& peaklist);
73
74
75public:
76
77
85 cMainThread(cParameters& parameters, cTheoreticalSpectrumList& listoftheoreticalspectra, bool enablelogwindow = true, bool enablestdout = true);
86
87
92 void setGraphReaderIsWorking(bool working);
93
94
100
101
105 typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
106
107
111 typedef CoutType& (*StandardEndLine)(CoutType&);
112
113
117 template<class T> cMainThread& operator<<(const T& x) {
118 if (enablelogwindow) {
119 emit message(to_string(x).c_str());
120 }
121
122 if (enablestdout) {
123 cout << x;
124 }
125
126 return *this;
127 }
128
129
133 cMainThread& operator<<(const char* x);
134
135
139 cMainThread& operator<<(const string& x);
140
141
146
147
152 void addToParallelOutputState(int value);
153
154
155protected:
156
157
161 void run();
162
163
167 void emitEndSignals();
168
169
170signals:
171
172
177 void message(QString s);
178
179
184 void enableRunButtonAndSettings(bool enable);
185
186
191 void enableStopButton(bool enable);
192
193
199
200
205 void sendParameters(cParameters parameters);
206
207
212
213
218 void setGraph(string s);
219
220
221private slots:
222
223 void stopComputation();
224
225 void graphReaderFinished();
226
227};
228
229
230#endif
231
The implementation of the de novo graph.
Isotope pattern cache (LRU cache is implemented).
cIsotopePatternCache isotopepatterncache
Global isotope pattern cache.
Definition: cMainThread.cpp:4
Definitions of program parameters.
The representation of a theoretical mass spectrum.
The class implementing the de novo graph.
Definition: cDeNovoGraph.h:46
Isotope pattern cache (LRU cache is implemented).
Definition: cIsotopePatternCache.h:21
The class representing a thread launched by the command 'Search->Run'.
Definition: cMainThread.h:34
void sendParameters(cParameters parameters)
Send parameters to cMainWindow when the thread has finished.
bool isGraphReaderWorking()
Check the flag whether the graph reader is working.
Definition: cMainThread.cpp:933
void reportSpectra()
Report results.
void setGraph(string s)
Set the graph into the cGraphWidget.
void run()
The main method of the thread.
Definition: cMainThread.cpp:992
void enableButtonsHandlingResults(bool enable)
Enable or disable buttons handling results.
void enableStopButton(bool enable)
Enable or disable the option 'Search->Stop'.
CoutType &(* StandardEndLine)(CoutType &)
This is the function signature of std::endl.
Definition: cMainThread.h:111
void emitEndSignals()
The signals emitted when the thread has successfully finished.
Definition: cMainThread.cpp:1592
void message(QString s)
A message which will be shown in log window.
void setGraphReaderIsWorking(bool working)
Set the flag that the graph reader is working.
Definition: cMainThread.cpp:928
std::basic_ostream< char, std::char_traits< char > > CoutType
This is the type of std::cout.
Definition: cMainThread.h:105
void addToParallelOutputState(int value)
Add a value to the output state (for internal threads).
Definition: cMainThread.cpp:979
cMainThread(cParameters &parameters, cTheoreticalSpectrumList &listoftheoreticalspectra, bool enablelogwindow=true, bool enablestdout=true)
The constructor.
Definition: cMainThread.cpp:914
void enableRunButtonAndSettings(bool enable)
Enable or disable options 'Search->Run' and 'Search->Settings...'.
cMainThread & operator<<(const T &x)
Overloaded operator <<.
Definition: cMainThread.h:117
The class storing parameters of the application.
Definition: cParameters.h:82
The class representing a peak list.
Definition: cPeaksList.h:68
The class representing a theoretical mass spectrum.
Definition: cTheoreticalSpectrum.h:106
The class representing lists of theoretical spectra.
Definition: cTheoreticalSpectrumList.h:25
Auxiliary funtions and structures.