Package org.jmol.symmetry
Class CIPChirality.CIPAtom
java.lang.Object
org.jmol.symmetry.CIPChirality.CIPAtom
- All Implemented Interfaces:
Cloneable
,Comparable<CIPChirality.CIPAtom>
- Enclosing class:
CIPChirality
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CIPChirality.CIPAtom
last atom of an alkene or cumulene atomprivate CIPChirality.CIPAtom
first atom of an alkene or cumulene atom(package private) SimpleNode
the associated Jmol (or otherwise) atom; use of the SimpleNode interface allows us to implement this in SMILES or Jmol as well as providing an interface other programs could use if implementing this code(package private) int
the application-assigned unique atom index for this atom; used in updating lstSmallRings(package private) CIPChirality.CIPAtom[]
the substituents -- up to four supported here at this timeprivate char
auxiliary chirality as determined in createAuxiliaryRule4Data; possibilities include R/S, r/s, M/P, m/p, C/T (but not c/t), or ~ (ASCII 126, no stereochemistry); for sorting purposes C=M=R invalid input: '<' p=r=s invalid input: '<' ~private int
auxiliary chirality E/Z for this atom node(package private) int
true atom covalent bond count; cached for better performanceprivate javajs.util.BS
bitset of indices of the associated atoms in the path to this atom node from the root; used to keep track of the path to this atom in order to prevent infinite cycling; the last atom in the path when cyclic is a duplicate atom.private javajs.util.BS
a list of only the undifferentiated ligands in Rule 6 -- root atom onlyprivate javajs.util.BS
used to count the number of prioritiesprivate String
ASCII-encoded priority string(package private) float
Rule 1a nominal element number; may be fractional for Kekule issues(package private) int
a count of how many 1H atoms we have found on this atom; used to halt further processing of this atomRule 1b hash table that maintains distance of the associated nonduplicated atom nodeprivate int
unique ID for this CIPAtom for debugging onlyprivate boolean
is one atom of a double bondprivate boolean
a flag used in Rule 3 to indicate the second carbon of a double bondprivate boolean
a check for downstream chirality(package private) boolean
a flag to indicate atom that is a duplicate, either due to ring closure or multiple bonding -- element number and mass, but no substituents; slightly lower in priority than standard atoms.private boolean
alkene or even cumulene, so chirality will be EZ, not MPprivate boolean
is an atom that is involved in more than one Kekule form(package private) boolean
odd/even toggle for comparisons of Rule5 results that would make for R/S, not r/s, if this flag is false.private boolean
a flag to prevent finalization of an atom node more than once(package private) boolean
a flag set false in evaluation of Rule 5 to indicate that there was more than one R/S decision made, so this center cannot be r/s; initially just indicates that the atom has 4 covalent bonds or is trigonal pyriamidal(package private) boolean
a flag to indicate an atom that has no substituents; a branch end point; typically H or a halogen (F, Cl, Br, I); also set TRUE if there is a problem setting an atom; does not include duplicates(package private) javajs.util.BS[]
bitsets for tracking R and S for Rule 4bprivate float
Rule 2 isotope mass number if identified or average atomic mass if not C (12.011) > 12C, O (15.999) invalid input: '<' 16O, and F (18.998) invalid input: '<' 19F Source:private boolean
potentially useful information that this duplicate is from an double- or triple-bond, not a ring closure(package private) String
String path, for debuggingprivate int
number of substituent atoms (non-null atoms[] entries)private CIPChirality.CIPAtom
points to next branching point that has two or more chiral branchesprivate CIPChirality.CIPAtom
first =X= atom in a string of =X=X=X=...(package private) int
the number of distinct priorities determined for this atom for the current rule; 0-4 for the root atom; 0-3 for all others(package private) int
number of root-duplicate atoms (root atom only(package private) int
the number of distinct priorities determined for this atom for the current rule; 0-4 for the root atom; 0-3 for all others(package private) int[]
priorities associated with each subsituent from high (0) to low (3); due to equivaliencies at a given rule level, these numbers may duplicate and have gaps - for example, [0 2 0 3](package private) CIPChirality.CIPAtom
direct ancestor of this atom(package private) int[]
priorities associated with each subsituent from high (0) to low (3); due to equivaliencies at a given rule level, these numbers may duplicate and have gaps - for example, [0 2 0 3](package private) int
current priority 0-3; used for Rule 4b and 5 priority sortingprivate int
Rule 1b measure: Distance from root of the corresponding nonduplicated atom (duplicate nodes only).(package private) CIPChirality.CIPAtom
sphere-1 node in this atom's root branchprivate int
Rule 4b reference chirality (R or S, 1 or 2); root only(package private) int
the auxiiary chirality type: 0: ~, 1: R, 2: S; normalized to R/S even if M/P or C/T(package private) int
reference index for Rule 6 -- root atom onlyprivate int
bond distance from the root atom to this atom -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate CIPChirality.CIPAtom
addAtom
(int i, SimpleNode other, boolean isDuplicate, boolean isAlkene, boolean isParentBond) Add a new atom or return nullprivate void
addChiralAtoms
(javajs.util.Lst<CIPChirality.CIPAtom> chiralAtoms, int ref) Create an ASCII string that allows the list of descriptors to be generated in order.private void
addReturnPath
(CIPChirality.CIPAtom newParent, CIPChirality.CIPAtom fromAtom) Add the path back to the root for an auxiliary center.private boolean
auxSort
(int rule) Sort by a given rule, preserving currentRule, which could be 4 or 5private int
breakTie
(CIPChirality.CIPAtom b, int sphere) Break a tie at any level in the iteration between to atoms that otherwise are the same by sorting their substituents.private int
Check this atom "A" vs a challenger "B" against the current rule.(package private) void
Clear Rule 4b information if Rule-5 pseudochiral centers have been found, as that could change the order of descriptors in the Mata list.clone()
private javajs.util.BS
compareLikeUnlike
(javajs.util.BS bsA, javajs.util.BS bsB) private int
Looking for phantom atom (atom number 0) or element numberprivate int
Looking for root distance -- duplicate atoms only.private int
Chapter 9 Rule 2.private int
Chapter 9 Rule 3.private int
Compare the better R-ref or S-ref list for A with the same for B.private int
Just look for match with the Rule 6 reference atom indexprivate int
compareRules4ac
(CIPChirality.CIPAtom b, String test) Chapter 9 Rules 4a and 4c.int
Used in Array.sort when an atom is set and Collection.sort when determining the Mata like/unlike sequence for Rules 4b and 5.private int
countAuxDuplicates
(int index) Get a count of the number of duplicate nodes to the auxiliary atom.(package private) CIPChirality.CIPAtom
create
(SimpleNode atom, CIPChirality.CIPAtom parent, boolean isAlkene, boolean isDuplicate, boolean isParentBond) (package private) boolean
By far the most complex of the methods, this method creates a list of downstream (higher-sphere) auxiliary chirality designators, starting with those furthest from the root and moving in, toward the root.private String
dots()
Provide an indent for clarity in debugging messagesprivate void
fillAtoms
(int pt) private CIPChirality.CIPAtom
getAuxEneEndWinner
(CIPChirality.CIPAtom end, CIPChirality.CIPAtom prevSP2, int[] retRule) Get the atom that is the highest priority of two atoms on the end of a double bond after sorting from Rule 1a through a given rule (Rule 3 or Rule 5)private int
getAuxEneWinnerChirality
(CIPChirality.CIPAtom end1, CIPChirality.CIPAtom end2, boolean isAxial, int[] retRule2) Determine the winner on one end of an alkene or cumulene and return also the rule by which that was determined.private javajs.util.BS
Create Mata-style linear atom.listRS and return the better of R-ref or S-ref.(package private) int
Check ene for first nonduplicate.private float
Calculate the average element numbers of associated double-bond atoms weighted by their most significant Kekule resonance contributor(s).private float
getMass()
get the atomic mass only if needed by Rule 2, testing for three special conditions in the case of isotopes: If a duplicate, or an isotope that is 100% nat abundant is specified, or isotopic mass is not specified, just use the average mass.(package private) int
getRule6Descriptor
(boolean isAux) The original Rule 6 implementation; allows cubane, tetrahedrane, and bicyclo[2.2.2]octane to be ns.private boolean
private javajs.util.BS
rank4bAndRead
(javajs.util.BS bsR) A thread-based sphere-ordered implementation that takes into account that lists cross the boundaries of branches.private void
replaceParentSubstituent
(CIPChirality.CIPAtom oldSub, CIPChirality.CIPAtom newParent, CIPChirality.CIPAtom newSub) Swap a substituent and the parent in preparation for reverse traversal of this path back to the root atom.private void
saveRestorePriorities
(boolean isRestore) Reset priorities after each Rule 6 test.private void
setEne()
Set all ene-related fields upon finding the second atom.(package private) boolean
setNode()
Set the atom to have substituents.private int
sign
(int score) Just a simple signum for integers(package private) boolean
sortSubstituents
(int sphere) Deep-Sort the substituents of an atom, setting the node's atoms[] and priorities[] arrays.toString()
private int
This check is not technically one of those listed in the rules, but it is useful when preparing to check substituents because if one of the atoms has substituents and the other doesn't, we are done -- there is no reason to check substituents.
-
Field Details
-
isRule5Pseudo
boolean isRule5Pseudoodd/even toggle for comparisons of Rule5 results that would make for R/S, not r/s, if this flag is false. -
id
private int idunique ID for this CIPAtom for debugging only -
sphere
private int spherebond distance from the root atom to this atom -
rootDistance
private int rootDistanceRule 1b measure: Distance from root of the corresponding nonduplicated atom (duplicate nodes only). AMENDED HERE for duplicate nodes associated with a double-bond in a 6-membered-ring benzenoid (benzene, naphthalene, pyridine, pyrazoline, etc.) "Kekule-ambiguous" system to be its sphere. -
isSet
private boolean isSeta flag to prevent finalization of an atom node more than once -
isDuplicate
boolean isDuplicatea flag to indicate atom that is a duplicate, either due to ring closure or multiple bonding -- element number and mass, but no substituents; slightly lower in priority than standard atoms. -
isTerminal
boolean isTerminala flag to indicate an atom that has no substituents; a branch end point; typically H or a halogen (F, Cl, Br, I); also set TRUE if there is a problem setting an atom; does not include duplicates -
isAlkene
private boolean isAlkeneis one atom of a double bond -
atom
SimpleNode atomthe associated Jmol (or otherwise) atom; use of the SimpleNode interface allows us to implement this in SMILES or Jmol as well as providing an interface other programs could use if implementing this code -
atomIndex
int atomIndexthe application-assigned unique atom index for this atom; used in updating lstSmallRings -
bondCount
int bondCounttrue atom covalent bond count; cached for better performance -
elemNo
float elemNoRule 1a nominal element number; may be fractional for Kekule issues -
mass
private float massRule 2 isotope mass number if identified or average atomic mass if not C (12.011) > 12C, O (15.999) invalid input: '<' 16O, and F (18.998) invalid input: '<' 19F Source: -
parent
CIPChirality.CIPAtom parentdirect ancestor of this atom -
rootSubstituent
CIPChirality.CIPAtom rootSubstituentsphere-1 node in this atom's root branch -
h1Count
int h1Counta count of how many 1H atoms we have found on this atom; used to halt further processing of this atom -
atoms
CIPChirality.CIPAtom[] atomsthe substituents -- up to four supported here at this time -
nAtoms
private int nAtomsnumber of substituent atoms (non-null atoms[] entries) -
bsPath
private javajs.util.BS bsPathbitset of indices of the associated atoms in the path to this atom node from the root; used to keep track of the path to this atom in order to prevent infinite cycling; the last atom in the path when cyclic is a duplicate atom. -
myPath
String myPathString path, for debugging -
oldPriorities
int[] oldPrioritiespriorities associated with each subsituent from high (0) to low (3); due to equivaliencies at a given rule level, these numbers may duplicate and have gaps - for example, [0 2 0 3] -
priorities
int[] prioritiespriorities associated with each subsituent from high (0) to low (3); due to equivaliencies at a given rule level, these numbers may duplicate and have gaps - for example, [0 2 0 3] -
oldNPriorities
int oldNPrioritiesthe number of distinct priorities determined for this atom for the current rule; 0-4 for the root atom; 0-3 for all others -
nPriorities
int nPrioritiesthe number of distinct priorities determined for this atom for the current rule; 0-4 for the root atom; 0-3 for all others -
priority
int prioritycurrent priority 0-3; used for Rule 4b and 5 priority sorting -
chiralPath
ASCII-encoded priority string -
nRootDuplicates
int nRootDuplicatesnumber of root-duplicate atoms (root atom only -
htPathPoints
Rule 1b hash table that maintains distance of the associated nonduplicated atom node -
rule6refIndex
int rule6refIndexreference index for Rule 6 -- root atom only -
bsRule6Subs
private javajs.util.BS bsRule6Subsa list of only the undifferentiated ligands in Rule 6 -- root atom only -
alkeneParent
first atom of an alkene or cumulene atom -
alkeneChild
last atom of an alkene or cumulene atom -
isAlkeneAtom2
private boolean isAlkeneAtom2a flag used in Rule 3 to indicate the second carbon of a double bond -
isKekuleAmbiguous
private boolean isKekuleAmbiguousis an atom that is involved in more than one Kekule form -
nextSP2
first =X= atom in a string of =X=X=X=... -
multipleBondDuplicate
private boolean multipleBondDuplicatepotentially useful information that this duplicate is from an double- or triple-bond, not a ring closure -
isEvenEne
private boolean isEvenEnealkene or even cumulene, so chirality will be EZ, not MP -
auxEZ
private int auxEZauxiliary chirality E/Z for this atom node -
isSP3
boolean isSP3a flag set false in evaluation of Rule 5 to indicate that there was more than one R/S decision made, so this center cannot be r/s; initially just indicates that the atom has 4 covalent bonds or is trigonal pyriamidal -
auxChirality
private char auxChiralityauxiliary chirality as determined in createAuxiliaryRule4Data; possibilities include R/S, r/s, M/P, m/p, C/T (but not c/t), or ~ (ASCII 126, no stereochemistry); for sorting purposes C=M=R invalid input: '<' p=r=s invalid input: '<' ~ -
nextChiralBranch
points to next branching point that has two or more chiral branches -
isChiralPath
private boolean isChiralPatha check for downstream chirality -
rule4Type
int rule4Typethe auxiiary chirality type: 0: ~, 1: R, 2: S; normalized to R/S even if M/P or C/T -
bsTemp
private javajs.util.BS bsTempused to count the number of priorities -
rule4Ref
private int rule4RefRule 4b reference chirality (R or S, 1 or 2); root only -
listRS
javajs.util.BS[] listRSbitsets for tracking R and S for Rule 4b
-
-
Constructor Details
-
CIPAtom
CIPAtom()
-
-
Method Details
-
create
CIPChirality.CIPAtom create(SimpleNode atom, CIPChirality.CIPAtom parent, boolean isAlkene, boolean isDuplicate, boolean isParentBond) - Parameters:
atom
- or null to indicate a null placeholderparent
-isAlkene
-isDuplicate
-isParentBond
-- Returns:
- this
-
getEneTop
int getEneTop()Check ene for first nonduplicate.- Returns:
- 1 or 2
-
getRule6Descriptor
int getRule6Descriptor(boolean isAux) The original Rule 6 implementation; allows cubane, tetrahedrane, and bicyclo[2.2.2]octane to be ns.- Parameters:
isAux
-- Returns:
- NO_CHIRALITY or descriptor
-
saveRestorePriorities
private void saveRestorePriorities(boolean isRestore) Reset priorities after each Rule 6 test.- Parameters:
isRestore
-
-
countAuxDuplicates
private int countAuxDuplicates(int index) Get a count of the number of duplicate nodes to the auxiliary atom.- Parameters:
index
-- Returns:
- the number of dublicates to the auxiliary center
-
getMass
private float getMass()get the atomic mass only if needed by Rule 2, testing for three special conditions in the case of isotopes: If a duplicate, or an isotope that is 100% nat abundant is specified, or isotopic mass is not specified, just use the average mass. Otherwise, use the integer isotope mass number, taking care in the cases of 16O, 52Cr, 96Mo, and 175Lu, to reduce this integer by 0.1 so as to put it in the correct relationship to the element's average mass.- Returns:
- mass or mass surrogate
-
isType
-
getKekuleElementNumber
private float getKekuleElementNumber()Calculate the average element numbers of associated double-bond atoms weighted by their most significant Kekule resonance contributor(s). We only consider simple benzenoid systems -- 6-membered rings and their 6-memebered rings fused to them. Calculated for the parent of an sp2-duplicate atom.- Returns:
- an averaged element number
-
setNode
boolean setNode()Set the atom to have substituents.- Returns:
- true if a valid atom for consideration
-
fillAtoms
private void fillAtoms(int pt) -
setEne
private void setEne()Set all ene-related fields upon finding the second atom. -
addAtom
private CIPChirality.CIPAtom addAtom(int i, SimpleNode other, boolean isDuplicate, boolean isAlkene, boolean isParentBond) Add a new atom or return null- Parameters:
i
-other
-isDuplicate
-isAlkene
-isParentBond
-- Returns:
- new atom or null
-
sortSubstituents
boolean sortSubstituents(int sphere) Deep-Sort the substituents of an atom, setting the node's atoms[] and priorities[] arrays. Checking for "ties" that will lead to pseudochirality is also done here.- Parameters:
sphere
- current working sphere; Integer.MIN_VALUE to not break ties- Returns:
- all priorities assigned
-
dots
Provide an indent for clarity in debugging messages- Returns:
- a string of dots based on the value of atom.sphere.
-
breakTie
Break a tie at any level in the iteration between to atoms that otherwise are the same by sorting their substituents.- Parameters:
b
-sphere
- current working sphere- Returns:
- [0 (TIED), -1 (A_WINS), or 1 (B_WINS)] * (sphere where broken)
-
compareTo
Used in Array.sort when an atom is set and Collection.sort when determining the Mata like/unlike sequence for Rules 4b and 5. Includes a preliminary check for duplicates, since we know that that atom will ultimately be lower priority if all other rules are tied. *- Specified by:
compareTo
in interfaceComparable<CIPChirality.CIPAtom>
- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
checkCurrentRule
Check this atom "A" vs a challenger "B" against the current rule. Note that example BB 2013 page 1258, P93.5.2.3 requires that RULE_1b be applied only after RULE_1a has been applied exhaustively for a sphere; otherwise C1 is R, not S (AY-236.53).- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS), or Intege.MIN_VALUE (IGNORE)
-
unlikeDuplicates
This check is not technically one of those listed in the rules, but it is useful when preparing to check substituents because if one of the atoms has substituents and the other doesn't, we are done -- there is no reason to check substituents.- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRule1a
Looking for phantom atom (atom number 0) or element number- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRule1b
Looking for root distance -- duplicate atoms only. (We have checked for- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRule2
Chapter 9 Rule 2. atomic mass, with possible reversal due to use of mass numbers. Also checks for temporary Rule 6 promotion for full Rule 6 implemenation (rr bicyclo[2.2.2]octane)- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRule3
Chapter 9 Rule 3. E/Z. We carry out this step only as a tie in the sphere AFTER the final atom of the alkene or even-cumulene. If this atom and the comparison atom b are on the same parent, then this is simply a request to break their tie based on Rule 3; otherwise two paths are being checked for one being seqCis and one being seqTrans.- Parameters:
b
-- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRules4ac
Chapter 9 Rules 4a and 4c. This method allows for "RS" to be checked as "either R or S". See AY236.66, AY236.67, AY236.147,148,156,170,171,201,202, etc. (4a)- Parameters:
b
-test
- String to test against; depends upon subrule being checked- Returns:
- 0 (TIED), -1 (A_WINS), or 1 (B_WINS)
-
compareRule4b5
Compare the better R-ref or S-ref list for A with the same for B.- Parameters:
b
-- Returns:
- A_WINS, B_WINS, or IGNORE
-
compareRule6
Just look for match with the Rule 6 reference atom index- Parameters:
b
-- Returns:
- A_WINS, B_WINS, or TIED
-
clearRule4Lists
void clearRule4Lists()Clear Rule 4b information if Rule-5 pseudochiral centers have been found, as that could change the order of descriptors in the Mata list. -
getBetter4bList
private javajs.util.BS getBetter4bList()Create Mata-style linear atom.listRS and return the better of R-ref or S-ref. Used first in Rule 4b and again in Rule 5.- Returns:
- the better 4b list
-
rank4bAndRead
private javajs.util.BS rank4bAndRead(javajs.util.BS bsR) A thread-based sphere-ordered implementation that takes into account that lists cross the boundaries of branches.- Parameters:
bsR
- null if this is for R or the R-ref list if this is for S- Returns:
- ranked list
-
addChiralAtoms
Create an ASCII string that allows the list of descriptors to be generated in order. This list must take into account both the current (Rule 4a or Rule 4c) priority group (0 highest to 3 lowest) of each point along the path back to the root for this node. This is done by multiplying the priority group by 4 and adding in the like- unlike-ness of the node as one of 0 (ns), 1 (like), or 2 (unlike). In this way, we can get cross-branch sorting, not just the typical breadth-first sorting that we usually use for ranking. For example, in BH_64_085, two branches of a ligand each have two branches that have identical Rule 4a priorities, leading to four branches that must be sorted as the "highest-priority" set in Rule 4b.- Parameters:
chiralAtoms
-ref
-
-
compareLikeUnlike
private javajs.util.BS compareLikeUnlike(javajs.util.BS bsA, javajs.util.BS bsB) -
createAuxiliaryDescriptors
By far the most complex of the methods, this method creates a list of downstream (higher-sphere) auxiliary chirality designators, starting with those furthest from the root and moving in, toward the root.- Parameters:
node1
- first node; sphere 1ret
- CIPAtom of next stereochemical branching point- Returns:
- collective string, with setting of rule4List
-
auxSort
private boolean auxSort(int rule) Sort by a given rule, preserving currentRule, which could be 4 or 5- Parameters:
rule
-- Returns:
- true if a decision has been made
-
getAuxEneWinnerChirality
private int getAuxEneWinnerChirality(CIPChirality.CIPAtom end1, CIPChirality.CIPAtom end2, boolean isAxial, int[] retRule2) Determine the winner on one end of an alkene or cumulene and return also the rule by which that was determined.- Parameters:
end1
-end2
-isAxial
-retRule2
- return for rule found for child end (furthest from root)- Returns:
- one of: {NO_CHIRALITY | STEREO_Z | STEREO_E | STEREO_M | STEREO_P}
-
getAuxEneEndWinner
private CIPChirality.CIPAtom getAuxEneEndWinner(CIPChirality.CIPAtom end, CIPChirality.CIPAtom prevSP2, int[] retRule) Get the atom that is the highest priority of two atoms on the end of a double bond after sorting from Rule 1a through a given rule (Rule 3 or Rule 5)- Parameters:
end
-prevSP2
-retRule
- return for deciding rule- Returns:
- higher-priority atom, or null if they are equivalent
-
addReturnPath
Add the path back to the root for an auxiliary center.- Parameters:
newParent
-fromAtom
-
-
replaceParentSubstituent
private void replaceParentSubstituent(CIPChirality.CIPAtom oldSub, CIPChirality.CIPAtom newParent, CIPChirality.CIPAtom newSub) Swap a substituent and the parent in preparation for reverse traversal of this path back to the root atom.- Parameters:
oldSub
-newParent
-newSub
-
-
sign
private int sign(int score) Just a simple signum for integers- Parameters:
score
-- Returns:
- 0, -1, or 1
-
clone
-
toString
-