16 #include <boost/unordered_map.hpp>
24 #include <basic/Tracer.hh>
28 #include <utility/vector0.hh>
29 #include <utility/vector1.hh>
31 #include <numeric/NumericTraits.hh>
36 static basic::Tracer
tr(
"protocols.sparta");
43 r1 = 9999; rN = -9999;
49 PDBfileName = fileName;
51 r1 = 9999; rN = -9999;
61 case 1:
return str.substr(0,6);
62 case 2:
return str.substr(6,5);
63 case 3:
return str.substr(11,5);
64 case 4:
return str.substr(17,4);
65 case 5:
return str.substr(21,1);
66 case 6:
return str.substr(22,4);
67 case 7:
return str.substr(30,8);
68 case 8:
return str.substr(38,8);
69 case 9:
return str.substr(46,8);
70 case 10:
return str.substr(54,6);
71 case 11:
return str.substr(60,6);
80 entry.
atomNum = atoi( getField(str,2).c_str() );
84 if ( atomName ==
"H" ) entry.
atomName=
"HN";
85 if ( atomName[0] >=
'1' && atomName[0] <=
'3' ) entry.
atomName = atomName.substr(1,4) + atomName[0];
90 entry.
resNum = atoi( getField(str,6).c_str() );
91 entry.
X = atof( getField(str,7).c_str() );
92 entry.
Y = atof( getField(str,8).c_str() );
93 entry.
Z = atof( getField(str,9).c_str() );
94 entry.
B_Factor = atof( getField(str,11).c_str() );;
103 PDBfileName = fileName;
105 ifstream file(fileName.c_str());
106 if (! file.is_open() ) {
107 tr.Error <<
"\tCan't open file " << fileName <<
" for reading" << endl;
115 std::stringstream obuffer;
117 std::stringstream ibuffer( obuffer.str() );
124 residListOne.clear();
128 acceptorList.clear();
132 int residue_offset = 0;
134 int conformer_count=1;
135 int lastline_index = 0;
137 while (!file.eof() ) {
139 file.getline(buf, 1000);
141 if ( str.empty() || str.size() == 0 )
continue;
142 int pos = str.find(
"ATOM");
143 int pos2 = str.find(
"TER"), pos3 = str.find(
"END");
144 if ( pos != 0 && pos2 != 0 && pos3 != 0 )
continue;
146 if ( pos2 == 0 || pos3 == 0) {
147 Conformers[conformer_count] = conformer;
155 loadPDB_Entry(str, temp);
157 if ( lastline_index>1 && temp.
chainName != conformer[lastline_index].chainName ) residue_offset = conformer[lastline_index].resNum-temp.
resNum+1;
161 conformer[temp.
atomNum] = temp;
177 if(conformer.size() != 0) Conformers[conformer_count] = conformer;
180 std::map<int, string> ::iterator it;
181 for ( it=residListOne.begin(); it!=residListOne.end(); it++ ) {
182 if ( it->second ==
"C" ) {
183 if ( isSSBonded(1, it->first) ) {
184 residListOne[it->first] =
"c";
185 residList[it->first] =
"cys";
194 if( residListOne[resNum] !=
"C" && residListOne[resNum] !=
"c" )
return false;
196 PDB_Entry CYS_SG = getEntry(1,resNum,
"SG");
198 std::map<int, string>::iterator it;
199 for ( it = residListOne.begin(); it != residListOne.end(); it++ )
201 if( (it->second ==
"C" || it->second ==
"c") && abs(it->first - resNum) >= 4 )
202 if( getDist(CYS_SG.
Coord, ATOMS[1][it->first][
"SG"].Coord ) <= 2.5 )
213 return ATOMS[conformerID][rNum][aName];
220 return Conformers[conformerID][aNum];
228 Vec3Copy(v,B); Vec3Copy(v1,A); Vec3Copy(v2,C);
235 float c = Vec3Scalar(v1, v2);
237 float s = Vec3Abs(v1);
239 return atan2f(s, c)*180.0/numeric::NumericTraits<Real>::pi();
251 double cb[3], n1[3], n2[3];
253 double TEMP, TEMP1, TEMP2, TEMP3, TEMP4, TEMP5;
258 cb[0] = c.
X - b.
X; cb[1] = c.
Y - b.
Y; cb[2] = c.
Z - b.
Z;
259 n1[0] = (b.
Y - a.
Y) * cb[2] + (a.
Z - b.
Z) * cb[1];
260 n1[1] = (b.
Z - a.
Z) * cb[0] + (a.
X - b.
X) * cb[2];
261 n1[2] = (b.
X - a.
X) * cb[1] + (a.
Y - b.
Y) * cb[0];
262 n2[0] = cb[1] * (d.
Z - c.
Z) + cb[2] * (c.
Y - d.
Y);
263 n2[1] = cb[2] * (d.
X - c.
X) + cb[0] * (c.
Z - d.
Z);
264 n2[2] = cb[0] * (d.
Y - c.
Y) + cb[1] * (c.
X - d.
X);
265 TEMP = n1[0]; TEMP1 = n1[1]; TEMP2 = n1[2];
266 TEMP3 = n2[0]; TEMP4 = n2[1]; TEMP5 = n2[2];
267 co = (float)((n1[0] * n2[0] + n1[1] * n2[1] + n1[2] * n2[2]) /
268 sqrt( (TEMP*TEMP + TEMP1*TEMP1 + TEMP2*TEMP2)*(TEMP3*TEMP3 + TEMP4*TEMP4 + TEMP5*TEMP5) ) );
271 return 180./numeric::NumericTraits<Real>::pi()*(arccos_(co)*
272 sgn( (
float)( (n1[1]*n2[2] - n1[2]*n2[1])*cb[0] + (n1[2]*n2[0] - n1[0]*n2[2])*cb[1] + (n1[0]*n2[1] - n1[1]*n2[0])*cb[2]) ) );
278 return getDihedralAngle(getEntry(conformerID,resNum-1,
"C"), \
279 getEntry(conformerID,resNum,
"N"), \
280 getEntry(conformerID,resNum,
"CA"), \
281 getEntry(conformerID,resNum,
"C") );
287 return getDihedralAngle(getEntry(conformerID,resNum,
"N"), \
288 getEntry(conformerID,resNum,
"CA"), \
289 getEntry(conformerID,resNum,
"C"), \
290 getEntry(conformerID,resNum+1,
"N") );
296 return getDihedralAngle(getEntry(conformerID,resNum-1,
"CA"), \
297 getEntry(conformerID,resNum-1,
"C"), \
298 getEntry(conformerID,resNum,
"N"), \
299 getEntry(conformerID,resNum,
"CA"));
305 string rName = residList[resNum];
308 if( rName ==
"GLY" || rName ==
"ALA" )
310 else if( rName ==
"VAL" )
311 R = getEntry(conformerID,resNum,
"CG2");
312 else if( rName ==
"ILE" )
313 R = getEntry(conformerID,resNum,
"CG1");
314 else if( rName ==
"THR" )
315 R = getEntry(conformerID,resNum,
"OG1");
316 else if( rName ==
"SER" )
317 R = getEntry(conformerID,resNum,
"OG" );
318 else if( rName ==
"CYS" || rName ==
"cys")
319 R = getEntry(conformerID,resNum,
"SG" );
321 R = getEntry(conformerID,resNum,
"CG" );
323 return getDihedralAngle(getEntry(conformerID,resNum,
"N"), \
324 getEntry(conformerID,resNum,
"CA"), \
325 getEntry(conformerID,resNum,
"CB"), R);
331 string rName = residList[resNum];
332 if( rName.compare(
"GLY") == 0 || rName.compare(
"ALA") == 0)
337 if( rName ==
"VAL" ){
338 R3 = getEntry(conformerID,resNum,
"CG1");
339 R4 = getEntry(conformerID,resNum,
"HG11");
341 else if( rName ==
"THR" ) {
342 R3 = getEntry(conformerID,resNum,
"CG2");
343 R4 = getEntry(conformerID,resNum,
"HG21");
345 else if( rName ==
"SER" ) {
346 R3 = getEntry(conformerID,resNum,
"OG");
347 R4 = getEntry(conformerID,resNum,
"HG");
349 else if( rName ==
"ILE" ) {
350 R3 = getEntry(conformerID,resNum,
"CG1" );
351 R4 = getEntry(conformerID,resNum,
"CD1" );
353 else if( rName ==
"CYS" || rName ==
"cys") {
354 R3 = getEntry(conformerID,resNum,
"SG" );
355 R4 = getEntry(conformerID,resNum,
"HG" );
358 R3 = getEntry(conformerID,resNum,
"CG" );
360 if( rName ==
"ASN" || rName ==
"ASP" ) R4 = getEntry(conformerID,resNum,
"OD1" );
361 else if( rName ==
"HIS" ) R4 = getEntry(conformerID,resNum,
"ND1" );
362 else if( rName ==
"MET" ) R4 = getEntry(conformerID,resNum,
"SD" );
363 else if( rName ==
"LEU" || rName ==
"PHE" || rName ==
"TYR" || rName ==
"TRP" )
364 R4 = getEntry(conformerID,resNum,
"CD1" );
365 else R4 = getEntry(conformerID,resNum,
"CD" );
367 return getDihedralAngle(getEntry(conformerID,resNum,
"CA"),getEntry(conformerID,resNum,
"CB"),R3, R4);
375 case 'A':
return "ALA";
376 case 'C':
return "CYS";
377 case 'c':
return "cys";
378 case 'D':
return "ASP";
379 case 'E':
return "GLU";
380 case 'F':
return "PHE";
381 case 'G':
return "GLY";
382 case 'H':
return "HIS";
383 case 'I':
return "ILE";
384 case 'K':
return "LYS";
385 case 'L':
return "LEU";
386 case 'M':
return "MET";
387 case 'N':
return "ASN";
388 case 'P':
return "PRO";
389 case 'Q':
return "GLN";
390 case 'R':
return "ARG";
391 case 'S':
return "SER";
392 case 'T':
return "THR";
393 case 'V':
return "VAL";
394 case 'W':
return "TRP";
395 case 'Y':
return "TYR";
405 if( a ==
"ALA")
return "A";
406 else if( a ==
"CYS")
return "C";
407 else if( a ==
"cys")
return "c";
408 else if( a ==
"ASP")
return "D";
409 else if( a ==
"GLU")
return "E";
410 else if( a ==
"PHE")
return "F";
411 else if( a ==
"GLY")
return "G";
412 else if( a ==
"HIS" || a ==
"HIS+")
return "H";
413 else if( a ==
"ILE")
return "I";
414 else if( a ==
"LYS" || a ==
"LYS+")
return "K";
415 else if( a ==
"LEU")
return "L";
416 else if( a ==
"MET")
return "M";
417 else if( a ==
"ASN")
return "N";
418 else if( a ==
"PRO")
return "P";
419 else if( a ==
"GLN")
return "Q";
420 else if( a ==
"ARG" || a ==
"ARG+")
return "R";
421 else if( a ==
"SER")
return "S";
422 else if( a ==
"THR")
return "T";
423 else if( a ==
"VAL")
return "V";
424 else if( a ==
"TRP")
return "W";
425 else if( a ==
"TYR")
return "Y";
436 Mol conf = Conformers[1];
438 string PF6Atoms[6] = {
"CG",
"CD1",
"CE1",
"CZ",
"CE2",
"CD2" };
439 string W6Atoms[6] = {
"CD2",
"CE2",
"CZ2",
"CH2",
"CZ3",
"CE3" };
440 string H5Atoms[5] = {
"CG",
"ND1",
"CE1",
"NE2",
"CD2" };
441 string W5Atoms[5] = {
"CG",
"CD1",
"NE1",
"CE2",
"CD2" };
443 std::map<int, string>::iterator it;
449 for ( it = residList.begin(); it != residList.end(); it++ )
451 int resID = it->first;
452 string resName = it->second;
454 if( resName ==
"PHE" || resName ==
"TYR" || resName ==
"TRP")
456 Rings[RingNo].resID = resID; Rings[RingNo].resName = resName; Rings[RingNo].atomNo = 6;
457 if( resName ==
"PHE" ) Rings[RingNo].ringFact = 1.46;
458 if( resName ==
"TYR" ) Rings[RingNo].ringFact = 1.24;
459 if( resName ==
"TRP" ) Rings[RingNo].ringFact = 1.24;
461 bool NO_MISSED_RING_ATOMS =
true;
463 for( i = 0; i < 6; i++ )
466 if( resName ==
"PHE" || resName ==
"TYR")
468 atom = getEntry(1,resID,PF6Atoms[i]);
470 Vec3Copy(Rings[RingNo].coordA[i], atom.
Coord);
471 else NO_MISSED_RING_ATOMS =
false;
473 else if ( resName ==
"TRP")
475 atom = getEntry(1,resID,W6Atoms[i]);
477 Vec3Copy(Rings[RingNo].coordA[i], atom.
Coord);
478 else NO_MISSED_RING_ATOMS =
false;
482 if(NO_MISSED_RING_ATOMS) RingNo++;
485 if( resName ==
"HIS" || resName ==
"TRP")
487 Rings[RingNo].resID = resID; Rings[RingNo].resName = resName; Rings[RingNo].atomNo = 5;
488 if( resName ==
"HIS" ) Rings[RingNo].ringFact = 1.35;
489 if( resName ==
"TRP" ) Rings[RingNo].ringFact = 1.32;
491 bool NO_MISSED_RING_ATOMS =
true;
493 for( i = 0; i < 5; i++ )
496 if( resName ==
"HIS" )
498 atom = getEntry(1,resID,H5Atoms[i]);
500 Vec3Copy(Rings[RingNo].coordA[i], atom.
Coord);
501 else NO_MISSED_RING_ATOMS =
false;
503 else if ( resName ==
"TRP" )
505 atom = getEntry(1,resID,W5Atoms[i]);
507 Vec3Copy(Rings[RingNo].coordA[i], atom.
Coord);
508 else NO_MISSED_RING_ATOMS =
false;
512 if(NO_MISSED_RING_ATOMS) RingNo++;
516 for(i=0; i < RingNo; i++)
517 calcPlane(&Rings[i]);
528 for(atomI = 0; atomI < ringP->
atomNo; atomI++)
532 Vec3Zero(ringP->
norm);
535 Vec3Sub(v1, ringP->
center);
536 for(atomI = 0; atomI < ringP->
atomNo; atomI++)
538 Vec3Copy(v2, ringP->
coordA[atomI]);
539 Vec3Sub(v2, ringP->
center);
540 ringP->
rad += Vec3Abs(v2);
542 Vec3Add(ringP->
norm, v1);
545 Vec3Norm(ringP->
norm);
554 if (ringP->
norm[0] > 0.5f || ringP->
norm[0] < -0.5f)
556 v1[0] = - ringP->
norm[1];
557 v1[1] = ringP->
norm[0];
562 v1[1] = - ringP->
norm[2];
563 v1[2] = ringP->
norm[1];
566 ringP->
transM[0][1] = v1[0];
567 ringP->
transM[1][1] = v1[1];
568 ringP->
transM[2][1] = v1[2];
570 Vec3Cross(v1, ringP->
norm);
571 ringP->
transM[0][0] = v1[0];
572 ringP->
transM[1][0] = v1[1];
573 ringP->
transM[2][0] = v1[2];
582 Vec3Copy( v, getEntry(conformerID,resNum,aName).Coord );
586 float ringShiftSum = 0.0f;
588 for(
int i=0; i < RingNo; i++)
592 float area, r1, r2, g,
b;
595 if( Rings[i].resID == resNum && aName !=
"HN" )
continue;
597 atomNo = Rings[i].atomNo;
601 for (atomI = 0; atomI < atomNo; atomI++)
603 Vec3Copy(v1, Rings[i].coordA[atomI]);
604 Vec3Copy(v2, Rings[i].coordA[(atomI + 1) % atomNo]);
606 r1 = Vec3DiffAbs(v1, v);
607 r2 = Vec3DiffAbs(v2, v);
610 Vec3Sub(vt, Rings[i].center);
611 Vec3Sub(v1, Rings[i].center);
612 Vec3Sub(v2, Rings[i].center);
614 Mat3VecMult(vt, Rings[i].transM);
615 Mat3VecMult(v1, Rings[i].transM);
616 Mat3VecMult(v2, Rings[i].transM);
620 area = v1[0] * v2[1] - v1[1] * v2[0];
621 g += area * (1.0f / (r1 * r1 * r1) + 1.0f / (r2 * r2 * r2));
626 b = (float) 5.4548e-6;
628 ringShiftSum += Rings[i].ringFact * b * g;
636 return ringShiftSum*((float)-1.0e6);
662 Mol conf = Conformers[1];
665 acceptorList.clear();
670 for ( it = conf.begin(); it != conf.end(); it++ ) {
677 donorList[it->first] = temp.
atomNum;
682 boost::unordered_map<int, int>::iterator itA, itD;
683 for(itA = acceptorList.begin(); itA != acceptorList.end(); itA++ ) {
685 PDB_Entry A = conf[ itA->first ], A_Heavy = conf[ itA->second ];;
688 for( itD = donorList.begin(); itD != donorList.end(); itD++ ) {
690 PDB_Entry D = conf[ itD->first ], D_Heavy = conf[ itD->second ];
694 float D_ON = getDist(A,D_Heavy);
695 float D_CH = getDist(A_Heavy,D);
696 float D_OH = getDist(A,D);
697 float D_CN = getDist(A_Heavy,D_Heavy);
699 if( D_OH > D_CN )
continue;
701 float HBond_E = 332.0*0.42*0.20;
702 HBond_E *= ( 1.0/D_ON+1.0/D_CH-1.0/D_OH-1.0/D_CN );
709 HB_DHO_AngleList[A.
resNum][A.
atomName] = getBondAngle(D_Heavy,D,A);
710 HB_HOA_AngleList[A.
resNum][A.
atomName] = getBondAngle(D,A,A_Heavy);
717 HB_DHO_AngleList[D.
resNum][D.
atomName] = getBondAngle(D_Heavy,D,A);
718 HB_HOA_AngleList[D.
resNum][D.
atomName] = getBondAngle(D,A,A_Heavy);
740 return HBDistList[resNum][atomName];
768 if(D.
atomName.find(
"HA") != string::npos )
return ATOMS[1][D.
resNum][
"CA"];
795 return ((x >= 0.0) - (x < 0.0));
801 const Real SPARTA_PI = numeric::NumericTraits<Real>::pi();
802 if (x > 1.0) x = 1.0;
803 else if (x < -1.0) x = -1.0;
805 if (fabs(x) >= 0.5) {
807 return atan(sqrt(1.0 - x * x) / x);
809 return (SPARTA_PI + atan(sqrt(1.0 - x * x) / x));
812 return (0.5 * SPARTA_PI - atan(x / sqrt(1.0 - x * x)));
818 for (
int i = 0; i < 3; i++)
825 for (
int i = 0; i < 3; i++)
832 return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
838 return sqrtf((v1[0] - v2[0]) * (v1[0] - v2[0]) +
839 (v1[1] - v2[1]) * (v1[1] - v2[1]) +
840 (v1[2] - v2[2]) * (v1[2] - v2[2]));
846 float a = Vec3Abs(v);
847 for(
int i = 0; i < 3; i++)
854 for(
int i = 0; i < 3; i++)
861 for(
int i = 0; i < 3; i++)
868 for(
int i = 0; i < 3; i++)
875 return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
883 vRes[0] = v1[1] * v2[2] - v1[2] * v2[1];
884 vRes[1] = v1[2] * v2[0] - v1[0] * v2[2];
885 vRes[2] = v1[0] * v2[1] - v1[1] * v2[0];
894 vRes[0] = v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0];
895 vRes[1] = v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1];
896 vRes[2] = v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2];
898 for(
int i = 0; i < 3; i++)
907 for (i = 0; i < 3; i++)
973 const Real SPARTA_PI = numeric::NumericTraits<Real>::pi();
974 Mol conf = Conformers[1];
977 boost::unordered_map<string, float> STD_AREA;
992 for( it = conf.begin(); it != conf.end(); it++ )
1007 bool fullInside, partInside;
1008 Vec3 cent, nCent, x, dx;
1015 if( b.
atomName ==
"C") b_atomName =
"CO";
1017 float b_rad = VDW_RAD[b_atomName] + rad_sol;
1018 Vec3Copy(cent, b.
Coord);
1019 for (
int pointI = 0; pointI < SpherePointNo; pointI++)
1022 Vec3ScaleAdd(x, b_rad, SpherePoints[pointI]);
1028 for (
int atomI = 0; atomI < (
int)Neighnors.size(); atomI++)
1030 PDB_Entry nAtomP = conf[ Neighnors[atomI] ];
1032 Vec3Copy(nCent, nAtomP.
Coord);
1037 if( nAtomP.
resNum < r1 || nAtomP.
resNum > rN )
continue;
1040 string nAtomP_atomName = nAtomP.
atomName;
1041 if( nAtomP.
atomName[0] ==
'C' ) nAtomP_atomName =
"C";
1042 if( nAtomP.
atomName ==
"C") nAtomP_atomName =
"CO";
1044 float nRad = VDW_RAD[nAtomP_atomName] + rad_sol;
1045 if (dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2] > nRad * nRad)
1052 if( resID == nAtomP.
resNum )
1059 if (! fullInside) fullNo++;
1061 if (! partInside) partNo++;
1066 AtomSurfaceFullList[resID][b.
atomName] = fullNo * b_rad * b_rad *4.0f * (float) SPARTA_PI / SpherePointNo;
1067 AtomSurfacePartList[resID][b.
atomName] = partNo * b_rad * b_rad *4.0f * (float) SPARTA_PI / SpherePointNo;
1069 ResSurfaceFullList[resID] += (fullNo * b_rad * b_rad *4.0f * (float) SPARTA_PI / SpherePointNo);
1070 ResSurfacePartList[resID] += (partNo * b_rad * b_rad *4.0f * (float) SPARTA_PI / SpherePointNo);
1074 boost::unordered_map< int,float>::iterator itS;
1075 for( itS = ResSurfaceFullList.begin(); itS != ResSurfaceFullList.end(); itS++ )
1077 string resName = residList[itS->first];
1088 Mol conf = Conformers[1];
1089 Mol::iterator it, itA;
1092 for( itA = conf.begin(); itA != conf.end(); itA++ )
1102 if( a.
atomName[0] ==
'C' ) a_atomName =
"C";
1103 if( a.
atomName ==
"C") a_atomName =
"CO";
1104 float rad_a = VDW_RAD[ a_atomName ];
1107 for( it = conf.begin(); it != conf.end(); it++ )
1114 if( b.
atomName[0] ==
'C' ) b_atomName =
"C";
1115 if( b.
atomName ==
"C") b_atomName =
"CO";
1117 float rad_b = VDW_RAD[ b_atomName ];
1119 if( getDist(a,b) < rad_a + rad_b + rad_sol )
1132 double x0,
double y0,
double z0,
1133 double x1,
double y1,
double z1,
1134 double x2,
double y2,
double z2,
1135 int rowStartA[],
int rowNo,
int quad,
1136 int row0,
int ind0,
int ind1,
1140 if (row0 + 1 == row2 || row2 + 1 == row0) {
1141 int row0Size, row2Size;
1143 if (row0 == - rowNo || row0 == rowNo)
1146 row0Size = rowNo + row0;
1148 row0Size = rowNo - row0;
1150 if (row2 == - rowNo || row2 == rowNo)
1153 row2Size = rowNo + row2;
1155 row2Size = rowNo - row2;
1157 if (ind0 < (quad + 1) * row0Size) {
1158 ind0 += rowStartA[rowNo + row0];
1159 pointA[ind0][0] = (float) x0;
1160 pointA[ind0][1] = (float) y0;
1161 pointA[ind0][2] = (float) z0;
1164 if (ind1 < (quad + 1) * row0Size) {
1165 ind1 += rowStartA[rowNo + row0];
1166 pointA[ind1][0] = (float) x1;
1167 pointA[ind1][1] = (float) y1;
1168 pointA[ind1][2] = (float) z1;
1171 if (ind2 < (quad + 1) * row2Size) {
1172 ind2 += rowStartA[rowNo + row2];
1173 pointA[ind2][0] = (float) x2;
1174 pointA[ind2][1] = (float) y2;
1175 pointA[ind2][2] = (float) z2;
1178 double x01, y01, z01;
1179 double x12, y12, z12;
1180 double x20, y20, z20;
1182 int rowMid, indMid01, indMid02, indMid12;
1187 a = sqrt(x01 * x01 + y01 * y01 + z01 * z01);
1195 a = sqrt(x12 * x12 + y12 * y12 + z12 * z12);
1203 a = sqrt(x20 * x20 + y20 * y20 + z20 * z20);
1208 rowMid = (row0 + row2) / 2;
1209 indMid01 = (ind0 + ind1) / 2;
1210 indMid02 = (ind0 + ind2) / 2;
1211 indMid12 = (ind1 + ind2) / 2;
1217 rowStartA, rowNo, quad,
1218 row0, ind0, indMid01,
1225 rowStartA, rowNo, quad,
1226 row0, indMid01, ind1,
1233 rowStartA, rowNo, quad,
1234 rowMid, indMid02, indMid12,
1241 rowStartA, rowNo, quad,
1242 rowMid, indMid02, indMid12,
1352 Mol conf = Conformers[1];
1356 std::map<int, string>::iterator itA;
1359 for ( itA = residList.begin(); itA != residList.end(); itA++ )
1361 int resID = itA->first;
1362 string resName = itA->second;
1364 PDB_Entry O_prev = ATOMS[1][resID-1][
"O"];
1372 if( resName ==
"PRO" ) H = ATOMS[1][resID][
"N"];
1376 for( it = conf.begin(); it != conf.end(); it++ )
1381 if( resID2 == resID || resID2 == resID-1 || b.
atomName[0] ==
'H' || (b.
atomName[1] ==
'H'&&b.
atomName[1] !=
'N'))
continue;
1383 float D_OK = getDist(O_prev,b);
1384 float D_HK = getDist(H,b);
1386 S2 += exp(-1.0*D_OK);
1387 S2 += 0.8*exp(-1.0*D_HK);
1394 S2 = (exp(S2)-exp(-S2))/(exp(S2)+exp(-S2))-0.1;
1400 if(HN_S2[r1+2]>0 && HN_S2[r1+1]>0 ) HN_S2[r1] = HN_S2[r1+1]-fabs(HN_S2[r1+1]-HN_S2[r1+2]);
1401 if(HN_S2[rN-2]>0 && HN_S2[rN-1]>0 ) HN_S2[rN] = HN_S2[rN-1]-fabs(HN_S2[rN-1]-HN_S2[rN-2]);
1409 const Real SPARTA_PI = numeric::NumericTraits<Real>::pi();
1410 Mol conf = Conformers[1];
1413 boost::unordered_map<string, string> targetAtomList;
1414 boost::unordered_map<string, string>::iterator itT;
1415 targetAtomList[
"HN"]=
"N";
1416 targetAtomList[
"HA"]=
"CA";
1419 boost::unordered_map<string, float> Qlist;
1420 Qlist[
"C"] = -0.9612;
1421 Qlist[
"O"] = 1.39374;
1422 Qlist[
"N"] = 0.7209;
1425 std::map<int, string>::iterator itA;
1426 ElectricField.clear();
1427 for ( itA = residList.begin(); itA != residList.end(); itA++ )
1429 int resID = itA->first;
1430 string resName = itA->second;
1433 for(itT = targetAtomList.begin(); itT != targetAtomList.end(); itT++)
1435 PDB_Entry target = ATOMS[1][resID][itT->first];
1436 PDB_Entry partner = ATOMS[1][resID][itT->second];
1438 if( (target.
atomName).empty() )
continue;
1441 for( it = conf.begin(); it != conf.end(); it++ )
1446 if( fabs((
double) (resID2 - resID)) <= 1 )
continue;
1448 if( atomName2 ==
"O" && target.
atomName ==
"HN" )
continue;
1451 if( atomName2==
"O" || atomName2.substr(0,2)==
"OD" || atomName2.substr(0,2)==
"OE" || atomName2==
"C" || atomName2==
"N")
1453 float c = cos(getBondAngle(partner,target,b)*SPARTA_PI/180.0);
1454 float dist = getDist(target,b);
1455 if( dist > 3.0 )
continue;
1456 ElectricField[resID][target.
atomName] += Qlist[atomName2.substr(0,1)]*c/(dist*dist);
1471 Mol conf = Conformers[1];
1474 ElectricField.clear();
1476 const Real SPARTA_PI = numeric::NumericTraits<Real>::pi();
1477 const Real RADS_PER_DEG = SPARTA_PI / 180.;
1479 boost::unordered_map<string, string> targetAtomList;
1480 boost::unordered_map<string, string>::iterator itT;
1481 targetAtomList[
"HN"]=
"N";
1482 targetAtomList[
"HA"]=
"CA";
1485 boost::unordered_map<string, float> Qlist;
1486 Qlist[
"C"] = -0.9612;
1487 Qlist[
"O"] = 1.39374;
1488 Qlist[
"N"] = 0.7209;
1491 std::map<int, string>::iterator itA;
1494 for ( itA = residList.begin(); itA != residList.end(); itA++ )
1496 int resID = itA->first;
1497 string resName = itA->second;
1499 PDB_Entry O_prev = ATOMS[1][resID-1][
"O"];
1507 if( resName ==
"PRO" ) H = ATOMS[1][resID][
"N"];
1510 PDB_Entry EF_target_HA = ATOMS[1][resID][
"HA"];
1511 PDB_Entry EF_partner_HA = ATOMS[1][resID][
"CA"];
1512 PDB_Entry EF_target_HN = ATOMS[1][resID][
"HN"];
1513 PDB_Entry EF_partner_HN = ATOMS[1][resID][
"N"];
1517 for( it = conf.begin(); it != conf.end(); it++ )
1523 if(!( resID2 == resID || resID2 == resID-1 || b.
atomName[0] ==
'H' || (b.
atomName[1] ==
'H'&&b.
atomName[1] !=
'N')) )
1525 float D_OK = getDist(O_prev,b);
1526 float D_HK = getDist(H,b);
1528 S2 += exp(-1.0*D_OK);
1529 S2 += 0.8*exp(-1.0*D_HK);
1534 if( fabs( (
double) (resID2 - resID)) <= 1 )
continue;
1537 if(!(EF_target_HA.
atomName).empty())
1540 if( atomName2==
"O" || atomName2.substr(0,2)==
"OD" || atomName2.substr(0,2)==
"OE" || atomName2==
"C" || atomName2==
"N")
1543 float dist = getDist(EF_target_HA,b);
1545 ElectricField[resID][
"HA"] += Qlist[atomName2.substr(0,1)]*cos(getBondAngle(EF_partner_HA,EF_target_HA,b)*RADS_PER_DEG)/(dist*dist);
1550 if(!(EF_target_HN.
atomName).empty())
1553 if( atomName2.substr(0,2)==
"OD" || atomName2.substr(0,2)==
"OE" || atomName2==
"C" || atomName2==
"N")
1556 float dist = getDist(EF_target_HN,b);
1558 ElectricField[resID][
"HN"] += Qlist[atomName2.substr(0,1)]*cos(getBondAngle(EF_partner_HN,EF_target_HN,b)*RADS_PER_DEG)/(dist*dist);
1568 S2 = (exp(S2)-exp(-S2))/(exp(S2)+exp(-S2))-0.1;
1574 if(HN_S2[r1+2]>0 && HN_S2[r1+1]>0 ) HN_S2[r1] = HN_S2[r1+1]-fabs(HN_S2[r1+1]-HN_S2[r1+2]);
1575 if(HN_S2[rN-2]>0 && HN_S2[rN-1]>0 ) HN_S2[rN] = HN_S2[rN-1]-fabs(HN_S2[rN-1]-HN_S2[rN-2]);