public static string[] LinesFromFile(string path, bool loadLatest) { string loadpath = path; if (loadLatest) { System.IO.FileInfo fileinfo = HFile.GetFileInfo(path); System.IO.FileInfo[] fileinfos = fileinfo.Directory.GetFiles(fileinfo.Name + "*"); if (fileinfos.Length != 0) { List <string> filepaths = new List <string>(); foreach (System.IO.FileInfo lfileinfo in fileinfos) { filepaths.Add(lfileinfo.FullName); } filepaths.Sort(); loadpath = filepaths.Last(); } } if (HFile.Exists(loadpath) == false) { return(null); } string[] lines = HFile.ReadAllLines(loadpath); return(lines); }
public static Crd FromFile(string path) { string[] lines = HFile.ReadAllLines(path); int? num_elems = null; List <Atom> elems = null; foreach (string line in lines) { if (line.StartsWith("*")) { // comment continue; } // " 358272 EXT" // " 1 1 TIP3 OH2 -79.8000000000 -20.4000000000 -4.2000000000 BWAT 1 0.0000000000" // 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 // " %8d %8d %-8s %-8s %18.10f %18.10f %18.10f %-8s %-8d %18.10f" if (elems == null) { // " 358272 EXT" // 012345678901234 // 0 1 string[] tokens = new string[] { line.Substring(0, 10), line.Substring(10), }; num_elems = int.Parse(tokens[0]); HDebug.Exception(tokens[1] == " EXT"); elems = new List <Atom>(num_elems.Value); } else { elems.Add(new Atom { line = line }); } } HDebug.Assert(elems.Count == num_elems); return(new Crd { atoms = elems.ToArray(), }); }
public static Xyz Intxyz(string intpath, string tempbase = null) { string[] intlines = HFile.ReadAllLines(intpath); Xyz xyz; var tmpdir = HDirectory.CreateTempDirectory(tempbase); string currpath = HEnvironment.CurrentDirectory; { HEnvironment.CurrentDirectory = tmpdir.FullName; HFile.WriteAllLines("test.int", intlines); Intxyz("test.int"); xyz = Xyz.FromFile("test.xyz", true); } HEnvironment.CurrentDirectory = currpath; try{ tmpdir.Delete(true); } catch {} return(xyz); }
public static Eigenvec FromFile(string filepath) { List <List <string> > frameliness; { string[] lines = HFile.ReadAllLines(filepath); frameliness = GroupByFrames(lines); } Eigenvec eigvec = new Eigenvec(); eigvec.frames = new List <Frame>(); foreach (List <string> framelines in frameliness) { Frame frame = Frame.FromLines(framelines.ToArray()); eigvec.frames.Add(frame); } return(eigvec); }
public static CTesthess Testhess (string testhesspath , string xyzpath , string prmpath , string keypath //=null , Dictionary <string, string[]> optOutSource // =null , Func <int, int, HessMatrix> HessMatrixZeros // =null ) { int size; { size = Tinker.Xyz.FromFile(xyzpath, false).atoms.Length; } { //bool ComputeAnalyticalHessianMatrix = true; string command = ""; command += testhesspath; //command += GetProgramPath("testhess.exe"); command += " " + xyzpath; command += " " + prmpath; if (keypath != null) { command += " -k " + keypath; } //command += " " + (ComputeAnalyticalHessianMatrix ? "Y" : "N"); command += " > output.txt"; bool pause = false; HProcess.StartAsBatchInConsole(null, pause, command); //int exitcode = HProcess.StartAsBatchSilent(null, null, null, command); } var testhess = ReadHess(xyzpath, "output.txt", optOutSource, HessMatrixZeros); testhess.prm = Prm.FromFile(prmpath); if (optOutSource != null) { optOutSource.Add("output.txt", HFile.ReadAllLines("output.txt")); } return(testhess); }
public static CPsfgen Psfgen (IList <Tuple <string, string, Pdb.IAtom[]> > lstSegFileAtoms // segname, filename, pdbatoms , string tempbase //=null , string parameters //=null , string namdversion //="2.8" , IList <string> infiles , IList <string> outfiles , string topology , IList <string> psfgen_lines = null , string psfgen_workdir = null , HOptions options = null ) { if (options == null) { options = new HOptions((string)null); } Dictionary <System.IO.FileInfo, string[]> infile_lines = new Dictionary <System.IO.FileInfo, string[]>(); foreach (string infile in infiles) { infile_lines.Add(HFile.GetFileInfo(infile), HFile.ReadAllLines(infile)); } string currpath = HEnvironment.CurrentDirectory; System.IO.DirectoryInfo tmpdir = null; if (psfgen_workdir != null) { HEnvironment.CurrentDirectory = psfgen_workdir; } else { tmpdir = HDirectory.CreateTempDirectory(tempbase); HEnvironment.CurrentDirectory = tmpdir.FullName; } string[] lines = null; if ((psfgen_lines != null) && (psfgen_lines.Count > 0)) { lines = psfgen_lines.ToArray(); } else { lines = GetPsfgenLines (custom_pdbalias: null , custom_patches: null ); } if (topology != null) { lines = lines.ToArray().HReplace("$topology$", topology); } List <string> psf_lines; List <string> pdb_lines; { { //foreach(var respath_filename in GetResourcePaths("2.8", "psfgen")) foreach (var respath_filename in GetResourcePaths(namdversion, "psfgen")) { string respath = respath_filename.Item1; string filename = respath_filename.Item2; HResource.CopyResourceTo <Tinker>(respath, filename); } } // Dictionary<string, Tuple<string, Pdb.IAtom[]>> segname_filename_pdbatoms = new Dictionary<string, Tuple<string, Pdb.IAtom[]>>(); // //if(pdbs.Length != 1) throw new ArgumentException(); // for(int i=0; i<lstSegFilePdb.Count; i++) // { // string segnameprefix = lstSegFilePdb[i].Item1; if( segnameprefix == null) segnameprefix = string.Format("{0:00}", i); // string filenameprefix = lstSegFilePdb[i].Item2; if(filenameprefix == null) filenameprefix = string.Format("{0:00}", i); // Pdb pdb = lstSegFilePdb[i].Item3; // List<Pdb.IAtom> pdb_atoms = new List<Pdb.IAtom>(); // pdb_atoms.AddRange(pdb.atoms); // pdb_atoms.AddRange(pdb.hetatms); // char[] chains = pdb_atoms.ListChainID().HToHashSet().ToArray(); // // HDebug.AssertIf(chains.Length> 1, segnameprefix.Length <= 5); // HDebug.AssertIf(chains.Length<=1, segnameprefix.Length <= 6); // foreach(char chain in chains) // { // Pdb.IAtom[] chain_atoms = pdb_atoms.SelectByChainID(chain).SelectByAltLoc().ToArray(); // string suffix = null; // if(('a' <= chain) && (chain <= 'z')) suffix = string.Format("L{0}", chain); // if(('A' <= chain) && (chain <= 'Z')) suffix = string.Format("U{0}", chain); // if(('0' <= chain) && (chain <= '9')) suffix = string.Format("N{0}", chain); // string segname = segnameprefix + ((chains.Length <= 1) ? "" : suffix); // string filename = filenameprefix + ((chains.Length <= 1) ? "" : suffix); // segname_filename_pdbatoms.Add(segname, new Tuple<string,Pdb.IAtom[]>(filename, chain_atoms)); // } // } foreach (var finfo_line in infile_lines) { string inname = finfo_line.Key.Name; string[] inlines = finfo_line.Value; HFile.WriteAllLines(inname, inlines); } HashSet <string> segnames = new HashSet <string>(); int segindex = 0; foreach (var seg_file_atoms in lstSegFileAtoms) { string segname = seg_file_atoms.Item1; string filename = seg_file_atoms.Item2; Pdb.IAtom[] chain_atoms = seg_file_atoms.Item3.SelectByAltLoc().ToArray(); HDebug.Exception(chain_atoms.ListChainID().HToHashSet().Count == 1); if (segname == null) { while (segindex <= 9999) { if (segnames.Contains(segindex.ToString()) == false) { segname = segindex.ToString(); segnames.Add(segname); break; } segindex++; } } if (filename == null) { filename = segname; } Pdb.ToFile (filename + ".pdb" , chain_atoms.HToType <Pdb.IAtom, Pdb.Element>() , false ); for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains("$segname$")) { string insert = lines[i]; insert = insert.Replace("$segname$", segname); insert = insert.Replace("$segfilename$", filename); lines = lines.HInsert(i, insert); i++; } } } lines = lines.HRemoveAllContains("$segname$"); HFile.WriteAllLines("prot.inp", lines); string command0 = string.Format("psfgen < prot.inp"); bool pause = options.Contains("psfgen pause"); HProcess.StartAsBatchInConsole(null, pause, command0); psf_lines = System.IO.File.ReadLines("prot.psf").ToList(); pdb_lines = System.IO.File.ReadLines("prot.pdb").ToList(); } HEnvironment.CurrentDirectory = currpath; if (tmpdir != null) { try{ tmpdir.Delete(true); } catch {} } return(new CPsfgen { psf_lines = psf_lines, pdb_lines = pdb_lines, }); }
public static CPdbxyz Pdbxyz (Pdb pdb , Tinker.Prm prm , string tempbase //=null , string parameters //=null , string tinkerversion //="6.2.1" , params string[] keys ) { var tmpdir = HDirectory.CreateTempDirectory(tempbase); string currpath = HEnvironment.CurrentDirectory; Tinker.Xyz xyz; string[] seq; string[] capture; { HEnvironment.CurrentDirectory = tmpdir.FullName; { foreach (var respath_filename in GetResourcePaths("6.2.1", "pdbxyz")) { string respath = respath_filename.Item1; string filename = respath_filename.Item2; HResource.CopyResourceTo <Tinker>(respath, filename); } } pdb.ToFile("prot.pdb"); prm.ToFile("prot.prm"); string keypath = null; if ((keys != null) && (keys.Length > 0)) { keypath = "prot.key"; HFile.WriteAllLines(keypath, keys); } { //bool ComputeAnalyticalGradientVector = true; //bool ComputeNumericalGradientVector = false; //bool OutputBreakdownByGradientComponent = false; string command = ""; command += "pdbxyz.exe"; command += " prot.pdb"; command += " prot.prm"; if (keypath != null) { command += " -k " + keypath; } command += " > output.txt"; List <string> errors = new List <string>(); int exitcode = HProcess.StartAsBatchSilent(null, null, errors, command); capture = HFile.ReadAllLines("output.txt"); capture = capture.HAddRange(errors.ToArray()); xyz = Tinker.Xyz.FromFile("prot.xyz", false); if (HFile.Exists("prot.seq")) { seq = HFile.ReadAllLines("prot.seq"); } else { seq = null; } } } HEnvironment.CurrentDirectory = currpath; try{ tmpdir.Delete(true); } catch {} return(new CPdbxyz { xyz = xyz, seq = seq, capture = capture, }); }
public static CNamd2 Namd2 (IList <string> pdb_lines , IList <string> psf_lines , IList <string> prm_lines , string tempbase // = null , string namd2version // = "2.8" , string option // = "+p3" , IList <string> infiles = null , IList <string> outfiles = null , IList <string> conf_lines = null ) { string[] lines = null; if ((conf_lines != null) && (conf_lines.Count > 0)) { lines = conf_lines.ToArray(); } else { // http://www.msg.ucsf.edu/local/programs/Vega/pages/tu_namdmin.htm lines = new string[] { "numsteps 10000 " // minimization steps //{ "numsteps 1000 " // minimization steps , "minimization on " , "dielectric 1.0 " , "coordinates prot.pdb " // coordinate file , "outputname output " // output file: prot.coor , "outputEnergies 1000 " , "binaryoutput no " , "DCDFreq 1000 " , "restartFreq 1000 " , "structure prot.psf " // psf file , "paraTypeCharmm on " , "parameters prot.prm " // parameter file //, "parameters par_all22_vega.inp " , "exclude scaled1-4 " , "1-4scaling 1.0 " , "switching on " , "switchdist 8.0 " , "cutoff 22.0 " //, "cutoff 12.0 " , "pairlistdist 23.5 " //, "pairlistdist 13.5 " , "margin 0.0 " , "stepspercycle 20 " , "fixedAtoms on " // fix atoms , "fixedAtomsCol O " // select fixing atoms from O }; } var tmpdir = HDirectory.CreateTempDirectory(tempbase); string currpath = HEnvironment.CurrentDirectory; HEnvironment.CurrentDirectory = tmpdir.FullName; string[] coor_lines = null; double coor_rmsd = double.NaN; { { //foreach(var respath_filename in GetResourcePaths("2.8", "psfgen")) foreach (var respath_filename in GetResourcePaths(namd2version, "namd2")) { string respath = respath_filename.Item1; string filename = respath_filename.Item2; HResource.CopyResourceTo <Tinker>(respath, filename); } } Vector[] coords0 = Pdb.FromLines(pdb_lines).atoms.ListCoord().ToArray(); System.IO.File.WriteAllLines("prot.pdb", pdb_lines); System.IO.File.WriteAllLines("prot.psf", psf_lines); System.IO.File.WriteAllLines("prot.prm", prm_lines); System.IO.File.WriteAllLines("prot.conf", lines); if (option == null) { option = ""; } string command = string.Format("namd2 {0} prot.conf", option); HProcess.StartAsBatchInConsole(null, false, command); if (HFile.Exists("output.coor")) { coor_lines = HFile.ReadAllLines("output.coor"); Vector[] coords1 = Pdb.FromLines(coor_lines).atoms.ListCoord().ToArray(); Vector[] coords1x = Align.MinRMSD.Align(coords0, coords1); coor_rmsd = Align.MinRMSD.GetRMSD(coords0, coords1x); } } HEnvironment.CurrentDirectory = currpath; try{ tmpdir.Delete(true); } catch {} if (coor_lines == null) { return(null); } return(new CNamd2 { coor_lines = coor_lines, coor_rmsd = coor_rmsd, }); }
public static ONewton Newton(string tinkerpath , Tinker.Xyz xyz , Tinker.Xyz.Atom.Format xyz_atoms_format , Tinker.Prm prm , string tempbase , string copytemp // = null , string param //, string precondition // = "A" // Precondition via Auto/None/Diag/Block/SSOR/ICCG [A] : A //, double gradCriterion // = 0.01 // Enter RMS Gradient per Atom Criterion [0.01] : 0.001 , IList <Tinker.Xyz.Atom> atomsToFix // = null , bool pause // = false , params string[] keys ) { if (HDebug.IsDebuggerAttached && atomsToFix != null) { Dictionary <int, Tinker.Xyz.Atom> xyzatoms = xyz.atoms.ToIdDictionary(); foreach (var atom in atomsToFix) { HDebug.Assert(object.ReferenceEquals(atom, xyzatoms[atom.Id])); } } Tinker.Xyz minxyz; string[] minlog; using (var temp = new HTempDirectory(tempbase, copytemp)) { temp.EnterTemp(); if (tinkerpath == null) { string resbase = "HTLib2.Bioinfo.HTLib2.Bioinfo.External.Tinker.Resources.tinker_6_2_06."; HResource.CopyResourceTo <Tinker>(resbase + "newton.exe", "newton.exe"); tinkerpath = "newton.exe"; } xyz.ToFile("prot.xyz", false); prm.ToFile("prot.prm"); List <string> keylines = new List <string>(keys); if (atomsToFix != null) { foreach (var atom in atomsToFix) { Vector coord = atom.Coord; double force_constant = 10000; // force constant in kcal/Å2 for the harmonic restraint potential string keyline = string.Format("RESTRAIN-POSITION {0} {1} {2} {3} {4}", atom.Id, coord[0], coord[1], coord[2], force_constant); keylines.Add(keyline); } } HFile.WriteAllLines("prot.key", keylines); // Precondition via Auto/None/Diag/Block/SSOR/ICCG [A] : A // Enter RMS Gradient per Atom Criterion [0.01] : 0.001 //bool pause = false; string command = tinkerpath; command += string.Format(" prot.xyz prot.prm"); command += string.Format(" -k prot.key"); command += string.Format(" {0}", param); HProcess.StartAsBatchInConsole("newton.bat", pause , "time /t >> prot.log" , command //+" >> prot.log" , "time /t >> prot.log" ); HDebug.Assert(HFile.Exists("prot.xyz_2")); HDebug.Assert(HFile.Exists("prot.xyz_3") == false); minxyz = Tinker.Xyz.FromFile("prot.xyz_2", false, xyz_atoms_format); minlog = HFile.ReadAllLines("prot.log"); temp.QuitTemp(); } return(new ONewton { minxyz = minxyz, minlog = minlog }); }
/// 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 CTestgrad ReadGrad (string outputpath , Dictionary <string, string[]> optOutSource // = null ) { string[] lines = HFile.ReadAllLines(outputpath); if (optOutSource != null) { optOutSource.Add("output.txt", lines); } #region output.txt /// ###################################################################### /// ########################################################################## /// ### ### /// ### TINKER --- Software Tools for Molecular Design ### /// ## ## /// ## Version 6.2 February 2013 ## /// ## ## /// ## Copyright (c) Jay William Ponder 1990-2013 ## /// ### All Rights Reserved ### /// ### ### /// ########################################################################## /// ###################################################################### /// /// /// Atoms with an Unusual Number of Attached Atoms : /// /// Type Atom Name Atom Type Expected Found /// /// Valence 1496-NR2 69 2 3 /// Valence 2438-FE 107 6 5 /// /// Total Potential Energy : -3753.7592 Kcal/mole /// /// Potential Energy Breakdown by Individual Components : /// /// Energy EB EA EBA EUB EAA EOPB /// Terms EOPD EID EIT ET EPT EBT /// ETT EV EC ECD ED EM /// EP ER ES ELF EG EX /// /// 134.1618 490.7835 0.0000 27.0850 0.0000 0.0000 /// 0.0000 22.5749 0.0000 644.4690 0.0000 0.0000 /// 0.0000 -645.8696 -4426.9638 0.0000 0.0000 0.0000 /// 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 /// /// Cartesian Gradient Breakdown over Individual Atoms : /// /// Type Atom dE/dX dE/dY dE/dZ Norm /// /// Anlyt 1 -0.2655 -0.4022 0.3265 0.5821 /// Anlyt 2 -0.0118 0.1880 -0.2657 0.3257 /// Anlyt 3 0.1314 0.0874 -0.0147 0.1585 /// Anlyt 4 0.1543 -0.0348 -0.1401 0.2113 /// Anlyt 5 0.0216 0.4618 0.4205 0.6250 /// Anlyt 6 -0.0560 -0.0821 -0.0337 0.1050 /// ... /// Anlyt 2510 0.2699 0.2529 0.4340 0.5703 /// /// Total Gradient Norm and RMS Gradient per Atom : /// /// Anlyt Total Gradient Norm Value 27.5518 /// /// Anlyt RMS Gradient over All Atoms 0.5499 #endregion double potential = double.NaN; List <CTestgrad.Anlyt> analyts = new List <CTestgrad.Anlyt>(); CTestgrad.EnrgCmpnt enrgCmpnt = null; for (int i = 0; i < lines.Length; i++) { string line = lines[i]; string[] tokens = line.Split().HRemoveAll(""); if (tokens.Length == 0) { continue; } int tmpint; if (tokens[0] == "Anlyt" && int.TryParse(tokens[1], out tmpint)) { CTestgrad.Anlyt analyt = new CTestgrad.Anlyt(); analyt.id = int.Parse(tokens[1]); //if(int.TryParse(tokens[1], out analyt.id) == false) continue; analyt.fx = double.Parse(tokens[2]); //if(double.TryParse(tokens[2], out analyt.fx) == false) continue; analyt.fy = double.Parse(tokens[3]); //if(double.TryParse(tokens[3], out analyt.fy) == false) continue; analyt.fz = double.Parse(tokens[4]); //if(double.TryParse(tokens[4], out analyt.fz) == false) continue; analyt.norm = double.Parse(tokens[5]); //if(double.TryParse(tokens[5], out analyt.norm) == false) continue; analyts.Add(analyt); continue; } if (tokens[0] == "Total" && tokens[1] == "Potential" && tokens[2] == "Energy") { double.TryParse(tokens[4], out potential); continue; } if (line.Contains("Potential Energy Breakdown by Individual Components :")) { int ii = 1; if (lines[i + ii].Trim().Length != 0) { continue; } ii++; Dictionary <string, int> energy_term_sequence = new Dictionary <string, int>(); while (lines[i + ii].Trim().Length != 0) { string[] iitokens = lines[i + ii].Split().HRemoveAll(""); iitokens = iitokens.HRemoveAll("Energy"); iitokens = iitokens.HRemoveAll("Terms"); foreach (string iitoken in iitokens) { energy_term_sequence.Add(iitoken, energy_term_sequence.Count); } ii++; } if (lines[i + ii].Trim().Length != 0) { continue; } ii++; List <double> energy_value_sequence = new List <double>(); // find location of toker break List <int> tokenbreak = new List <int>(); { int jj = ii; while (lines[i + jj].Trim().Length != 0) { string iiline = lines[i + jj]; string[] iitokens = iiline.Split().HRemoveAll(""); foreach (string iitoken in iitokens) { string iitoken2 = iitoken.Substring(0, iitoken.Length - 1) + "@"; HDebug.Assert(iitoken2.Length == iitoken.Length); HDebug.Assert(iitoken2.Last() == '@'); iiline = iiline.Replace(iitoken, iitoken2); } for (int idx = 0; idx < iiline.Length; idx++) { if (iiline[idx] == '@') { tokenbreak.Add(idx); } } jj++; } tokenbreak.Add(-1); tokenbreak = tokenbreak.HToHashSet() .ToList() .HSort() .ToList() ; } while (lines[i + ii].Trim().Length != 0) { string iiline = lines[i + ii]; //string[] iitokens = iiline.Split().HRemoveAll(""); List <string> iitokens = new List <string>(); { string iiline2 = ""; for (int jj = 0; jj < tokenbreak.Count - 1; jj++) { int idx0 = tokenbreak[jj] + 1; int idx1 = tokenbreak[jj + 1]; if (idx1 >= iiline.Length) { break; } int leng = idx1 - idx0 + 1; iitokens.Add(iiline.Substring(idx0, leng)); iiline2 += iitokens[jj]; } HDebug.Assert(iiline == iiline2); } foreach (string iitoken in iitokens) { if (iitoken.Contains("*")) { /// Handle "**********" //// Energy EB EA EBA EUB //// Terms EAA EOPB EOPD EID //// EIT ET EPT EBT //// EAT ETT EV EC //// ECD ED EM EP //// ER ES ELF EG //// EX //// //// 56384.95472959 41770.94471911 0.00000000 0.00000000 //// 0.00000000 0.00000000 0.00000000 0.00000000 //// 0.00000000 0.00000000 0.00000000 0.00000000 //// 0.00000000 0.00000000 232979.82170784**************** //// 0.00000000 0.00000000 0.00000000 0.00000000 //// 0.00000000 0.00000000 0.00000000 0.00000000 //// 0.00000000 if (iitoken.StartsWith("*")) { HDebug.Assert(iitoken.EndsWith("*")); energy_value_sequence.Add(double.NaN); } else { HDebug.Assert(iitoken.EndsWith("*")); string liitoken = iitoken.Replace("*", ""); energy_value_sequence.Add(double.Parse(liitoken)); energy_value_sequence.Add(double.NaN); } } else { energy_value_sequence.Add(double.Parse(iitoken)); } } ii++; } if (lines[i + ii].Trim().Length != 0) { continue; } ii++; if (energy_term_sequence.Count != energy_value_sequence.Count) { continue; } #region format ///0 1 2 3 4 5 6 7 |8 ///01234567890123456789012345678901234567890123456789012345678901234567890123456789|0 /// /// Potential Energy Breakdown by Individual Components : /// /// Energy EB EA EBA EUB EAA EOPB /// Terms EOPD EID EIT ET EPT EBT /// ETT EV EC ECD ED EM /// EP ER ES ELF EG EX /// /// 134.0512 490.5575 0.0000 27.1282 0.0000 0.0000 /// 0.0000 22.6363 0.0000 775.1337 0.0000 0.0000 /// 0.0000************ -4039.6760 0.0000 0.0000 0.0000 /// 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 /// ///0 1 2 3 4 5 6 7 |8 ///01234567890123456789012345678901234567890123456789012345678901234567890123456789|0 /// /// Potential Energy Breakdown by Individual Components : /// /// Energy EB EA EBA EUB /// Terms EAA EOPB EOPD EID /// EIT ET EPT EBT /// ETT EV EC ECD /// ED EM EP ER /// ES ELF EG EX /// /// 1827.83562614 115.54269101 0.00000000 139.97155716 /// 0.00000000 0.00000000 0.00000000 6.08959854 /// 0.00000000 176.68828153 0.00000000 0.00000000 /// 0.00000000 0.00000000 0.00000000 0.00000000 /// 0.00000000 0.00000000 0.00000000 0.00000000 /// 0.00000000 0.00000000 0.00000000 0.00000000 #endregion CTestgrad.EnrgCmpnt ec = new CTestgrad.EnrgCmpnt(); if (energy_term_sequence.ContainsKey("EB")) { ec.EB = energy_value_sequence[energy_term_sequence["EB"]]; } if (energy_term_sequence.ContainsKey("EA")) { ec.EA = energy_value_sequence[energy_term_sequence["EA"]]; } if (energy_term_sequence.ContainsKey("EBA")) { ec.EBA = energy_value_sequence[energy_term_sequence["EBA"]]; } if (energy_term_sequence.ContainsKey("EUB")) { ec.EUB = energy_value_sequence[energy_term_sequence["EUB"]]; } if (energy_term_sequence.ContainsKey("EAA")) { ec.EAA = energy_value_sequence[energy_term_sequence["EAA"]]; } if (energy_term_sequence.ContainsKey("EOPB")) { ec.EOPB = energy_value_sequence[energy_term_sequence["EOPB"]]; } if (energy_term_sequence.ContainsKey("EOPD")) { ec.EOPD = energy_value_sequence[energy_term_sequence["EOPD"]]; } if (energy_term_sequence.ContainsKey("EID")) { ec.EID = energy_value_sequence[energy_term_sequence["EID"]]; } if (energy_term_sequence.ContainsKey("EIT")) { ec.EIT = energy_value_sequence[energy_term_sequence["EIT"]]; } if (energy_term_sequence.ContainsKey("ET")) { ec.ET = energy_value_sequence[energy_term_sequence["ET"]]; } if (energy_term_sequence.ContainsKey("EPT")) { ec.EPT = energy_value_sequence[energy_term_sequence["EPT"]]; } if (energy_term_sequence.ContainsKey("EBT")) { ec.EBT = energy_value_sequence[energy_term_sequence["EBT"]]; } if (energy_term_sequence.ContainsKey("ETT")) { ec.ETT = energy_value_sequence[energy_term_sequence["ETT"]]; } if (energy_term_sequence.ContainsKey("EV")) { ec.EV = energy_value_sequence[energy_term_sequence["EV"]]; } if (energy_term_sequence.ContainsKey("EC")) { ec.EC = energy_value_sequence[energy_term_sequence["EC"]]; } if (energy_term_sequence.ContainsKey("ECD")) { ec.ECD = energy_value_sequence[energy_term_sequence["ECD"]]; } if (energy_term_sequence.ContainsKey("ED")) { ec.ED = energy_value_sequence[energy_term_sequence["ED"]]; } if (energy_term_sequence.ContainsKey("EM")) { ec.EM = energy_value_sequence[energy_term_sequence["EM"]]; } if (energy_term_sequence.ContainsKey("EP")) { ec.EP = energy_value_sequence[energy_term_sequence["EP"]]; } if (energy_term_sequence.ContainsKey("ER")) { ec.ER = energy_value_sequence[energy_term_sequence["ER"]]; } if (energy_term_sequence.ContainsKey("ES")) { ec.ES = energy_value_sequence[energy_term_sequence["ES"]]; } if (energy_term_sequence.ContainsKey("ELF")) { ec.ELF = energy_value_sequence[energy_term_sequence["ELF"]]; } if (energy_term_sequence.ContainsKey("EG")) { ec.EG = energy_value_sequence[energy_term_sequence["EG"]]; } if (energy_term_sequence.ContainsKey("EX")) { ec.EX = energy_value_sequence[energy_term_sequence["EX"]]; } enrgCmpnt = ec; } } return(new CTestgrad { potential = potential, enrgCmpnt = enrgCmpnt, anlyts = analyts.ToArray() }); }
public static OMinimize Minimize(string minimizepath , Tinker.Xyz xyz , Tinker.Xyz.Atom.Format xyz_atoms_format , Tinker.Prm prm , string tempbase , string copytemp // = null , string param , IList <Tinker.Xyz.Atom> atomsToFix // = null , bool pause // = false , params string[] keys ) { if (HDebug.IsDebuggerAttached && atomsToFix != null) { Dictionary <int, Tinker.Xyz.Atom> xyzatoms = xyz.atoms.ToIdDictionary(); foreach (var atom in atomsToFix) { HDebug.Assert(object.ReferenceEquals(atom, xyzatoms[atom.Id])); } } Tinker.Xyz minxyz; string[] minlog; using (var temp = new HTempDirectory(tempbase, copytemp)) { temp.EnterTemp(); xyz.ToFile("prot.xyz", false); prm.ToFile("prot.prm"); List <string> keylines = new List <string>(); //if(grdmin != null) //{ // string keyline = string.Format("GRDMIN {0}", grdmin.Value); // keylines.Add(keyline); //} if (atomsToFix != null) { foreach (var atom in atomsToFix) { Vector coord = atom.Coord; double force_constant = 10000; // force constant in kcal/Å2 for the harmonic restraint potential string keyline = string.Format("RESTRAIN-POSITION {0} {1} {2} {3} {4}", atom.Id, coord[0], coord[1], coord[2], force_constant); keylines.Add(keyline); } } if (keys != null) { keylines.AddRange(keys); } HFile.WriteAllLines("prot.key", keylines); // Enter RMS Gradient per Atom Criterion [0.01] : string command = minimizepath; command += " prot.xyz prot.prm"; command += " -k prot.key < param.txt"; HFile.WriteAllLines("param.txt", param.HSplit()); //command += string.Format(" >> prot.log"); HProcess.StartAsBatchInConsole("minimize.bat", pause , "time /t >> prot.log" , command , "time /t >> prot.log" ); HDebug.Assert(HFile.Exists("prot.xyz_2")); HDebug.Assert(HFile.Exists("prot.xyz_3") == false); minxyz = Tinker.Xyz.FromFile("prot.xyz_2", false, xyz.atoms_format); minlog = HFile.ReadAllLines("prot.log"); temp.QuitTemp(); } return(new OMinimize { minxyz = minxyz, minlog = minlog }); }
public static FileGro FromFile(string filepath) { string[] lines = HFile.ReadAllLines(filepath); return(FromLines(lines)); }
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); }
public static Top FromFile(string path, List <string> defines) { List <string> lines = new List <string>(HFile.ReadAllLines(path)); List <LineElement> elements = new List <LineElement>(); //List<Tuple<string,List<LineElement>>> elementgroup = new List<Tuple<string, List<LineElement>>>(); //Dictionary<int,Atom> atoms = new Dictionary<int, Atom>(); //List<Bond> bonds = new List<Bond>(); //List<Pair> pairs = new List<Pair>(); //List<Angle> angles = new List<Angle>(); string type = null; while (lines.Count > 0) //for(int i=0; i<lines.Length; i++) { string line = lines[0]; lines.RemoveAt(0); //LineElement element = new LineElement(lines[i]); string typei = LineElement.GetType(line); if (typei != null) { type = typei; //elementgroup.Add(new Tuple<string, List<LineElement>>(type, new List<LineElement>())); continue; } { line = line.Trim(); if (line.EndsWith("\\")) { while (lines.Count > 0) { line = line + "\n" + lines[0].Trim(); lines.RemoveAt(0); if (line.EndsWith("\\") == false) { break; } } //line = ""; //for(; i<lines.Length; i++) //{ // string lline = lines[i].Trim(); // line = line + lline + "\n"; // if(lline.EndsWith("\\") == false) // break; //} } line = (line.IndexOf(';') == -1) ? line.Trim() : line.Substring(0, line.IndexOf(';')).Trim(); if (line.Length == 0) { continue; } if (line[0] == '*') { continue; } if (line.StartsWith("#define")) { string define = line.Replace("#define", "").Trim(); defines.Add(define); continue; } if (line.StartsWith("#include")) { string includepath; { includepath = line.Replace("#include", "").Trim().Replace("\"", "").Trim(); if (HFile.Exists(includepath) == false) { includepath = @"C:\Program Files (x86)\Gromacs\share\gromacs\top\" + line.Replace("#include", "").Trim().Replace("\"", "").Trim(); } if (HFile.Exists(includepath) == false) { includepath = HDirectory.GetParent(path).FullName + "\\" //path.Substring(0, path.LastIndexOf('/')+1) + line.Replace("#include", "").Trim().Replace("\"", "").Trim(); } HDebug.Assert(HFile.Exists(includepath)); } Top includetop = FromFile(includepath, defines); elements.AddRange(includetop.elements); type = null; continue; } if (line.StartsWith("#ifdef")) { FromFile_ifdef(defines, lines, line); continue; } if (line.StartsWith("#")) { HDebug.Assert(false); } if (type == "moleculetype") { LineElement element = new Moleculetype(line, path); elements.Add(element); continue; } if (type == "atoms") { LineElement element = new Atom(line, path); elements.Add(element); continue; } if (type == "bonds") { LineElement element = new Bond(line, path); elements.Add(element); continue; } if (type == "pairs") { LineElement element = new Pair(line, path); elements.Add(element); continue; } if (type == "angles") { LineElement element = new Angle(line, path); elements.Add(element); continue; } if (type == "dihedrals") { LineElement element = new Dihedral(line, path); elements.Add(element); continue; } if (type == "cmap") { LineElement element = new Cmap(line, path); elements.Add(element); continue; } if (type == "position_restraints") { LineElement element = new Position_restraints(line, path); elements.Add(element); continue; } if (type == "system") { LineElement element = new System(line, path); elements.Add(element); continue; } if (type == "molecules") { LineElement element = new Molecules(line, path); elements.Add(element); continue; } if (type == "defaults") { LineElement element = new Defaults(line, path); elements.Add(element); continue; } if (type == "atomtypes") { LineElement element = new Atomtypes(line, path); elements.Add(element); continue; } if (type == "pairtypes") { LineElement element = new Pairtypes(line, path); elements.Add(element); continue; } if (type == "bondtypes") { LineElement element = new Bondtypes(line, path); elements.Add(element); continue; } if (type == "constrainttypes") { LineElement element = new Constrainttypes(line, path); elements.Add(element); continue; } if (type == "angletypes") { LineElement element = new Angletypes(line, path); elements.Add(element); continue; } if (type == "dihedraltypes") { LineElement element = new Dihedraltypes(line, path); elements.Add(element); continue; } if (type == "implicit_genborn_params") { LineElement element = new Implicit_genborn_params(line, path); elements.Add(element); continue; } if (type == "cmaptypes") { LineElement element = new Cmaptypes(line, path); elements.Add(element); continue; } if (type == "settles") { LineElement element = new Settles(line, path); elements.Add(element); continue; } if (type == "exclusions") { LineElement element = new Exclusions(line, path); elements.Add(element); continue; } HDebug.Assert(false); } } Top top = new Top(); top.elements = elements.ToArray(); return(top); }
/// 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); }