//using dist for no image // and kernel for when we use solute molecule center void Action_Closest::Action_NoImage_Center(Frame&, double maxD) { double Dist; int solventMol; AtomMask::const_iterator solute_atom; Iarray::const_iterator solvent_atom; Vec3 maskCenter = frmIn.VGeometricCenter( distanceMask_ ); for (solventMol=0; solventMol < NsolventMolecules_; solventMol++) { //standard loop SolventMols_[solventMol].D = maxD; for (solvent_atom = SolventMols_[solventMol].solventAtoms.begin(); solvent_atom != SolventMols_[solventMol].solventAtoms.end(); ++solvent_atom) { //main dist2_noImage code double *a1 = maskCenter.Dptr(); //center of solute molecule double *a2 = frmIn.XYZ(*solvent_atom); double x = a1[0] - a2[0]; double y = a1[1] - a2[1]; double z = a1[2] - a2[2]; Dist = (x*x + y*y + z*z); if (Dist < SolventMols_[solventMol].D) SolventMols_[solventMol].D = Dist; } } }
//pulling out the dist control statement void Action_Closest::Action_NoImage(Frame& frmIn,double maxD) { double Dist; int solventMol; AtomMask::const_iterator solute_atom; Iarray::const_iterator solvent_atom; // Loop over all solvent molecules in original frame if (useMaskCenter_) { Vec3 maskCenter = frmIn.VGeometricCenter( distanceMask_ ); for (solventMol=0; solventMol < NsolventMolecules_; solventMol++) { SolventMols_[solventMol].D = maxD; for (solvent_atom = SolventMols_[solventMol].solventAtoms.begin(); solvent_atom != SolventMols_[solventMol].solventAtoms.end(); ++solvent_atom) { Dist = DIST2_NoImage( maskCenter.Dptr(), frmIn.XYZ(*solvent_atom)); //printf("DIST = %f\n", Dist); if (Dist < SolventMols_[solventMol].D) SolventMols_[solventMol].D = Dist; } } } else { for (solventMol=0; solventMol < NsolventMolecules_; solventMol++) { if (debug_ > 1) mprintf("DEBUG: Calculating distance for molecule %i\n", solventMol); // Set the initial minimum distance for this solvent mol to be the // max possible distance. SolventMols_[solventMol].D = maxD; // Calculate distance between each atom in distanceMask and atoms in solvent Mask for (solvent_atom = SolventMols_[solventMol].solventAtoms.begin(); solvent_atom != SolventMols_[solventMol].solventAtoms.end(); ++solvent_atom) { for (solute_atom = distanceMask_.begin(); solute_atom != distanceMask_.end(); ++solute_atom) { Dist = DIST2_NoImage(frmIn.XYZ(*solute_atom), frmIn.XYZ(*solvent_atom)); //printf("no center DIST = %f\n", Dist); if (Dist < SolventMols_[solventMol].D) SolventMols_[solventMol].D = Dist; if (debug_ > 2) mprintf("DEBUG: SolvMol %i, soluteAtom %i, solventAtom %i, D= %f, minD= %f\n", solventMol, *solute_atom, *solvent_atom, Dist, sqrt(SolventMols_[solventMol].D)); } } if (debug_ > 1) mprintf("DEBUG:\tMol %8i minD= %lf\n",solventMol, SolventMols_[solventMol].D); } // END for loop over solventMol } }
/** Find the minimum distance between atoms in distanceMask and each * solvent Mask. */ Action_Closest::RetType Action_Closest::DoAction(int frameNum, Frame& frmIn) { int solventMol; double Dist, maxD; Matrix_3x3 ucell, recip; AtomMask::const_iterator solute_atom; Iarray::const_iterator solvent_atom; if (image_.ImagingEnabled()) { frmIn.BoxCrd().ToRecip(ucell, recip); // Calculate max possible imaged distance maxD = frmIn.BoxCrd().BoxX() + frmIn.BoxCrd().BoxY() + frmIn.BoxCrd().BoxZ(); maxD *= maxD; } else { // If not imaging, set max distance to an arbitrarily large number maxD = DBL_MAX; } // Loop over all solvent molecules in original frame if (useMaskCenter_) { Vec3 maskCenter = frmIn.VGeometricCenter( distanceMask_ ); for (solventMol=0; solventMol < NsolventMolecules_; solventMol++) { SolventMols_[solventMol].D = maxD; for (solvent_atom = SolventMols_[solventMol].solventAtoms.begin(); solvent_atom != SolventMols_[solventMol].solventAtoms.end(); ++solvent_atom) { Dist = DIST2( maskCenter.Dptr(), frmIn.XYZ(*solvent_atom), image_.ImageType(), frmIn.BoxCrd(), ucell, recip); if (Dist < SolventMols_[solventMol].D) SolventMols_[solventMol].D = Dist; } } } else { for (solventMol=0; solventMol < NsolventMolecules_; solventMol++) { if (debug_ > 1) mprintf("DEBUG: Calculating distance for molecule %i\n", solventMol); // Set the initial minimum distance for this solvent mol to be the // max possible distance. SolventMols_[solventMol].D = maxD; // Calculate distance between each atom in distanceMask and atoms in solvent Mask for (solvent_atom = SolventMols_[solventMol].solventAtoms.begin(); solvent_atom != SolventMols_[solventMol].solventAtoms.end(); ++solvent_atom) { for (solute_atom = distanceMask_.begin(); solute_atom != distanceMask_.end(); ++solute_atom) { Dist = DIST2(frmIn.XYZ(*solute_atom), frmIn.XYZ(*solvent_atom), image_.ImageType(), frmIn.BoxCrd(), ucell, recip); if (Dist < SolventMols_[solventMol].D) SolventMols_[solventMol].D = Dist; if (debug_ > 2) mprintf("DEBUG: SolvMol %i, soluteAtom %i, solventAtom %i, D= %f, minD= %f\n", solventMol, *solute_atom, *solvent_atom, Dist, sqrt(SolventMols_[solventMol].D)); } } if (debug_ > 1) mprintf("DEBUG:\tMol %8i minD= %lf\n",solventMol, SolventMols_[solventMol].D); } // END for loop over solventMol } // Sort distances std::sort( SolventMols_.begin(), SolventMols_.end(), moldist_cmp() ); // Add first closestWaters solvent atoms to stripMask std::vector<MolDist>::iterator solventend = SolventMols_.begin() + closestWaters_; for ( std::vector<MolDist>::const_iterator solvent = SolventMols_.begin(); solvent != solventend; ++solvent ) { solvent_atom = solvent->mask.begin(); mprintf("\tMol= %8i Atom= %8i Dist= %10.4f\n", solvent->mol, *solvent_atom + 1, sqrt( solvent->D )); } return Action_Closest::OK; }