48 #define G4cout std::cout
49 #define G4cerr std::cerr
50 #define G4endl std::endl
51 #define G4String std::string // string included in PDBatom.hh
66 fNbNucleotidsPerStrand(0)
83 unsigned short int& isDNA,
84 unsigned short int verbose = 0)
88 infile.open(filename.c_str());
91 G4cout <<
"PDBlib::load >> file " << filename <<
" not found !!!!"
102 Atom * AtomicOld =
nullptr;
103 Atom * AtomicNext =
nullptr;
112 Residue * residueOld =
nullptr;
113 Residue * residueFirst =
nullptr;
114 Residue * residueNext =
nullptr;
123 double minGlobZ, maxGlobZ;
124 double minGlobX, maxGlobX;
125 double minGlobY, maxGlobY;
146 unsigned short int numModel = 0;
147 unsigned short int model = 0;
157 getline(infile, sLine);
158 std::size_t found = sLine.find(
"DNA");
159 if(found != G4String::npos)
166 found = sLine.find(
"HEADER");
167 if(found == G4String::npos)
170 infile.open(filename.c_str());
172 G4cout <<
"PDBlib::load >> No header found !!!!" <<
G4endl;
178 getline(infile, sLine);
180 if((sLine.substr(0, 6)).
compare(
"NUMMDL") == 0)
182 istringstream((sLine.substr(10, 4))) >> numModel;
184 if((numModel > 0) && ((sLine.substr(0, 6)).
compare(
"MODEL ") == 0))
186 istringstream((sLine.substr(10, 4))) >>
model;
192 if((sLine.substr(0, 6)).
compare(
"SEQRES") == 0)
199 if((numModel > 0) && ((sLine.substr(0, 6)).
compare(
"ENDMDL") == 0))
203 else if((sLine.substr(0, 6)).
compare(
"TER ") == 0)
208 if(ter > terMax)
break;
221 if(moleculeOld == NULL)
224 moleculeOld =
new Molecule(nameMol, nbMolecule);
225 moleculeOld->
SetFirst(residueFirst);
227 moleculeFirst = moleculeOld;
231 moleculeNext =
new Molecule(nameMol, nbMolecule);
232 moleculeOld->
SetNext(moleculeNext);
233 moleculeNext->
SetFirst(residueFirst);
235 moleculeOld = moleculeNext;
240 moleculeOld->
fCenterX = (
int) ((minX + maxX) / 2.);
241 moleculeOld->
fCenterY = (
int) ((minY + maxY) / 2.);
242 moleculeOld->
fCenterZ = (
int) ((minZ + maxZ) / 2.);
274 else if((sLine.substr(0, 6)).
compare(
"ATOM ") == 0)
279 istringstream((sLine.substr(6, 5))) >> serial;
283 atomName = sLine.substr(12, 4);
284 if(atomName.substr(0, 1).compare(
" ") == 0) element = sLine.substr(13,
286 else element = sLine.substr(12, 1);
289 double vdwRadius = -1.;
294 else if(element ==
"C")
298 else if(element ==
"N")
302 else if(element ==
"O")
306 else if(element ==
"P")
310 else if(element ==
"S")
317 G4cerr <<
"Element not recognized : " << element <<
G4endl;
322 errMsg <<
"Element not recognized : " << element <<
G4endl;
325 "ELEM_NOT_RECOGNIZED",
335 resName = sLine.substr(17, 3);
337 istringstream((sLine.substr(22, 4))) >> resSeq;
339 stringstream((sLine.substr(30, 8))) >>
x;
340 stringstream((sLine.substr(38, 8))) >>
y;
341 stringstream((sLine.substr(46, 8))) >>
z;
345 if(minGlobZ < z) minGlobZ =
z;
346 if(maxGlobZ > z) maxGlobZ =
z;
347 if(minGlobX < x) minGlobX =
x;
348 if(maxGlobX > x) maxGlobX =
x;
349 if(minGlobY < y) minGlobY =
y;
350 if(maxGlobY > y) maxGlobY =
y;
351 if(minX > x) minX =
x;
352 if(maxX < x) maxX =
x;
353 if(minY > y) minY =
y;
354 if(maxY < y) maxY =
y;
355 if(minZ > z) minZ =
z;
356 if(maxZ < z) maxZ =
z;
359 if(AtomicOld == NULL)
361 AtomicOld =
new Atom(serial,
377 AtomicNext =
new Atom(serial,
389 AtomicOld->
SetNext(AtomicNext);
390 AtomicOld = AtomicNext;
396 if(residueOld == NULL)
398 if(verbose > 2)
G4cout <<
"residueOld == NULL" <<
G4endl;
401 residueOld =
new Residue(resName, resSeq);
404 residueFirst = residueOld;
410 if(lastResSeq == resSeq)
420 residueNext =
new Residue(resName, resSeq);
422 residueOld->
SetNext(residueNext);
423 residueOld->
fNbAtom = nbAtom - 1;
426 residueOld = residueNext;
437 return moleculeFirst;
467 while(moleculeListTemp)
469 residueListTemp = moleculeListTemp->
GetFirst();
475 int correctNumerotationNumber = 0;
476 if(k == 2 && residueListTemp->
fResSeq > 1)
478 correctNumerotationNumber = residueListTemp->
fResSeq;
481 while(residueListTemp)
483 AtomTemp = residueListTemp->
GetFirst();
487 if(correctNumerotationNumber != 0)
490 - correctNumerotationNumber
495 double baryX = 0., baryY = 0., baryZ = 0.;
496 double baryBaseX = 0., baryBaseY = 0., baryBaseZ = 0.;
497 double barySugX = 0., barySugY = 0., barySugZ = 0.;
498 double baryPhosX = 0., baryPhosY = 0., baryPhosZ = 0.;
499 unsigned short int nbAtomInBase = 0;
501 for(
int i = 0; i < residueListTemp->
fNbAtom; i++)
504 baryX += AtomTemp->
fX;
505 baryY += AtomTemp->
fY;
506 baryZ += AtomTemp->
fZ;
508 if(residueListTemp->
fResSeq == 1)
512 baryPhosX += AtomTemp->
fX;
513 baryPhosY += AtomTemp->
fY;
514 baryPhosZ += AtomTemp->
fZ;
518 barySugX += AtomTemp->
fX;
519 barySugY += AtomTemp->
fY;
520 barySugZ += AtomTemp->
fZ;
528 baryBaseX += AtomTemp->
fX;
529 baryBaseY += AtomTemp->
fY;
530 baryBaseZ += AtomTemp->
fZ;
539 baryPhosX += AtomTemp->
fX;
540 baryPhosY += AtomTemp->
fY;
541 baryPhosZ += AtomTemp->
fZ;
545 barySugX += AtomTemp->
fX;
546 barySugY += AtomTemp->
fY;
547 barySugZ += AtomTemp->
fZ;
555 baryBaseX += AtomTemp->
fX;
556 baryBaseY += AtomTemp->
fY;
557 baryBaseZ += AtomTemp->
fZ;
562 AtomTemp = AtomTemp->
GetNext();
565 baryX = baryX / (double) residueListTemp->
fNbAtom;
566 baryY = baryY / (
double) residueListTemp->
fNbAtom;
567 baryZ = baryZ / (double) residueListTemp->
fNbAtom;
569 if(residueListTemp->
fResSeq != 1)
571 baryPhosX = baryPhosX / 4.;
572 baryPhosY = baryPhosY / 4.;
573 baryPhosZ = baryPhosZ / 4.;
575 barySugX = barySugX / 7.;
576 barySugY = barySugY / 7.;
577 barySugZ = barySugZ / 7.;
578 baryBaseX = baryBaseX / (double) nbAtomInBase;
579 baryBaseY = baryBaseY / (double) nbAtomInBase;
580 baryBaseZ = baryBaseZ / (double) nbAtomInBase;
583 if(BarycenterOld == NULL)
585 BarycenterOld =
new Barycenter(j + j_old, baryX, baryY, baryZ,
595 BarycenterFirst = BarycenterOld;
612 BarycenterOld->
SetNext(BarycenterNext);
613 BarycenterOld = BarycenterNext;
619 AtomTemp = residueListTemp->
GetFirst();
622 for(
int ii = 0; ii < residueListTemp->
fNbAtom; ii++)
631 if(dT3Dp > max) max = dT3Dp;
632 AtomTemp = AtomTemp->
GetNext();
636 residueListTemp = residueListTemp->
GetNext();
643 moleculeListTemp = moleculeListTemp->
GetNext();
646 if(BarycenterNext != NULL)
651 return BarycenterFirst;
669 double minminX, minminY, minminZ;
670 double maxmaxX, maxmaxY, maxmaxZ;
679 while(moleculeListTemp)
681 if(minminX > moleculeListTemp->
fMaxGlobX)
685 if(minminY > moleculeListTemp->
fMaxGlobY)
689 if(minminZ > moleculeListTemp->
fMaxGlobZ)
693 if(maxmaxX < moleculeListTemp->fMinGlobX)
697 if(maxmaxY < moleculeListTemp->fMinGlobY)
701 if(maxmaxZ < moleculeListTemp->fMinGlobZ)
706 moleculeListTemp = moleculeListTemp->
GetNext();
709 dX = (maxmaxX - minminX) / 2. + 1.8;
710 dY = (maxmaxY - minminY) / 2. + 1.8;
711 dZ = (maxmaxZ - minminZ) / 2. + 1.8;
713 tX = minminX + (maxmaxX - minminX) / 2.;
714 tY = minminY + (maxmaxY - minminY) / 2.;
715 tZ = minminZ + (maxmaxZ - minminZ) / 2.;
732 while(moleculeListTemp)
734 residueListTemp = moleculeListTemp->
GetFirst();
739 while(residueListTemp)
742 residueListTemp = residueListTemp->
GetNext();
746 moleculeListTemp = moleculeListTemp->
GetNext();
768 unsigned short int matchFound = 0;
770 Molecule *mLTsavedPointer = moleculeListTemp;
773 short int strandNum = 0;
776 unsigned short int BSP = 2;
788 moleculeListTemp = mLTsavedPointer;
789 BarycenterList = BLsavedPointer;
792 while(moleculeListTemp)
795 residueListTemp = moleculeListTemp->
GetFirst();
801 while(residueListTemp)
805 if(j - j_save > 2)
break;
813 if(distEdepDNA < BarycenterList->GetRadius())
818 AtomTemp = residueListTemp->
GetFirst();
819 for(
int iii = 0; iii < residueListTemp->
fNbAtom; iii++)
829 if((distEdepAtom < AtomTemp->GetVanDerWaalsRadius()) && (smallestDist
841 residueNum = residueListTemp->
fResSeq;
844 baseName = (residueListTemp->
fResName)[2];
845 if(residueListTemp->
fResSeq == 1)
847 if(iii == 0) BSP = 0;
848 else if(iii < 8) BSP = 1;
854 else if(iii < 11) BSP = 1;
858 smallestDist = distEdepAtom;
862 if(j_save == j_max_value) j_save = j;
865 AtomTemp = AtomTemp->
GetNext();
868 BarycenterList = BarycenterList->
GetNext();
869 residueListTemp = residueListTemp->
GetNext();
871 moleculeListTemp = moleculeListTemp->
GetNext();
874 numStrand = strandNum;
875 numNucleotid = residueNum;
890 return sqrt((xA - xB) * (xA - xB) + (yA - yB) * (yA - yB)
891 + (zA - zB) * (zA - zB));