Package org.jmol.adapter.readers.cif
Class TopoCifParser
- java.lang.Object
-
- org.jmol.adapter.readers.cif.TopoCifParser
-
- All Implemented Interfaces:
CifReader.Parser
public class TopoCifParser extends java.lang.Object implements CifReader.Parser
see https://github.com/COMCIFS/TopoCif Basic idea: We have TLinks, TNodes, and TAtoms TLinks each have two TNodes and may also be associated with bridging TAtom sets. TNode extends TAtom and may also maintain a list of TAtoms. TAtoms extend Atom and may have symmetry aspects.- Author:
- Bob Hanson hansonr@stolaf.edu 2020.11.17 2021.05.07
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
TopoCifParser.TAtom
private class
TopoCifParser.TLink
A class to hold the TOPOL_LINK data item information and transform it as needed.private class
TopoCifParser.TNet
private class
TopoCifParser.TNode
private static interface
TopoCifParser.TPoint
-
Field Summary
Fields Modifier and Type Field Description private int
ac0
private java.lang.String
allowedTypes
(package private) int
atomCount
(package private) javajs.util.Lst<TopoCifParser.TAtom>
atoms
list of TOPOL_ATOM loop data(package private) int
b0
base bond index to be added to any bond bitsetsprivate int
bc0
private javajs.api.GenericCifDataParser
cifParser
(package private) static double
ERROR_TOLERANCE
(package private) java.lang.String
failed
and indictor that we should abort, and why(package private) int
i0
base atom index to be added to any atom bitsetsstatic int
LINK_TYPE_AROM
static int
LINK_TYPE_BITS
static int
LINK_TYPE_DELO
static int
LINK_TYPE_DOUBLE
static int
LINK_TYPE_GENERIC_LINK
types set by filter TOPOSE_TYPES in the format of one or more of {v, vw, hb} separated by "+"; default is v+hbstatic int
LINK_TYPE_HBOND
static int
LINK_TYPE_OCTUPLE
static int
LINK_TYPE_OTHER
static int
LINK_TYPE_PI
static int
LINK_TYPE_POLY
static int
LINK_TYPE_QUADRUPLE
static int
LINK_TYPE_QUINTUPLE
static int
LINK_TYPE_SEPTUPLE
static int
LINK_TYPE_SEXTUPLE
static int
LINK_TYPE_SINGLE
static int
LINK_TYPE_TRIPLE
static int
LINK_TYPE_VDW
(package private) int
linkCount
(package private) javajs.util.Lst<TopoCifParser.TLink>
links
list of TOPOL_LINK loop datastatic java.lang.String
linkTypes
(package private) int
netCount
(package private) java.lang.String
netNotes
(package private) javajs.util.Lst<TopoCifParser.TNet>
nets
list of TOPOL_NET loop or single data item data(package private) javajs.util.Lst<TopoCifParser.TNode>
nodes
list of TOPOL_NODE loop data(package private) javajs.util.M4[]
ops
symmetry operations for this space group(package private) CifReader
reader
reader will be null if filter includes TOPOS_IGNORE(package private) java.lang.String
selectedNet
(package private) TopoCifParser.TNet
singleNet
storage for a single net from a non-looped data itemprivate SymmetryInterface
sym
(package private) javajs.util.T3
temp1
(package private) javajs.util.T3
temp2
private static byte
topol_atom_atom_label
private static byte
topol_atom_element_symbol
private static byte
topol_atom_fract_x
private static byte
topol_atom_fract_y
private static byte
topol_atom_fract_z
private static byte
topol_atom_id
private static byte
topol_atom_link_id
private static byte
topol_atom_node_id
private static byte
topol_atom_symop_id
private static byte
topol_atom_translation
private static byte
topol_atom_translation_x
private static byte
topol_atom_translation_y
private static byte
topol_atom_translation_z
(package private) static int
TOPOL_GROUP
(package private) static int
TOPOL_LINK
private static byte
topol_link_distance
private static byte
topol_link_id
private static byte
topol_link_multiplicity
private static byte
topol_link_net_id
private static byte
topol_link_node_id_1
private static byte
topol_link_node_id_2
private static byte
topol_link_node_label_1_DEPRECATED
private static byte
topol_link_node_label_2_DEPRECATED
private static byte
topol_link_order
private static byte
topol_link_site_symmetry_symop_1_DEPRECATED
private static byte
topol_link_site_symmetry_symop_2_DEPRECATED
private static byte
topol_link_site_symmetry_translation_1_DEPRECATED
private static byte
topol_link_site_symmetry_translation_1_x_DEPRECATED
private static byte
topol_link_site_symmetry_translation_1_y_DEPRECATED
private static byte
topol_link_site_symmetry_translation_1_z_DEPRECATED
private static byte
topol_link_site_symmetry_translation_2_DEPRECATED
private static byte
topol_link_site_symmetry_translation_2_x_DEPRECATED
private static byte
topol_link_site_symmetry_translation_2_y_DEPRECATED
private static byte
topol_link_site_symmetry_translation_2_z_DEPRECATED
private static byte
topol_link_symop_id_1
private static byte
topol_link_symop_id_2
private static byte
topol_link_translation_1
private static byte
topol_link_translation_1_x
private static byte
topol_link_translation_1_y
private static byte
topol_link_translation_1_z
private static byte
topol_link_translation_2
private static byte
topol_link_translation_2_x
private static byte
topol_link_translation_2_y
private static byte
topol_link_translation_2_z
private static byte
topol_link_type
private static byte
topol_link_voronoi_solidangle
private static byte
topol_net_id
private static byte
topol_net_label
private static byte
topol_net_special_details
(package private) static int
TOPOL_NODE
private static byte
topol_node_fract_x
private static byte
topol_node_fract_y
private static byte
topol_node_fract_z
private static byte
topol_node_id
private static byte
topol_node_label
private static byte
topol_node_net_id
private static byte
topol_node_symop_id
private static byte
topol_node_translation
private static byte
topol_node_translation_x
private static byte
topol_node_translation_y
private static byte
topol_node_translation_z
private static java.lang.String[]
topolFields
(package private) static javajs.util.P3
ZERO
-
Constructor Summary
Constructors Constructor Description TopoCifParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static void
applySymmetry(Atom a, javajs.util.M4[] ops, int op, javajs.util.T3 t)
Apply the symmetry and translation(package private) float
calculateDistance(javajs.util.P3 p1, javajs.util.P3 p2)
boolean
finalizeReader()
PRIOR to symmetry application, process all internal symop/translation aspects.void
finalizeSymmetry(boolean haveSymmetry)
Symmetry has been applied.TopoCifParser.TNode
findNode(java.lang.String nodeID, int op, javajs.util.P3 trans)
Called from TLink and TAtom to find a node with the given symmetry.(package private) TopoCifParser.TNode
getAssociatedNodeByIdx(int idx)
Find the node for this TAtom.(package private) TopoCifParser.TLink
getAssoiatedLinkByIdx(int idx)
Find the link for this TAtom.Atom
getAtomFromName(java.lang.String atomLabel)
(package private) static int
getBondType(java.lang.String type, int order)
private java.lang.String
getDataValue(byte key)
Read the data value.private float
getFloat(java.lang.String f)
private int
getInt(java.lang.String f)
(package private) static java.lang.String
getMF(javajs.util.Lst<TopoCifParser.TAtom> tatoms)
TopoCifParser.TNet
getNetByID(java.lang.String id)
Find or create a net with this netID, giving it a default name "Net"+idTopoCifParser.TNet
getNetFor(java.lang.String id, java.lang.String label, boolean forceNew)
Find or create a TNet for this id and label.(package private) static boolean
isEqualD(javajs.util.T3 p1, javajs.util.T3 p2, double d)
private int
processAssociations(javajs.util.BS bsConnected, javajs.util.BS bsAtoms)
Find and process all "bonds" associated with all links and nodes.private void
processAtoms()
boolean
processBlock(java.lang.String key)
private void
processLinks()
private void
processNets()
Process all nets.private void
processNodes()
void
ProcessRecord(java.lang.String key, java.lang.String data)
process _topol_node.id 1private int[]
processTranslation(int p, int[] t, java.lang.String field)
private void
selectNet()
(package private) static void
setElementSymbol(Atom a, java.lang.String sym)
TopoCifParser
setReader(CifReader reader)
filter "TOPOS_TYPES=hb" will only load hydrogen bonds; options include v, vw, and hb(package private) static void
setTAtom(Atom a, Atom b)
(package private) static javajs.util.BS
shiftBits(javajs.util.BS bsAtoms, javajs.util.BS bs)
Shift bits to the left to account for missing atoms in the final atom list.
-
-
-
Field Detail
-
TOPOL_LINK
static final int TOPOL_LINK
- See Also:
- Constant Field Values
-
TOPOL_GROUP
static final int TOPOL_GROUP
- See Also:
- Constant Field Values
-
TOPOL_NODE
static final int TOPOL_NODE
- See Also:
- Constant Field Values
-
LINK_TYPE_GENERIC_LINK
public static final int LINK_TYPE_GENERIC_LINK
types set by filter TOPOSE_TYPES in the format of one or more of {v, vw, hb} separated by "+"; default is v+hb- See Also:
- Constant Field Values
-
LINK_TYPE_SINGLE
public static final int LINK_TYPE_SINGLE
- See Also:
- Constant Field Values
-
LINK_TYPE_DOUBLE
public static final int LINK_TYPE_DOUBLE
- See Also:
- Constant Field Values
-
LINK_TYPE_TRIPLE
public static final int LINK_TYPE_TRIPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_QUADRUPLE
public static final int LINK_TYPE_QUADRUPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_QUINTUPLE
public static final int LINK_TYPE_QUINTUPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_SEXTUPLE
public static final int LINK_TYPE_SEXTUPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_SEPTUPLE
public static final int LINK_TYPE_SEPTUPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_OCTUPLE
public static final int LINK_TYPE_OCTUPLE
- See Also:
- Constant Field Values
-
LINK_TYPE_AROM
public static final int LINK_TYPE_AROM
- See Also:
- Constant Field Values
-
LINK_TYPE_POLY
public static final int LINK_TYPE_POLY
- See Also:
- Constant Field Values
-
LINK_TYPE_DELO
public static final int LINK_TYPE_DELO
- See Also:
- Constant Field Values
-
LINK_TYPE_PI
public static final int LINK_TYPE_PI
- See Also:
- Constant Field Values
-
LINK_TYPE_HBOND
public static final int LINK_TYPE_HBOND
- See Also:
- Constant Field Values
-
LINK_TYPE_VDW
public static final int LINK_TYPE_VDW
- See Also:
- Constant Field Values
-
LINK_TYPE_OTHER
public static final int LINK_TYPE_OTHER
- See Also:
- Constant Field Values
-
linkTypes
public static java.lang.String linkTypes
-
LINK_TYPE_BITS
public static final int LINK_TYPE_BITS
- See Also:
- Constant Field Values
-
ERROR_TOLERANCE
static double ERROR_TOLERANCE
-
reader
CifReader reader
reader will be null if filter includes TOPOS_IGNORE
-
atoms
javajs.util.Lst<TopoCifParser.TAtom> atoms
list of TOPOL_ATOM loop data
-
nodes
javajs.util.Lst<TopoCifParser.TNode> nodes
list of TOPOL_NODE loop data
-
links
javajs.util.Lst<TopoCifParser.TLink> links
list of TOPOL_LINK loop data
-
nets
javajs.util.Lst<TopoCifParser.TNet> nets
list of TOPOL_NET loop or single data item data
-
singleNet
TopoCifParser.TNet singleNet
storage for a single net from a non-looped data item
-
netCount
int netCount
-
linkCount
int linkCount
-
atomCount
int atomCount
-
temp1
javajs.util.T3 temp1
-
temp2
javajs.util.T3 temp2
-
ac0
private int ac0
-
bc0
private int bc0
-
cifParser
private javajs.api.GenericCifDataParser cifParser
-
failed
java.lang.String failed
and indictor that we should abort, and why
-
ops
javajs.util.M4[] ops
symmetry operations for this space group
-
i0
int i0
base atom index to be added to any atom bitsets
-
b0
int b0
base bond index to be added to any bond bitsets
-
allowedTypes
private java.lang.String allowedTypes
-
netNotes
java.lang.String netNotes
-
sym
private SymmetryInterface sym
-
selectedNet
java.lang.String selectedNet
-
topolFields
private static final java.lang.String[] topolFields
-
topol_net_id
private static final byte topol_net_id
- See Also:
- Constant Field Values
-
topol_net_label
private static final byte topol_net_label
- See Also:
- Constant Field Values
-
topol_net_special_details
private static final byte topol_net_special_details
- See Also:
- Constant Field Values
-
topol_link_id
private static final byte topol_link_id
- See Also:
- Constant Field Values
-
topol_link_net_id
private static final byte topol_link_net_id
- See Also:
- Constant Field Values
-
topol_link_node_id_1
private static final byte topol_link_node_id_1
- See Also:
- Constant Field Values
-
topol_link_node_id_2
private static final byte topol_link_node_id_2
- See Also:
- Constant Field Values
-
topol_link_symop_id_1
private static final byte topol_link_symop_id_1
- See Also:
- Constant Field Values
-
topol_link_translation_1
private static final byte topol_link_translation_1
- See Also:
- Constant Field Values
-
topol_link_translation_1_x
private static final byte topol_link_translation_1_x
- See Also:
- Constant Field Values
-
topol_link_translation_1_y
private static final byte topol_link_translation_1_y
- See Also:
- Constant Field Values
-
topol_link_translation_1_z
private static final byte topol_link_translation_1_z
- See Also:
- Constant Field Values
-
topol_link_symop_id_2
private static final byte topol_link_symop_id_2
- See Also:
- Constant Field Values
-
topol_link_translation_2
private static final byte topol_link_translation_2
- See Also:
- Constant Field Values
-
topol_link_translation_2_x
private static final byte topol_link_translation_2_x
- See Also:
- Constant Field Values
-
topol_link_translation_2_y
private static final byte topol_link_translation_2_y
- See Also:
- Constant Field Values
-
topol_link_translation_2_z
private static final byte topol_link_translation_2_z
- See Also:
- Constant Field Values
-
topol_link_distance
private static final byte topol_link_distance
- See Also:
- Constant Field Values
-
topol_link_type
private static final byte topol_link_type
- See Also:
- Constant Field Values
-
topol_link_multiplicity
private static final byte topol_link_multiplicity
- See Also:
- Constant Field Values
-
topol_link_voronoi_solidangle
private static final byte topol_link_voronoi_solidangle
- See Also:
- Constant Field Values
-
topol_link_order
private static final byte topol_link_order
- See Also:
- Constant Field Values
-
topol_node_id
private static final byte topol_node_id
- See Also:
- Constant Field Values
-
topol_node_net_id
private static final byte topol_node_net_id
- See Also:
- Constant Field Values
-
topol_node_label
private static final byte topol_node_label
- See Also:
- Constant Field Values
-
topol_node_symop_id
private static final byte topol_node_symop_id
- See Also:
- Constant Field Values
-
topol_node_translation
private static final byte topol_node_translation
- See Also:
- Constant Field Values
-
topol_node_translation_x
private static final byte topol_node_translation_x
- See Also:
- Constant Field Values
-
topol_node_translation_y
private static final byte topol_node_translation_y
- See Also:
- Constant Field Values
-
topol_node_translation_z
private static final byte topol_node_translation_z
- See Also:
- Constant Field Values
-
topol_node_fract_x
private static final byte topol_node_fract_x
- See Also:
- Constant Field Values
-
topol_node_fract_y
private static final byte topol_node_fract_y
- See Also:
- Constant Field Values
-
topol_node_fract_z
private static final byte topol_node_fract_z
- See Also:
- Constant Field Values
-
topol_atom_id
private static final byte topol_atom_id
- See Also:
- Constant Field Values
-
topol_atom_atom_label
private static final byte topol_atom_atom_label
- See Also:
- Constant Field Values
-
topol_atom_node_id
private static final byte topol_atom_node_id
- See Also:
- Constant Field Values
-
topol_atom_link_id
private static final byte topol_atom_link_id
- See Also:
- Constant Field Values
-
topol_atom_symop_id
private static final byte topol_atom_symop_id
- See Also:
- Constant Field Values
-
topol_atom_translation
private static final byte topol_atom_translation
- See Also:
- Constant Field Values
-
topol_atom_translation_x
private static final byte topol_atom_translation_x
- See Also:
- Constant Field Values
-
topol_atom_translation_y
private static final byte topol_atom_translation_y
- See Also:
- Constant Field Values
-
topol_atom_translation_z
private static final byte topol_atom_translation_z
- See Also:
- Constant Field Values
-
topol_atom_fract_x
private static final byte topol_atom_fract_x
- See Also:
- Constant Field Values
-
topol_atom_fract_y
private static final byte topol_atom_fract_y
- See Also:
- Constant Field Values
-
topol_atom_fract_z
private static final byte topol_atom_fract_z
- See Also:
- Constant Field Values
-
topol_atom_element_symbol
private static final byte topol_atom_element_symbol
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_symop_1_DEPRECATED
private static final byte topol_link_site_symmetry_symop_1_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_1_x_DEPRECATED
private static final byte topol_link_site_symmetry_translation_1_x_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_1_y_DEPRECATED
private static final byte topol_link_site_symmetry_translation_1_y_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_1_z_DEPRECATED
private static final byte topol_link_site_symmetry_translation_1_z_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_symop_2_DEPRECATED
private static final byte topol_link_site_symmetry_symop_2_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_2_x_DEPRECATED
private static final byte topol_link_site_symmetry_translation_2_x_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_2_y_DEPRECATED
private static final byte topol_link_site_symmetry_translation_2_y_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_2_z_DEPRECATED
private static final byte topol_link_site_symmetry_translation_2_z_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_1_DEPRECATED
private static final byte topol_link_site_symmetry_translation_1_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_site_symmetry_translation_2_DEPRECATED
private static final byte topol_link_site_symmetry_translation_2_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_node_label_1_DEPRECATED
private static final byte topol_link_node_label_1_DEPRECATED
- See Also:
- Constant Field Values
-
topol_link_node_label_2_DEPRECATED
private static final byte topol_link_node_label_2_DEPRECATED
- See Also:
- Constant Field Values
-
ZERO
static final javajs.util.P3 ZERO
-
-
Method Detail
-
getBondType
static int getBondType(java.lang.String type, int order)
-
setReader
public TopoCifParser setReader(CifReader reader)
filter "TOPOS_TYPES=hb" will only load hydrogen bonds; options include v, vw, and hb- Specified by:
setReader
in interfaceCifReader.Parser
-
ProcessRecord
public void ProcessRecord(java.lang.String key, java.lang.String data) throws java.lang.Exception
process _topol_node.id 1- Specified by:
ProcessRecord
in interfaceCifReader.Parser
- Throws:
java.lang.Exception
-
processBlock
public boolean processBlock(java.lang.String key) throws java.lang.Exception
- Specified by:
processBlock
in interfaceCifReader.Parser
- Throws:
java.lang.Exception
-
processNets
private void processNets() throws java.lang.Exception
Process all nets. Note that the nets list is self-populating with a "Net1" value if there is no TOPOL_NET section.- Throws:
java.lang.Exception
-
processLinks
private void processLinks() throws java.lang.Exception
- Throws:
java.lang.Exception
-
processNodes
private void processNodes() throws java.lang.Exception
- Throws:
java.lang.Exception
-
processAtoms
private void processAtoms() throws java.lang.Exception
- Throws:
java.lang.Exception
-
processTranslation
private int[] processTranslation(int p, int[] t, java.lang.String field)
-
finalizeReader
public boolean finalizeReader() throws java.lang.Exception
PRIOR to symmetry application, process all internal symop/translation aspects.- Specified by:
finalizeReader
in interfaceCifReader.Parser
- Throws:
java.lang.Exception
-
selectNet
private void selectNet()
-
finalizeSymmetry
public void finalizeSymmetry(boolean haveSymmetry) throws java.lang.Exception
Symmetry has been applied. Identify all of the connected atoms and process the group associations- Specified by:
finalizeSymmetry
in interfaceCifReader.Parser
- Throws:
java.lang.Exception
-
shiftBits
static javajs.util.BS shiftBits(javajs.util.BS bsAtoms, javajs.util.BS bs)
Shift bits to the left to account for missing atoms in the final atom list.- Parameters:
bsAtoms
-bs
-- Returns:
- shifted bitset
-
processAssociations
private int processAssociations(javajs.util.BS bsConnected, javajs.util.BS bsAtoms)
Find and process all "bonds" associated with all links and nodes. This method runs AFTER generation of all the symmetry-related atoms. BOND_LINK + index indicates linked nodes BOND_GROUP + index indicates associated nodes- Parameters:
bsConnected
- prevent Jmol from adding bonds to this atombsAtoms
- allow Jmol to add bonds to these atoms, inclusively- Returns:
- number of bonds created
-
isEqualD
static boolean isEqualD(javajs.util.T3 p1, javajs.util.T3 p2, double d)
-
getDataValue
private java.lang.String getDataValue(byte key)
Read the data value.- Parameters:
key
-- Returns:
- the value or null if does not exist or is '.' or '?'
-
getInt
private int getInt(java.lang.String f)
-
getFloat
private float getFloat(java.lang.String f)
-
getMF
static java.lang.String getMF(javajs.util.Lst<TopoCifParser.TAtom> tatoms)
-
setElementSymbol
static void setElementSymbol(Atom a, java.lang.String sym)
- Parameters:
a
- TNode or TAtomsym
-
-
applySymmetry
static void applySymmetry(Atom a, javajs.util.M4[] ops, int op, javajs.util.T3 t)
Apply the symmetry and translation- Parameters:
a
- TNode or TAtomops
-op
-t
-
-
getNetByID
public TopoCifParser.TNet getNetByID(java.lang.String id)
Find or create a net with this netID, giving it a default name "Net"+id- Parameters:
id
-- Returns:
- net, never null
-
getAtomFromName
public Atom getAtomFromName(java.lang.String atomLabel)
-
calculateDistance
float calculateDistance(javajs.util.P3 p1, javajs.util.P3 p2)
-
getNetFor
public TopoCifParser.TNet getNetFor(java.lang.String id, java.lang.String label, boolean forceNew)
Find or create a TNet for this id and label.- Parameters:
id
- or nulllabel
- or nullforceNew
- true to create a new net- Returns:
- a net, or null if not forceNew and not found
-
getAssociatedNodeByIdx
TopoCifParser.TNode getAssociatedNodeByIdx(int idx)
Find the node for this TAtom.- Parameters:
idx
-- Returns:
- the node or null
-
getAssoiatedLinkByIdx
TopoCifParser.TLink getAssoiatedLinkByIdx(int idx)
Find the link for this TAtom.- Parameters:
idx
-- Returns:
- the link or null
-
findNode
public TopoCifParser.TNode findNode(java.lang.String nodeID, int op, javajs.util.P3 trans)
Called from TLink and TAtom to find a node with the given symmetry.- Parameters:
nodeID
-op
- match for linkSymoptrans
- match for linkTrans- Returns:
- the node, or null if no such node was found
-
-