public static bool carboxylatesBlocked(OBMol mol, OBAtom aA, OBAtom carbA, OBAtom aB, OBAtom carbB) { bool inCone = OBFunctions.atomsInCarboxylateCone(aA, carbA, mol); inCone = inCone || OBFunctions.atomsInCarboxylateCone(aB, carbB, mol); return(inCone); }
public static void trajectoryFrameToCIF(string frame, string outFile, List <int> esequence, OBConversion obconv) { //converts a frame from the above function into a CIF file //lammps trajectory files have unit cell dimension data for every frame //requires an element sequence for identifying element type from lammps atom types OBUnitCell uc = new OBUnitCell(); OBMol mol = new OBMol(); OBMatrix3x3 mat = new OBMatrix3x3(); using (StringReader reader = new StringReader(frame)) { string line = ""; bool foundMatrix = false; do { line = reader.ReadLine(); if (line.Contains("BOX BOUNDS")) { //data from lammps is in this format //ITEM: BOX BOUNDS xy xz yz //xlo_bound xhi_bound xy //ylo_bound yhi_bound xz //zlo_bound zhi_bound yz string row0 = reader.ReadLine(); double[] row0d = OBFunctions.spacedStringToDoubleArray(row0); double xlo = row0d[0]; double xhi = row0d[1]; double xy = row0d[2]; string row1 = reader.ReadLine(); double[] row1d = OBFunctions.spacedStringToDoubleArray(row1); double ylo = row1d[0]; double yhi = row1d[1]; double xz = row1d[2]; string row2 = reader.ReadLine(); double[] row2d = OBFunctions.spacedStringToDoubleArray(row2); double zlo = row2d[0]; double zhi = row2d[1]; double yz = row2d[2]; //adjust box bounds, taken from VMD's source for reading lammps files double xdelta = Math.Min(0, xy); xdelta = Math.Min(xdelta, xz); xdelta = Math.Min(xdelta, xy + xz); xlo = xlo - xdelta; xdelta = Math.Max(0, xy); xdelta = Math.Max(xdelta, xz); xdelta = Math.Max(xdelta, xy + xz); xhi = xhi - xdelta; ylo = ylo - Math.Min(0, yz); yhi = yhi - Math.Max(0, yz); OBVector3 A = new OBVector3(xhi - xlo, 0, 0); OBVector3 B = new OBVector3(xy, yhi - ylo, 0); OBVector3 C = new OBVector3(xz, yz, zhi - zlo); //OBVector3 A = new OBVector3 (xhi-xlo, xy, xz); //OBVector3 B = new OBVector3 (0, yhi-ylo, yz); //OBVector3 C= new OBVector3 (0, 0, zhi-zlo); mat = new OBMatrix3x3(A, B, C); uc.SetData(A, B, C); foundMatrix = true; } } while (!foundMatrix); //uc.SetData (mat); bool foundAtoms = false; do { line = reader.ReadLine(); if (line.Contains("ITEM: ATOMS")) { foundAtoms = true; } } while (!foundAtoms); while ((line = reader.ReadLine()) != null) { string[] splitline = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); int lammpstype = Convert.ToInt32(splitline[1]) - 1; int atype = esequence[lammpstype]; OBAtom a = new OBAtom(); a.SetAtomicNum(atype); //position in fraction coordinates OBVector3 fvec = new OBVector3(Convert.ToDouble(splitline[3]), Convert.ToDouble(splitline[4]), Convert.ToDouble(splitline[5])); //OBVector3 fvec = new OBVector3 (Convert.ToDouble (splitline [2]), Convert.ToDouble (splitline [3]), Convert.ToDouble (splitline [4])); //convert to cartesian. OBVector3 cvec = uc.FractionalToCartesian(fvec); a.SetVector(cvec); mol.AddAtom(a); } mol.CloneData(uc); obconv.SetOutFormat("cif"); obconv.AddOption("b"); obconv.WriteFile(mol, outFile); } }
public static double trajectoryFrameVolume(string frame) { using (StringReader reader = new StringReader(frame)) { string line = ""; bool foundMatrix = false; double volume = 0; do { line = reader.ReadLine(); if (line.Contains("BOX BOUNDS")) { //data from lammps is in this format //ITEM: BOX BOUNDS xy xz yz //xlo_bound xhi_bound xy //ylo_bound yhi_bound xz //zlo_bound zhi_bound yz string row0 = reader.ReadLine(); double[] row0d = OBFunctions.spacedStringToDoubleArray(row0); double xlo = row0d[0]; double xhi = row0d[1]; double xy = row0d[2]; string row1 = reader.ReadLine(); double[] row1d = OBFunctions.spacedStringToDoubleArray(row1); double ylo = row1d[0]; double yhi = row1d[1]; double xz = row1d[2]; string row2 = reader.ReadLine(); double[] row2d = OBFunctions.spacedStringToDoubleArray(row2); double zlo = row2d[0]; double zhi = row2d[1]; double yz = row2d[2]; //adjust box bounds, taken from VMD's source for reading lammps files double xdelta = Math.Min(0, xy); xdelta = Math.Min(xdelta, xz); xdelta = Math.Min(xdelta, xy + xz); xlo = xlo - xdelta; xdelta = Math.Max(0, xy); xdelta = Math.Max(xdelta, xz); xdelta = Math.Max(xdelta, xy + xz); xhi = xhi - xdelta; ylo = ylo - Math.Min(0, yz); yhi = yhi - Math.Max(0, yz); double[] A = new double[] { xhi - xlo, 0, 0 }; double[] B = new double[] { xy, yhi - ylo, 0 }; double[] C = new double[] { xz, yz, zhi - zlo }; volume = StarMath.dotProduct(A, StarMath.crossProduct(B, C)); foundMatrix = true; } } while (!foundMatrix); return(volume); } }