From: <ha...@us...> - 2007-11-03 03:57:16
|
Revision: 8558 http://jmol.svn.sourceforge.net/jmol/?rev=8558&view=rev Author: hansonr Date: 2007-11-02 20:56:59 -0700 (Fri, 02 Nov 2007) Log Message: ----------- version=11.3.40 VERSION # new feature: Ramachandran/Model commands switch between plot and model # -- one Ramachandran plot per model # -- axes labels and special hover label for Ramachandran plots # -- Ramachandran saved in state Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/Atom.java trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/modelset/Bond.java trunk/Jmol/src/org/jmol/modelset/Model.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/modelset/ModelLoader.java trunk/Jmol/src/org/jmol/modelset/ModelSet.java trunk/Jmol/src/org/jmol/modelsetbio/AlphaMonomer.java trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java trunk/Jmol/src/org/jmol/shape/HoverRenderer.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/RepaintManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Atom.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/Atom.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -826,15 +826,19 @@ */ public String getInfo() { - return getIdentity(); - } + return getIdentity(true); + } String getInfoXYZ(boolean withScreens) { - return getIdentity() + " " + x + " " + y + " " + z + return getIdentity(true) + " " + x + " " + y + " " + z + (withScreens ? " ### " + screenX + " " + screenY + " " + screenZ : ""); } - public String getIdentity() { + private String getIdentityXYZ() { + return getIdentity(false) + " " + x + " " + y + " " + z; + } + + private String getIdentity(boolean allInfo) { StringBuffer info = new StringBuffer(); String group3 = getGroup3(); String seqcodeString = getSeqcodeString(); @@ -850,6 +854,8 @@ info.append(":"); info.append(chainID); } + if (!allInfo) + return info.toString(); String atomName = getAtomNameOrNull(); if (atomName != null) { if (info.length() > 0) @@ -1124,6 +1130,7 @@ case 'D': atom inDex (was "X") case 'e': element symbol case 'E': insErtion code + case 'f': phi case 'g': selected group index (for testing) case 'i': atom number case 'I': Ionic radius @@ -1134,6 +1141,7 @@ case 'n': group3 case 'N': molecule Number case 'o': symmetry operator set + case 'p': psi case 'P': Partial charge case 'q': occupancy 0-100% case 'Q': occupancy 0.00 - 1.00 @@ -1148,6 +1156,7 @@ case 'V': van der Waals case 'x': x coord case 'X': fractional X coord + case 'W': identity - with X,Y,Z case 'y': y coord case 'Y': fractional Y coord case 'z': z coord @@ -1221,6 +1230,12 @@ case 'P': floatT = getPartialCharge(); break; + case 'f': + floatT = getGroupPhi(); + break; + case 'p': + floatT = getGroupPsi(); + break; case 'v': ch = (ich < strFormat.length() ? strFormat.charAt(ich++) : '\0'); switch (ch) { @@ -1285,8 +1300,11 @@ strT = "" + getResno(); break; case 'U': - strT = getIdentity(); + strT = getIdentity(true); break; + case 'W': + strT = getIdentityXYZ(); + break; case 'u': floatT = getSurfaceDistance100() / 100f; break; Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -434,7 +434,7 @@ float d = points[j].distance(atom) - envelopeRadius; if (d < 0 && Logger.isActiveLevel(Logger.LEVEL_DEBUG)) Logger.debug("draw d" + j + " " + Escape.escape(points[j]) - + " \"" + d + " ? " + atom.getIdentity() + "\""); + + " \"" + d + " ? " + atom.getInfo() + "\""); dMin = Math.min(d, dMin); } int d = surfaceDistance100s[i] = (int) (dMin * 100); @@ -789,7 +789,7 @@ for (int i = 0; i < atomCount; i++) if (t.get(i)) { s.append(i + 1).append(" ").append(atoms[i].getElementSymbol()) - .append(" ").append(atoms[i].getIdentity().replace(' ', '_')).append(" "); + .append(" ").append(atoms[i].getInfo().replace(' ', '_')).append(" "); switch (type) { case TAINT_COORD: dataLabel = "coord set"; @@ -1170,7 +1170,7 @@ z.normalize(); if (Logger.isActiveLevel(Logger.LEVEL_DEBUG)) { - Logger.debug(atom.getIdentity() + " nBonds=" + nBonds + " " + hybridization); + Logger.debug(atom.getInfo() + " nBonds=" + nBonds + " " + hybridization); } if (hybridizationCompatible) { if (hybridization == "") Modified: trunk/Jmol/src/org/jmol/modelset/Bond.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Bond.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/Bond.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -96,8 +96,8 @@ } public String getIdentity() { - return (index + 1) + " "+ order + " " + atom1.getIdentity() + " -- " - + atom2.getIdentity(); + return (index + 1) + " "+ order + " " + atom1.getInfo() + " -- " + + atom2.getInfo(); } public String formatLabel(String strFormat, int[] indices) { Modified: trunk/Jmol/src/org/jmol/modelset/Model.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Model.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/Model.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -81,19 +81,15 @@ int moleculeCount; int nAltLocs; int nInsertions; + int ramachandranFrame; + int quaternionFrame = -1; + int dataSourceFrame = -1; + boolean isPDB = false; String jmolData; // from a PDB remark "Jmol PDB-encoded data" String jmolDataType; - boolean isJmolDataFrame() { - return (jmolData != null); - } - - String getJmolDataFrameType() { - return jmolDataType; - } - private int chainCount = 0; private Chain[] chains = new Chain[8]; private int bioPolymerCount = 0; Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -45,6 +45,7 @@ import org.jmol.util.Escape; import org.jmol.util.Logger; import org.jmol.util.Parser; +import org.jmol.util.TextFormat; import org.jmol.viewer.JmolConstants; import org.jmol.viewer.Token; @@ -651,22 +652,21 @@ /* ONLY from one model * */ - private String getPdbData(String type, char ctype, BitSet bsAtoms, + private String getPdbData(String type, char ctype, int modelIndex, boolean isDerivative) { - StringBuffer pdbATOM = new StringBuffer(); StringBuffer pdbCONECT = new StringBuffer(); - int firstAtom = BitSetUtil.firstSetBit(bsAtoms); - if (firstAtom < 0) - return null; - int modelIndex = atoms[firstAtom].modelIndex; if (isJmolDataFrame(modelIndex)) - return null; + modelIndex = viewer.getJmolDataSourceFrame(modelIndex); + if (modelIndex < 0) + return ""; int nPoly = models[modelIndex].getBioPolymerCount(); + StringBuffer pdbATOM = new StringBuffer(); + BitSet bsAtoms = getModelAtomBitSet(modelIndex); for (int p = 0; p < nPoly; p++) models[modelIndex].getPdbData(ctype, isDerivative, bsAtoms, pdbATOM, pdbCONECT); pdbATOM.append(pdbCONECT); - return pdbATOM.toString(); + return getProteinStructureState(bsAtoms) + pdbATOM.toString(); } /* ********************** @@ -675,13 +675,13 @@ * *****************************/ - public String getPdbData(String type, BitSet bsAtoms) { + public String getPdbData(int modelIndex, String type) { char ctype = (type.length() > 11 && type.indexOf("quaternion ") >= 0 ? type .charAt(11) : 'r'); - String s = getPdbData(type, ctype, bsAtoms, (type.indexOf(" deriv") >= 0)); - if (s == null) - return null; - String remark = "REMARK 999 Jmol PDB-encoded data: " + type + String s = getPdbData(type, ctype, modelIndex, (type.indexOf(" deriv") >= 0)); + if (s.length() == 0) + return ""; + String remark = "REMARK 6 Jmol PDB-encoded data: " + type + " data(x,y,z,charge)="; switch (ctype) { case 'w': @@ -721,28 +721,31 @@ } public boolean isJmolDataFrame(int modelIndex) { - return (modelIndex >= 0 && modelIndex < modelCount && models[modelIndex] - .isJmolDataFrame()); + return (modelIndex >= 0 && modelIndex < modelCount && models[modelIndex].jmolData != null); } - protected Hashtable htJmolData = new Hashtable(); - - public void setPtJmolDataFrame(String type, int modelIndex) { - htJmolData.put(type, new Integer(modelIndex)); + public void setJmolDataFrame(String type, int modelIndex, int modelDataIndex) { + if (type.equals("ramachandan")) + models[modelIndex].ramachandranFrame = modelDataIndex; + else + models[modelIndex].quaternionFrame = modelDataIndex; + models[modelDataIndex].dataSourceFrame = modelIndex; } - public int getPtJmolDataFrame(String type) { - Integer iModel = (Integer) htJmolData.get(type); - if (iModel == null) - return -1; - return iModel.intValue(); + public int getJmolDataFrameIndex(int modelIndex, String type) { + return (type.equals("ramachandan") ? models[modelIndex].ramachandranFrame + : models[modelIndex].quaternionFrame); } + public String getJmolDataFrameType(int modelIndex) { - return (modelIndex >= 0 && modelIndex < modelCount ? models[modelIndex] - .getJmolDataFrameType() : "modelSet"); + return (modelIndex >= 0 && modelIndex < modelCount ? models[modelIndex].jmolDataType : "modelSet"); } + public int getJmolDataSourceFrame(int modelIndex) { + return (modelIndex >= 0 && modelIndex < modelCount ? models[modelIndex].dataSourceFrame : -1); + } + private String pdbHeader; /* final static String[] pdbRecords = { "ATOM ", "HELIX ", "SHEET ", "TURN ", @@ -1397,47 +1400,109 @@ } //////////// state definition /////////// - - - protected String getProteinStructureState() { + + protected String getProteinStructureState(BitSet bsAtoms) { BitSet bs = null; StringBuffer cmd = new StringBuffer(); + StringBuffer sbTurn = new StringBuffer(); + StringBuffer sbHelix = new StringBuffer(); + StringBuffer sbSheet = new StringBuffer(); int itype = 0; int id = 0; int iLastAtom = 0; int lastId = -1; int res1 = 0; int res2 = 0; + String group1 = ""; + String group2 = ""; int n = 0; - for (int i = 0; i <= atomCount; i++) { - id = Integer.MIN_VALUE; - if (i == atomCount - || (id = atoms[i].getProteinStructureID()) != lastId) { - if (bs != null) { - n++; - cmd.append(" structure ") - .append(JmolConstants.getProteinStructureName(itype)) - .append(" ").append(Escape.escape(bs)) - .append(" \t# model=").append(getModelName(-1 - atoms[iLastAtom].modelIndex)) - .append(" & (").append(res1).append(" - ").append(res2).append(");\n"); - bs = null; + int nHelix = 0; + int nTurn = 0; + int nSheet = 0; + for (int i = 0; i <= atomCount; i++) + if (bsAtoms == null || bsAtoms.get(i)) { + id = Integer.MIN_VALUE; + if (i == atomCount || (id = atoms[i].getProteinStructureID()) != lastId) { + if (bs != null) { + if (itype != JmolConstants.PROTEIN_STRUCTURE_HELIX + && itype != JmolConstants.PROTEIN_STRUCTURE_TURN + && itype != JmolConstants.PROTEIN_STRUCTURE_SHEET) { + bs = null; + continue; + } + n++; + if (bsAtoms == null) { + cmd.append(" structure ").append( + JmolConstants.getProteinStructureName(itype)).append(" ") + .append(Escape.escape(bs)).append(" \t# model=").append( + getModelName(-1 - atoms[iLastAtom].modelIndex)).append( + " & (").append(res1).append(" - ").append(res2).append( + ");\n"); + } else { + String str; + int nx; + String sid; + StringBuffer sb; + switch (itype) { + case JmolConstants.PROTEIN_STRUCTURE_HELIX: + nx = ++nHelix; + sid = "H" + nx; + str = "HELIX %3N %3ID %3GROUPA %4RESA %3GROUPB %4RESB\n"; + sb = sbHelix; + break; + case JmolConstants.PROTEIN_STRUCTURE_SHEET: + nx = ++nSheet; + sid = "S" + nx; + str = "SHEET %3N %3ID 2 %3GROUPA %4RESA %3GROUPB %4RESB\n"; + sb = sbSheet; + break; + case JmolConstants.PROTEIN_STRUCTURE_TURN: + default: + nx = ++nTurn; + sid = "T" + nx; + str = "TURN %3N %3ID %3GROUPA %4RESA %3GROUPB %4RESB\n"; + sb = sbTurn; + break; + } + str = TextFormat.formatString(str, "N", nx); + str = TextFormat.formatString(str, "ID", sid); + str = TextFormat.formatString(str, "GROUPA", group1); + str = TextFormat.formatString(str, "RESA", res1); + str = TextFormat.formatString(str, "GROUPB", group2); + str = TextFormat.formatString(str, "RESB", res2); + sb.append(str); + + /* + HELIX 1 H1 ILE 7 PRO 19 1 3/10 CONFORMATION RES 17,19 1CRN 55 + HELIX 2 H2 GLU 23 THR 30 1 DISTORTED 3/10 AT RES 30 1CRN 56 + SHEET 1 S1 2 THR 1 CYS 4 0 1CRNA 4 + SHEET 2 S1 2 CYS 32 ILE 35 -1 1CRN 58 + TURN 1 T1 PRO 41 TYR 44 1CRN 59 + */ + } + bs = null; + } + if (id == Integer.MIN_VALUE || + bsAtoms != null + && (Float.isNaN(atoms[i].getGroupPhi()) || Float.isNaN(atoms[i].getGroupPsi()))) + continue; + res1 = atoms[i].getResno(); + group1 = atoms[i].getGroup3(); } - if (id == Integer.MIN_VALUE) - continue; - res1 = atoms[i].getResno(); + if (bs == null) { + bs = new BitSet(); + } + itype = atoms[i].getProteinStructureType(); + bs.set(i); + lastId = id; + res2 = atoms[i].getResno(); + group2 = atoms[i].getGroup3(); + iLastAtom = i; } - if (bs == null) { - bs = new BitSet(); - } - itype = atoms[i].getProteinStructureType(); - bs.set(i); - lastId = id; - res2 = atoms[i].getResno(); - iLastAtom = i; - } if (n > 0) cmd.append("\n"); - return cmd.toString(); + return (bsAtoms == null ? cmd.toString() : sbHelix.append(sbSheet).append( + sbTurn).append(cmd).toString()); } public String getModelInfoAsString() { Modified: trunk/Jmol/src/org/jmol/modelset/ModelLoader.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -128,7 +128,6 @@ someModelsHaveUnitcells |= mergeModelSet.getModelSetAuxiliaryInfoBoolean("someModelsHaveUnitcells"); someModelsHaveFractionalCoordinates |= mergeModelSet.getModelSetAuxiliaryInfoBoolean("someModelsHaveFractionalCoordinates"); someModelsHaveAromaticBonds |= mergeModelSet.someModelsHaveAromaticBonds; - htJmolData = mergeModelSet.htJmolData; } initializeBuild(nAtoms); } Modified: trunk/Jmol/src/org/jmol/modelset/ModelSet.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelset/ModelSet.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -378,12 +378,13 @@ private Vector stateScripts = new Vector(); private int thisStateModel = 0; - public void addStateScript(String script) { + public void addStateScript(String script, boolean addFrameNumber) { int iModel = viewer.getCurrentModelIndex(); if (thisStateModel != iModel) { thisStateModel = iModel; - script = "frame " + (iModel < 0 ? "" + iModel : getModelName(-1 - iModel)) - + ";\n" + script; + if (addFrameNumber) + script = " frame " + (iModel < 0 ? "" + iModel : getModelName(-1 - iModel)) + + ";\n" + script; } stateScripts.addElement(script); } @@ -422,7 +423,7 @@ setModelVisibility(); - commands.append(getProteinStructureState()); + commands.append(getProteinStructureState(null)); for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) { Shape shape = shapes[i]; Modified: trunk/Jmol/src/org/jmol/modelsetbio/AlphaMonomer.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/AlphaMonomer.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelsetbio/AlphaMonomer.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -101,7 +101,7 @@ setStructure(new Helix((AlphaPolymer) bioPolymer, monomerIndex, 1)); break; case JmolConstants.PROTEIN_STRUCTURE_SHEET: - setStructure(new Sheet((AminoPolymer) bioPolymer, monomerIndex, 1)); + setStructure(new Sheet((AlphaPolymer) bioPolymer, monomerIndex, 1)); break; case JmolConstants.PROTEIN_STRUCTURE_TURN: setStructure(new Turn((AlphaPolymer) bioPolymer, monomerIndex, 1)); Modified: trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -548,7 +548,17 @@ Monomer monomer = p.monomers[m]; if (bsAtoms.get(monomer.getLeadAtomIndex())) { Atom a = monomer.getLeadAtom(); - if (ctype != 'r') { + if (isRamachandran) { + x = monomer.getPhi(); + y = monomer.getPsi(); + z = monomer.getOmega(); + if (z < -90) + z += 360; + z -= 180; + if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) + continue; + w = a.getPartialCharge(); + } else { Quaternion q = a.getQuaternion(); if (q == null) { qlast = null; @@ -594,16 +604,6 @@ w = q.q1; break; } - } else { - x = monomer.getPhi(); - y = monomer.getPsi(); - z = monomer.getOmega(); - if (z < -90) - z += 360; - z -= 180; - if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) - continue; - w = a.getPartialCharge(); } pdbATOM.append(a.formatLabel("ATOM %5i %-3a%1A%3n %1c%4R%1E ")); pdbATOM.append(TextFormat.formatString("%8.3x", "x", x * factor)); Modified: trunk/Jmol/src/org/jmol/shape/HoverRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/HoverRenderer.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/shape/HoverRenderer.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -36,7 +36,7 @@ String label = (hover.atomFormats != null && hover.atomFormats[hover.atomIndex] != null ? atom.formatLabel(hover.atomFormats[hover.atomIndex]) - : hover.labelFormat != null ? atom.formatLabel(hover.labelFormat) + : hover.labelFormat != null ? atom.formatLabel(fixLabel(atom, hover.labelFormat)) : null); if (label == null) return; @@ -52,4 +52,11 @@ text.render(g3d, antialias); } } + + String fixLabel(Atom atom, String label) { + if (label == null) + return null; + return (viewer.isJmolDataFrame(atom.getModelIndex()) + && label.equals("%U") ?"%W" : label); + } } Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -915,7 +915,7 @@ if (mesh.diameter > 0) str.append(" diameter ").append(mesh.diameter); int nVertices = mesh.drawVertexCount > 0 ? mesh.drawVertexCount - : mesh.drawVertexCounts[0]; + : mesh.drawVertexCounts[iModel >= 0 ? iModel : 0]; switch (mesh.drawTypes == null ? mesh.drawType : mesh.drawTypes[iModel]) { case JmolConstants.DRAW_ARROW: str.append(" ARROW"); @@ -936,6 +936,8 @@ if (mesh.modelIndex < 0 && !mesh.isFixed) { for (int i = 0; i < modelCount; i++) if (isPolygonDisplayable(mesh, i)) { + if (nVertices == 0) + nVertices = mesh.drawVertexCounts[i]; str.append(" [ " + i); str.append(getVertexList(mesh, i, nVertices)); str.append(" ] "); @@ -952,7 +954,9 @@ } static boolean isPolygonDisplayable(Mesh mesh, int i) { - return (mesh.polygonIndexes[i] != null && mesh.polygonIndexes[i].length > 0); + return (i < mesh.polygonIndexes.length + && mesh.polygonIndexes[i] != null + && mesh.polygonIndexes[i].length > 0); } private static String getVertexList(Mesh mesh, int iModel, int nVertices) { Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -3871,7 +3871,7 @@ for (int i = statementLength; --i >= 0;) code[i] = statement[i]; variables.put("!" + variable.substring(8), code); - viewer.addStateScript(thisCommand); + viewer.addStateScript(thisCommand, false); } else { assignBitsetVariable(variable, bs); } @@ -4162,49 +4162,45 @@ } if (isSyntaxCheck) //just in case we later add parameter options to this return; - BitSet bs = viewer.getSelectedAtoms(); - int firstAtom = BitSetUtil.firstSetBit(bs); - if (firstAtom < 0) - return; //for now, just one frame visible - int modelIndex = viewer.getAtomModelIndex(firstAtom); - int ptDataFrame = viewer.getPtJmolDataFrame(type + ":" + modelIndex); + int modelIndex = viewer.getCurrentModelIndex(); + if (modelIndex < 0) + multipleModelsNotOK(type); + int ptDataFrame = viewer.getJmolDataFrameIndex(modelIndex, type); if (ptDataFrame > 0) { - viewer.setCurrentModelIndex(-1); - BitSet bs2 = viewer.getModelAtomBitSet(ptDataFrame); - bs2.and(bs); + // data frame can't be 0. + viewer.setCurrentModelIndex(ptDataFrame, true); +// BitSet bs2 = viewer.getModelAtomBitSet(ptDataFrame); + // bs2.and(bs); //need to be able to set data directly as well. - viewer.display(BitSetUtil.setAll(viewer.getAtomCount()), bs2, tQuiet); + // viewer.display(BitSetUtil.setAll(viewer.getAtomCount()), bs2, tQuiet); return; } + String script; switch (datatype) { case JmolConstants.JMOL_DATA_RAMACHANDRAN: - loadPdbDataWithScript(modelIndex, - type, - "frame 0.0; frame last; reset; center {0 0 0};zoomTo 0 (visible) 0;" - + "select visible; color structure; select *;" - + "draw ramaAxisX%N% {-10 0 0} {10 0 0};draw ramaAxisY%N% {0 -10 0} {0 10 0};"); + default: + script = "frame 0.0; frame last; reset; center {0 0 0};" + + "select visible; color structure; select *;" + + "draw ramaAxisX%N% {20 0 0} {-20 0 0} \"phi\";" + + "draw ramaAxisY%N% {0 20 0} {0 -20 0} \"psi\";"; break; - case JmolConstants.JMOL_DATA_QUATERNION: - loadPdbDataWithScript(modelIndex, - type, - "frame 0.0; frame last; reset; center {0 0 0};zoomTo 0 (visible) 0;" - + "select visible; trace 0.1; color trace structure; select *;" - + "isosurface quatSphere%N% resolution 1.0 sphere 10.0 mesh nofill translucent 0.8;"); + case JmolConstants.JMOL_DATA_QUATERNION: + script = "frame 0.0; frame last; reset; center {0 0 0};" + + "select visible; trace 0.1; color trace structure; select *;" + + "isosurface quatSphere%N% resolution 1.0 sphere 10.0 mesh nofill translucent 0.8;"; break; } - } - - private void loadPdbDataWithScript(int modelIndex, String type, String script) - throws ScriptException { String[] savedFileInfo = viewer.getFileInfo(); - boolean isOK = viewer.loadInline(viewer.getPdbData(type), '\n', true); + boolean isOK = viewer.loadInline(viewer.getPdbData(modelIndex, type), '\n', true); viewer.setFileInfo(savedFileInfo); if (!isOK) return; int modelCount = viewer.getModelCount(); runScript(TextFormat.simpleReplace(script, "%N%", "" + modelCount)); - viewer.setPtJmolDataFrame(type, modelIndex); + viewer.setJmolDataFrame(type, modelIndex, modelCount - 1); + viewer.addStateScript("frame " + viewer.getModelNumberDotted(modelIndex) + + "; " + type + ";", false); showString("frame " + viewer.getModelName(-modelCount) + " created: " + type); } @@ -5443,15 +5439,16 @@ if (statementLength == 1) { bsConfigurations = viewer.setConformation(); viewer - .addStateScript("select " + Escape.escape(viewer.getSelectionSet())); - viewer.addStateScript("configuration;"); + .addStateScript("select " + + Escape.escape(viewer.getSelectionSet()) + + "; configuration;", true); } else { checkLength2(); if (isSyntaxCheck) return; int n = intParameter(1); bsConfigurations = viewer.setConformation(n - 1); - viewer.addStateScript("configuration " + n + ";"); + viewer.addStateScript("configuration " + n + ";", true); } if (isSyntaxCheck) return; @@ -5718,7 +5715,7 @@ case Token.surface: viewer.calculateSurface(null, null, -1); if (!isSyntaxCheck) - viewer.addStateScript(thisCommand); + viewer.addStateScript(thisCommand, true); return; case Token.identifier: if (parameterAsString(1).equalsIgnoreCase("AROMATIC")) { @@ -5900,6 +5897,13 @@ boolean useModelNumber = true; // for now -- as before -- remove to implement // frame/model difference + if (statementLength == 1 && !isTrajectory && offset == 1) { + int modelIndex = viewer.getCurrentModelIndex(); + if (!isSyntaxCheck && modelIndex >= 0 + && (modelIndex = viewer.getJmolDataSourceFrame(modelIndex)) >= 0) + viewer.setCurrentModelIndex(modelIndex, true); + return; + } if (getToken(offset).tok == Token.minus) { ++offset; checkStatementLength(offset + 1); @@ -5915,6 +5919,7 @@ boolean isHyphen = false; int[] frameList = new int[] { -1, -1 }; int nFrames = 0; + for (int i = offset; i < statementLength; i++) { switch (getToken(i).tok) { case Token.all: @@ -6814,7 +6819,7 @@ String str = label; if (isAtoms) { if (str == null) { - str = modelSet.getAtomAt(j).getIdentity(); + str = modelSet.getAtomAt(j).getInfo(); } else { str = modelSet.getAtomAt(j).formatLabel(str, '\0', indices); for (int k = 0; k < nProp; k++) @@ -7975,7 +7980,10 @@ } else if (data == "PDB" || data == "XYZ" || data == "MOL") { data = viewer.getData("selected", data); } else if (data == "QUAT" || data == "RAMA") { - data = viewer.getPdbData(type2); + int modelIndex = viewer.getCurrentModelIndex(); + if (modelIndex < 0) + multipleModelsNotOK("write " + type2); + data = viewer.getPdbData(modelIndex, type2); } else if (data == "FUNCS") { data = getFunctionCalls(""); } else if (data == "FILE") { @@ -8092,13 +8100,15 @@ str = "scaleAngstromsPerInch"; break; case Token.quaternion: + case Token.ramachandran: if (isSyntaxCheck) return; - msg = viewer.getPdbData("quaternion w"); + int modelIndex = viewer.getCurrentModelIndex(); + if (modelIndex < 0) + multipleModelsNotOK("show " + theToken.value); + msg = viewer.getPdbData(modelIndex, + theTok == Token.quaternion ? "quaternion w" : "ramachandran"); break; - case Token.ramachandran: - msg = viewer.getPdbData("ramachandran"); - break; case Token.identifier: if (str.equalsIgnoreCase("historyLevel")) { value = "" + commandHistoryLevelMax; @@ -8389,7 +8399,7 @@ viewer.loadShape(JmolConstants.SHAPE_MO); int modelIndex = viewer.getDisplayModelIndex(); if (modelIndex < 0) - multipleModelsNotOK(); + multipleModelsNotOK("MO isosurfaces"); Hashtable moData = (Hashtable) viewer.getModelAuxiliaryInfo(modelIndex, "moData"); if (moData == null) @@ -9038,7 +9048,7 @@ int modelIndex = viewer.getDisplayModelIndex(); int offset = Integer.MAX_VALUE; if (!isSyntaxCheck && modelIndex < 0) - multipleModelsNotOK(); + multipleModelsNotOK("MO isosurfaces"); viewer.loadShape(JmolConstants.SHAPE_MO); if (tokAt(1) == Token.list && listIsosurface(JmolConstants.SHAPE_MO)) return true; @@ -9193,7 +9203,7 @@ if (modelIndex == 0) modelIndex = viewer.getDisplayModelIndex(); if (modelIndex < 0) - multipleModelsNotOK(); + multipleModelsNotOK("MO isosurfaces"); Hashtable moData = (Hashtable) viewer.getModelAuxiliaryInfo(modelIndex, "jmolSurfaceInfo"); if (moData != null && ((String) moData.get("surfaceDataType")).equals("mo")) { @@ -9908,8 +9918,8 @@ // new ScriptException(message); // } - private void multipleModelsNotOK() throws ScriptException { - evalError(GT._("MO isosurfaces require that only one model be displayed")); + private void multipleModelsNotOK(String what) throws ScriptException { + evalError(GT._("{0} require that only one model be displayed", what)); } private void unrecognizedCommand() throws ScriptException { @@ -11085,15 +11095,12 @@ private boolean evaluateLabel(Token[] args) throws ScriptException { Token x1 = getX(); - if (args.length != 1) + String format = (args.length == 0 ? "%U" : Token.sValue(args[0])); + if (args.length > 1 || x1.tok != Token.bitset) return false; if (isSyntaxCheck) return addX(""); - Token x2 = args[0]; - if (x1.tok != Token.bitset || x2.tok != Token.string) - return false; - return addX(getBitsetIdent(Token.bsSelect(x1), Token.sValue(x2), - x1.value, true)); + return addX(getBitsetIdent(Token.bsSelect(x1), format, x1.value, true)); } private boolean evaluateWithin(Token[] args) throws ScriptException { Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2007-11-03 03:56:59 UTC (rev 8558) @@ -1,5 +1,10 @@ -version=11.3.40_dev +version=11.3.40 +# new feature: Ramachandran/Model commands switch between plot and model +# -- one Ramachandran plot per model +# -- axes labels and special hover label for Ramachandran plots +# -- Ramachandran saved in state + # bug fix: Overlapping CPK at a slab now correct for up to 10.000 clipped atoms. # bug fix: @{} for within(1.0,point,@{....}) Modified: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -69,7 +69,7 @@ // leaving or entering data frame? Then restore new frame's index if (fromDataFrame || toDataFrame) { viewer.restoreOrientation(toDataFrame ? viewer.getJmolDataFrameType(modelIndex) - : "modelSet", 0); + : "modelSet", -1); } } if (modelSet == null || modelIndex < 0 Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -1636,7 +1636,8 @@ if (!Float.isNaN(navDepth)) setNavigationDepthPercent(0, navDepth); } - viewer.requestRepaintAndWait(); + if (floatSecondsTotal >= 0) + viewer.requestRepaintAndWait(); viewer.setInMotion(false); } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-11-02 19:22:22 UTC (rev 8557) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-11-03 03:56:59 UTC (rev 8558) @@ -560,7 +560,7 @@ void moveTo(float floatSecondsTotal, Matrix3f rotationMatrix, Point3f center, float zoom, float xTrans, float yTrans, float rotationRadius, Point3f navCenter, float xNav, float yNav, float navDepth) { - //from StateManager + //from StateManager -- -1 for time --> no repaint transformManager.moveTo(floatSecondsTotal, rotationMatrix, center, zoom, xTrans, yTrans, rotationRadius, navCenter, xNav, yNav, navDepth); } @@ -1704,8 +1704,8 @@ modelSet.fillAtomData(atomData, mode); } - void addStateScript(String script) { - modelSet.addStateScript(script); + void addStateScript(String script, boolean addFrameNumber) { + modelSet.addStateScript(script, addFrameNumber); } public boolean getEchoStateActive() { @@ -1833,7 +1833,7 @@ public void calculateStructures() { //Eval modelSet.calculateStructures(repaintManager.currentModelIndex); - addStateScript("calculate structure"); + addStateScript("calculate structure", true); } void clearBfactorRange() { @@ -2380,7 +2380,7 @@ int autoHbond(BitSet bsBonds) { //Eval BitSet bs = getSelectionSet(); - addStateScript("calculate hbonds"); + addStateScript("calculate hbonds", false); return autoHbond(bs, bs, bsBonds); } @@ -5726,26 +5726,30 @@ return (String) Eval.evaluateExpression(this, exp); } - String getPdbData(String type) { - return modelSet.getPdbData(type, selectionManager.bsSelection); + String getPdbData(int modelIndex, String type) { + return modelSet.getPdbData(modelIndex, type); } - boolean isJmolDataFrame(int modelIndex) { + public boolean isJmolDataFrame(int modelIndex) { return modelSet.isJmolDataFrame(modelIndex); } - int getPtJmolDataFrame(String type) { - return modelSet.getPtJmolDataFrame(type); + int getJmolDataFrameIndex(int modelIndex, String type) { + return modelSet.getJmolDataFrameIndex(modelIndex, type); } - void setPtJmolDataFrame(String type, int modelIndex) { - modelSet.setPtJmolDataFrame(type, modelIndex); + void setJmolDataFrame(String type, int modelIndex, int dataIndex) { + modelSet.setJmolDataFrame(type, modelIndex, dataIndex); } String getJmolDataFrameType(int modelIndex) { return modelSet.getJmolDataFrameType(modelIndex); } + public int getJmolDataSourceFrame(int modelIndex) { + return modelSet.getJmolDataSourceFrame(modelIndex); + } + public void setAtomCoord(int atomIndex, float x, float y, float z) { //Frame equivalent used in DATA "coord set" modelSet.setAtomCoord(atomIndex, x, y, z); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |