public static List <Pdb.Element> UpdateElement(this List <Pdb.Element> elements) { elements = elements.HClone(); int?iatom_lastserial = 0; for (int i = 0; i < elements.Count; i++) { elements[i] = elements[i].UpdateElement(); if (elements[i] is Pdb.IAtom) { Pdb.IAtom iatom = elements[i] as Pdb.IAtom; bool hexserial = false; if (iatom_lastserial >= 99999) { if (iatom.Serial(true) >= 99999) { hexserial = true; } } iatom.hexserial = hexserial; iatom_lastserial = iatom.Serial(); } } return(elements); }
public static PdbStatic.ResInfo GetResInfo(this Pdb.IAtom atom) { return(new PdbStatic.ResInfo { resName = atom.resName, chainID = atom.chainID, resSeq = atom.resSeq, iCode = atom.iCode, }); }
public static IEnumerable <IList <Pdb.IAtom> > SoakMoleculeISolventBox(IList <Pdb.IAtom> mole, IList <IList <Pdb.IAtom> > solv_atoms, Namd.Prm prm) { yield return(mole); KDTree.KDTree <Pdb.IAtom> kdtree_mole = new KDTree.KDTree <Pdb.IAtom>(3); foreach (var atom in mole) { kdtree_mole.insert(atom.coord, atom); } //List<Pdb.IAtom> socked = new List<Pdb.IAtom>(); //socked.AddRange(mole); Dictionary <string, double> elem_radius = new Dictionary <string, double> { #region {"C", 1.90}, ... // public static NbndInfo[] nbndinfo_set_SSTeMcs6c = new NbndInfo[] // { { "C", 1.90 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="C", rmin2=1.90, charge=0.0, epsilon=-0.1}, { "H", 1.20 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="H", rmin2=1.20, charge=0.0, epsilon=-0.1}, { "O", 1.70 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="O", rmin2=1.70, charge=0.0, epsilon=-0.1}, { "N", 1.85 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="N", rmin2=1.85, charge=0.0, epsilon=-0.1}, { "S", 2.00 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="S", rmin2=2.00, charge=0.0, epsilon=-0.1}, { "F", 1.47 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="F", rmin2=1.47, charge=0.0, epsilon=-0.1}, /// same to unif0 { "P", 1.80 }, // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="P", rmin2=1.80, charge=0.0, epsilon=-0.1}, /// same to unif0 // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="C", rmin2=1.90, charge=0.0, epsilon=-0.1}, // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="H", rmin2=1.20, charge=0.0, epsilon=-0.1}, // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="O", rmin2=1.40, charge=0.0, epsilon=-0.1}, /// special treatment: 1.70 -> 1.40 // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="N", rmin2=1.55, charge=0.0, epsilon=-0.1}, /// special treatment: 1.85 -> 1.55 // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="S", rmin2=2.00, charge=0.0, epsilon=-0.1}, // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="F", rmin2=1.47, charge=0.0, epsilon=-0.1}, /// same to unif0 // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="P", rmin2=1.80, charge=0.0, epsilon=-0.1}, /// same to unif0 // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // //new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="", rmin2=0.00, charge=0.0, epsilon=-0.1}, // // http://en.wikipedia.org/wiki/Van_der_Waals_radius { "CL", 1.75 }, // new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="CL", rmin2=1.75, charge=0.0, epsilon=-0.1}, { "CU", 1.40 }, // new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="CU", rmin2=1.40, charge=0.0, epsilon=-0.1}, // // http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page) { "MG", 1.73 }, // new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="MG", rmin2=1.73, charge=0.0, epsilon=-0.1}, // magnesium { "K", 2.75 }, // new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="K" , rmin2=2.75, charge=0.0, epsilon=-0.1}, // potassium { "POT", 2.75 }, // new NbndInfo{ nbndtype=NbndType.nbnd, atomelem="POT",rmin2=2.75, charge=0.0, epsilon=-0.1}, // potassium // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // par_all27_prot_na.prm // // FE 0.010000 0.000000 0.650000 ! ALLOW HEM // new NbndInfo{ nbndtype=NbndType.nbnd , atomelem="FE" ,rmin2=0.65, charge=0.0, epsilon=-0.1}, // new NbndInfo{ nbndtype=NbndType.nbnd14, atomelem="FE" ,rmin2=0.65, charge=0.0, epsilon=-0.1}, // }; #endregion }; bool noclash_with_mole = false; foreach (var atoms in solv_atoms) { List <Pdb.IAtom> noclash_atoms = new List <Pdb.IAtom>(); foreach (var atom in atoms) { Vector atom_coord = atom.coord; double atom_rmin = elem_radius[atom.element.Trim()]; Pdb.IAtom near = kdtree_mole.nearest(atom_coord); double near_rmin = elem_radius[near.element.Trim()]; double dist = (atom_coord - near.coord).Dist; if (atom.name == "OH2 ") { if ((atom_rmin + near_rmin) < dist) { noclash_with_mole = true; } else { noclash_with_mole = false; } } if (noclash_with_mole) { noclash_atoms.Add(atom); //yield return atom; //socked.Add(atom); } } if (noclash_atoms.Count != 0) { yield return(noclash_atoms); } } }
public static double[] GetCoord(this Pdb.IAtom iatom) { return(new double[] { iatom.x, iatom.y, iatom.z }); }
public static CPsfgenExt PsfgenExt (IList <Tuple <string, string, Pdb.IAtom[]> > lstSegFileAtoms , string[] toplines , string[] parlines , Pdb alignto , string[] psfgen_lines , IList <string> minimize_conf_lines = null , HOptions options = null ) { if (options == null) { options = new HOptions((string)null); } string tempbase = @"C:\temp\"; string psfgen_workdir = null; string topname = "prot.top"; string parname = "prot.par"; List <string> psf_lines = null; List <string> pdb_lines = null; using (var temp = new HTempDirectory(tempbase, null)) { temp.EnterTemp(); HFile.WriteAllLines(topname, toplines); HFile.WriteAllLines(parname, parlines); if ((HFile.Exists("prot.pdb") == false) || (HFile.Exists("prot.psf") == false)) { var psfgen = Namd.RunPsfgen (lstSegFileAtoms, tempbase, null, "2.10" , new string[] { topname } , new string[] {} , topname , psfgen_lines: psfgen_lines , psfgen_workdir: psfgen_workdir , options: options ); psf_lines = psfgen.psf_lines; pdb_lines = psfgen.pdb_lines; if (alignto != null) { HDebug.Exception("check!!!"); //////////////////////////// Pdb prot = Pdb.FromLines(pdb_lines); prot = PsfgenExt_AlignTo(prot, alignto); pdb_lines = prot.ToLines().ToList(); } HFile.WriteAllLines("prot.pdb", pdb_lines); HFile.WriteAllLines("prot.psf", psf_lines); } if (options.Contains("nomin") == false) { if ((HFile.Exists("protmin.coor") == false) || (HFile.Exists("protmin.pdb") == false)) { List <string> psfgen_pdb_lines = System.IO.File.ReadLines("prot.pdb").ToList(); List <string> psfgen_psf_lines = System.IO.File.ReadLines("prot.psf").ToList(); List <string> prm_lines = System.IO.File.ReadLines(parname).ToList(); string Namd2_opt = null; if (options.HSelectStartsWith("minimize option:").Length >= 1) { Namd2_opt = options.HSelectStartsWith("minimize option:").First().Replace("minimize option:", ""); } var minpdb = Namd.Run.Namd2 (psfgen_pdb_lines , psfgen_psf_lines , prm_lines , tempbase , "2.10" , ((Namd2_opt == null) ? "+p3" : Namd2_opt) , conf_lines: minimize_conf_lines ); HFile.WriteAllLines("protmin.coor", minpdb.coor_lines); Pdb prot0 = Pdb.FromLines(psfgen_pdb_lines); Pdb prot1 = Pdb.FromLines(minpdb.coor_lines); HDebug.Exception(prot0.atoms.Length == prot1.atoms.Length); HDebug.Exception(prot0.elements.Length == prot1.elements.Length); // update conformation to minimized conformation for (int i = 0; i < prot0.elements.Length; i++) { if (prot0.elements[i].GetType() != prot1.elements[i].GetType()) { throw new HException("prot0.elements[i].GetType() != prot1.elements[i].GetType()"); } if ((prot0.elements[i] is Pdb.IAtom) == false) { continue; } Pdb.IAtom iatom0 = prot0.elements[i] as Pdb.IAtom; Pdb.IAtom iatom1 = prot1.elements[i] as Pdb.IAtom; Vector coord0 = iatom0.coord; Vector coord1 = iatom1.coord; double dist = (coord0 - coord1).Dist; if (iatom0.occupancy != 0) { if (dist != 0) { throw new HException("iatom0.coord - iatom1.coord != 0"); } } if (dist != 0) { if (iatom0 is Pdb.Atom) { string nline0 = (iatom0 as Pdb.Atom).GetUpdatedLine(coord1); Pdb.Atom natom0 = Pdb.Atom.FromString(nline0); prot0.elements[i] = natom0; continue; } if (iatom0 is Pdb.Hetatm) { string nline0 = (iatom0 as Pdb.Hetatm).GetUpdatedLine(coord1); Pdb.Hetatm natom0 = Pdb.Hetatm.FromString(nline0); prot0.elements[i] = natom0; continue; } } } if ((prot0.elements[0] is Pdb.Remark) && (prot1.elements[0] is Pdb.Remark)) { prot0.elements[0] = Pdb.Remark.FromString(prot1.elements[0].line); } prot0.ToFile("protmin.pdb"); pdb_lines = System.IO.File.ReadLines("protmin.pdb").ToList(); } } //{ // Pdb confpdb = GetConfPdb(options); // var psf = Namd.Psf.FromFile("prot.psf"); // var prm = Namd.Prm.FromFile(parname); // List<string> log = new List<string>(); // Universe univ = Universe.BuilderNamd.Build(psf, prm, confpdb, true, new TextLogger(log)); // return univ; //} temp.QuitTemp(); } return(new CPsfgenExt { psflines = psf_lines, pdblines = pdb_lines, }); }