From: <ha...@us...> - 2010-07-01 14:41:58
|
Revision: 13494 http://jmol.svn.sourceforge.net/jmol/?rev=13494&view=rev Author: hansonr Date: 2010-07-01 14:41:51 +0000 (Thu, 01 Jul 2010) Log Message: ----------- version=12.0.RC23_dev # new feature: data map {from}.property1 {to}.property2 propertyKey # Allows mapping of property data from one set of atoms to another # based on a key such as regno or atomno. Property2 must be "settable". # For example, creating a quaternion map, then mapping that data # with straightness, and then selecting a very specific subset of # the quaternion data and using that selection to select data # in the original model: # # load 3cc2.pdb # calculate straightness # set quaternionframe "A" # quaternion r difference # display {rna} # data map {1.1 and *.P}.straightness {2.1 and rna}.property_x resno # select 2.1 and rna; color property_x;spacefill 0.1 # select 2.1 and rna and within(2.0,{1.7700001 -0.49 2.62}) # data map {2.1 and rna and selected}.selected {1.1 and *.P}.selected resno Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/LabelToken.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/Token.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/modelset/LabelToken.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/LabelToken.java 2010-06-30 21:56:33 UTC (rev 13493) +++ trunk/Jmol/src/org/jmol/modelset/LabelToken.java 2010-07-01 14:41:51 UTC (rev 13494) @@ -164,6 +164,7 @@ Token.polymer, Token.property, Token.radius, + Token.selected, Token.sequence, Token.spacefill, Token.structure, Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-06-30 21:56:33 UTC (rev 13493) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-07-01 14:41:51 UTC (rev 13494) @@ -591,10 +591,10 @@ public boolean deleteAtoms(int modelIndex, BitSet bsBonds, BitSet bsAtoms) { //false return means delete this script if (modelIndex == this.modelIndex) + return false; + if (modelIndex > this.modelIndex) { +// this.modelIndex--; return true; - if (modelIndex < this.modelIndex) { -// this.modelIndex--; - return false; } BitSetUtil.deleteBits(this.bsBonds, bsBonds); BitSetUtil.deleteBits(this.bsAtoms1, bsAtoms); @@ -2186,7 +2186,7 @@ public BitSet getAtomsWithin(float distance, Point3f coord, BitSet bsResult, int modelIndex) { - if (bsResult == null) + if (bsResult == null) bsResult = new BitSet(); if (distance < 0) { // just check all unitCell distances @@ -2204,7 +2204,7 @@ return bsResult; } - BitSet bsCheck = getIterativeModels(false); + BitSet bsCheck = getIterativeModels(true); AtomIndexIterator iter = getSelectedAtomIterator(null, false, false, false); for (int iModel = modelCount; --iModel >= 0;) { if (!bsCheck.get(iModel)) Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-06-30 21:56:33 UTC (rev 13493) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-07-01 14:41:51 UTC (rev 13494) @@ -3255,12 +3255,17 @@ case Token.opGT: case Token.opEQ: case Token.opNE: + if (pc + 1 == code.length) + error(ERROR_invalidArgument); val = code[++pc].value; int tokOperator = instruction.tok; int tokWhat = instruction.intValue; String property = (tokWhat == Token.property ? (String) val : null); - if (property != null) + if (property != null) { + if (pc + 1 == code.length) + error(ERROR_invalidArgument); val = code[++pc].value; + } if (tokWhat == Token.configuration && tokOperator != Token.opEQ) error(ERROR_invalidArgument); if (isSyntaxCheck) { @@ -7218,6 +7223,48 @@ String dataLabel = null; boolean isOneValue = false; int i; + if (tokAt(1) == Token.map) { + // {resno=x}.straightness = ({i}).straightness + // data map {1.1}.straightness {2.1}.property_x resno + BitSet bsFrom = atomExpression(2); + while (true) { + if (tokAt(++iToken) != Token.per + || !Token.tokAttr(tokAt(++iToken), Token.atomproperty)) + break; + String property1 = parameterAsString(iToken); + BitSet bsTo = atomExpression(++iToken); + if (tokAt(++iToken) != Token.per + || !Token.tokAttr(tokAt(++iToken), Token.settable)) + break; + String property2 = parameterAsString(iToken); + if (!Token.tokAttr(tokAt(++iToken), Token.atomproperty)) + break; + String mapKey = parameterAsString(iToken); + + if (isSyntaxCheck) + return; + String format = "{" + mapKey + "=%[" + mapKey + "]}." + property2 + + " = %[" + property1 + "]"; + String[] data = (String[]) getBitsetIdent(bsFrom, format, null, false, + Integer.MAX_VALUE, false); + StringBuffer sb = new StringBuffer(); + for (i = 0; i < data.length; i++) + if (data[i].indexOf("null") < 0) + sb.append(data[i]).append('\n'); + if (Logger.debugging) + Logger.info(sb.toString()); + BitSet bsSubset = BitSetUtil.copy(viewer.getSelectionSubset()); + viewer.setSelectionSubset(bsTo); + try { + runScript(sb.toString()); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + viewer.setSelectionSubset(bsSubset); + return; + } + error(ERROR_invalidArgument); + } switch (iToken = statementLength) { case 5: // parameters 3 and 4 are just for the ride: [end] and ["key"] @@ -7945,6 +7992,7 @@ boolean isRamachandranRelative = false; String stateScript = ""; int pt = statementLength - 1; + String qFrame = ""; String type = optParameterAsString(pt).toLowerCase(); switch (datatype) { case JmolConstants.JMOL_DATA_RAMACHANDRAN: @@ -7957,7 +8005,8 @@ + (isDraw ? " draw" : ""); break; case JmolConstants.JMOL_DATA_QUATERNION: - stateScript = "set quaternionFrame " + Escape.escape("" + viewer.getQuaternionFrame()) + ";\n "; + qFrame = " \"" + viewer.getQuaternionFrame() + "\""; + stateScript = "set quaternionFrame" + qFrame + ";\n "; isQuaternion = true; // working backward this time: if (type.equalsIgnoreCase("draw")) { @@ -7986,6 +8035,7 @@ if (isSyntaxCheck) // just in case we later add parameter options to this return; // for now, just one frame visible + stateScript += type; int modelIndex = viewer.getCurrentModelIndex(); if (modelIndex < 0) error(ERROR_multipleModelsDisplayedNotOK, type); @@ -7994,16 +8044,16 @@ runScript(viewer.getPdbData(modelIndex, type)); return; } - int ptDataFrame = viewer.getJmolDataFrameIndex(modelIndex, type); + int ptDataFrame = viewer.getJmolDataFrameIndex(modelIndex, stateScript); if (ptDataFrame > 0) { - viewer.deleteAtoms(viewer.getModelUndeletedAtomsBitSet(ptDataFrame), true); + // no -- this is that way we switch frames. viewer.deleteAtoms(viewer.getModelUndeletedAtomsBitSet(ptDataFrame), true); // data frame can't be 0. - // viewer.setCurrentModelIndex(ptDataFrame, true); + 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); - // return; + return; } String[] savedFileInfo = viewer.getFileInfo(); boolean oldAppendNew = viewer.getAppendNew(); @@ -8014,14 +8064,14 @@ viewer.setFileInfo(savedFileInfo); if (!isOK) return; - StateScript ss = viewer.addStateScript(stateScript + type, true, false); + StateScript ss = viewer.addStateScript(stateScript, true, false); int modelCount = viewer.getModelCount(); - viewer.setJmolDataFrame(type, modelIndex, modelCount - 1); + viewer.setJmolDataFrame(stateScript, modelIndex, modelCount - 1); String script; switch (datatype) { case JmolConstants.JMOL_DATA_RAMACHANDRAN: default: - viewer.setFrameTitle(modelCount - 1, type + " plot for model " + viewer.setFrameTitle(modelCount - 1, " plot for model " + viewer.getModelNumberDotted(modelIndex)); script = "frame 0.0; frame last; reset;" + "select visible; color structure; spacefill 3.0; wireframe 0;" @@ -8032,7 +8082,8 @@ ; break; case JmolConstants.JMOL_DATA_QUATERNION: - viewer.setFrameTitle(modelCount - 1, type + " for model " + viewer.setFrameTitle(modelCount - 1, + type.replace('w', ' ') + qFrame + " for model " + viewer.getModelNumberDotted(modelIndex)); String color = (Graphics3D .getHexCode(viewer.getColixBackgroundContrast())); @@ -8053,7 +8104,7 @@ viewer.setRotationRadius(isQuaternion ? 12.5f : 260f, true); loadShape(JmolConstants.SHAPE_ECHO); showString("frame " + viewer.getModelNumberDotted(modelCount - 1) - + " created: " + type); + + " created: " + type + (isQuaternion ? qFrame : "")); } private void measure() throws ScriptException { Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2010-06-30 21:56:33 UTC (rev 13493) +++ trunk/Jmol/src/org/jmol/script/Token.java 2010-07-01 14:41:51 UTC (rev 13494) @@ -132,7 +132,7 @@ * x x shapeCommand * x noArgs * x defaultON - * xxxxxxxxxxxx uniqueID (may include math flags) + * xxxxxxxxxxx uniqueID (may include math flags) * * * math bit flags: Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-06-30 21:56:33 UTC (rev 13493) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-07-01 14:41:51 UTC (rev 13494) @@ -3,6 +3,24 @@ version=12.0.RC23_dev +# new feature: data map {from}.property1 {to}.property2 propertyKey +# Allows mapping of property data from one set of atoms to another +# based on a key such as regno or atomno. Property2 must be "settable". +# For example, creating a quaternion map, then mapping that data +# with straightness, and then selecting a very specific subset of +# the quaternion data and using that selection to select data +# in the original model: +# +# load 3cc2.pdb +# calculate straightness +# set quaternionframe "A" +# quaternion r difference +# display {rna} +# data map {1.1 and *.P}.straightness {2.1 and rna}.property_x resno +# select 2.1 and rna; color property_x;spacefill 0.1 +# select 2.1 and rna and within(2.0,{1.7700001 -0.49 2.62}) +# data map {2.1 and rna and selected}.selected {1.1 and *.P}.selected resno + # bug fix: state save for quaternion/ramachandran data frames fails # bug fix: Spartan reader not reading MOs when there is only one atom (AOs, that is) # -------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |