|
71 | 71 | * <li>{@link #HBPY9}: Heptagonal Bipyramidal</li> |
72 | 72 | * </ul> |
73 | 73 | * |
| 74 | + * <b><u>Stereo Groups (Enhanced stereo):</u></b> |
| 75 | + * Stereochemistry group information, aka "enhanced stereochemistry" in V3000 MOLFile etc allows you to specify |
| 76 | + * racemic and unknown enantiomers. In V2000 MOLfile the if chiral flag was 0 it indicates the structure was a mixture |
| 77 | + * of enantiomers. V3000 extended this concept to not only encode mixtures (and enantiomer) but also unknown |
| 78 | + * stereochemistry (or enantiomer) and to be per chiral centre. Reading an MDLV2000 molfile a chiral flag of 0 is |
| 79 | + * equivalent to setting all stereocentres to {@link #GRP_AND1}. This information can also be encoded in CXSMILES. By |
| 80 | + * default all stereocentres are {@link #GRP_ABS}. |
| 81 | + * |
| 82 | + * The stereo group information is stored in the high bytes of the stereo configuration. You can access the basic |
| 83 | + * information as follows: |
| 84 | + * <pre>{@code |
| 85 | + * int grpconfig = stereo.getGroupInfo(); |
| 86 | + * if (grpconfig & IStereoElement.GRP_AND1) { |
| 87 | + * // group is AND1 |
| 88 | + * } else if (config & IStereoElement.GRP_OR1) { |
| 89 | + * // group is OR1 |
| 90 | + * } |
| 91 | + * }</pre> |
| 92 | + * |
| 93 | + * You can also unpack the various parts of the information manually. |
| 94 | + * |
| 95 | + * <pre>{@code |
| 96 | + * int grpconfig = stereo.getGroupInfo(); |
| 97 | + * switch (grpconfig & IStereoElement.GRP_TYPE_MASK) { |
| 98 | + * case IStereoElement.GRP_ABS: |
| 99 | + * break; |
| 100 | + * case IStereoElement.GRP_AND: |
| 101 | + * break; |
| 102 | + * case IStereoElement.GRP_OR: |
| 103 | + * break; |
| 104 | + * } |
| 105 | + * |
| 106 | + * // the group number 1, 2, 3, 4 is a little more tricky, you can mask off the value as |
| 107 | + * // follows but it's shifted up into position |
| 108 | + * int num = grpconfig & IStereoElement.GRP_NUM_MASK; |
| 109 | + * |
| 110 | + * // to get the number 1, 2, 3, etc you can simply shift it down as follows |
| 111 | + * int num_act = grpconfig >>> IStereoElement.GRP_NUM_SHIFT; |
| 112 | + * }</pre> |
| 113 | + * |
74 | 114 | * @cdk.module interfaces |
75 | 115 | * @cdk.githash |
76 | 116 | * |
@@ -174,6 +214,43 @@ public interface IStereoElement<F extends IChemObject, C extends IChemObject> |
174 | 214 | /** Square Planar Configutation in Z Shape */ |
175 | 215 | public static final int SPZ = SP | 3; |
176 | 216 |
|
| 217 | + /** Mask for the stereo group information */ |
| 218 | + public static final int GRP_MASK = 0xff_0000; |
| 219 | + /** Mask for the stereo group type information, GRP_ABS, GRP_AND, GRP_OR */ |
| 220 | + public static final int GRP_TYPE_MASK = 0x03_0000; |
| 221 | + /** Mask for the stereo group number information, 0x0 .. 0xf (1..15) */ |
| 222 | + public static final int GRP_NUM_MASK = 0xfc_0000; |
| 223 | + public static final int GRP_NUM_SHIFT = 18; // Integer.numberOfTrailingZeros(0xfc_0000); |
| 224 | + |
| 225 | + /** Stereo group type ABS (absolute) */ |
| 226 | + public static final int GRP_ABS = 0x00_0000; |
| 227 | + /** Stereo group type AND (and enantiomer) */ |
| 228 | + public static final int GRP_AND = 0x01_0000; |
| 229 | + /** Stereo group type OR (or enantiomer) */ |
| 230 | + public static final int GRP_OR = 0x02_0000; |
| 231 | + |
| 232 | + /** Convenience field for testing if the stereo is group AND1 (&1). */ |
| 233 | + public static final int GRP_AND1 = GRP_AND | (1 << GRP_NUM_SHIFT); |
| 234 | + /** Convenience field for testing if the stereo is group AND2 (&2). */ |
| 235 | + public static final int GRP_AND2 = GRP_AND | (2 << GRP_NUM_SHIFT); |
| 236 | + /** Convenience field for testing if the stereo is group AND3 (&3). */ |
| 237 | + public static final int GRP_AND3 = GRP_AND | (3 << GRP_NUM_SHIFT); |
| 238 | + /** Convenience field for testing if the stereo is group AND4 (&4). */ |
| 239 | + public static final int GRP_AND4 = GRP_AND | (4 << GRP_NUM_SHIFT); |
| 240 | + /** Convenience field for testing if the stereo is group AND5 (&5). */ |
| 241 | + public static final int GRP_AND5 = GRP_AND | (5 << GRP_NUM_SHIFT); |
| 242 | + |
| 243 | + /** Convenience field for testing if the stereo is group OR1 (&1). */ |
| 244 | + public static final int GRP_OR1 = GRP_OR | (1 << GRP_NUM_SHIFT); |
| 245 | + /** Convenience field for testing if the stereo is group OR2 (&2). */ |
| 246 | + public static final int GRP_OR2 = GRP_OR | (2 << GRP_NUM_SHIFT); |
| 247 | + /** Convenience field for testing if the stereo is group OR3 (&3). */ |
| 248 | + public static final int GRP_OR3 = GRP_OR | (3 << GRP_NUM_SHIFT); |
| 249 | + /** Convenience field for testing if the stereo is group OR4 (&4). */ |
| 250 | + public static final int GRP_OR4 = GRP_OR | (4 << GRP_NUM_SHIFT); |
| 251 | + /** Convenience field for testing if the stereo is group OR5 (&5). */ |
| 252 | + public static final int GRP_OR5 = GRP_OR | (5 << GRP_NUM_SHIFT); |
| 253 | + |
177 | 254 | /** |
178 | 255 | * The focus atom or bond at the 'centre' of the stereo-configuration. |
179 | 256 | * @return the focus |
@@ -210,6 +287,18 @@ public interface IStereoElement<F extends IChemObject, C extends IChemObject> |
210 | 287 | */ |
211 | 288 | int getConfig(); |
212 | 289 |
|
| 290 | + /** |
| 291 | + * Access the stereo group information - see class doc. |
| 292 | + * @return the group info |
| 293 | + */ |
| 294 | + int getGroupInfo(); |
| 295 | + |
| 296 | + /** |
| 297 | + * Set the stereo group information - see class doc. |
| 298 | + * @param grp the group info |
| 299 | + */ |
| 300 | + void setGrpConfig(int grp); |
| 301 | + |
213 | 302 | /** |
214 | 303 | * Does the stereo element contain the provided atom. |
215 | 304 | * |
|
0 commit comments