Package org.jmol.adapter.readers.pymol
Class PyMOLReader
java.lang.Object
org.jmol.adapter.smarter.AtomSetCollectionReader
org.jmol.adapter.readers.pdb.PdbReader
org.jmol.adapter.readers.pymol.PyMOLReader
- All Implemented Interfaces:
javajs.api.GenericLineReader,PymolAtomReader
PyMOL PSE (binary Python session) file reader.
development started Feb 2013 Jmol 13.1.13
reasonably full implementation May 2013 Jmol 13.1.16
PyMOL state --> Jmol model
PyMOL object --> Jmol named atom set, isosurface, CGO, or measurement
PyMOL group --> Jmol named atom set (TODO: add isosurfaces and measures to these?)
PyMOL movie: an initial view and a set of N "frames"
PyMOL frame: references (a) a state, (b) a script, and (c) a view
PyMOL scene --> Jmol scene, including view, frame, visibilities, colors
using set LOGFILE, we can dump this to a readable form.
trajectories are not supported yet.
Basic idea is as follows:
1) Pickle file is read into a Hashtable.
2) Atoms, bonds, and structures are created, as per other readers, from MOLECULE objects
3) Rendering of atoms and bonds is interpreted as JmolObject objects via PyMOLScene
3) Other objects such as electron density maps, compiled graphical objects, and
measures are interpreted, creating more JmolObjects
3) JmolObjects are finalized after file reading takes place by a call from ModelLoader
back here to finalizeModelSet(), which runs PyMOLScene.setObjects, which runs JmolObject.finalizeObject.
TODO: Handle discrete objects, DiscreteAtmToIdx?
- Author:
- Bob Hanson hansonr@stolaf.edu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate booleanprivate boolean(package private) byte[]private int[]private Atom[]private intprivate intprivate javajs.util.BSprivate javajs.util.BSprivate booleanprivate booleanprivate int[]private booleanprivate booleanprivate booleanprivate booleanprivate booleanprivate booleanprivate booleanprivate javajs.util.Lst<javajs.util.Lst<Object>>private static final intprivate intprivate static Stringprivate Stringprivate final javajs.util.P3private intprivate PyMOLSceneprivate intprivate javajs.util.BS[]private javajs.util.Lst<Object>private booleanprivate intprivate intprivate intprivate intprivate javajs.util.P3[]private javajs.util.P3private javajs.util.P3Fields inherited from class org.jmol.adapter.readers.pdb.PdbReader
biomtChainAtomCounts, fileAtomIndex, gromacsWideFormatFields inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader
addedData, addedDataKey, addVibrations, allow_a_len_1, allowPDBFilter, ANGSTROMS_PER_BOHR, applySymmetryToBonds, asc, baseAtomIndex, baseBondIndex, binaryDoc, bsFilter, bsModels, calculationType, CELL_TYPE_CONVENTIONAL, CELL_TYPE_PRIMITIVE, centroidPacked, continuing, debugging, desiredModelNumber, desiredSpaceGroupIndex, desiredVibrationNumber, doApplySymmetry, doCentralize, doCentroidUnitCell, doCheckUnitCell, doConvertToFractional, doPackUnitCell, doProcessLines, doReadMolecularOrbitals, dssr, fileName, fileOffset, filePath, fileScaling, fillRange, filter, filterAllHetero, filterCased, filterHetero, fixJavaFloat, forcePacked, getHeader, haveAtomFilter, haveModel, havePartialChargeFilter, htParams, ignoreFileSpaceGroupName, ignoreFileSymmetryOperators, ignoreFileUnitCell, ignoreStructure, iHaveFractionalCoordinates, iHaveSymmetryOperators, iHaveUnitCell, is2D, isBinary, isConcatenated, isDSSP1, isFinalized, isMolecular, isPrimitive, isSequential, isTrajectory, latticeCells, latticeScaling, latticeType, line, lstNCS, matUnitCellOrientation, merging, modDim, modelNumber, ms, mustFinalizeModelSet, next, noHydrogens, noPack, optimize2D, out, packingError, paramsCentroid, paramsLattice, prevline, primitiveToCrystal, ptLine, ptSupercell, reader, readerName, requiresBSFilter, reverseModels, rotateHexCell, sgName, slabXY, stateScriptVersionInt, strSupercell, symmetry, templateAtomCount, thisBiomolecule, trajectorySteps, ucItems, unitCellOffset, unitCellParams, useAltNames, useFileModelNumbers, validation, vibrationNumber, vibsFractional, vwr -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate javajs.util.P3addAtom(javajs.util.Lst<Object> pymolAtoms, int apt, byte[] atomArray, int[] vArray, String[] lexStr, int icoord, javajs.util.Lst<Object> coords, float[] coordArray, javajs.util.Lst<Object> labelPositions, float[] labelArray, javajs.util.BS bsState, int iState) private voidprivate voidAdd new colors from the main "colors" map object.private voidSecondary structure definition.private voidprivate booleanatomBool(byte[] atomArray, int pt, int offset, int mask) private floatatomFloat(byte[] atomArray, int pt, int offset) private intatomInt(byte[] atomArray, int pt, int offset) private Stringprivate static StringbytesToString(Object object) private booleancheckObject(javajs.util.Lst<Object> execObject) (package private) static intcolorSettingClamped(javajs.util.Lst<Object> c, javajs.util.P3 ptTemp) booleancompareAtoms(int iPrev, int i) private voidCreate JmolObjects for all the molecular shapes; not executed for a state script.private voidfillFloatArrayFromBytes(byte[] b, float[] array) private voidfillIntArrayFromBytes(byte[] b, int[] array) voidAt the end of the day, we need to finalize all the JmolObjects, set the trajectories, and, if filtered with DOCACHE, cache a streamlined binary file for inclusion in the PNGJ file.private voidMake sure atom uniqueID (vectorX) and cartoonType (vectorY) are made permanentprotected voidoptional reader-specific method run first.private static javajs.util.Lst<Object>fixMovieCommands(javajs.util.Lst<Object> cmds) Could possibly implement something here that interprets PyMOL script commands.private static javajs.util.Lst<Object>fixMovieViews(javajs.util.Lst<Object> views) Could implement something here that creates a Jmol view.private javajs.util.Lst<Object>fixSettings(javajs.util.Lst<Object> settings) Recent PyMOL files may not have all settings.(package private) static float(package private) static float[]private voidgetAtomAndStateCount(javajs.util.Lst<Object> names) Look through all named objects for molecules, counting atoms and also states; see if trajectories are compatible (experimental).private javajs.util.Lst<Bond>getBondList(javajs.util.Lst<Object> bonds) Create the bond set.private static javajs.util.BSintgetCartoonType(int iAtom) (package private) static intgetColorPt(Object o, javajs.util.P3 ptTemp) private StringgetCStr(byte[] lex, int pt) private booleangetFrameScenes(Map<String, Object> map) remove all scenes that do not define a frame.private String[]getLexStr(byte[] lex) private static javajs.util.Lst<Object>getMapList(Map<String, Object> map, String key) intgetSequenceNumber(int iAtom) intgetUniqueID(int iAtom) floatgetVDW(int iAtom) protected void(package private) static int(package private) static javajs.util.Lst<Object>return a map of lists of the type: [ [name1,...], [name2,...], ...](package private) static javajs.util.P3private voidThe main processor.voidprivate voidprocessCGO(javajs.util.Lst<Object> pymolObject) Create a CGO JmolObject, just passing on key information.private voidCreate a JmolObject that will define atom sets based on PyMOL objectsprivate voidprocessGadget(javajs.util.Lst<Object> pymolObject) Only process _e_pot objects -- which we need for color settingsprivate voidprocessMap(javajs.util.Lst<Object> pymolObject, boolean isObject, boolean isGadget) Create mapObjects and volumeData; create an ISOSURFACE JmolObject.private voidprocessMeasure(javajs.util.Lst<Object> pymolObject) Create a MEASURE JmolObject.private voidCreate mesh or mep JmolObjects.private voidprocessMolCryst(javajs.util.Lst<Object> cryst) Pick up the crystal data.private javajs.util.BSprocessMolecule(javajs.util.Lst<Object> pymolObject, int iState) Create everything necessary to generate a molecule in Jmol.private voidprocessMovie(javajs.util.Lst<Object> mov, int frameCount) Create a JmolObject that will represent the movie.private voidprocessObject(javajs.util.Lst<Object> execObject, boolean moleculeOnly, int iState) The main object processor.private voidA PyMOL scene consists of one or more of: view frame visibilities, by object colors, by color reps, by type currently just extracts viewpointprotected voidadaptable via subclassingprivate intsetUniqueSettings(javajs.util.Lst<Object> list) Create uniqueSettings from the "unique_settings" map item.protected void(package private) static Stringstatic javajs.util.Lst<Object>Methods inherited from class org.jmol.adapter.readers.pdb.PdbReader
checkLine, checkRemark, deduceElementSymbol, filterPDBAtom, finalizeReaderPDB, fixRadius, model, processAtom, processAtom2Methods inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader
addAtomXYZSymName, addExplicitLatticeVector, addJmolScript, addSites, addSiteScript, appendLoadNote, appendUunitCellInfo, applySymmetryAndSetTrajectory, applySymTrajASCR, checkAndRemoveFilterKey, checkCurrentLineForScript, checkFilterKey, checkLastModel, checkLineForScript, clearUnitCell, cloneLastAtomSet, discardLinesUntilBlank, discardLinesUntilContains, discardLinesUntilContains2, discardLinesUntilNonBlank, discardLinesUntilStartsWith, discardPreviousAtoms, doGetModel, doGetVibration, doPreSymmetry, fill3x3, fillDataBlock, fillDataBlockFixed, fillFloatArray, fillFrequencyData, filterAtom, filterReject, finalizeMOData, finalizeReaderASCR, finalizeSubclassSymmetry, forceSymmetry, fractionalizeCoordinates, getElementSymbol, getFilter, getFilterWithCase, getFortranFormatLengths, getInterface, getNewSymmetry, getStrings, getSymmetry, getTokens, getTokensFloat, initializeSymmetry, initializeSymmetryOptions, initializeTrajectoryFile, isLastModel, newAtomSet, parseFloat, parseFloatRange, parseFloatStr, parseInt, parseIntAt, parseIntRange, parseIntStr, parseToken, parseTokenNext, parseTokenRange, parseTokenStr, processDOM, rd, read3Vectors, readDataObject, readLines, readNextLine, rejectAtomName, RL, set2D, setAtomCoord, setAtomCoordScaled, setAtomCoordTokens, setAtomCoordXYZ, setChainID, setElementAndIsotope, setFilter, setFilterAtomTypeStr, setFractionalCoordinates, setIsPDB, setLoadNote, setModelPDB, setSpaceGroupName, setSymmetryOperator, setTransform, setUnitCell, setUnitCellItem, setupASCR
-
Field Details
-
MIN_RESNO
private static final int MIN_RESNO- See Also:
-
nucleic
-
allowSurface
private boolean allowSurface -
doResize
private boolean doResize -
doCache
private boolean doCache -
isStateScript
private boolean isStateScript -
sourcePNGJ
private boolean sourcePNGJ -
ac0
private int ac0 -
ac
private int ac -
stateCount
private int stateCount -
structureCount
private int structureCount -
isHidden
private boolean isHidden -
bsStructureDefined
private javajs.util.BS bsStructureDefined -
bsBytesExcluded
private javajs.util.BS bsBytesExcluded -
atomMap
private int[] atomMap -
ssMapSeq
-
pymolScene
-
xyzMin
private javajs.util.P3 xyzMin -
xyzMax
private javajs.util.P3 xyzMax -
nModels
private int nModels -
logging
private boolean logging -
reps
private javajs.util.BS[] reps -
isMovie
private boolean isMovie -
pymolFrame
private int pymolFrame -
allStates
private boolean allStates -
totalAtomCount
private int totalAtomCount -
pymolVersion
private int pymolVersion -
trajectoryStep
private javajs.util.P3[] trajectoryStep -
trajectoryPtr
private int trajectoryPtr -
objectName
-
volumeData
-
mapObjects
-
haveMeasurements
private boolean haveMeasurements -
frames
private int[] frames -
uniqueSettings
-
atoms
-
haveScenes
private boolean haveScenes -
baseModelIndex
private int baseModelIndex -
sceneOrder
-
bondCount
private int bondCount -
haveBinaryArrays
private boolean haveBinaryArrays -
ptTemp
private final javajs.util.P3 ptTemp -
aTemp
byte[] aTemp
-
-
Constructor Details
-
PyMOLReader
public PyMOLReader()
-
-
Method Details
-
setup
- Overrides:
setupin classAtomSetCollectionReader
-
initializeReader
- Overrides:
initializeReaderin classPdbReader- Throws:
Exception
-
processBinaryDocument
- Overrides:
processBinaryDocumentin classAtomSetCollectionReader- Throws:
Exception
-
setAdditionalAtomParameters
Description copied from class:PdbReaderadaptable via subclassing- Overrides:
setAdditionalAtomParametersin classPdbReader
-
finalizeSubclassReader
Description copied from class:AtomSetCollectionReaderoptional reader-specific method run first.- Overrides:
finalizeSubclassReaderin classPdbReader- Throws:
Exception
-
finalizeModelSet
public void finalizeModelSet()At the end of the day, we need to finalize all the JmolObjects, set the trajectories, and, if filtered with DOCACHE, cache a streamlined binary file for inclusion in the PNGJ file.- Overrides:
finalizeModelSetin classAtomSetCollectionReader
-
process
The main processor.- Parameters:
map-
-
fixSettings
Recent PyMOL files may not have all settings. For now, we just add null values;- Parameters:
settings-- Returns:
- settings
-
getFrameScenes
remove all scenes that do not define a frame.- Parameters:
map-- Returns:
- true if there are scenes that define a frame
-
setUniqueSettings
Create uniqueSettings from the "unique_settings" map item. This will be used later in processing molecule objects.- Parameters:
list-- Returns:
- max id
-
addColors
Add new colors from the main "colors" map object. Not 100% clear how color clamping works.- Parameters:
colors-isClamped-
-
getAtomAndStateCount
Look through all named objects for molecules, counting atoms and also states; see if trajectories are compatible (experimental).- Parameters:
names-
-
checkObject
-
processMovie
Create a JmolObject that will represent the movie. For now, only process unscripted movies without views.- Parameters:
mov-frameCount-
-
fixMovieViews
Could implement something here that creates a Jmol view.- Parameters:
views-- Returns:
- new views
-
fixMovieCommands
Could possibly implement something here that interprets PyMOL script commands.- Parameters:
cmds-- Returns:
- new cmds
-
processObject
The main object processor. Not implemented: ALIGNMENT, CALLBACK, SLICE, SURFACE- Parameters:
execObject-moleculeOnly-iState-
-
processCGO
Create a CGO JmolObject, just passing on key information.- Parameters:
pymolObject-
-
processGadget
Only process _e_pot objects -- which we need for color settings- Parameters:
pymolObject-
-
processMap
Create mapObjects and volumeData; create an ISOSURFACE JmolObject.- Parameters:
pymolObject-isObject-isGadget-
-
processMeasure
Create a MEASURE JmolObject.- Parameters:
pymolObject-
-
processMolecule
Create everything necessary to generate a molecule in Jmol.- Parameters:
pymolObject-iState-- Returns:
- atom set only if this is a trajectory.
-
getLexStr
-
getCStr
-
processMolCryst
Pick up the crystal data.- Parameters:
cryst-
-
getBondList
Create the bond set.- Parameters:
bonds-- Returns:
- list of bonds
-
fillIntArrayFromBytes
private void fillIntArrayFromBytes(byte[] b, int[] array) -
fillFloatArrayFromBytes
private void fillFloatArrayFromBytes(byte[] b, float[] array) -
addAtom
private javajs.util.P3 addAtom(javajs.util.Lst<Object> pymolAtoms, int apt, byte[] atomArray, int[] vArray, String[] lexStr, int icoord, javajs.util.Lst<Object> coords, float[] coordArray, javajs.util.Lst<Object> labelPositions, float[] labelArray, javajs.util.BS bsState, int iState) - Parameters:
pymolAtoms- list of atom detailsapt- array pointer into pymolAtomsatomArray-vArray-lexStr-icoord- array pointer into coords (/3)coords- coordinates arraycoordArray-labelPositions-labelArray-bsState- this state -- Jmol atomIndexiState-- Returns:
- true if successful
-
atomBool
private boolean atomBool(byte[] atomArray, int pt, int offset, int mask) -
atomFloat
private float atomFloat(byte[] atomArray, int pt, int offset) -
atomStr
-
atomInt
private int atomInt(byte[] atomArray, int pt, int offset) -
addBonds
-
addMolStructures
private void addMolStructures() -
addMolSS
Secondary structure definition.- Parameters:
ssType-type-
-
createShapeObjects
private void createShapeObjects()Create JmolObjects for all the molecular shapes; not executed for a state script. -
processMeshes
private void processMeshes()Create mesh or mep JmolObjects. Caching the volumeData, because it will be needed by org.jmol.jvxl.readers.PyMOLMeshReader -
processDefinitions
private void processDefinitions()Create a JmolObject that will define atom sets based on PyMOL objects -
processSelectionsAndScenes
A PyMOL scene consists of one or more of: view frame visibilities, by object colors, by color reps, by type currently just extracts viewpoint- Parameters:
map-
-
finalizeSceneData
private void finalizeSceneData()Make sure atom uniqueID (vectorX) and cartoonType (vectorY) are made permanent -
intAt
-
pointAt
-
floatsAt
-
floatAt
-
listAt
-
sublistAt
-
listToMap
return a map of lists of the type: [ [name1,...], [name2,...], ...]- Parameters:
list-- Returns:
- Hashtable
-
stringAt
-
bytesToString
-
colorSettingClamped
-
getColorPt
-
getMapList
-
getBsReps
-
getUniqueID
public int getUniqueID(int iAtom) - Specified by:
getUniqueIDin interfacePymolAtomReader
-
getCartoonType
public int getCartoonType(int iAtom) - Specified by:
getCartoonTypein interfacePymolAtomReader
-
getVDW
public float getVDW(int iAtom) - Specified by:
getVDWin interfacePymolAtomReader
-
getSequenceNumber
public int getSequenceNumber(int iAtom) - Specified by:
getSequenceNumberin interfacePymolAtomReader
-
compareAtoms
public boolean compareAtoms(int iPrev, int i) - Specified by:
compareAtomsin interfacePymolAtomReader
-