public void setIsPDB() { atomSetCollection.setGlobalBoolean(AtomSetCollection.GLOBAL_ISPDB); atomSetCollection.setAtomSetAuxiliaryInfo("isPDB", Boolean.TRUE); if (htParams.get("pdbNoHydrogens") != null) atomSetCollection.setAtomSetCollectionAuxiliaryInfo( "pdbNoHydrogens", htParams.get("pdbNoHydrogens")); }
public void setSymmetryOperator(String xyz) { if (ignoreFileSymmetryOperators) return; atomSetCollection.setLatticeCells( latticeCells, applySymmetryToBonds, doPackUnitCell, supercell); if (!atomSetCollection.addSpaceGroupOperation(xyz)) Logger.warn("Skipping symmetry operation " + xyz); iHaveSymmetryOperators = true; }
private void setError(Throwable e) { e.printStackTrace(); if (line == null) atomSetCollection.errorMessage = "Unexpected end of file after line " + --ptLine + ":\n" + prevline; else atomSetCollection.errorMessage = "Error reading file at line " + ptLine + ":\n" + line + "\n" + e.getMessage(); }
private Object finish() { String s = (String) htParams.get("loadState"); atomSetCollection.setAtomSetCollectionAuxiliaryInfo("loadState", s == null ? "" : s); s = (String) htParams.get("smilesString"); if (s != null) atomSetCollection.setAtomSetCollectionAuxiliaryInfo("smilesString", s); if (!htParams.containsKey("templateAtomCount")) htParams.put("templateAtomCount", Integer.valueOf(atomSetCollection.getAtomCount())); if (htParams.containsKey("bsFilter")) htParams.put( "filteredAtomCount", Integer.valueOf(BitSetUtil.cardinalityOf((BitSet) htParams.get("bsFilter")))); if (!calculationType.equals("?")) atomSetCollection.setAtomSetCollectionAuxiliaryInfo("calculationType", calculationType); String name = atomSetCollection.getFileTypeName(); String fileType = name; if (fileType.indexOf("(") >= 0) fileType = fileType.substring(0, fileType.indexOf("(")); for (int i = atomSetCollection.getAtomSetCount(); --i >= 0; ) { atomSetCollection.setAtomSetAuxiliaryInfo("fileName", filePath, i); atomSetCollection.setAtomSetAuxiliaryInfo("fileType", fileType, i); } atomSetCollection.freeze(reverseModels); if (atomSetCollection.errorMessage != null) return atomSetCollection.errorMessage + "\nfor file " + filePath + "\ntype " + name; if ((atomSetCollection.bsAtoms == null ? atomSetCollection.getAtomCount() : atomSetCollection.bsAtoms.cardinality()) == 0 && fileType.indexOf("DataOnly") < 0) return "No atoms found\nfor file " + filePath + "\ntype " + name; return atomSetCollection; }
protected int cloneLastAtomSet(int atomCount, Point3f[] pts) throws Exception { int lastAtomCount = atomSetCollection.getLastAtomSetAtomCount(); atomSetCollection.cloneLastAtomSet(atomCount, pts); if (atomSetCollection.haveUnitCell) { iHaveUnitCell = true; doCheckUnitCell = true; spaceGroup = previousSpaceGroup; notionalUnitCell = previousUnitCell; } return lastAtomCount; }
@SuppressWarnings("unchecked") public void setMOData(Map<String, Object> moData) { atomSetCollection.setAtomSetAuxiliaryInfo("moData", moData); if (moData == null) return; List<Map<String, Object>> orbitals = (List<Map<String, Object>>) moData.get("mos"); if (orbitals != null) Logger.info( orbitals.size() + " molecular orbitals read in model " + atomSetCollection.getAtomSetCount()); }
protected void addSiteScript(String script) { if (siteScript == null) siteScript = ""; else if (!siteScript.endsWith(";")) siteScript += ";"; siteScript += script; atomSetCollection.setAtomSetCollectionAuxiliaryInfo( "sitescript", siteScript); // checked in ScriptEvaluator.load() }
protected void addJmolScript(String script) { Logger.info("#jmolScript: " + script); if (previousScript == null) previousScript = ""; else if (!previousScript.endsWith(";")) previousScript += ";"; previousScript += script; atomSetCollection.setAtomSetCollectionAuxiliaryInfo("jmolscript", previousScript); }
/** * @param atom * @param iAtom * @return true if we want this atom */ protected boolean filterAtom(Atom atom, int iAtom) { if (!haveAtomFilter) return true; // cif, mdtop, pdb, gromacs, pqr boolean isOK = checkFilter(atom, filter1); if (filter2 != null) isOK |= checkFilter(atom, filter2); if (isOK && filterEveryNth) isOK = (((nFiltered++) % filterN) == 0); bsFilter.set(iAtom >= 0 ? iAtom : atomSetCollection.getAtomCount(), isOK); return isOK; }
public void setTransform( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) { if (matrixRotate != null || !doSetOrientation) return; matrixRotate = new Matrix3f(); Vector3f v = new Vector3f(); // rows in Sygress/CAChe and Spartan become columns here v.set(x1, y1, z1); v.normalize(); matrixRotate.setColumn(0, v); v.set(x2, y2, z2); v.normalize(); matrixRotate.setColumn(1, v); v.set(x3, y3, z3); v.normalize(); matrixRotate.setColumn(2, v); atomSetCollection.setAtomSetCollectionAuxiliaryInfo( "defaultOrientationMatrix", new Matrix3f(matrixRotate)); // first two matrix column vectors define quaternion X and XY plane Quaternion q = new Quaternion(matrixRotate); atomSetCollection.setAtomSetCollectionAuxiliaryInfo("defaultOrientationQuaternion", q); Logger.info("defaultOrientationMatrix = " + matrixRotate); }
protected void newAtomSet(String name) { if (atomSetCollection.getCurrentAtomSetIndex() >= 0) { atomSetCollection.newAtomSet(); atomSetCollection.setCollectionName( "<collection of " + (atomSetCollection.getCurrentAtomSetIndex() + 1) + " models>"); } else { atomSetCollection.setCollectionName(name); } atomSetCollection.setAtomSetAuxiliaryInfo( "name", name, Math.max(0, atomSetCollection.getCurrentAtomSetIndex())); }
protected void addSites(Map<String, Map<String, Object>> htSites) { atomSetCollection.setAtomSetAuxiliaryInfo("pdbSites", htSites); String sites = ""; for (Map.Entry<String, Map<String, Object>> entry : htSites.entrySet()) { String name = entry.getKey(); Map<String, Object> htSite = entry.getValue(); char ch; for (int i = name.length(); --i >= 0; ) if (!Character.isLetterOrDigit(ch = name.charAt(i)) && ch != '\'') name = name.substring(0, i) + "_" + name.substring(i + 1); // String seqNum = (String) htSite.get("seqNum"); String groups = (String) htSite.get("groups"); if (groups.length() == 0) continue; addSiteScript("@site_" + name + " " + groups); // addJmolScript("@" + seqNum + " " + groups); addSiteScript("site_" + name + " = \"" + groups + "\".split(\",\")"); sites += (sites == "" ? "" : ",") + "site_" + name; } addSiteScript("site_list = \"" + sites + "\".split(\",\")"); }
/** * Extracts a block of frequency data from a file. This block may be of two types -- either X Y Z * across a row or each of X Y Z on a separate line. Data is presumed to be in fixed FORTRAN-like * column format, not space-separated columns. * * @param iAtom0 the first atom to be assigned a frequency * @param atomCount the number of atoms to be assigned * @param modelAtomCount the number of atoms in each model * @param ignore the frequencies to ignore because the user has selected only certain vibrations * to be read or for whatever reason; length serves to set the number of frequencies to be * read * @param isWide when TRUE, this is a table that has X Y Z for each mode within the same row; when * FALSE, this is a table that has X Y Z for each mode on a separate line. * @param col0 the column in which data starts * @param colWidth the width of the data columns * @param atomIndexes an array either null or indicating exactly which atoms get the frequencies * (used by CrystalReader) * @param minLineLen * @param minlineLen TODO * @throws Exception */ protected void fillFrequencyData( int iAtom0, int atomCount, int modelAtomCount, boolean[] ignore, boolean isWide, int col0, int colWidth, int[] atomIndexes, int minLineLen) throws Exception { boolean withSymmetry = (modelAtomCount != atomCount); if (atomIndexes != null) atomCount = atomIndexes.length; int nLines = (isWide ? atomCount : atomCount * 3); int nFreq = ignore.length; String[][] data = new String[nLines][]; fillDataBlock(data, col0, colWidth, minLineLen); for (int i = 0, atomPt = 0; i < nLines; i++, atomPt++) { String[] values = data[i]; String[] valuesY = (isWide ? null : data[++i]); String[] valuesZ = (isWide ? null : data[++i]); int dataPt = values.length - (isWide ? nFreq * 3 : nFreq) - 1; for (int j = 0, jj = 0; jj < nFreq; jj++) { ++dataPt; String x = values[dataPt]; if (x.charAt(0) == ')') // AMPAC reader! x = x.substring(1); float vx = parseFloat(x); float vy = parseFloat(isWide ? values[++dataPt] : valuesY[dataPt]); float vz = parseFloat(isWide ? values[++dataPt] : valuesZ[dataPt]); if (ignore[jj]) continue; int iAtom = (atomIndexes == null ? atomPt : atomIndexes[atomPt]); if (iAtom < 0) continue; if (Logger.debugging) Logger.debug("atom " + iAtom + " vib" + j + ": " + vx + " " + vy + " " + vz); atomSetCollection.addVibrationVector( iAtom0 + modelAtomCount * j++ + iAtom, vx, vy, vz, withSymmetry); } } }
public boolean doGetModel(int modelNumber, String title) { if (title != null && nameRequired != null && nameRequired.length() > 0 && title.toUpperCase().indexOf(nameRequired) < 0) return false; // modelNumber is 1-based, but firstLastStep is 0-based boolean isOK = (bsModels == null ? desiredModelNumber < 1 || modelNumber == desiredModelNumber : modelNumber > lastModelNumber ? false : modelNumber > 0 && bsModels.get(modelNumber - 1) || haveModel && firstLastStep != null && firstLastStep[1] < 0 && (firstLastStep[2] < 2 || (modelNumber - 1 - firstLastStep[0]) % firstLastStep[2] == 0)); if (isOK && desiredModelNumber == 0) atomSetCollection.discardPreviousAtoms(); haveModel |= isOK; if (isOK) doProcessLines = true; return isOK; }
BondIterator(AtomSetCollection atomSetCollection) { bsAtoms = atomSetCollection.bsAtoms; bonds = atomSetCollection.getBonds(); bondCount = atomSetCollection.getBondCount(); ibond = 0; }
protected void finalizeReader() throws Exception { applySymmetryAndSetTrajectory(); if (loadNote.length() > 0) atomSetCollection.setAtomSetCollectionAuxiliaryInfo("modelLoadNote", loadNote.toString()); if (doCentralize) atomSetCollection.centralize(); }
public void applySymmetryAndSetTrajectory() throws Exception { if (iHaveUnitCell && doCheckUnitCell) { atomSetCollection.setCoordinatesAreFractional(iHaveFractionalCoordinates); atomSetCollection.setNotionalUnitCell( notionalUnitCell, matUnitCellOrientation, unitCellOffset); atomSetCollection.setAtomSetSpaceGroupName(spaceGroup); atomSetCollection.setSymmetryRange(symmetryRange); if (doConvertToFractional || fileCoordinatesAreFractional) { atomSetCollection.setLatticeCells( latticeCells, applySymmetryToBonds, doPackUnitCell, supercell); if (ignoreFileSpaceGroupName || !iHaveSymmetryOperators) { if (!merging || symmetry == null) getSymmetry(); if (symmetry.createSpaceGroup( desiredSpaceGroupIndex, (spaceGroup.indexOf("!") >= 0 ? "P1" : spaceGroup), notionalUnitCell)) { atomSetCollection.setAtomSetSpaceGroupName(symmetry.getSpaceGroupName()); atomSetCollection.applySymmetry(symmetry); } } else { atomSetCollection.applySymmetry(); } } if (iHaveFractionalCoordinates && merging && symmetry != null) { // when merging (with appendNew false), we must return cartesians atomSetCollection.toCartesian(symmetry); atomSetCollection.setCoordinatesAreFractional(false); // We no longer allow merging of multiple-model files // when the file to be appended has fractional coordinates and vibrations addVibrations = false; } } if (isTrajectory) atomSetCollection.setTrajectory(); initializeSymmetry(); }
public void checkLineForScript() { if (line.indexOf("Jmol") >= 0) { if (line.indexOf("Jmol PDB-encoded data") >= 0) { atomSetCollection.setAtomSetCollectionAuxiliaryInfo("jmolData", line); if (!line.endsWith("#noautobond")) line += "#noautobond"; } if (line.indexOf("Jmol data min") >= 0) { Logger.info(line); // The idea here is to use a line such as the following: // // REMARK 6 Jmol data min = {-1 -1 -1} max = {1 1 1} // unScaledXyz = xyz / {10 10 10} + {0 0 0} // plotScale = {100 100 100} // // to pass on to Jmol how to graph non-molecular data. // The format allows for the actual data to be linearly transformed // so that it fits into the PDB format for x, y, and z coordinates. // This adapter will then unscale the data and also pass on to // Jmol the unit cell equivalent that takes the actual data (which // will be considered the fractional coordinates) to Jmol coordinates, // which will be a cube centered at {0 0 0} and ranging from {-100 -100 -100} // to {100 100 100}. // // Jmol 12.0.RC23 uses this to pass through the adapter a quaternion, // ramachandran, or other sort of plot. float[] data = new float[15]; parseStringInfestedFloatArray( line.substring(10).replace('=', ' ').replace('{', ' ').replace('}', ' '), data); Point3f minXYZ = new Point3f(data[0], data[1], data[2]); Point3f maxXYZ = new Point3f(data[3], data[4], data[5]); fileScaling = new Point3f(data[6], data[7], data[8]); fileOffset = new Point3f(data[9], data[10], data[11]); Point3f plotScale = new Point3f(data[12], data[13], data[14]); if (plotScale.x <= 0) plotScale.x = 100; if (plotScale.y <= 0) plotScale.y = 100; if (plotScale.z <= 0) plotScale.z = 100; if (fileScaling.y == 0) fileScaling.y = 1; if (fileScaling.z == 0) fileScaling.z = 1; setFractionalCoordinates(true); latticeCells = new int[3]; atomSetCollection.setLatticeCells(latticeCells, true, false, supercell); setUnitCell( plotScale.x * 2 / (maxXYZ.x - minXYZ.x), plotScale.y * 2 / (maxXYZ.y - minXYZ.y), plotScale.z * 2 / (maxXYZ.z == minXYZ.z ? 1 : maxXYZ.z - minXYZ.z), 90, 90, 90); /* unitCellOffset = new Point3f(minXYZ); symmetry.toCartesian(unitCellOffset); System.out.println(unitCellOffset); unitCellOffset = new Point3f(maxXYZ); symmetry.toCartesian(unitCellOffset); System.out.println(unitCellOffset); */ unitCellOffset = new Point3f(plotScale); unitCellOffset.scale(-1); symmetry.toFractional(unitCellOffset, false); unitCellOffset.scaleAdd(-1f, minXYZ, unitCellOffset); symmetry.setUnitCellOffset(unitCellOffset); /* Point3f pt = new Point3f(minXYZ); symmetry.toCartesian(pt); System.out.println("ASCR minXYZ " + pt); pt.set(maxXYZ); symmetry.toCartesian(pt); System.out.println("ASCR maxXYZ " + pt); */ atomSetCollection.setAtomSetCollectionAuxiliaryInfo( "jmolDataScaling", new Point3f[] {minXYZ, maxXYZ, plotScale}); } } if (line.endsWith("#noautobond")) { line = line.substring(0, line.lastIndexOf('#')).trim(); atomSetCollection.setNoAutoBond(); } int pt = line.indexOf("jmolscript:"); if (pt >= 0) { String script = line.substring(pt + 11, line.length()); if (script.indexOf("#") >= 0) { script = script.substring(0, script.indexOf("#")); } addJmolScript(script); line = line.substring(0, pt).trim(); } }
protected void set2D() { // MOL and JME atomSetCollection.setAtomSetCollectionAuxiliaryInfo("is2D", Boolean.TRUE); if (!checkFilter("NOMIN")) atomSetCollection.setAtomSetCollectionAuxiliaryInfo("doMinimize", Boolean.TRUE); }