CycloBranch
cDeNovoGraphNode.h
Go to the documentation of this file.
1
7#ifndef _CDENOVOGRAPHNODE_H
8#define _CDENOVOGRAPHNODE_H
9
10#include <unordered_set>
11#include <vector>
12#include <map>
13#include <fstream>
14
15#include "core/cFragmentIons.h"
16
17using namespace std;
18
19
23struct nodeEdge {
24
28 int nodeid;
29
30
34 int edgeid;
35
36
41 void store(ofstream& os);
42
43
48 void load(ifstream& is);
49
50};
51
52
59bool operator == (nodeEdge const& a, nodeEdge const& b);
60
61
65struct cEdge {
66
71
72
77
78
82 double ppmerror;
83
84
89
90
95
96
101
102
107
108
113
114
118 string summary;
119
120
125
126
131
132
137
138
143
144
149
150
155 clear();
156 }
157
158
162 void clear() {
163 targetnode = 0;
164 brickid = 0;
165 ppmerror = 0;
166 massdifference = 0;
167 sourcecharge = 1;
168 targetcharge = 1;
169 targetintensity = 0;
170 composition = "";
171 summary = "";
172 startmodifID = 0;
173 middlemodifID = 0;
174 endmodifID = 0;
175 sourceion = fragmentIonTypeEnd;
176 targetion = fragmentIonTypeEnd;
177 }
178
179};
180
181
186
192 size_t operator()(const cEdge& e) const {
193 return std::hash<int>()(e.targetnode) ^ std::hash<int>()(e.brickid) ^ std::hash<int>()((int)(e.sourceion)) ^ std::hash<int>()((int)(e.targetion));
194 }
195
196};
197
198
205bool operator == (cEdge const& a, cEdge const& b);
206
207
214bool compareEdgesByPPMError(const cEdge& a, const cEdge& b);
215
216
223bool compareEdgesByTargetNodeIntensityDesc(const cEdge& a, const cEdge& b);
224
225
230
231 double mzratio;
232 double intensity;
233
234 unordered_set<cEdge, hash_cEdge> tempedges;
235 vector<cEdge> edges;
236 map<eFragmentIonType, bool> ionannotation;
237
238public:
239
240
245
246
250 void clear();
251
252
257 double getMZRatio();
258
259
264 void setMZRatio(double mzratio);
265
266
271 double getIntensity();
272
273
278 void setIntensity(double intensity);
279
280
285 void insertTempEdge(cEdge& e);
286
287
292 void insertEdge(cEdge& e);
293
294
298 void sortEdgesByPPMError();
299
300
305
306
310 void createVectorOfEdges();
311
312
317 int size();
318
319
325 cEdge& operator[](int position);
326
327
332 void removeEdge(int position);
333
334
338 void clearEdges();
339
340
346
347
354
355};
356
357
358#endif
bool compareEdgesByTargetNodeIntensityDesc(const cEdge &a, const cEdge &b)
Compare edges by target node intensity.
Definition: cDeNovoGraphNode.cpp:31
bool compareEdgesByPPMError(const cEdge &a, const cEdge &b)
Compare edges by ppm error.
Definition: cDeNovoGraphNode.cpp:26
bool operator==(nodeEdge const &a, nodeEdge const &b)
Overloaded operator ==.
Definition: cDeNovoGraphNode.cpp:16
Basic definitions of fragment ions occurring in the mass spectra.
eFragmentIonType
The types of supported fragment ions.
Definition: cFragmentIons.h:944
The class representing a node in the de novo graph.
Definition: cDeNovoGraphNode.h:229
bool checkIonAnnotation(eFragmentIonType iontype)
Check ion annotation.
Definition: cDeNovoGraphNode.cpp:130
void clearEdges()
Clear edges.
Definition: cDeNovoGraphNode.cpp:120
cEdge & operator[](int position)
Overloaded operator [].
Definition: cDeNovoGraphNode.cpp:110
void createVectorOfEdges()
Create a vector of edges from an unordered set of temporary edges.
Definition: cDeNovoGraphNode.cpp:96
void addIonAnnotation(eFragmentIonType iontype)
Add ion annotation.
Definition: cDeNovoGraphNode.cpp:125
void setMZRatio(double mzratio)
Set the mz ratio of the node.
Definition: cDeNovoGraphNode.cpp:61
double getIntensity()
Get the intensity of the node.
Definition: cDeNovoGraphNode.cpp:66
void sortEdgesByTargetNodeIntensity()
Sort a vector of edges by target node intensity.
Definition: cDeNovoGraphNode.cpp:91
int size()
Get the number of edges.
Definition: cDeNovoGraphNode.cpp:105
double getMZRatio()
Get the mz ratio of the node.
Definition: cDeNovoGraphNode.cpp:56
void insertTempEdge(cEdge &e)
Insert an edge into a temporary unordered set.
Definition: cDeNovoGraphNode.cpp:76
void insertEdge(cEdge &e)
Insert an edge into a vector of edges.
Definition: cDeNovoGraphNode.cpp:81
cDeNovoGraphNode()
The constructor.
Definition: cDeNovoGraphNode.cpp:36
void setIntensity(double intensity)
Set the intensity of the node.
Definition: cDeNovoGraphNode.cpp:71
void removeEdge(int position)
Remove an edge.
Definition: cDeNovoGraphNode.cpp:115
void clear()
Clear the class.
Definition: cDeNovoGraphNode.cpp:41
void sortEdgesByPPMError()
Sort a vector of edges by ppm error.
Definition: cDeNovoGraphNode.cpp:86
The structure representing an outgoing edge from a node.
Definition: cDeNovoGraphNode.h:65
double massdifference
A mass difference.
Definition: cDeNovoGraphNode.h:88
double targetintensity
Intensity of the target node.
Definition: cDeNovoGraphNode.h:106
int endmodifID
Id of a terminal modification (at the end of a spectrum).
Definition: cDeNovoGraphNode.h:136
int targetcharge
Charge of the target node.
Definition: cDeNovoGraphNode.h:100
eFragmentIonType sourceion
Source ion name.
Definition: cDeNovoGraphNode.h:142
int targetnode
Id of a target node.
Definition: cDeNovoGraphNode.h:70
double ppmerror
Error in ppm.
Definition: cDeNovoGraphNode.h:82
string composition
ids of bricks separated by '-'.
Definition: cDeNovoGraphNode.h:112
int startmodifID
Id of a terminal modification (at the beginning of a spectrum).
Definition: cDeNovoGraphNode.h:124
int middlemodifID
Id of a terminal modification of a branched peptide (in the middle of a spectrum).
Definition: cDeNovoGraphNode.h:130
string summary
summary formula as a string
Definition: cDeNovoGraphNode.h:118
int sourcecharge
Charge of the source node.
Definition: cDeNovoGraphNode.h:94
void clear()
Clear the structure.
Definition: cDeNovoGraphNode.h:162
cEdge()
The constructor.
Definition: cDeNovoGraphNode.h:154
int brickid
Id of a brick.
Definition: cDeNovoGraphNode.h:76
eFragmentIonType targetion
Target ion name.
Definition: cDeNovoGraphNode.h:148
The structure defining a hash function of cEdge.
Definition: cDeNovoGraphNode.h:185
size_t operator()(const cEdge &e) const
Hash an edge.
Definition: cDeNovoGraphNode.h:192
An auxiliary structure to store relationship between a node and an edge.
Definition: cDeNovoGraphNode.h:23
int nodeid
Id of a node.
Definition: cDeNovoGraphNode.h:28
void store(ofstream &os)
Store the structure into an output stream.
Definition: cDeNovoGraphNode.cpp:4
int edgeid
Id of an edge.
Definition: cDeNovoGraphNode.h:34
void load(ifstream &is)
Load the structure from an input stream.
Definition: cDeNovoGraphNode.cpp:10