75 unsigned short int verbose=0)
79 infile.open(filename.c_str());
83 G4cout<<
"PDBlib::load >> file "<<filename<<
" not found !!!!"<<
G4endl;
85 cout <<
"PDBlib::load >> file "<<filename<<
" not found !!!!"<<endl;
96 Atom * AtomicOld = NULL;
97 Atom * AtomicNext = NULL;
117 double minGlobZ,maxGlobZ;
118 double minGlobX,maxGlobX;
119 double minGlobY,maxGlobY;
120 double minX,maxX,minY,maxY,minZ,maxZ;
123 minGlobZ=-2000000000;
124 minGlobX=-2000000000;
125 minGlobY=-2000000000;
155 unsigned short int numModel=0;
156 unsigned short int model=0;
162 int terMax=2000000000;
168 getline(infile, sLine);
169 std::size_t found = sLine.find(
"DNA");
170 if (found!=std::string::npos)
178 found = sLine.find(
"HEADER");
179 if (found==std::string::npos)
182 infile.open(filename.c_str());
187 cout<<
"PDBlib::load >> No header found !!!!"<<endl;
193 while (!infile.eof())
195 getline(infile, sLine);
197 if ((sLine.substr(0,6)).compare(
"NUMMDL") == 0)
199 istringstream ((sLine.substr(10,4))) >> numModel;
201 if ((numModel > 0) && ( (sLine.substr(0,6)).compare(
"MODEL ") == 0))
203 istringstream ((sLine.substr(10,4))) >> model;
205 if (model > 1)
break;
209 if ((sLine.substr(0,6)).compare(
"SEQRES") == 0)
215 if (verbose > 1) cout << sLine << endl;
220 if ((numModel > 0) && ( (sLine.substr(0,6)).compare(
"ENDMDL") == 0))
223 else if ((sLine.substr(0,6)).compare(
"TER ") == 0)
228 if (ter > terMax)
break;
241 if (moleculeOld == NULL)
244 moleculeOld =
new Molecule(nameMol,nbMolecule);
245 moleculeOld->
SetFirst(residueFirst);
247 moleculeFirst = moleculeOld;
251 moleculeNext =
new Molecule(nameMol,nbMolecule);
252 moleculeOld->
SetNext(moleculeNext);
253 moleculeNext ->
SetFirst(residueFirst);
255 moleculeOld = moleculeNext;
260 moleculeOld->
fCenterX = (int)((minX + maxX) /2.);
261 moleculeOld->
fCenterY = (int)((minY + maxY) /2.);
262 moleculeOld->
fCenterZ = (int)((minZ + maxZ) /2.);
271 minGlobZ=-2000000000;
272 minGlobX=-2000000000;
273 minGlobY=-2000000000;
309 else if ((sLine.substr(0,6)).compare(
"ATOM ") == 0)
314 istringstream ((sLine.substr(6,5))) >> serial;
318 atomName=sLine.substr(12,4);
319 if (atomName.substr(0,1).compare(
" ") == 0 )
320 element=sLine.substr(13,1);
322 element=sLine.substr(12,1);
330 else if (element==
"C")
334 else if (element==
"N")
338 else if (element==
"O")
342 else if (element==
"P")
346 else if (element==
"S")
353 G4cout <<
"Element not recognized : " << element <<
G4endl;
356 cout <<
"Element not recognized : " << element << endl;
357 cout <<
"Stop now" << endl;
366 resName=sLine.substr(17,3);
368 istringstream ((sLine.substr(22,4))) >> resSeq;
370 stringstream ((sLine.substr(30,8))) >> x;
371 stringstream ((sLine.substr(38,8))) >> y;
372 stringstream ((sLine.substr(46,8))) >>
z;
376 if (minGlobZ < z) minGlobZ=
z;
377 if (maxGlobZ > z) maxGlobZ=
z;
378 if (minGlobX < x) minGlobX=x;
379 if (maxGlobX > x) maxGlobX=x;
380 if (minGlobY < y) minGlobY=y;
381 if (maxGlobY > y) maxGlobY=y;
382 if (minX > x) minX=x;
383 if (maxX < x) maxX=x;
384 if (minY > y) minY=y;
385 if (maxY < y) maxY=y;
386 if (minZ > z) minZ=
z;
387 if (maxZ < z) maxZ=
z;
390 if (AtomicOld == NULL)
392 AtomicOld =
new Atom(serial,
406 AtomicNext =
new Atom(serial,
416 AtomicOld->
SetNext(AtomicNext);
417 AtomicOld = AtomicNext;
423 if (residueOld == NULL)
428 if (verbose>2) cout <<
"residueOld == NULL"<<endl;
431 residueOld =
new Residue(resName,resSeq);
434 residueFirst = residueOld;
440 if (lastResSeq==resSeq)
450 residueNext =
new Residue(resName,resSeq);
452 residueOld->
SetNext(residueNext);
456 residueOld = residueNext;
467 return moleculeFirst;
497 while (moleculeListTemp)
499 residueListTemp = moleculeListTemp->
GetFirst();
505 int correctNumerotationNumber=0;
506 if (k==2 && residueListTemp->
fResSeq > 1)
508 correctNumerotationNumber=residueListTemp->
fResSeq;
511 while (residueListTemp)
513 AtomTemp=residueListTemp->
GetFirst();
517 if (correctNumerotationNumber!=0)
520 correctNumerotationNumber+1;
524 double baryX=0.,baryY=0.,baryZ=0.;
525 double baryBaseX=0.,baryBaseY=0.,baryBaseZ=0.;
526 double barySugX=0.,barySugY=0.,barySugZ=0.;
527 double baryPhosX=0.,baryPhosY=0.,baryPhosZ=0.;
528 unsigned short int nbAtomInBase=0;
530 for (
int i=0 ; i < residueListTemp->
fNbAtom ; i++)
537 if (residueListTemp->
fResSeq == 1)
541 baryPhosX+=AtomTemp->
fX;
542 baryPhosY+=AtomTemp->
fY;
543 baryPhosZ+=AtomTemp->
fZ;
547 barySugX+=AtomTemp->
fX;
548 barySugY+=AtomTemp->
fY;
549 barySugZ+=AtomTemp->
fZ;
556 baryBaseX+=AtomTemp->
fX;
557 baryBaseY+=AtomTemp->
fY;
558 baryBaseZ+=AtomTemp->
fZ;
566 baryPhosX+=AtomTemp->
fX;
567 baryPhosY+=AtomTemp->
fY;
568 baryPhosZ+=AtomTemp->
fZ;
572 barySugX+=AtomTemp->
fX;
573 barySugY+=AtomTemp->
fY;
574 barySugZ+=AtomTemp->
fZ;
581 baryBaseX+=AtomTemp->
fX;
582 baryBaseY+=AtomTemp->
fY;
583 baryBaseZ+=AtomTemp->
fZ;
590 baryX = baryX / (double)residueListTemp->
fNbAtom;
591 baryY = baryY / (
double)residueListTemp->
fNbAtom;
592 baryZ = baryZ / (double)residueListTemp->
fNbAtom;
594 if (residueListTemp->
fResSeq != 1)
596 baryPhosX = baryPhosX / 4.;
597 baryPhosY = baryPhosY / 4.;
598 baryPhosZ = baryPhosZ / 4.;
600 barySugX = barySugX / 7.;
601 barySugY = barySugY / 7.;
602 barySugZ = barySugZ / 7.;
603 baryBaseX = baryBaseX / (double)nbAtomInBase;
604 baryBaseY = baryBaseY / (double)nbAtomInBase;
605 baryBaseZ = baryBaseZ / (double)nbAtomInBase;
608 if (BarycenterOld == NULL)
610 BarycenterOld =
new Barycenter(j+j_old,baryX,baryY,baryZ,
611 baryBaseX,baryBaseY,baryBaseZ,
612 barySugX,barySugY,barySugZ,
613 baryPhosX,baryPhosY,baryPhosZ);
614 BarycenterFirst = BarycenterOld;
618 BarycenterNext =
new Barycenter(j+j_old,baryX,baryY,baryZ,
619 baryBaseX,baryBaseY,baryBaseZ,
620 barySugX,barySugY,barySugZ,
621 baryPhosX,baryPhosY,baryPhosZ);
622 BarycenterOld -> SetNext(BarycenterNext);
623 BarycenterOld = BarycenterNext;
629 AtomTemp=residueListTemp->
GetFirst();
632 for (
int ii=0 ; ii < residueListTemp->
fNbAtom ; ii++)
638 if (dT3Dp>max) max=dT3Dp;
643 residueListTemp=residueListTemp->
GetNext();
651 moleculeListTemp=moleculeListTemp->
GetNext();
654 if(BarycenterNext!=NULL)
656 BarycenterNext -> SetNext(NULL);
659 return BarycenterFirst;
670 double &dX,
double &dY,
double &dZ,
671 double &tX,
double &tY,
double &tZ)
673 double minminX,minminY,minminZ;
674 double maxmaxX,maxmaxY,maxmaxZ;
693 while (moleculeListTemp)
695 if (minminX > moleculeListTemp->
fMaxGlobX)
699 if (minminY > moleculeListTemp->
fMaxGlobY)
703 if (minminZ > moleculeListTemp->
fMaxGlobZ)
707 if (maxmaxX < moleculeListTemp->fMinGlobX)
711 if (maxmaxY < moleculeListTemp->fMinGlobY)
715 if (maxmaxZ < moleculeListTemp->fMinGlobZ)
720 moleculeListTemp=moleculeListTemp->
GetNext();
723 dX=(maxmaxX-minminX)/2.+1.8;
724 dY=(maxmaxY-minminY)/2.+1.8;
725 dZ=(maxmaxZ-minminZ)/2.+1.8;
727 tX=minminX+(maxmaxX-minminX)/2.;
728 tY=minminY+(maxmaxY-minminY)/2.;
729 tZ=minminZ+(maxmaxZ-minminZ)/2.;
746 while (moleculeListTemp)
748 residueListTemp = moleculeListTemp->
GetFirst();
753 while (residueListTemp)
756 residueListTemp=residueListTemp->
GetNext();
760 moleculeListTemp=moleculeListTemp->
GetNext();
777 double x,
double y,
double z,
778 int &numStrand,
int &numNucleotid,
int &codeResidue)
780 unsigned short int matchFound=0;
782 Molecule *mLTsavedPointer = moleculeListTemp;
785 short int strandNum=0;
788 unsigned short int BSP=2;
800 moleculeListTemp = mLTsavedPointer;
801 BarycenterList = BLsavedPointer;
804 while (moleculeListTemp)
807 residueListTemp = moleculeListTemp->
GetFirst();
812 int j_save=2000000000;
817 while (residueListTemp)
821 if (j - j_save > 2 )
break;
826 if (distEdepDNA < BarycenterList->GetRadius())
831 AtomTemp=residueListTemp->
GetFirst();
832 for (
int iii=0 ; iii < residueListTemp->
fNbAtom ; iii++)
839 if ((distEdepAtom < AtomTemp->GetVanDerWaalsRadius())
840 && (smallestDist > distEdepAtom))
850 residueNum = residueListTemp->
fResSeq;
853 baseName = (residueListTemp->
fResName)[2];
854 if (residueListTemp->
fResSeq == 1)
856 if (iii == 0) BSP = 0;
857 else if (iii < 8) BSP = 1;
862 if (iii < 4) BSP = 0;
863 else if (iii < 11) BSP = 1;
867 smallestDist=distEdepAtom;
870 int j_max_value=2000000000;
874 if (j_save == j_max_value) j_save = j;
880 BarycenterList=BarycenterList->
GetNext();
881 residueListTemp=residueListTemp->
GetNext();
883 moleculeListTemp=moleculeListTemp->
GetNext();
886 numStrand = strandNum;
887 numNucleotid = residueNum;
898 return std::sqrt ( (xA-xB)*(xA-xB) + (yA-yB)*(yA-yB) + (zA-zB)*(zA-zB) );
int fCenterZ
"Z center" of this Molecule (for rotation...)
void SetRadius(double)
Set the distance between the farther atom and nucleotide barycenter.
double fCenterY
"Y coordinate" of this nucelotide Barycenter
double fCenterX
"X coordinate" of this nucelotide Barycenter
void SetNext(Molecule *)
Set the next Molecule.
int fNbAtom
Number of atoms into a residue (usage before vector)
Barycenter * ComputeNucleotideBarycenters(Molecule *moleculeListTemp)
Compute nucleotide barycenter from memory.
Residue * GetFirst()
Get the first Residue.
Residue * GetNext()
Get the next residue.
double fZ
Z orthogonal coordinates in Angstroms.
void SetFirst(Residue *)
Set the first Residue.
double GetX()
Return the X position for the Atom.
void SetNext(Atom *)
Set the next atom.
int fCenterX
"X center" of this Molecule (for rotation...)
double DistanceTwo3Dpoints(double xA, double xB, double yA, double yB, double zA, double zB)
return distance between two 3D points
void SetDistance(int i, double)
Set the distance between atom i and nucleotide barycenter.
int fNumInRes
its number in residue sequence
G4GLOB_DLL std::ostream G4cout
double GetZ()
Return the Z position for the Atom.
int fCenterY
"Y center" of this Molecule (for rotation...)
string fElement
Element symbol extracted from 'atom name'.
void ComputeNbNucleotidsPerStrand(Molecule *moleculeListTemp)
Compute number of nucleotide per strand.
unsigned short int ComputeMatchEdepDNA(Barycenter *, Molecule *, double x, double y, double z, int &numStrand, int &numNucleotid, int &codeResidue)
Compute if energy is deposited in per atom.
Molecule * GetNext()
information about molecule (not implemented)
Barycenter * GetNext()
Get the next Barycenter.
Molecule * Load(const string &filename, unsigned short int &isDNA, unsigned short int verbose)
Load PDB file into memory.
int fNbResidue
Number of residue inside the molecule.
T max(const T t1, const T t2)
brief Return the largest of the two arguments
string fResName
Residue name.
Atom * GetFirst()
Get the first atom.
void SetNext(Residue *)
Set the next residue.
int fNbNucleotidsPerStrand
Number of nucleotid per strand.
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void ComputeBoundingVolumeParams(Molecule *moleculeListTemp, double &dX, double &dY, double &dZ, double &tX, double &tY, double &tZ)
Compute the corresponding bounding volume parameters.
double fX
X orthogonal coordinates in Angstroms.
Atom * GetNext()
Returns the next Atom.
double fY
Y orthogonal coordinates in Angstroms.
int fResSeq
Residue sequence number.
double fCenterZ
"Z coordinate" of this nucelotide Barycenter
PDBlib()
First constructor.
double GetY()
Return the Y position for the Atom.
Definition of the PDBlib class.
void SetFirst(Atom *)
Set the first Atom of the residue.