/// https://www.charmmtutorial.org/index.php/Full_example public static SPsfCrd Solvate (IEnumerable <string> toplines , IEnumerable <string> parlines , IEnumerable <string> psflines_prot , IEnumerable <string> crdlines_prot , IEnumerable <string> crdlines_water ) { string tempbase = @"C:\temp\"; SPsfCrd psfcrd; using (var temp = new HTempDirectory(tempbase, null)) { temp.EnterTemp(); string topname = "top.rtf"; HFile.WriteAllLines(topname, toplines); string parname = "par.prm"; HFile.WriteAllLines(parname, parlines); string psfname_prot = "prot.psf"; HFile.WriteAllLines(psfname_prot, psflines_prot); string crdname_prot = "prot.crd"; HFile.WriteAllLines(crdname_prot, crdlines_prot); string crdname_water = "water.crd"; HFile.WriteAllLines(crdname_water, crdlines_water); string psfname_protwater = "protwater.psf"; string crdname_protwater = "protwater.crd"; string conf_inp = @"* Run Segment Through CHARMM * ! read topology and parameter files read rtf card name $$topname$$ read para card name $$parname$$ ! read the psf and coordinate file read psf card name $$psfname_prot$$ read coor card name $$crdname_prot$$ ! Read in water sequence read sequence tip3 46656 ! Generate new segment for the water generate bwat noangle nodihedral ! Read the water PDB coordinates and append them to the protein read coor card append name $$crdname_water$$ ! Delete waters which overlap with protein delete atom sort - select .byres. (segid bwat .AND. type oh2 .and. - ((.not. (segid bwat .OR. hydrogen)) .around. 2.5)) end ! set headstr = rhdo with a crystal dimension of @greatervalue set headstr = test xxx ! we want to do a quick-and-dirty minimization to remove bad contacts. Therefore, we should ! set up shake and the non-bond parameters again. shake bonh param sele all end nbond inbfrq -1 elec fswitch vdw vswitch cutnb 16. ctofnb 12. ctonnb 10. mini sd nstep 100 nprint 1 tolgrd 100.0 ! use Expanded I/O format ioform extended ! since we've changed the structure by adding waters, we need to write out a new PSF write psf card name $$psfname_protwater$$ * new_1cbn-18126-1-solv.psf * solvation: @headstr * write coor card name $$crdname_protwater$$ * new_1cbn-18126-1-solv.crd * solvation: @headstr * stop ".Replace("$$topname$$", topname) .Replace("$$parname$$", parname) .Replace("$$psfname_prot$$", psfname_prot) .Replace("$$crdname_prot$$", crdname_prot) .Replace("$$crdname_water$$", crdname_water) .Replace("$$psfname_protwater$$", psfname_protwater) .Replace("$$crdname_protwater$$", crdname_protwater) ; HFile.WriteAllText("conf.inp", conf_inp); System.Console.WriteLine("Run the following command at " + temp + " :"); System.Console.WriteLine(" $ charmm < conf.inp"); System.Console.WriteLine(" or $ mpd&"); System.Console.WriteLine(" $ mpirun -n 38 charmm_M < conf.inp"); System.Console.WriteLine("Then, copy " + psfname_protwater + " and " + crdname_protwater + " to " + temp); while (true) { bool next = HConsole.ReadValue <bool>("Ready for next? ", false, null, false, true); if (next) { if (HFile.ExistsAll(psfname_protwater, crdname_protwater)) { string[] psflines_protwater = HFile.ReadAllLines(psfname_protwater); string[] crdlines_protwater = HFile.ReadAllLines(crdname_protwater); psfcrd = new SPsfCrd { psflines = psflines_protwater, crdlines = crdlines_protwater, }; break; } System.Console.WriteLine("DO, copy " + psfname_protwater + " and " + crdname_protwater + " to " + temp); } } temp.QuitTemp(); } return(psfcrd); }
public static Vector[] GetRotate(Vector[] coords, Vector cent, int[] block) { throw new Exception("this implementation is wrong. Use the following algorithm to get rotation modes for RTB."); double[] io_mass = null; if (HDebug.IsDebuggerAttached) { using (var temp = new HTempDirectory(@"K:\temp\", null)) { temp.EnterTemp(); HFile.WriteAllText("rtbProjection.m", @" function [P, xyz] = rtbProjection(xyz, mass) % the approach is to find the inertia. compute the principal axes. and then use them to determine directly translation or rotation. n = size(xyz, 1); % n: the number of atoms if nargin == 1 mass = ones(n,1); end M = sum(mass); % find the mass center. m3 = repmat(mass, 1, 3); center = sum (xyz.*m3)/M; xyz = xyz - center(ones(n, 1), :); mwX = sqrt (m3).*xyz; inertia = sum(sum(mwX.^2))*eye(3) - mwX'*mwX; [V,D] = eig(inertia); tV = V'; % tV: transpose of V. Columns of V are principal axes. for i=1:3 trans{i} = tV(ones(n,1)*i, :); % the 3 translations are along principal axes end P = zeros(n*3, 6); for i=1:3 rotate{i} = cross(trans{i}, xyz); temp = mat2vec(trans{i}); P(:,i) = temp/norm(temp); temp = mat2vec(rotate{i}); P(:,i+3) = temp/norm(temp); end m3 = mat2vec(sqrt(m3)); P = repmat (m3(:),1,size(P,2)).*P; % now normalize columns of P P = P*diag(1./normMat(P,1)); function vec = mat2vec(mat) % convert a matrix to a vector, extracting data *row-wise*. vec = reshape(mat',1,prod(size(mat))); "); Matlab.Execute("cd \'" + temp.dirinfo.FullName + "\'"); Matlab.PutMatrix("xyz", coords.ToMatrix(false)); Matlab.PutVector("mass", io_mass); temp.QuitTemp(); } } HDebug.Assert(coords.Length == io_mass.Length); Vector mwcenter = new double[3]; for (int i = 0; i < coords.Length; i++) { mwcenter += (coords[i] * io_mass[i]); } mwcenter /= io_mass.Sum(); Vector[] mwcoords = new Vector[coords.Length]; for (int i = 0; i < coords.Length; i++) { mwcoords[i] = (coords[i] - mwcenter) * io_mass[i]; } Matrix mwPCA = new double[3, 3]; for (int i = 0; i < coords.Length; i++) { mwPCA += LinAlg.VVt(mwcoords[i], mwcoords[i]); } var V_D = LinAlg.Eig(mwPCA.ToArray()); var V = V_D.Item1; Vector[] rotvecs = new Vector[3]; for (int i = 0; i < 3; i++) { Vector rotaxis = new double[] { V[0, i], V[1, i], V[2, i] }; Vector[] rotveci = new Vector[coords.Length]; for (int j = 0; j < coords.Length; j++) { rotveci[j] = LinAlg.CrossProd(rotaxis, mwcoords[i]); } rotvecs[i] = rotveci.ToVector().UnitVector(); } if (HDebug.IsDebuggerAttached) { double dot01 = LinAlg.VtV(rotvecs[0], rotvecs[1]); double dot02 = LinAlg.VtV(rotvecs[0], rotvecs[2]); double dot12 = LinAlg.VtV(rotvecs[1], rotvecs[2]); HDebug.Assert(Math.Abs(dot01) < 0.0000001); HDebug.Assert(Math.Abs(dot02) < 0.0000001); HDebug.Assert(Math.Abs(dot12) < 0.0000001); } return(rotvecs); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// from song: rtbProjection.m //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// function [P, xyz] = rtbProjection(xyz, mass) /// % the approach is to find the inertia. compute the principal axes. and then use them to determine directly translation or rotation. /// /// n = size(xyz, 1); % n: the number of atoms /// if nargin == 1 /// mass = ones(n,1); /// end /// /// M = sum(mass); /// % find the mass center. /// m3 = repmat(mass, 1, 3); /// center = sum (xyz.*m3)/M; /// xyz = xyz - center(ones(n, 1), :); /// /// mwX = sqrt (m3).*xyz; /// inertia = sum(sum(mwX.^2))*eye(3) - mwX'*mwX; /// [V,D] = eig(inertia); /// tV = V'; % tV: transpose of V. Columns of V are principal axes. /// for i=1:3 /// trans{i} = tV(ones(n,1)*i, :); % the 3 translations are along principal axes /// end /// P = zeros(n*3, 6); /// for i=1:3 /// rotate{i} = cross(trans{i}, xyz); /// temp = mat2vec(trans{i}); /// P(:,i) = temp/norm(temp); /// temp = mat2vec(rotate{i}); /// P(:,i+3) = temp/norm(temp); /// end /// m3 = mat2vec(sqrt(m3)); /// P = repmat (m3(:),1,size(P,2)).*P; /// % now normalize columns of P /// P = P*diag(1./normMat(P,1)); /// /// function vec = mat2vec(mat) /// % convert a matrix to a vector, extracting data *row-wise*. /// vec = reshape(mat',1,prod(size(mat))); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// rotx[t_ ] := { { 1,0,0,0},{ 0,Cos[t],-Sin[t],0},{ 0,Sin[t],Cos[t],0},{ 0,0,0,1} }; /// roty[t_ ] := { { Cos[t],0,Sin[t],0},{ 0,1,0,0},{ -Sin[t],0,Cos[t],0},{ 0,0,0,1} }; /// rotz[t_ ] := { { Cos[t],-Sin[t],0,0},{ Sin[t],Cos[t],0,0},{ 0,0,1,0},{ 0,0,0,1} }; /// tran[tx_, ty_, tz_] := { { 1,0,0,tx},{ 0,1,0,ty},{ 0,0,1,tz},{ 0,0,0,1} }; /// pt = Transpose[{{px,py,pz,1}}]; /// /// point : (px,py,pz) /// center : (cx,cy,cz) /// angle : t /// /// tran[cx, cy, cz].rotx[t].tran[-cx, -cy, -cz].pt = {{px}, {cy - cy Cos[t] + py Cos[t] + cz Sin[t] - pz Sin[t]}, {cz - cz Cos[t] + pz Cos[t] - cy Sin[t] + py Sin[t]}, {1}} /// tran[cx, cy, cz].roty[t].tran[-cx, -cy, -cz].pt = {{cx - cx Cos[t] + px Cos[t] - cz Sin[t] + pz Sin[t]}, {py}, {cz - cz Cos[t] + pz Cos[t] + cx Sin[t] - px Sin[t]}, {1}} /// tran[cx, cy, cz].rotz[t].tran[-cx, -cy, -cz].pt = {{cx - cx Cos[t] + px Cos[t] + cy Sin[t] - py Sin[t]}, {cy - cy Cos[t] + py Cos[t] - cx Sin[t] + px Sin[t]}, {pz}, {1}} /// /// D[tran[cx, cy, cz].rotx[t].tran[-cx, -cy, -cz].pt, t] = {{0}, {cz Cos[t] - pz Cos[t] + cy Sin[t] - py Sin[t]}, {-cy Cos[t] + py Cos[t] + cz Sin[t] - pz Sin[t]}, {0}} /// D[tran[cx, cy, cz].roty[t].tran[-cx, -cy, -cz].pt, t] = {{-cz Cos[t] + pz Cos[t] + cx Sin[t] - px Sin[t]}, {0}, {cx Cos[t] - px Cos[t] + cz Sin[t] - pz Sin[t]}, {0}} /// D[tran[cx, cy, cz].rotz[t].tran[-cx, -cy, -cz].pt, t] = {{cy Cos[t] - py Cos[t] + cx Sin[t] - px Sin[t]}, {-cx Cos[t] + px Cos[t] + cy Sin[t] - py Sin[t]}, {0}, {0}} /// /// D[tran[cx,cy,cz].rotx[a].tran[-cx,-cy,-cz].pt,a]/.a->0 = {{0}, {cz - pz}, {-cy + py}, {0}} /// D[tran[cx,cy,cz].roty[a].tran[-cx,-cy,-cz].pt,a]/.a->0 = {{-cz + pz}, {0}, {cx - px}, {0}} /// D[tran[cx,cy,cz].rotz[a].tran[-cx,-cy,-cz].pt,a]/.a->0 = {{cy - py}, {-cx + px}, {0}, {0}} /// rotx of atom (px,py,pz) with center (cx,cy,cz): {{0}, {cz - pz}, {-cy + py}, {0}} = { 0, cz - pz, -cy + py, 0 } => { 0, cz - pz, -cy + py } /// rotx of atom (px,py,pz) with center (cx,cy,cz): {{-cz + pz}, {0}, {cx - px}, {0}} = { -cz + pz, 0, cx - px, 0 } => { -cz + pz, 0, cx - px } /// rotx of atom (px,py,pz) with center (cx,cy,cz): {{cy - py}, {-cx + px}, {0}, {0}} = { cy - py, -cx + px, 0, 0 } => { cy - py, -cx + px, 0 } /// int leng = coords.Length; Vector[] rots; { Vector[] rotbyx = new Vector[leng]; Vector[] rotbyy = new Vector[leng]; Vector[] rotbyz = new Vector[leng]; double cx = cent[0]; double cy = cent[1]; double cz = cent[2]; for (int i = 0; i < leng; i++) { double px = coords[i][0]; double py = coords[i][1]; double pz = coords[i][2]; rotbyx[i] = new double[] { 0, cz - pz, -cy + py }; rotbyy[i] = new double[] { -cz + pz, 0, cx - px }; rotbyz[i] = new double[] { cy - py, -cx + px, 0 }; } rots = new Vector[] { rotbyx.ToVector().UnitVector(), rotbyy.ToVector().UnitVector(), rotbyz.ToVector().UnitVector(), }; } if (HDebug.IsDebuggerAttached) { Vector[] rotbyx = new Vector[leng]; Vector[] rotbyy = new Vector[leng]; Vector[] rotbyz = new Vector[leng]; Vector zeros = new double[3]; for (int i = 0; i < leng; i++) { rotbyx[i] = rotbyy[i] = rotbyz[i] = zeros; } Vector rx = new double[3] { 1, 0, 0 }; Vector ry = new double[3] { 0, 1, 0 }; Vector rz = new double[3] { 0, 0, 1 }; Func <Vector, Vector, Vector> GetTangent = delegate(Vector pt, Vector axisdirect) { /// Magnitude of rotation tangent is proportional to the distance from the point to the axis. /// Ex) when a point is in x-axis (r,0), rotating along z-axis by θ is: (r*sin(θ), 0) /// /// | /// | ^ sin(θ) /// | | /// -+-----------------r---------- /// Vector rot1 = cent; Vector rot2 = cent + axisdirect; double dist = Geometry.DistancePointLine(pt, rot1, rot2); Vector tan = Geometry.RotateTangentUnit(pt, rot1, rot2) * dist; return(tan); }; IEnumerable <int> enumblock = block; if (block != null) { enumblock = block; } else { enumblock = HEnum.HEnumCount(leng); } foreach (int i in enumblock) { Vector pt = coords[i]; rotbyx[i] = GetTangent(pt, rx); rotbyy[i] = GetTangent(pt, ry); rotbyz[i] = GetTangent(pt, rz); } Vector[] trots = new Vector[3] { rotbyx.ToVector().UnitVector(), rotbyy.ToVector().UnitVector(), rotbyz.ToVector().UnitVector(), }; double test0 = LinAlg.VtV(rots[0], trots[0]); double test1 = LinAlg.VtV(rots[1], trots[1]); double test2 = LinAlg.VtV(rots[2], trots[2]); HDebug.Assert(Math.Abs(test0 - 1) < 0.00000001); HDebug.Assert(Math.Abs(test1 - 1) < 0.00000001); HDebug.Assert(Math.Abs(test2 - 1) < 0.00000001); } return(rots); }
/// https://www.charmmtutorial.org/index.php/Full_example public static string[] MinimizeCrd (IEnumerable <string> toplines , IEnumerable <string> parlines , IEnumerable <string> psflines , IEnumerable <string> crdlines , string conf_inp_mini ) { string tempbase = @"C:\temp\"; if (conf_inp_mini == null) { conf_inp_mini = @" mini sd nstep 100 mini abnr nstep 1000 nprint 10000 tolg 0.0001 ! mini abnr nstep 1000 nprint 100 tolg 0.01 ! mini abnr nstep 10000000 nprint 100 tolg 0.00 ! mini abnr nstep 1000000 nprint 100 tolg 10.00 ! target-min-step1-tolg-10_00.crd ! mini abnr nstep 1000000 nprint 100 tolg 1.00 ! target-min-step2-tolg-1_00.crd ! mini abnr nstep 1000000 nprint 100 tolg 0.10 ! mini sd nstep 10000 ! target-min-step3-sd10000.crd ! mini abnr nstep 1000000 nprint 100 tolg 0.01 ! target-min-step4-tolg-0_01.crd ! mini abnr nstep 10000 nprint 100 tolg 0.0001 ! target-min-step5-tolg-0_0001.crd ! mini abnr nstep 10000 nprint 100 tolg 0.000001 ! target-min-step6-tolg-0_000001.crd ! mini abnr nstep 10000 nprint 100 tolg 0.000000 ! target-min-step7-tolg-0_000000.crd "; } string[] mincrdlines; using (var temp = new HTempDirectory(tempbase, null)) { temp.EnterTemp(); string topname = "top.rtf"; HFile.WriteAllLines(topname, toplines); string parname = "par.prm"; HFile.WriteAllLines(parname, parlines); string psfname = "target.psf"; HFile.WriteAllLines(psfname, psflines); string crdname = "target.crd"; HFile.WriteAllLines(crdname, crdlines); string mincrdname = "target-minimized.crd"; string conf_inp = @"* Minimize PDB * ! read topology and parameter file read rtf card name $$topname$$ read param card name $$parname$$ ! read the psf and coordinate file read psf card name $$psfname$$ read coor card name $$crdname$$ ! set up shake shake bonh param sele all end ! set up electrostatics, since we're not using PME, set up switching ! electrostatics nbond inbfrq -1 elec fswitch vdw vswitch cutnb 16. ctofnb 12. ctonnb 10. energy coor copy comp " + conf_inp_mini + @" coor rms ioform extended write coor card name $$mincrdname$$ * Initial minimization, no PME. * stop "; conf_inp = conf_inp.Replace("$$topname$$", topname) .Replace("$$parname$$", parname) .Replace("$$psfname$$", psfname) .Replace("$$crdname$$", crdname) .Replace("$$mincrdname$$", mincrdname) ; HFile.WriteAllText("conf.inp", conf_inp); System.Console.WriteLine("Run the following command at " + temp + " :"); System.Console.WriteLine(" $ charmm < conf.inp"); System.Console.WriteLine(" or $ mpd&"); System.Console.WriteLine(" $ mpirun -n 38 charmm_M < conf.inp"); System.Console.WriteLine("Then, copy target-minimized.crd to " + temp); while (true) { bool next = HConsole.ReadValue <bool>("Ready for next? ", false, null, false, true); if (next) { if (HFile.ExistsAll(mincrdname)) { mincrdlines = HFile.ReadAllLines(mincrdname); break; } System.Console.WriteLine("DO, copy target.psf and target.crd to " + temp); } } temp.QuitTemp(); } return(mincrdlines); }
/// https://www.charmmtutorial.org/index.php/Full_example public static string[] Hessian (IEnumerable <string> toplines , IEnumerable <string> parlines , IEnumerable <string> psflines , IEnumerable <string> crdlines ) { string tempbase = @"C:\temp\"; string[] mincrdlines; using (var temp = new HTempDirectory(tempbase, null)) { temp.EnterTemp(); string topname = "top.rtf"; HFile.WriteAllLines(topname, toplines); string parname = "par.prm"; HFile.WriteAllLines(parname, parlines); string psfname = "target.psf"; HFile.WriteAllLines(psfname, psflines); string crdname = "target.crd"; HFile.WriteAllLines(crdname, crdlines); string mincrdname = "target-minimized.crd"; string conf_inp = @"* Minimize PDB * Minimize PDB * ! read topology and parameter file read rtf card name top.rtf read param card name par.prm ! read the psf and coordinate file read psf card name target.psf read coor card name target.crd ! set up shake shake bonh param sele all end ! set up electrostatics, since we're not using PME, set up switching ! electrostatics nbond inbfrq -1 elec fswitch vdw vswitch cutnb 16. ctofnb 12. ctonnb 10. energy coor copy comp ! mini sd nstep 100 ! mini abnr nstep 1000 nprint 10000 tolg 0.0000 ! ! mini abnr nstep 1000 nprint 100 tolg 0.01 ! ! mini abnr nstep 10000000 nprint 100 tolg 0.00 ! ! mini abnr nstep 1000000 nprint 100 tolg 10.00 ! target-min-step1-tolg-10_00.crd ! ! mini abnr nstep 1000000 nprint 100 tolg 1.00 ! target-min-step2-tolg-1_00.crd ! ! mini abnr nstep 1000000 nprint 100 tolg 0.10 ! ! mini sd nstep 10000 ! target-min-step3-sd10000.crd ! ! mini abnr nstep 1000000 nprint 100 tolg 0.01 ! target-min-step4-tolg-0_01.crd ! ! mini abnr nstep 10000 nprint 100 tolg 0.0001 ! target-min-step5-tolg-0_0001.crd ! ! mini abnr nstep 10000 nprint 100 tolg 0.000001 ! target-min-step6-tolg-0_000001.crd ! ! mini abnr nstep 10000 nprint 100 tolg 0.000000 ! target-min-step7-tolg-0_000000.crd ! ! ! coor rms ! ! ioform extended ! ! write coor card name target-minimized.crd ! * Initial minimization, no PME. ! * ! VIBRAN NMOD 20 ATOM FSWITCH rdie eps 4.0 VDW VSHIFT cutnb 13.0 ctofnb 12.0 CTONNB 8.0 ! ! DIMB ITERations 500 TOLErance 0.04 PARDim 200 IUNMode 21 DWIN ! ! WRITe SECOnd-derivatives card ! BOMLEV -2 ! VIBRAN ! DIAG ENTRopy ! VIBRan NMODes 500 ! DIAG ! print norm vector dipole !mini abnr nstep 100 nprint 100 tolg 0.000000 ! target-min-step7-tolg-0_000000.crd BOMLEV -2 open unit 1 write form name " + " \"second.dat\" " + @" REDUce CMPAct vibran !diag write second card unit 1 close unit 1 !calc natom3 ?NATOM *3 !vibran nmode @natom3 !diag !print norm !bomlev - 2 !VIBRan NMOD 300 !DIAGonalize !https://www.charmm.org/charmm/documentation/by-version/c42b1/params/doc/vibran/ stop "; conf_inp = conf_inp.Replace("$$topname$$", topname) .Replace("$$parname$$", parname) .Replace("$$psfname$$", psfname) .Replace("$$crdname$$", crdname) .Replace("$$mincrdname$$", mincrdname) ; HFile.WriteAllText("conf.inp", conf_inp); System.Console.WriteLine("Run the following command at " + temp + " :"); System.Console.WriteLine(" $ charmm < conf.inp"); System.Console.WriteLine(" or $ mpd&"); System.Console.WriteLine(" $ mpirun -n 38 charmm_M < conf.inp"); System.Console.WriteLine("Then, copy second.dat to " + temp); while (true) { bool next = HConsole.ReadValue <bool>("Ready for next? ", false, null, false, true); if (next) { if (HFile.ExistsAll(mincrdname)) { mincrdlines = HFile.ReadAllLines(mincrdname); /// second.dat has the following format /// /// num-atoms /// pot-energy /// atom1-xforce atom1-yforce atom1-zforce /// atom2-xforce atom2-yforce atom2-zforce /// ... /// atomn-xforce atomn-yforce atomn-zforce /// upper- or lower-diag elem 1 /// upper- or lower-diag elem 2 /// .... /// upper- or lower-diag elem 3n*3n/2 /// atom1-xcoord atom1-ycoord atom1-zcoord /// atom2-xcoord atom2-ycoord atom2-zcoord /// ... /// atomn-xcoord atomn-ycoord atomn-zcoord /// break; } System.Console.WriteLine("DO, copy target.psf and target.crd to " + temp); } } temp.QuitTemp(); } return(mincrdlines); }
public static SPsfCrd BuildPsfCrd (IEnumerable <string> toplines , IEnumerable <string> parlines , IEnumerable <string> pdblines ) { string tempbase = @"C:\temp\"; SPsfCrd psfcrd; using (var temp = new HTempDirectory(tempbase, null)) { temp.EnterTemp(); string topname = "top.rtf"; HFile.WriteAllLines(topname, toplines); string parname = "par.prm"; HFile.WriteAllLines(parname, parlines); string tgtname = "target"; HFile.WriteAllLines(tgtname + ".pdb", pdblines); string Setup_inp = @"* Run Segment Through CHARMM * ! read topology and parameter files read rtf card name $$topname$$ read para card name $$parname$$ ! Read sequence from the PDB coordinate file open unit 1 card read name $$tgtname$$.pdb read sequ pdb unit 1 ! now generate the PSF and also the IC table (SETU keyword) generate setu a-pro first NTER last CTER rewind unit 1 ! set bomlev to -1 to avois sying on lack of hydrogen coordinates bomlev -1 read coor pdb unit 1 ! them put bomlev back up to 0 bomlev 0 close unit 1 ! prints out number of atoms that still have undefined coordinates. define test select segid a-pro .and. ( .not. hydrogen ) .and. ( .not. init ) show end ic para ic fill preserve ic build hbuild sele all end ! write out the protein structure file (psf) and ! the coordinate file in pdb and crd format. write psf card name $$tgtname$$.psf * PSF * write coor card name $$tgtname$$.crd * Coords * stop " .Replace("$$topname$$", topname) .Replace("$$parname$$", parname) .Replace("$$tgtname$$", tgtname); HFile.WriteAllText("Setup.inp", Setup_inp); System.Console.WriteLine("Run the following command at " + temp + " :"); System.Console.WriteLine(" $ charmm < Setup.inp"); System.Console.WriteLine(" or $ mpd&"); System.Console.WriteLine(" $ mpirun -n 38 charmm_M < Setup.inp"); System.Console.WriteLine("Then, copy target.psf and target.crd to " + temp); while (true) { bool next = HConsole.ReadValue <bool>("Ready for next? ", false, null, false, true); if (next) { if (HFile.ExistsAll("target.crd", "target.psf")) { string[] crdlines = HFile.ReadAllLines("target.crd"); string[] psflines = HFile.ReadAllLines("target.psf"); psfcrd = new SPsfCrd { crdlines = crdlines, psflines = psflines, }; break; } System.Console.WriteLine("DO, copy target.psf and target.crd to " + temp); } } temp.QuitTemp(); } return(psfcrd); }