-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightVertex.C
More file actions
193 lines (127 loc) · 2.84 KB
/
LightVertex.C
File metadata and controls
193 lines (127 loc) · 2.84 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/****************************************************************
LightVertex.C
Copyright (C)2013 William H. Majoros (martiandna@gmail.com).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
****************************************************************/
#include <iostream>
#include "LightVertex.H"
#include "LightEdge.H"
using namespace std;
using namespace BOOM;
LightVertex::LightVertex(const String &substrate,SignalType t,int begin,
int end,float score,Strand s,int ID)
: type(t), begin(begin), end(end), score(score), strand(s), ID(ID),
substrate(substrate), supported(false), annotated(false)
{
// ctor
}
void LightVertex::addEdgeIn(LightEdge *e)
{
if(e->getLeft()->getBegin()>begin) INTERNAL_ERROR;
edgesIn.push_back(e);
}
void LightVertex::addEdgeOut(LightEdge *e)
{
if(e->getRight()->getBegin()<begin) {
cout<<*this<<endl;
cout<<*e->getRight()<<endl;
INTERNAL_ERROR;
}
edgesOut.push_back(e);
}
SignalType LightVertex::getType() const
{
return type;
}
Interval LightVertex::getInterval() const
{
return Interval(begin,end);
}
int LightVertex::distanceTo(const LightVertex &other) const
{
return getInterval().distanceTo(other.getInterval());
}
int LightVertex::getBegin() const
{
return begin;
}
int LightVertex::getEnd() const
{
return end;
}
float LightVertex::getScore() const
{
return score;
}
void LightVertex::setScore(float s)
{
score=s;
}
Strand LightVertex::getStrand() const
{
return strand;
}
Vector<LightEdge*> &LightVertex::getEdgesIn()
{
return edgesIn;
}
Vector<LightEdge*> &LightVertex::getEdgesOut()
{
return edgesOut;
}
void LightVertex::printOn(ostream &os,String vertexType)
{
int supportString=supported ? 1 : 0;
os<<substrate<<"\t"<<vertexType<<"\t"<<signalTypeToName(type)
<<"\t"<<begin+1<<"\t"<<
end<<"\t"<<score<<"\t"<<strand<<"\t.\tID="<<ID<<"; in="<<edgesIn.size()
<<"; out="<<edgesOut.size()<<"; sup="<<supportString<<";";
}
int LightVertex::getID() const
{
return ID;
}
ostream &operator<<(ostream &os,const LightVertex &v)
{
v.printOn(os);
return os;
}
bool LightVertex::isSupported() const
{
return supported;
}
void LightVertex::setSupport(bool s)
{
supported=s;
}
void LightVertex::setID(int id)
{
ID=id;
}
void LightVertex::dropEdgeIn(LightEdge *e)
{
int n=edgesIn.size();
for(int i=0 ; i<n ; ++i)
if(edgesIn[i]==e) {
edgesIn.cut(i);
break;
}
}
void LightVertex::dropEdgeOut(LightEdge *e)
{
int n=edgesOut.size();
for(int i=0 ; i<n ; ++i)
if(edgesOut[i]==e) {
edgesOut.cut(i);
break;
}
}
bool LightVertex::operator==(const LightVertex &other) const
{
return substrate==other.substrate &&
strand==other.strand &&
begin==other.begin &&
end==other.end &&
type==other.type;
}