int Parm_PDB::ReadParm(std::string const& fname, Topology &TopIn) { PDBfile infile; double XYZ[3]; int current_res = 0; int last_res = -1; if (infile.OpenRead(fname)) return 1; // Loop over PDB records while ( infile.NextLine() != 0 ) { if (infile.IsPDBatomKeyword()) { // If this is an ATOM / HETATM keyword, add to topology infile.pdb_XYZ(XYZ); NameType pdbresname = infile.pdb_Residue( current_res ); TopIn.AddTopAtom(infile.pdb_Atom(), pdbresname, current_res, last_res, XYZ); } else if (infile.IsPDB_TER() || infile.IsPDB_END()) { // Indicate end of molecule for TER/END. Finish if END. TopIn.StartNewMol(); if (infile.IsPDB_END()) break; } } // If Topology name not set with TITLE etc, use base filename. // TODO: Read in title. std::string pdbtitle; TopIn.SetParmName( pdbtitle, infile.Filename().Base() ); infile.CloseFile(); return 0; }
/** Initialize and set up pairlist. */ int Ewald::Setup_Pairlist(Box const& boxIn, Vec3 const& recipLengths, double skinnbIn) { if (pairList_.InitPairList(cutoff_, skinnbIn, debug_)) return 1; if (pairList_.SetupPairList( boxIn.Type(), recipLengths )) return 1; # ifdef DEBUG_PAIRLIST // Write grid PDB PDBfile gridpdb; Matrix_3x3 ucell, recip; boxIn.ToRecip(ucell, recip); gridpdb.OpenWrite("gridpoints.pdb"); for (int iz = 0; iz != pairList_.NZ(); iz++) for (int iy = 0; iy != pairList_.NY(); iy++) for (int ix = 0; ix != pairList_.NX(); ix++) { double fx = (double)ix / (double)pairList_.NX(); double fy = (double)iy / (double)pairList_.NY(); double fz = (double)iz / (double)pairList_.NZ(); Vec3 cart = ucell.TransposeMult( Vec3(fx,fy,fz) ); gridpdb.WriteHET(1, cart[0], cart[1], cart[2]); } gridpdb.CloseFile(); # endif return 0; }