Skip to content

Commit f3682e5

Browse files
author
drelatgithub
committed
Merge pull request #1 from drelatgithub/develop
First runnable program
2 parents 783ddbc + 3332e09 commit f3682e5

10 files changed

Lines changed: 529 additions & 23 deletions

GraduateProject_DNASelfAssembling/GraduateProject_DNASelfAssembling.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "stdafx.h"
55

6+
mt19937 gen(123456);
7+
68
int programInitiation(){
79
ornt2bpornt_init();
810
unitcell_init();
@@ -12,10 +14,8 @@ int _tmain(int argc, _TCHAR* argv[])
1214
{
1315
programInitiation();
1416
patchPreset();
15-
16-
17-
17+
simulationPrepare();
18+
simulationProcess();
1819

1920
return 0;
2021
}
21-

GraduateProject_DNASelfAssembling/GraduateProject_DNASelfAssembling.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,19 @@
7979
<Text Include="ReadMe.txt" />
8080
</ItemGroup>
8181
<ItemGroup>
82+
<ClInclude Include="GraduateProject_Data.h" />
8283
<ClInclude Include="GraduateProject_PatchesAndPresets.h" />
8384
<ClInclude Include="GraduateProject_PositionAndOrientation.h" />
85+
<ClInclude Include="GraduateProject_Simulation.h" />
8486
<ClInclude Include="stdafx.h" />
8587
<ClInclude Include="targetver.h" />
8688
</ItemGroup>
8789
<ItemGroup>
90+
<ClCompile Include="GraduateProject_Data.cpp" />
8891
<ClCompile Include="GraduateProject_DNASelfAssembling.cpp" />
8992
<ClCompile Include="GraduateProject_PatchesAndPresets.cpp" />
9093
<ClCompile Include="GraduateProject_PositionAndOrientation.cpp" />
94+
<ClCompile Include="GraduateProject_Simulation.cpp" />
9195
<ClCompile Include="stdafx.cpp">
9296
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
9397
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>

GraduateProject_DNASelfAssembling/GraduateProject_DNASelfAssembling.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
<ClInclude Include="GraduateProject_PatchesAndPresets.h">
3131
<Filter>头文件</Filter>
3232
</ClInclude>
33+
<ClInclude Include="GraduateProject_Simulation.h">
34+
<Filter>头文件</Filter>
35+
</ClInclude>
36+
<ClInclude Include="GraduateProject_Data.h">
37+
<Filter>头文件</Filter>
38+
</ClInclude>
3339
</ItemGroup>
3440
<ItemGroup>
3541
<ClCompile Include="stdafx.cpp">
@@ -44,5 +50,11 @@
4450
<ClCompile Include="GraduateProject_PatchesAndPresets.cpp">
4551
<Filter>源文件</Filter>
4652
</ClCompile>
53+
<ClCompile Include="GraduateProject_Simulation.cpp">
54+
<Filter>源文件</Filter>
55+
</ClCompile>
56+
<ClCompile Include="GraduateProject_Data.cpp">
57+
<Filter>源文件</Filter>
58+
</ClCompile>
4759
</ItemGroup>
4860
</Project>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#include"stdafx.h"
2+
3+
const double NN_dH_kcal[4][4][4] = {
4+
{ // AX/TY
5+
{ 1.2, 2.3, -0.6, -7.6 },
6+
{ 5.3, 0.0, -8.4, 0.7 },
7+
{ -0.7, -7.8, -3.1, 1.0 },
8+
{ -7.2, -1.2, -2.5, -2.7 }
9+
},
10+
{ // CX/GY
11+
{ -0.9, 1.9, -0.7, -8.5 },
12+
{ 0.6, -1.5, -8.0, -0.8 },
13+
{ -4.0, -10.6, -4.9, -4.1 },
14+
{ -7.8, -1.5, -2.8, -5.0 }
15+
},
16+
{ // GX/CY
17+
{ -2.9, 5.2, -0.6, -8.2 },
18+
{ -0.7, 3.6, -9.8, 2.3 },
19+
{ 0.5, -8.0, -6.0, 3.3 },
20+
{ -8.4, 5.2, -4.4, -2.2 }
21+
},
22+
{ // TX/AY
23+
{ 4.7, 3.4, 0.7, -7.2 },
24+
{ 7.6, 6.1, -8.2, 1.2 },
25+
{ 3.0, -8.5, 1.6, -0.1 },
26+
{ -7.6, 1.0, -1.3, 0.2 }
27+
}
28+
};
29+
const double NN_dS_cal[4][4][4] = {
30+
{ // AX/TY
31+
{ 1.7, 4.6, -2.3, -21.3 },
32+
{ 14.6, -4.4, -22.4, 0.2 },
33+
{ -2.3, -21.0, -9.5, 0.9 },
34+
{ -20.4, -6.2, -8.3, -10.8 }
35+
},
36+
{ // CX/GY
37+
{ -4.2, 3.7, -2.3, -22.7 },
38+
{ -0.6, -7.2, -19.9, -4.5 },
39+
{ -13.2, -27.2, -15.3, -11.7 },
40+
{ -21.0, -6.1, -8.0, -15.8 }
41+
},
42+
{ // GX/CY
43+
{ -9.8, 14.2, -1.0, -22.2 },
44+
{ -3.8, 8.9, -24.4, 5.4 },
45+
{ 3.2, -19.9, -15.8, 10.4 },
46+
{ -22.4, 13.5, -12.3, -8.4 }
47+
},
48+
{ // TX/AY
49+
{ 12.9, 8.0, 0.7, -21.3 },
50+
{ 20.2, 16.4, -22.2, 0.7 },
51+
{ 7.4, -22.7, 3.6, -1.7 },
52+
{ -21.3, 0.7, -5.3, -1.5 }
53+
}
54+
};
55+
int NN_dG_check(){
56+
double check[4][4][4];
57+
int i, j, k;
58+
double T37 = 273.15 + 37;
59+
for (i = 0; i < 4; i++){
60+
for (j = 0; j < 4; j++){
61+
for (k = 0; k < 4; k++){
62+
check[i][j][k] = NN_dH_kcal[i][j][k] - T37*NN_dS_cal[i][j][k] / 1000;
63+
cout << " \t" << check[i][j][k];
64+
}
65+
cout << endl;
66+
}
67+
cout << endl;
68+
}
69+
return 0;
70+
}
71+
const double NN_dH_init_kcal = 0.2;
72+
const double NN_dS_init_cal = -5.7;
73+
const double NN_dH_ATPenalty_kcal = 2.2;
74+
const double NN_dS_ATPenalty_cal = 6.9;
75+
/*
76+
References:
77+
78+
1. J. SantaLucia, Jr. and D. Hicks, The Thermodynamics of DNA Structural Motifs, Annu. Rev. Biophys. Biomol. Struct. 33, 415 (2004)
79+
2. Allawi HT, SantaLucia J Jr. Thermodynamics and NMR of internal G-T mismatches in DNA. Biochemistry 36:10581-94 (1997)
80+
3. Allawi HT, SantaLucia J Jr. Nearestneighbor thermodynamics of internal A-C mismatches in DNA: sequence dependence and pH effects. Biochemistry 37:9435-44 (1998)
81+
4. Allawi HT, SantaLucia J Jr. Nearestneighbor thermodynamics parameters for internal G-A mismatches in DNA. Biochemistry 37:2170-79 (1998)
82+
5. Allawi HT, SantaLucia J Jr. Thermodynamics of internal C-T mismatches in DNA. Nucleic Acids Res. 26:2694-701 (1998)
83+
6. Peyret N, Seneviratne PA, Allawi HT, SantaLucia J Jr. Nearest-neighbor thermodynamics and NMR of DNA sequences with internal A-A, C-C, G-G, and T-T mismatches. Biochemistry 38:3468-77 (1999)
84+
*/
85+
86+
extern const double NN_dH_DE_kcal[2][4][4] = {
87+
{
88+
{ 0.2, 0.6, -1.1, -6.9 },
89+
{ -6.3, -4.4, -5.1, -4.0 },
90+
{ -3.7, -4.0, -3.9, -4.9 },
91+
{ -2.9, -4.1, -4.2, -0.2 }
92+
},
93+
{
94+
{ -0.5, 4.7, -4.1, -3.8 },
95+
{ -5.9, -2.6, -3.2, -5.2 },
96+
{ -2.1, -0.2, -3.9, -4.4 },
97+
{ -0.7, 4.4, -1.6, 2.9 }
98+
}
99+
};
100+
extern const double NN_dS_DE_cal[2][4][4] = {
101+
{
102+
{ 2.3, 3.3, -1.6, -20.0 },
103+
{ -17.1, -12.6, -14.0, -10.9 },
104+
{ -10.0, -11.9, -10.9, -13.8 },
105+
{ -7.6, -13.0, -15.0, -0.5 }
106+
},
107+
{
108+
{ -1.1, 14.2, -13.1, -12.6 },
109+
{ -16.5, -7.4, -10.4, -15.0 },
110+
{ -3.9, -0.1, -11.2, -13.1 },
111+
{ -0.8, 14.9, -3.6, 10.4 }
112+
}
113+
};
114+
int NN_dG_DE_check(){
115+
double check[2][4][4];
116+
int i, j, k;
117+
double T37 = 273.15 + 37;
118+
for (i = 0; i < 2; i++){
119+
for (j = 0; j < 4; j++){
120+
for (k = 0; k < 4; k++){
121+
check[i][j][k] = NN_dH_DE_kcal[i][j][k] - T37*NN_dS_DE_cal[i][j][k] / 1000;
122+
cout << " \t" << check[i][j][k];
123+
}
124+
cout << endl;
125+
}
126+
cout << endl;
127+
}
128+
return 0;
129+
}
130+
/*
131+
References:
132+
133+
1. J. SantaLucia, Jr. and D. Hicks, The Thermodynamics of DNA Structural Motifs, Annu. Rev. Biophys. Biomol. Struct. 33, 415 (2004)
134+
2. Bommarito S, Peyret N, SantaLucia J Jr. Thermodynamic parameters for DNA sequences with dangling ends. Nucleic Acids Res. 28:1929-34 (2000)
135+
*/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#pragma once
2+
3+
extern const double NN_dH_kcal[4][4][4];
4+
extern const double NN_dS_cal[4][4][4];
5+
/*
6+
NN_dH_kcal[a][b][c], NN_dS_cal[a][b][c]
7+
8+
5' --- a --- b --- 3'
9+
| |
10+
3' --- a' --- c --- 5'
11+
12+
where a' is the paired nucleotide of a.
13+
If c = b' then the index [a][b][b'] and [b'][a'][a] must refer to the same value.
14+
*/
15+
//int NN_dG_check();
16+
extern const double NN_dH_init_kcal;
17+
extern const double NN_dS_init_cal;
18+
extern const double NN_dH_ATPenalty_kcal;
19+
extern const double NN_dS_ATPenalty_cal;
20+
21+
extern const double NN_dH_DE_kcal[2][4][4];
22+
extern const double NN_dS_DE_cal[2][4][4];
23+
/*
24+
NN_dH_DE_kcal[0,1][a][b], NN_dS_DE_cal[0,1][a][b]
25+
26+
0 mode: 5' dangling ends
27+
28+
5' --- b --- a --- 3'
29+
|
30+
a' --- 5'
31+
32+
1 mode: 3' dangling ends
33+
34+
a' --- 3'
35+
|
36+
3' --- b --- a --- 5'
37+
*/
38+
//int NN_dG_DE_check();

GraduateProject_DNASelfAssembling/GraduateProject_PatchesAndPresets.cpp

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ atom_in_unitcell atom_in_unitcell::set(int nx, int ny, int nz, int nsd, int norn
55
sd = nsd;
66
int mainOrnt = nornt0;
77
int subOrnt = 0, subOrnt_as_pow = 7 - nornt0^nornt1;
8-
while (subOrnt_as_pow > 1){
9-
subOrnt_as_pow >>= 1;
10-
subOrnt++;
11-
}
8+
for (; subOrnt_as_pow > 1; subOrnt_as_pow >>= 1)subOrnt++;
129
ornt = mainOrnt + 8 * subOrnt;
1310
return *this;
1411
}
@@ -28,8 +25,10 @@ int unitcell_init(){
2825
DNAmol::DNAmol(){
2926
px.x = px.y = px.z = 0;
3027
ornt = 0;
31-
for (int i = 0; i < 4; i++){
28+
int i, j;
29+
for (i = 0; i < 4; i++){
3230
correctbond[i] = -1;
31+
for (j = 0; j < 8; j++)patch[i][j] = 'T';
3332
}
3433
}
3534
DNAmol DNAmol::put(int nx, int ny, int nz, int nornt){
@@ -42,10 +41,53 @@ DNAmol DNAmol::put(const atom_in_unitcell &a, int x_init, int y_init, int z_init
4241
ornt = a.ornt;
4342
return *this;
4443
}
44+
int DNAmol::displayPatch()const{
45+
for (int i = 0; i < 4; i++){
46+
cout.write(patch[i], 8);
47+
}
48+
cout << endl;
49+
return 0;
50+
}
51+
int DNAmol::displayPatch(ofstream &out)const{
52+
for (int i = 0; i < 4; i++){
53+
out.write(patch[i], 8);
54+
}
55+
out << endl;
56+
return 0;
57+
}
58+
int DNAmol::findPatchSerial(int whichOrnt)const{ // Find the patch serial in the designated orientation. -1 if not found.
59+
for (int m = 0; m < 4; m++){
60+
if (ornt2bpornt[ornt][m] == whichOrnt){
61+
return m;
62+
}
63+
}
64+
return -1;
65+
}
4566
int stage[_Nx][_Ny][_Nz]; // To store DNAmol serial. -1 if not occupied. Using periodic boundary conditions.
4667
DNAmol *mol;
4768
int N; // Total molecules.
4869

70+
char nt[4] = { 'A', 'C', 'G', 'T' };
71+
int ntSerial(char which_nt){
72+
switch (which_nt){
73+
case'A':return 0;
74+
case'C':return 1;
75+
case'G':return 2;
76+
case'T':return 3;
77+
}
78+
}
79+
int ntSerialPair[4] = { 3, 2, 1, 0 };
80+
char ntPair(char which_nt){
81+
return nt[ntSerialPair[ntSerial(which_nt)]];
82+
}
83+
int couldPatchInteract[4][4] = {
84+
{ 0, 1, 1, 0 },
85+
{ 1, 0, 0, 1 },
86+
{ 1, 0, 0, 1 },
87+
{ 0, 1, 1, 0 }
88+
};
89+
int isPatchConsequent[4] = { 1, 0, 0, 1 };
90+
4991
int stageClear(){
5092
int i, j, k;
5193
for (i = 0; i < _Nx; i++){
@@ -89,22 +131,19 @@ int correctbonding(int n0serial, int n01x, int n01y, int n01z){
89131
int ornt0 = 4 * (n01x + 1) / 2 + 2 * (n01y + 1) / 2 + (n01z + 1) / 2;
90132
int ornt1 = 7 - ornt0;
91133
int n0ps = -1, n1ps = -1; // patch serial for the right bonding. -1 if not exist.
92-
int m;
93-
for (m = 0; m < 4; m++){
94-
if (ornt2bpornt[mol[n0serial].ornt][m] == ornt0){
95-
n0ps = m; break;
96-
}
97-
}
98-
for (m = 0; m < 4; m++){
99-
if (ornt2bpornt[mol[n1serial].ornt][m] == ornt1){
100-
n1ps = m; break;
101-
}
102-
}
103-
if (n0ps >= 0 && n1ps >= 0 && abs(n0ps - n1ps) == 2){
134+
int temp_ntSerial;
135+
n0ps = mol[n0serial].findPatchSerial(ornt0);
136+
n1ps = mol[n1serial].findPatchSerial(ornt1);
137+
if (n0ps >= 0 && n1ps >= 0 && couldPatchInteract[n0ps][n1ps]){
104138
mol[n0serial].correctbond[n0ps] = n1serial;
105139
mol[n1serial].correctbond[n1ps] = n0serial;
106140
// patch assign
107-
141+
static uniform_int_distribution<> patchDis(0, 3);
142+
for (int i = 0; i < 8; i++){
143+
temp_ntSerial = patchDis(gen);
144+
mol[n0serial].patch[n0ps][i] = nt[temp_ntSerial];
145+
mol[n1serial].patch[n1ps][7 - i] = nt[3 - temp_ntSerial];
146+
}
108147
return 0;
109148
}
110149
return 1;
@@ -124,11 +163,17 @@ int nucleotidePreset(){
124163
}
125164
}
126165
}
166+
ofstream out("F:\\DNAPatches.txt");
167+
for (m = 0; m < N; m++){
168+
mol[m].displayPatch(out);
169+
}
170+
out.close();
127171
return 0;
128172
}
129173
int patchPreset(){
130174
stageClear();
131175
molPreset();
132176
nucleotidePreset();
177+
stageClear();
133178
return 0;
134179
}

GraduateProject_DNASelfAssembling/GraduateProject_PatchesAndPresets.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ struct DNAmol{
1717
DNAmol();
1818
DNAmol put(int nx, int ny, int nz, int nornt);
1919
DNAmol put(const atom_in_unitcell &a, int x_init, int y_init, int z_init);
20+
int displayPatch()const;
21+
int displayPatch(ofstream &out)const;
22+
int findPatchSerial(int whichOrnt)const; // Find the patch serial in the designated orientation. -1 if not found.
2023
};
2124
extern DNAmol *mol;
2225
extern int stage[_Nx][_Ny][_Nz]; // To store DNAmol serial. -1 if not occupied. Using periodic boundary conditions.
2326
extern int N; // Total molecules.
2427

28+
extern char nt[4];
29+
int ntSerial(char which_nt);
30+
extern int ntSerialPair[4];
31+
char ntPair(char which_nt);
32+
extern int couldPatchInteract[4][4];
33+
extern int isPatchConsequent[4]; // If the nucleotide sequence in a patch is 5'-3', it is consequent.
34+
2535
int patchPreset();

0 commit comments

Comments
 (0)