-
Notifications
You must be signed in to change notification settings - Fork 0
/
SigMol.cpp
287 lines (255 loc) · 6.05 KB
/
SigMol.cpp
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
// SigMol.cpp: implementation of the CSigMol class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "surface.h"
#include "General.h"
#include "SigMol.h"
#include "Grid.h"
#include "Receptor.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSigMol::CSigMol()
{
}
CSigMol::CSigMol(int index, SM_Type sm_type)
{
m_SM_index = index;
m_type = sm_type;
m_MyRaft = -1;
m_bound_Rec = -1;
m_use = false;
m_is_active = false;
m_CurrentD = CGeneral::SMprofileVec[sm_type].GetDefaultD();
m_P_enterRaft = CGeneral::SMprofileVec[sm_type].GetDefault_P_enterRaft();
m_P_leave_raft = CGeneral::SMprofileVec[sm_type].GetDefault_P_leaveRaft();
m_R_binding_step = -1;
m_upTime = 0;
m_R_binding_duration = 0;
m_activation_duration = 0;
vector<int>::iterator iterStringVec;
iterStringVec = CGeneral::SMprofileVec[sm_type].GetSubstratesVec().begin();
for( ; iterStringVec !=CGeneral::SMprofileVec[sm_type].GetSubstratesVec().end() ; iterStringVec++ )
{
// SubstratesVec[*iterStringVec] = -1; //proverit pochemu padaet
} // for
switch(sm_type)
{
case SNAP25:
m_name = "IFNb";
break;
case Vamp:
m_name = "Vamp";
break;
case NSF:
m_name = "NSF";
break;
case Alpha:
m_name = "Alpha";
break;
}
}
CSigMol::~CSigMol()
{
}
bool CSigMol::Move(Kind_of_Move KindOfMove, int distance) //right now distance is (-1)
{
/*
int newX = Location.x;
int newY = Location.y;
switch(KindOfMove)
{
case LEFT:
// x - 1
if(--newX < 0) newX = GRID_SIZE - 1;
break;
case UP:
// y - 1
if(--newY < 0) newY = GRID_SIZE - 1;
break;
case RIGHT :
// x + 1
if(++newX >= GRID_SIZE) newX = 0;
break;
case DOWN:
// y + 1
if(++newY >= GRID_SIZE) newY = 0;
break;
}
if(CGeneral::grid.m_Grid[newY][newX].array[SM] != -1)
return false;
CGeneral::grid.m_Grid[newY][newX].array[SM] =
CGeneral::grid.m_Grid[Location.y][Location.x].array[SM];
CGeneral::grid.m_Grid[Location.y][Location.x].array[SM] = -1;
Location.x = newX;
Location.y = newY;
int raft_id = CGeneral::RArray[m_bound_Rec].GetCRaft();
if( m_MyRaft != raft_id )
{
if( m_MyRaft == -1 ) // sm right now outside the raft on the way inside
{
CGeneral::RaftArray[raft_id].SetSMIndex(m_SM_index);
m_MyRaft = raft_id;
} // if
else
{//// sm right now inside the raft on the way outside
CGeneral::RaftArray[m_MyRaft].DelSMIndex(m_SM_index);
m_MyRaft = -1;
} // if
} // if
*/
return true;
}
bool CSigMol::MoveFreeSM(Kind_of_Move KindOfMove, int distance) { //right now distance is (-1)
/*
assert(this->IsInUse());
int newX = Location.x;
int newY = Location.y;
switch(KindOfMove)
{
case LEFT:
// x - 1
if(--newX < 0) newX = GRID_SIZE - 1;
break;
case UP:
// y - 1
if(--newY < 0) newY = GRID_SIZE - 1;
break;
case RIGHT :
// x + 1
if(++newX >= GRID_SIZE) newX = 0;
break;
case DOWN:
// y + 1
if(++newY >= GRID_SIZE) newY = 0;
break;
}
if(CGeneral::grid.m_Grid[newY][newX].array[SM] != -1)
return false;
int raft_id = CGeneral::grid.m_Grid[newY][newX].array[Raft];
if( m_MyRaft != raft_id)
{
if( m_MyRaft == -1 ) // sm right now outside the raft on the way inside
{
if(CGeneral::My_rand0_1() > m_P_enterRaft) //
return false;
CGeneral::RaftArray[raft_id].SetSMIndex(m_SM_index);
GetInRaft(raft_id);
} // if
else
{//// sm right now inside the raft on the way outside
if(CGeneral::My_rand0_1() > m_P_leave_raft) //
return false;
CGeneral::RaftArray[m_MyRaft].DelSMIndex(m_SM_index);
GetOutRaft();
} // if
} // if
CGeneral::grid.m_Grid[newY][newX].array[SM] =
CGeneral::grid.m_Grid[Location.y][Location.x].array[SM];
CGeneral::grid.m_Grid[Location.y][Location.x].array[SM] = -1;
Location.x = newX;
Location.y = newY;
*/
return true;
}
bool CSigMol::IsCanMove(Kind_of_Move KindOfMove, int distance)
{
int newX = Location.x;
int newY = Location.y;
switch(KindOfMove)
{
case LEFT:
// x - 1
if(--newX < 0) newX = GRID_SIZE - 1;
break;
case UP:
// y - 1
if(--newY < 0) newY = GRID_SIZE - 1;
break;
case RIGHT :
// x + 1
if(++newX >= GRID_SIZE) newX = 0;
break;
case DOWN:
// y + 1
if(++newY >= GRID_SIZE) newY = 0;
break;
}
if(CGeneral::grid.m_Grid[newY][newX].array[SM] != -1)
return false;
return true;
}
void CSigMol::EraseFromList()
{
// CGeneral::delSMStack.push(m_SM_index);
m_MyRaft = -1;
m_bound_Rec = -1;
m_use = false;
// m_is_active = false;
// m_type = nullSM;
SubstratesVec.clear();
CGeneral::grid.m_Grid[Location.y][Location.x].array[SM] = -1;
Location.x = Location.y = -1;
}
bool CSigMol::IsAttached()
{
//////check for R presence ///////////
// int original_x = Location.x;
// int original_y = Location.y;
int ag_x = Location.x; //temprorary for "k">0 but is correct for "k"==0
int ag_y = Location.y;//temprorary for "k">0 but is correct for "k"==0
POINT pts[5] = {0,0, -1,0, 0,-1, 1,0, 0,1 };
for(int k=SM_BINDING_RULE; k<5; k++)
{
switch(k)
{
case 0:
break;
case 1:
// x - 1 = left
if( (ag_x = Location.x + pts[k].x) < 0 ) ag_x = GRID_SIZE - 1;
break;
case 2:
// y - 1 = up
if( (ag_y = Location.y + pts[k].y) < 0 ) ag_y = GRID_SIZE - 1;
break;
case 3 :
// x + 1 = right
if( (ag_x = Location.x + pts[k].x) >= GRID_SIZE ) ag_x = 0;
break;
case 4:
// y + 1 = down
if( (ag_y = Location.y + pts[k].y) >= GRID_SIZE ) ag_y = 0;
break;
}//switch
if(CGeneral::grid.m_Grid[ag_y] [ag_x].array[Rec] != -1) //there is receptor
{
return true;
}
ag_x = Location.x;
ag_y = Location.y;
}
return false;
}
void CSigMol::GetInRaft(int raftID)
{
if( (m_type != NSF) )
{
m_CurrentD = CGeneral::SMprofileVec[m_type].Get_D_inRaft();
m_MyRaft = raftID;
}
}
void CSigMol::GetOutRaft()
{
if(m_type != NSF)
{
m_CurrentD = CGeneral::SMprofileVec[m_type].GetDefaultD();
m_MyRaft = -1;
}
}