InChI
 
Loading...
Searching...
No Matches
extr_ct.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2024 IUPAC and InChI Trust
4 */
5
6
7#ifndef _EXTR_CT_H_
8#define _EXTR_CT_H_
9
10
11
12#include "mode.h"
13#include "ichisize.h"
14#include "util.h"
15
16
17
18struct AtData
19{
20 char element[3];
22};
23
24
25
26#define NUM_CHEM_ELEMENTS 127 /* well above number of known chem. elements */
27
28
29
30#define AT_ISO_SORT_KEY_MULT 32 /* up to 32 identical hydrogen isotopes */
31 /* (similar to T_GROUP_ISOWT_MULT) */
32 /* changed from 16 9-12-2003 */
33
34typedef long AT_ISO_SORT_KEY; /* signed, should hold up to 4096*max_iso_diff */
35 /* (similar to T_GROUP_ISOWT) */
36/*
37 = num_1H + AT_ISO_SORT_KEY_MULT*(num_D + AT_ISO_SORT_KEY_MULT*(num_T+AT_ISO_SORT_KEY_MULT*iso_atw_diff))
38*/
39
40/* typedef signed char AT_ISOTOPIC; */ /* + or - */
46
53
62
64
65
66
67#define BYTE_BITS 8 /* number of bits in one byte */
68#define BOND_MASK 0xf /* 4 bits */
69#define BOND_BITS 4 /* 3 or 4 does not matter; 2 is too small for BOND_TAUTOM */
70#define BOND_ADD (BOND_BITS==2?-1:0) /* subtract 1 from bonds stored in CT */
71
72
73
74typedef struct tagAtom
75{
77 AT_NUMB neighbor[MAXVAL]; /* changed to unsigned 2-2-95. D.Ch. */
78 AT_NUMB init_rank; /* also used in remove_terminal_HDT() to save */
79 /* orig. at. number */
82 /* low 3 bits=bond type; */
83 /* high 5 bits (in case of cut-vertex atom) = an attached part number */
85 U_CHAR el_number; /* periodic table number = charge of the nucleus = */
86 /* number of the protons */
87 /* U_CHAR hill_type; */ /* number in pseudo Hill order */
89 S_CHAR chem_bonds_valence; /* 8-24-00 to treat tautomer centerpoints, etc. */
90 S_CHAR num_H; /* first not including D, T; add_DT_to_num_H() includes. */
91 S_CHAR num_iso_H[NUM_H_ISOTOPES]; /* num 1H, 2H(D), 3H(T) */
93 S_CHAR iso_atw_diff; /* abs(iso_atw_diff) < 127 or 31 - ??? */
94 AT_ISO_SORT_KEY iso_sort_key; /* = num_1H + AT_ISO_SORT_KEY_MULT^1*num_D */
95 /* + AT_ISO_SORT_KEY_MULT^2*num_T */
96 /* + AT_ISO_SORT_KEY_MULT^3*iso_atw_diff */
98 S_CHAR radical; /* 1=>doublet(.), 2=> triplet as singlet (:) */
99 /* ???? why are they same ???? */
101
102 AT_NUMB endpoint; /* tautomer analysis. If != 0 then the hydrogens & (-)charge */
103 /* are in the tautomer group. */
104
105 /*
106 Pairs stereo_bond_neighbor[] and stereo_bond_neighbor2[], etc
107 initially refer to non-isotopic and isotopic cases, respectively.
108 To use same stereo processing code these arrays are swapped when
109 switching from non-isotopic to isotopic processing and back.
110 */
111 AT_NUMB stereo_bond_neighbor[MAX_NUM_STEREO_BONDS]; /* Original number of an opposite atom */
112 AT_NUMB stereo_bond_neighbor2[MAX_NUM_STEREO_BONDS];/* (stereo bond neighbor) +1; */
113 S_CHAR stereo_bond_ord[MAX_NUM_STEREO_BONDS]; /* Ordering number of a bond/neighbor */
114 /* in the direction to the */
115 S_CHAR stereo_bond_ord2[MAX_NUM_STEREO_BONDS]; /* stereo bond opposite atom (important */
116 /* for cumulenes); */
117 S_CHAR stereo_bond_z_prod[MAX_NUM_STEREO_BONDS]; /* Relative atom-neighbors */
118 S_CHAR stereo_bond_z_prod2[MAX_NUM_STEREO_BONDS]; /* double bond planes orientation; */
119 S_CHAR stereo_bond_parity[MAX_NUM_STEREO_BONDS]; /* parity + MULT_STEREOBOND*chain_length, */
121 /*
122 parity (Mask 0x07=BITS_PARITY):
123
124 0 = AB_PARITY_NONE = not a stereo bond
125 1/2 = AB_PARITY_ODD/EVEN = bond parity defined from initial ranks
126 3 = AB_PARITY_UNKN = geometry is unknown to the user
127 4 = AB_PARITY_UNDF = not enough geometry info to find the parity
128 6 = AB_PARITY_CALC = calculate later from the neighbor ranks;
129 some ot them can be replaced with AB_PARITY_ODD/EVEN
130 after equivalence ranks have been determined
131
132 length (Mask 0x38=MASK_CUMULENE_LEN, length=stereo_bond_parity[i]/MULT_STEREOBOND):
133
134 0 => double or alternating stereogenic bond
135 1 => cumulene with 2 double bonds (stereogenic center)
136 2 => cumulene with 3 double bonds (stereogenic bond)
137 length <= (MAX_CUMULENE_LEN=2)
138 bit KNOWN_PARITIES_EQL = 0x40: all pairs of const. equ. atoms are connected
139 by stereo bonds and these bonds have identical parities
140 */
141
142 S_CHAR parity; /* -- Mask 0x07=BITS_PARITY: --
143 0 = AB_PARITY_NONE => no parity; also parity&0x38 = 0
144 1 = AB_PARITY_ODD => odd parity
145 2 = AB_PARITY_EVEN => even parity
146 3 = AB_PARITY_UNKN => user marked as unknown parity
147 4 = AB_PARITY_UNDF => parity cannot be defined because of symmetry
148 or not well defined geometry
149 */
150 S_CHAR parity2; /* parity including parity due to isotopic terminal H */
151 /* bit msks: 0x07 => known parity (1,2,3,4) or AB_PARITY_CALC=6, AB_PARITY_IISO = 6 */
152 /* 0x40 => KNOWN_PARITIES_EQL */
153 S_CHAR stereo_atom_parity; /* similar to stereo_bond_parity[]: known in
154 /( advance AB_PARITY_* value + KNOWN_PARITIES_EQL bit */
156 S_CHAR final_parity; /* defined by equivalence ranks */
157 S_CHAR final_parity2; /* defined by equivalence ranks, incl. due to terminal isotopic H */
161
162#if ( FIND_RING_SYSTEMS == 1 )
167
168#if ( FIND_RINS_SYSTEMS_DISTANCES == 1 )
170#endif
171
172#endif
173
176
177#define BOND_SINGLE BOND_TYPE_SINGLE /* 1 */
178#define BOND_DOUBLE BOND_TYPE_DOUBLE /* 2 */
179#define BOND_TRIPLE BOND_TYPE_TRIPLE /* 3 */
180#define BOND_ALTERN BOND_TYPE_ALTERN /* 4 single/double */
181
182#define BOND_ALT_123 5 /* single/double/triple */
183#define BOND_ALT_13 6 /* single/triple */
184#define BOND_ALT_23 7 /* double/triple */
185#define BOND_TAUTOM 8
186#define BOND_ALT12NS 9
187#define BOND_NUMDIF 9 /* number of different kinds of bonds */
188
189#define BOND_TYPE_MASK 0x0f
190
191#define BOND_MARK_ALL 0xf0 /* complement to BOND_TYPE_MASK */
192
193#define BOND_MARK_ALT12 0x10
194#define BOND_MARK_ALT123 0x20
195#define BOND_MARK_ALT13 0x30
196#define BOND_MARK_ALT23 0x40
197#define BOND_MARK_ALT12NS 0x50 /* 1 or 2, non-stereo */
198#define BOND_MARK_MASK 0x70
199
200#define ACTUAL_ORDER(PBNS, IAT,IBOND, BTYPE) ( ((PBNS) && (PBNS)->edge && (PBNS)->vert &&\
201 ((BTYPE)==BOND_ALT_123 || (BTYPE)==BOND_ALT_13 || (BTYPE)==BOND_ALT_23))? (PBNS)->edge[(PBNS)->vert[IAT].iedge[IBOND]].flow+BOND_TYPE_SINGLE:(BTYPE))
202
203
204#define BITS_PARITY 0x07 /* mask to retrieve half-bond parity */
205#define MASK_CUMULENE_LEN 0x38 /* mask to retrieve (cumulene chain length - 1)*MULT_STEREOBOND */
206#define KNOWN_PARITIES_EQL 0x40 /* parity is same for all pairs of constit. equivalent atoms */
207#define MAX_CUMULENE_LEN 2 /* max number of bonds in a cumulene chain - 1 */
208
209#define MULT_STEREOBOND 0x08 /* multiplier for cumulene chain length
210 odd length => chiral, even length => stereogenic bond */
212#define MAKE_BITS_CUMULENE_LEN(X) ((X)*MULT_STEREOBOND)
213#define GET_BITS_CUMULENE_LEN(X) ((X)&MASK_CUMULENE_LEN)
214#define BOND_CHAIN_LEN(X) (GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND) /* 0 => double bond, 1 => allene, 2 => cumulene,..*/
215#define IS_ALLENE_CHAIN(X) ((GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND)%2)
216
217/* atom or bond parity value definitions */
218#define AB_PARITY_NONE 0 /* 0 => no parity; also parity&0x38 = 0 */
219#define AB_PARITY_ODD 1 /* 1 => odd parity */
220#define AB_PARITY_EVEN 2 /* 2 => even parity */
221#define AB_PARITY_UNKN 3 /* 3 => user marked as unknown parity */
222#define AB_PARITY_UNDF 4 /* 4 => parity cannot be defined because of symmetry or not well defined geometry */
223#define AB_PARITY_IISO 5 /* 5 => no parity because of identical atoms */
224#define AB_PARITY_CALC 6 /* 6 => calculate parity later */
225#define AB_PARITY_0D 8 /* 8 => bit signifies 0D case -- not used */
227#define AB_INV_PARITY_BITS (AB_PARITY_ODD ^ AB_PARITY_EVEN)
228
230#define AB_MAX_KNOWN_PARITY 4 /* precalculated from const. equivalence parities */
231#define AB_MIN_KNOWN_PARITY 1
233#define AB_MAX_PART_DEFINED_PARITY 3 /* 1, 2, 3 => defined parities, uncluding 'unknown' */
234#define AB_MIN_PART_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN, AB_PARITY_UNKN) */
236#define AB_MAX_WELL_DEFINED_PARITY 2 /* 1, 2 => well defined parities, uncluding 'unknown' */
237#define AB_MIN_WELL_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN) */
239#define AB_MIN_ILL_DEFINED_PARITY 3
240#define AB_MAX_ILL_DEFINED_PARITY 4
242#define AB_MAX_ANY_PARITY 4
243#define AB_MIN_ANY_PARITY 1
245#define AMBIGUOUS_STEREO 1
246#define AMBIGUOUS_STEREO_ATOM 2
247#define AMBIGUOUS_STEREO_BOND 4
248#define AMBIGUOUS_STEREO_ATOM_ISO 8
249#define AMBIGUOUS_STEREO_BOND_ISO 16
250#define AMBIGUOUS_STEREO_ERROR 32
251
253#define MIN_DOT_PROD 50 /* min value of at->stereo_bond_z_prod[i] to define parity */
255#define ATOM_PARITY_VAL(X) (X)
256#define ATOM_PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= (X) && (X) <= AB_MAX_PART_DEFINED_PARITY)
257#define ATOM_PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_ILL_DEFINED_PARITY)
258#define ATOM_PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= (X) && (X) <= AB_MAX_KNOWN_PARITY)
259#define ATOM_PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_WELL_DEFINED_PARITY)
260#define ATOM_PARITY_NOT_UNKN(X) (ATOM_PARITY_KNOWN(X) && (X) != AB_PARITY_UNKN)
262#define PARITY_VAL(X) ((X) & BITS_PARITY)
263#define PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_PART_DEFINED_PARITY)
264#define PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_ILL_DEFINED_PARITY)
265#define PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_KNOWN_PARITY)
266#define PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_WELL_DEFINED_PARITY)
267#define PARITY_CALCULATE(X) (AB_PARITY_CALC == PARITY_VAL(X))
268#define BOND_PARITY_PART_DEFINED(X) (PARITY_PART_DEF(X) || PARITY_CALCULATE(X))
269#define BOND_PARITY_PART_KNOWN(X) (PARITY_KNOWN(X) || PARITY_CALCULATE(X))
270#define ALL_BUT_PARITY(X) ((X)&~BITS_PARITY)
272#define ALWAYS_SET_STEREO_PARITY 0
273#define NO_ISOLATED_NON_6RING_AROM_BOND 0 /* for Yuri */
274#define SAVE_6_AROM_CENTERS 0 /* for Yuri */
275
276
277
278#endif /* _EXTR_CT_H_ */
struct tagStereoDble AT_STEREO_DBLE
struct tagAtom sp_ATOM
AT_NUMB AT_STEREO
Definition extr_ct.h:63
struct tagIsotopicAtom AT_ISOTOPIC
long AT_ISO_SORT_KEY
Definition extr_ct.h:34
struct tagStereoCarb AT_STEREO_CARB
#define ATOM_EL_LEN
Definition ichicant.h:62
#define MAXVAL
Definition ichicant.h:60
unsigned short AT_NUMB
Definition ichisize.h:10
signed short NUM_H
Definition ichisize.h:14
signed char S_CHAR
Definition inchi_api.h:78
#define NUM_H_ISOTOPES
Definition inchi_api.h:72
unsigned char U_CHAR
Definition inchi_api.h:79
#define MAX_NUM_STEREO_BONDS
Definition inchi_api.h:1141
Definition extr_ct.h:19
int maxvalence
Definition extr_ct.h:21
char element[3]
Definition extr_ct.h:20
Definition extr_ct.h:75
AT_NUMB nBlockSystem
Definition extr_ct.h:166
AT_NUMB orig_at_number
Definition extr_ct.h:80
S_CHAR marked
Definition extr_ct.h:100
S_CHAR stereo_bond_z_prod2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:118
S_CHAR num_iso_H[NUM_H_ISOTOPES]
Definition extr_ct.h:91
U_CHAR bond_type[MAXVAL]
Definition extr_ct.h:84
S_CHAR stereo_bond_ord2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:115
S_CHAR valence
Definition extr_ct.h:88
AT_NUMB init_rank
Definition extr_ct.h:78
S_CHAR stereo_atom_parity2
Definition extr_ct.h:155
S_CHAR chem_bonds_valence
Definition extr_ct.h:89
S_CHAR bHasStereoOrEquToStereo2
Definition extr_ct.h:160
AT_NUMB neighbor[MAXVAL]
Definition extr_ct.h:77
S_CHAR bHasStereoOrEquToStereo
Definition extr_ct.h:159
AT_NUMB stereo_bond_neighbor[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:111
S_CHAR stereo_bond_parity2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:120
char elname[ATOM_EL_LEN]
Definition extr_ct.h:76
S_CHAR stereo_bond_parity[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:119
AT_ISO_SORT_KEY iso_sort_key
Definition extr_ct.h:94
S_CHAR charge
Definition extr_ct.h:97
AT_NUMB nNumAtInRingSystem
Definition extr_ct.h:165
S_CHAR z_dir[3]
Definition extr_ct.h:174
AT_NUMB endpoint
Definition extr_ct.h:102
S_CHAR stereo_bond_z_prod[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:117
S_CHAR final_parity2
Definition extr_ct.h:157
S_CHAR num_H
Definition extr_ct.h:90
S_CHAR bCutVertex
Definition extr_ct.h:163
AT_NUMB orig_compt_at_numb
Definition extr_ct.h:81
S_CHAR parity2
Definition extr_ct.h:150
S_CHAR final_parity
Definition extr_ct.h:156
U_CHAR el_number
Definition extr_ct.h:85
S_CHAR stereo_atom_parity
Definition extr_ct.h:153
S_CHAR radical
Definition extr_ct.h:98
S_CHAR iso_atw_diff
Definition extr_ct.h:93
S_CHAR parity
Definition extr_ct.h:142
S_CHAR bAmbiguousStereo
Definition extr_ct.h:158
S_CHAR stereo_bond_ord[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:113
AT_NUMB nRingSystem
Definition extr_ct.h:164
S_CHAR cFlags
Definition extr_ct.h:92
AT_NUMB stereo_bond_neighbor2[MAX_NUM_STEREO_BONDS]
Definition extr_ct.h:112
Definition extr_ct.h:55
AT_NUMB at_num
Definition extr_ct.h:56
NUM_H num_T
Definition extr_ct.h:59
NUM_H num_1H
Definition extr_ct.h:57
NUM_H num_D
Definition extr_ct.h:58
NUM_H iso_atw_diff
Definition extr_ct.h:60
Definition extr_ct.h:42
U_CHAR parity
Definition extr_ct.h:44
AT_NUMB at_num
Definition extr_ct.h:43
Definition extr_ct.h:48
AT_NUMB at_num1
Definition extr_ct.h:49
AT_NUMB at_num2
Definition extr_ct.h:50
U_CHAR parity
Definition extr_ct.h:51