/// 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); }
/// 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); }