InChI
 
Loading...
Searching...
No Matches
extr_ct.h
Go to the documentation of this file.
1/*
2 * International Chemical Identifier (InChI)
3 * Version 1
4 * Software version 1.07
5 * April 30, 2024
6 *
7 * MIT License
8 *
9 * Copyright (c) 2024 IUPAC and InChI Trust
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in all
19 * copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28*
29* The InChI library and programs are free software developed under the
30 * auspices of the International Union of Pure and Applied Chemistry (IUPAC).
31 * Originally developed at NIST.
32 * Modifications and additions by IUPAC and the InChI Trust.
33 * Some portions of code were developed/changed by external contributors
34 * (either contractor or volunteer) which are listed in the file
35 * 'External-contributors' included in this distribution.
36 *
37 * info@inchi-trust.org
38 *
39*/
40
41
42#ifndef _EXTR_CT_H_
43#define _EXTR_CT_H_
44
45
46
47#include "mode.h"
48#include "ichisize.h"
49#include "util.h"
50
51
52
53struct AtData
54{
55 char element[3];
57};
58
59
60
61#define NUM_CHEM_ELEMENTS 127 /* well above number of known chem. elements */
62
63
64
65#define AT_ISO_SORT_KEY_MULT 32 /* up to 32 identical hydrogen isotopes */
66 /* (similar to T_GROUP_ISOWT_MULT) */
67 /* changed from 16 9-12-2003 */
68
69typedef long AT_ISO_SORT_KEY; /* signed, should hold up to 4096*max_iso_diff */
70 /* (similar to T_GROUP_ISOWT) */
71/*
72 = num_1H + AT_ISO_SORT_KEY_MULT*(num_D + AT_ISO_SORT_KEY_MULT*(num_T+AT_ISO_SORT_KEY_MULT*iso_atw_diff))
73*/
74
75/* typedef signed char AT_ISOTOPIC; */ /* + or - */
81
88
97
99
100
101
102#define BYTE_BITS 8 /* number of bits in one byte */
103#define BOND_MASK 0xf /* 4 bits */
104#define BOND_BITS 4 /* 3 or 4 does not matter; 2 is too small for BOND_TAUTOM */
105#define BOND_ADD (BOND_BITS==2?-1:0) /* subtract 1 from bonds stored in CT */
106
107
108
109typedef struct tagAtom
110{
112 AT_NUMB neighbor[MAXVAL]; /* changed to unsigned 2-2-95. D.Ch. */
113 AT_NUMB init_rank; /* also used in remove_terminal_HDT() to save */
114 /* orig. at. number */
117 /* low 3 bits=bond type; */
118 /* high 5 bits (in case of cut-vertex atom) = an attached part number */
120 U_CHAR el_number; /* periodic table number = charge of the nucleus = */
121 /* number of the protons */
122 /* U_CHAR hill_type; */ /* number in pseudo Hill order */
124 S_CHAR chem_bonds_valence; /* 8-24-00 to treat tautomer centerpoints, etc. */
125 S_CHAR num_H; /* first not including D, T; add_DT_to_num_H() includes. */
126 S_CHAR num_iso_H[NUM_H_ISOTOPES]; /* num 1H, 2H(D), 3H(T) */
128 S_CHAR iso_atw_diff; /* abs(iso_atw_diff) < 127 or 31 - ??? */
129 AT_ISO_SORT_KEY iso_sort_key; /* = num_1H + AT_ISO_SORT_KEY_MULT^1*num_D */
130 /* + AT_ISO_SORT_KEY_MULT^2*num_T */
131 /* + AT_ISO_SORT_KEY_MULT^3*iso_atw_diff */
133 S_CHAR radical; /* 1=>doublet(.), 2=> triplet as singlet (:) */
134 /* ???? why are they same ???? */
136
137 AT_NUMB endpoint; /* tautomer analysis. If != 0 then the hydrogens & (-)charge */
138 /* are in the tautomer group. */
139
140 /*
141 Pairs stereo_bond_neighbor[] and stereo_bond_neighbor2[], etc
142 initially refer to non-isotopic and isotopic cases, respectively.
143 To use same stereo processing code these arrays are swapped when
144 switching from non-isotopic to isotopic processing and back.
145 */
146 AT_NUMB stereo_bond_neighbor[MAX_NUM_STEREO_BONDS]; /* Original number of an opposite atom */
147 AT_NUMB stereo_bond_neighbor2[MAX_NUM_STEREO_BONDS];/* (stereo bond neighbor) +1; */
148 S_CHAR stereo_bond_ord[MAX_NUM_STEREO_BONDS]; /* Ordering number of a bond/neighbor */
149 /* in the direction to the */
150 S_CHAR stereo_bond_ord2[MAX_NUM_STEREO_BONDS]; /* stereo bond opposite atom (important */
151 /* for cumulenes); */
152 S_CHAR stereo_bond_z_prod[MAX_NUM_STEREO_BONDS]; /* Relative atom-neighbors */
153 S_CHAR stereo_bond_z_prod2[MAX_NUM_STEREO_BONDS]; /* double bond planes orientation; */
154 S_CHAR stereo_bond_parity[MAX_NUM_STEREO_BONDS]; /* parity + MULT_STEREOBOND*chain_length, */
156 /*
157 parity (Mask 0x07=BITS_PARITY):
158
159 0 = AB_PARITY_NONE = not a stereo bond
160 1/2 = AB_PARITY_ODD/EVEN = bond parity defined from initial ranks
161 3 = AB_PARITY_UNKN = geometry is unknown to the user
162 4 = AB_PARITY_UNDF = not enough geometry info to find the parity
163 6 = AB_PARITY_CALC = calculate later from the neighbor ranks;
164 some ot them can be replaced with AB_PARITY_ODD/EVEN
165 after equivalence ranks have been determined
166
167 length (Mask 0x38=MASK_CUMULENE_LEN, length=stereo_bond_parity[i]/MULT_STEREOBOND):
168
169 0 => double or alternating stereogenic bond
170 1 => cumulene with 2 double bonds (stereogenic center)
171 2 => cumulene with 3 double bonds (stereogenic bond)
172 length <= (MAX_CUMULENE_LEN=2)
173 bit KNOWN_PARITIES_EQL = 0x40: all pairs of const. equ. atoms are connected
174 by stereo bonds and these bonds have identical parities
175 */
176
177 S_CHAR parity; /* -- Mask 0x07=BITS_PARITY: --
178 0 = AB_PARITY_NONE => no parity; also parity&0x38 = 0
179 1 = AB_PARITY_ODD => odd parity
180 2 = AB_PARITY_EVEN => even parity
181 3 = AB_PARITY_UNKN => user marked as unknown parity
182 4 = AB_PARITY_UNDF => parity cannot be defined because of symmetry
183 or not well defined geometry
184 */
185 S_CHAR parity2; /* parity including parity due to isotopic terminal H */
186 /* bit msks: 0x07 => known parity (1,2,3,4) or AB_PARITY_CALC=6, AB_PARITY_IISO = 6 */
187 /* 0x40 => KNOWN_PARITIES_EQL */
188 S_CHAR stereo_atom_parity; /* similar to stereo_bond_parity[]: known in
189 /( advance AB_PARITY_* value + KNOWN_PARITIES_EQL bit */
191 S_CHAR final_parity; /* defined by equivalence ranks */
192 S_CHAR final_parity2; /* defined by equivalence ranks, incl. due to terminal isotopic H */
196
197#if ( FIND_RING_SYSTEMS == 1 )
202
203#if ( FIND_RINS_SYSTEMS_DISTANCES == 1 )
205#endif
206
207#endif
208
211
212#define BOND_SINGLE BOND_TYPE_SINGLE /* 1 */
213#define BOND_DOUBLE BOND_TYPE_DOUBLE /* 2 */
214#define BOND_TRIPLE BOND_TYPE_TRIPLE /* 3 */
215#define BOND_ALTERN BOND_TYPE_ALTERN /* 4 single/double */
216
217#define BOND_ALT_123 5 /* single/double/triple */
218#define BOND_ALT_13 6 /* single/triple */
219#define BOND_ALT_23 7 /* double/triple */
220#define BOND_TAUTOM 8
221#define BOND_ALT12NS 9
222#define BOND_NUMDIF 9 /* number of different kinds of bonds */
223
224#define BOND_TYPE_MASK 0x0f
225
226#define BOND_MARK_ALL 0xf0 /* complement to BOND_TYPE_MASK */
227
228#define BOND_MARK_ALT12 0x10
229#define BOND_MARK_ALT123 0x20
230#define BOND_MARK_ALT13 0x30
231#define BOND_MARK_ALT23 0x40
232#define BOND_MARK_ALT12NS 0x50 /* 1 or 2, non-stereo */
233#define BOND_MARK_MASK 0x70
234
235#define ACTUAL_ORDER(PBNS, IAT,IBOND, BTYPE) ( ((PBNS) && (PBNS)->edge && (PBNS)->vert &&\
236 ((BTYPE)==BOND_ALT_123 || (BTYPE)==BOND_ALT_13 || (BTYPE)==BOND_ALT_23))? (PBNS)->edge[(PBNS)->vert[IAT].iedge[IBOND]].flow+BOND_TYPE_SINGLE:(BTYPE))
237
238
239#define BITS_PARITY 0x07 /* mask to retrieve half-bond parity */
240#define MASK_CUMULENE_LEN 0x38 /* mask to retrieve (cumulene chain length - 1)*MULT_STEREOBOND */
241#define KNOWN_PARITIES_EQL 0x40 /* parity is same for all pairs of constit. equivalent atoms */
242#define MAX_CUMULENE_LEN 2 /* max number of bonds in a cumulene chain - 1 */
243
244#define MULT_STEREOBOND 0x08 /* multiplier for cumulene chain length
245 odd length => chiral, even length => stereogenic bond */
247#define MAKE_BITS_CUMULENE_LEN(X) ((X)*MULT_STEREOBOND)
248#define GET_BITS_CUMULENE_LEN(X) ((X)&MASK_CUMULENE_LEN)
249#define BOND_CHAIN_LEN(X) (GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND) /* 0 => double bond, 1 => allene, 2 => cumulene,..*/
250#define IS_ALLENE_CHAIN(X) ((GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND)%2)
251
252/* atom or bond parity value definitions */
253#define AB_PARITY_NONE 0 /* 0 => no parity; also parity&0x38 = 0 */
254#define AB_PARITY_ODD 1 /* 1 => odd parity */
255#define AB_PARITY_EVEN 2 /* 2 => even parity */
256#define AB_PARITY_UNKN 3 /* 3 => user marked as unknown parity */
257#define AB_PARITY_UNDF 4 /* 4 => parity cannot be defined because of symmetry or not well defined geometry */
258#define AB_PARITY_IISO 5 /* 5 => no parity because of identical atoms */
259#define AB_PARITY_CALC 6 /* 6 => calculate parity later */
260#define AB_PARITY_0D 8 /* 8 => bit signifies 0D case -- not used */
262#define AB_INV_PARITY_BITS (AB_PARITY_ODD ^ AB_PARITY_EVEN)
263
265#define AB_MAX_KNOWN_PARITY 4 /* precalculated from const. equivalence parities */
266#define AB_MIN_KNOWN_PARITY 1
268#define AB_MAX_PART_DEFINED_PARITY 3 /* 1, 2, 3 => defined parities, uncluding 'unknown' */
269#define AB_MIN_PART_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN, AB_PARITY_UNKN) */
271#define AB_MAX_WELL_DEFINED_PARITY 2 /* 1, 2 => well defined parities, uncluding 'unknown' */
272#define AB_MIN_WELL_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN) */
274#define AB_MIN_ILL_DEFINED_PARITY 3
275#define AB_MAX_ILL_DEFINED_PARITY 4
277#define AB_MAX_ANY_PARITY 4
278#define AB_MIN_ANY_PARITY 1
280#define AMBIGUOUS_STEREO 1
281#define AMBIGUOUS_STEREO_ATOM 2
282#define AMBIGUOUS_STEREO_BOND 4
283#define AMBIGUOUS_STEREO_ATOM_ISO 8
284#define AMBIGUOUS_STEREO_BOND_ISO 16
285#define AMBIGUOUS_STEREO_ERROR 32
286
288#define MIN_DOT_PROD 50 /* min value of at->stereo_bond_z_prod[i] to define parity */
290#define ATOM_PARITY_VAL(X) (X)
291#define ATOM_PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= (X) && (X) <= AB_MAX_PART_DEFINED_PARITY)
292#define ATOM_PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_ILL_DEFINED_PARITY)
293#define ATOM_PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= (X) && (X) <= AB_MAX_KNOWN_PARITY)
294#define ATOM_PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_WELL_DEFINED_PARITY)
295#define ATOM_PARITY_NOT_UNKN(X) (ATOM_PARITY_KNOWN(X) && (X) != AB_PARITY_UNKN)
297#define PARITY_VAL(X) ((X) & BITS_PARITY)
298#define PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_PART_DEFINED_PARITY)
299#define PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_ILL_DEFINED_PARITY)
300#define PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_KNOWN_PARITY)
301#define PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_WELL_DEFINED_PARITY)
302#define PARITY_CALCULATE(X) (AB_PARITY_CALC == PARITY_VAL(X))
303#define BOND_PARITY_PART_DEFINED(X) (PARITY_PART_DEF(X) || PARITY_CALCULATE(X))
304#define BOND_PARITY_PART_KNOWN(X) (PARITY_KNOWN(X) || PARITY_CALCULATE(X))
305#define ALL_BUT_PARITY(X) ((X)&~BITS_PARITY)
307#define ALWAYS_SET_STEREO_PARITY 0
308#define NO_ISOLATED_NON_6RING_AROM_BOND 0 /* for Yuri */
309#define SAVE_6_AROM_CENTERS 0 /* for Yuri */
310
311
312
313#endif /* _EXTR_CT_H_ */
struct tagStereoDble AT_STEREO_DBLE
struct tagAtom sp_ATOM
AT_NUMB AT_STEREO
Definition extr_ct.h:98
struct tagIsotopicAtom AT_ISOTOPIC
long AT_ISO_SORT_KEY
Definition extr_ct.h:69
struct tagStereoCarb AT_STEREO_CARB
#define ATOM_EL_LEN
Definition ichicant.h:97
#define MAXVAL
Definition ichicant.h:95
unsigned short AT_NUMB
Definition ichisize.h:45
signed short NUM_H
Definition ichisize.h:49
signed char S_CHAR
Definition inchi_api.h:113
#define NUM_H_ISOTOPES
Definition inchi_api.h:107
unsigned char U_CHAR
Definition inchi_api.h:114
#define MAX_NUM_STEREO_BONDS
Definition inchi_api.h:1176
Definition extr_ct.h:54
int maxvalence
Definition extr_ct.h:56
char element[3]
Definition extr_ct.h:55
Definition extr_ct.h:110
AT_NUMB nBlockSystem
Definition extr_ct.h:201
AT_NUMB orig_at_number
Definition extr_ct.h:115
S_CHAR marked
Definition extr_ct.h:135
S_CHAR stereo_bond_z_prod2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:153
S_CHAR num_iso_H[NUM_H_ISOTOPES]
Definition extr_ct.h:126
U_CHAR bond_type[MAXVAL]
Definition extr_ct.h:119
S_CHAR stereo_bond_ord2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:150
S_CHAR valence
Definition extr_ct.h:123
AT_NUMB init_rank
Definition extr_ct.h:113
S_CHAR stereo_atom_parity2
Definition extr_ct.h:190
S_CHAR chem_bonds_valence
Definition extr_ct.h:124
S_CHAR bHasStereoOrEquToStereo2
Definition extr_ct.h:195
AT_NUMB neighbor[MAXVAL]
Definition extr_ct.h:112
S_CHAR bHasStereoOrEquToStereo
Definition extr_ct.h:194
AT_NUMB stereo_bond_neighbor[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:146
S_CHAR stereo_bond_parity2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:155
char elname[ATOM_EL_LEN]
Definition extr_ct.h:111
S_CHAR stereo_bond_parity[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:154
AT_ISO_SORT_KEY iso_sort_key
Definition extr_ct.h:129
S_CHAR charge
Definition extr_ct.h:132
AT_NUMB nNumAtInRingSystem
Definition extr_ct.h:200
S_CHAR z_dir[3]
Definition extr_ct.h:209
AT_NUMB endpoint
Definition extr_ct.h:137
S_CHAR stereo_bond_z_prod[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:152
S_CHAR final_parity2
Definition extr_ct.h:192
S_CHAR num_H
Definition extr_ct.h:125
S_CHAR bCutVertex
Definition extr_ct.h:198
AT_NUMB orig_compt_at_numb
Definition extr_ct.h:116
S_CHAR parity2
Definition extr_ct.h:185
S_CHAR final_parity
Definition extr_ct.h:191
U_CHAR el_number
Definition extr_ct.h:120
S_CHAR stereo_atom_parity
Definition extr_ct.h:188
S_CHAR radical
Definition extr_ct.h:133
S_CHAR iso_atw_diff
Definition extr_ct.h:128
S_CHAR parity
Definition extr_ct.h:177
S_CHAR bAmbiguousStereo
Definition extr_ct.h:193
S_CHAR stereo_bond_ord[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:148
AT_NUMB nRingSystem
Definition extr_ct.h:199
S_CHAR cFlags
Definition extr_ct.h:127
AT_NUMB stereo_bond_neighbor2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:147
Definition extr_ct.h:90
AT_NUMB at_num
Definition extr_ct.h:91
NUM_H num_T
Definition extr_ct.h:94
NUM_H num_1H
Definition extr_ct.h:92
NUM_H num_D
Definition extr_ct.h:93
NUM_H iso_atw_diff
Definition extr_ct.h:95
Definition extr_ct.h:77
U_CHAR parity
Definition extr_ct.h:79
AT_NUMB at_num
Definition extr_ct.h:78
Definition extr_ct.h:83
AT_NUMB at_num1
Definition extr_ct.h:84
AT_NUMB at_num2
Definition extr_ct.h:85
U_CHAR parity
Definition extr_ct.h:86