Package org.jmol.adapter.readers.xml
Class XmlChemDrawReader
java.lang.Object
org.jmol.adapter.smarter.AtomSetCollectionReader
org.jmol.adapter.readers.xml.XmlReader
org.jmol.adapter.readers.xml.XmlChemDrawReader
- All Implemented Interfaces:
javajs.api.GenericLineReader
- Direct Known Subclasses:
CDXReader
A reader for ChemDraw CDXML files.
See
https://www.cambridgesoft.com/services/documentation/sdk/chemdraw/cdx/IntroCDXML.htm
for the full, detailed specification.
Here we are just looking for simple aspects that could be converted to valid
2D MOL files, SMILES, and InChI.
Fragments (such as CH2CH2OH) and "Nickname"-type fragments such as Ac and Ph,
are processed correctly. But their 2D representations are pretty nuts.
ChemDraw does not make any attempt to place these in reasonable locations.
That said, Jmol's 3D minimization does a pretty fair job, and the default is
to do that minimization.
If minimization and addition of H is not desired, use FILTER "NOH" or FILTER
"NO3D"
XmlChemDrawReader also serves as the reader for binary CDX files, as
CDXReader subclasses this class. See that class for details.
- Author:
- hansonr
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate floatprivate floatprivate floatprivate floatprivate floatprivate floatprivate booleanChemDraw can mess up 3D completely with octahedral stereochemistry; setting filter "no3D" ensures the raw 2D structure is returned.private Stack<XmlChemDrawReader.CDNode>private List<XmlChemDrawReader.CDNode>private Stringtemporary holder of style chunks within text objectsprivate Stringprivate XmlChemDrawReader.CDNodeFields inherited from class org.jmol.adapter.readers.xml.XmlReader
atom, atts, bond, chars, keepChars, parentFields 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 voidAdjust the scale to have an average bond length of 1.45 Angstroms.private booleancheckWarningOK(String warning) protected voidFix connections to Fragments and Nicknames, adjust stereochemistry for wavy displays, flag invalid atoms, and adjust the scale to something more molecular.private voidFirst fix all the attachments, tying together the atoms identified as ExternalConnectionPoints with atoms of bonds indicating "BeginAttach" or "EndAttach".private voidRemove fragment, external point, or invalid unconnected nodes (including unconnected carbon nodes, which can arise from deletions (in my experience) and are then not noticed because they have no associated text.(package private) voidprocessEndElement(String localName) voidprocessStartElement(String localName, String nodeName) protected voidprocessXml(XmlReader parent, Object saxReader) private voidSet the 2D or pseudo-3D coordinates of the atoms.private voidsetBond()Process the bond tags.private voidSet the atom information.Methods inherited from class org.jmol.adapter.readers.xml.XmlReader
applySymmetryAndSetTrajectory, createDomNodeJS, endDocument, initializeReader, processDOM, processXml2, setKeepCharsMethods inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader
addAtomXYZSymName, addExplicitLatticeVector, addJmolScript, addSites, addSiteScript, appendLoadNote, appendUunitCellInfo, applySymTrajASCR, checkAndRemoveFilterKey, checkCurrentLineForScript, checkFilterKey, checkLastModel, checkLine, checkLineForScript, clearUnitCell, cloneLastAtomSet, discardLinesUntilBlank, discardLinesUntilContains, discardLinesUntilContains2, discardLinesUntilNonBlank, discardLinesUntilStartsWith, discardPreviousAtoms, doGetModel, doGetVibration, doPreSymmetry, fill3x3, fillDataBlock, fillDataBlockFixed, fillFloatArray, fillFrequencyData, filterAtom, filterReject, finalizeMOData, finalizeModelSet, 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, processBinaryDocument, 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, setup, setupASCR
-
Field Details
-
minX
private float minX -
minY
private float minY -
minZ
private float minZ -
maxZ
private float maxZ -
maxY
private float maxY -
maxX
private float maxX -
no3D
private boolean no3DChemDraw can mess up 3D completely with octahedral stereochemistry; setting filter "no3D" ensures the raw 2D structure is returned. -
fragments
-
thisFragment
-
thisNode
-
nodes
-
nostereo
-
textBuffer
temporary holder of style chunks within text objects
-
-
Constructor Details
-
XmlChemDrawReader
public XmlChemDrawReader()
-
-
Method Details
-
processXml
- Overrides:
processXmlin classXmlReader- Throws:
Exception
-
processStartElement
- Overrides:
processStartElementin classXmlReadernodeName- TODO
-
processEndElement
- Overrides:
processEndElementin classXmlReader
-
setNode
Set the atom information. Reading: NodeType, Warning. Element, Isotope, Charge, xyz, p 3D coordinates xyz is only used if there are no 2D p coordinates. This may not be possible. I don't know. These aren't real 3D coordinates, just enhanced z values.- Parameters:
id-
-
checkWarningOK
-
setBond
private void setBond()Process the bond tags. We only look at the following attributes: B beginning atom (atom1) E ending atom (atom2) BeginAttach associates atom1 with a fragment EndAttach associates atom2 with a fragment Order -- the bond order Display -- wedges and such Display2 -- only important here for partial bonds bonds to multiple attachments are not actually made. -
setAtom
Set the 2D or pseudo-3D coordinates of the atoms. ChemDraw pseudo-3D is just a z-layering of chunks of the molecule. Nothing really useful. These coordinates are ignored if there are any atoms also with 2D coordinates or for FILTER "NO3D". So, pretty much, the z coordinates are never used.- Parameters:
key-
-
finalizeSubclassReader
Fix connections to Fragments and Nicknames, adjust stereochemistry for wavy displays, flag invalid atoms, and adjust the scale to something more molecular. Finalize the 2D/3D business.- Overrides:
finalizeSubclassReaderin classXmlReader- Throws:
Exception
-
fixConnections
private void fixConnections()First fix all the attachments, tying together the atoms identified as ExternalConnectionPoints with atoms of bonds indicating "BeginAttach" or "EndAttach". Then flag all unconnected atoms and also remove any wedges or hashes that are associated with bonds to atoms that also have wavy bonds. -
centerAndScale
private void centerAndScale()Adjust the scale to have an average bond length of 1.45 Angstroms. This is just to get the structure in the range of other structures rather than being huge. -
fixInvalidAtoms
private void fixInvalidAtoms()Remove fragment, external point, or invalid unconnected nodes (including unconnected carbon nodes, which can arise from deletions (in my experience) and are then not noticed because they have no associated text.
-