2
* International Union of Pure and Applied Chemistry (IUPAC)
3
* International Chemical Identifier (InChI)
5
* Software version 1.00
10
#ifndef __INCHICANT_H__
11
#define __INCHICANT_H__
13
/******************************************************/
15
/* Canonicalization definitions */
17
/******************************************************/
21
#ifndef INCHI_US_SHORT_DEF
22
typedef signed short S_SHORT;
23
typedef unsigned short U_SHORT;
24
#define INCHI_US_SHORT_DEF
27
/*typedef unsigned long INCHI_MODE;*/
29
typedef union tagSplitLong {
34
#define _HI 1 /* Intel platform */
37
#define NEIGH_LIST_LEN 4
40
#ifndef defined_NEIGH_LIST
41
typedef AT_RANK *NEIGH_LIST;
42
#define defined_NEIGH_LIST
45
typedef struct tagEQUIV_INFO {
47
int *nCutVertexAtom; /* cut-vertex atom for the set of equivalent atoms */
48
int *nFirstInSet; /* first of equivalent atoms in the connected to the cut-vertex atom parts of the structure */
49
int *nNumInSet; /* number of the equivalent atoms connected to the cut-vertex atom */
50
int *nAtomNo; /* eqivalent atom number */
51
int *nAddToRank; /* number to add to the rank to normalize */
54
#define MOL_PART_MASK (~0x0U ^ 0x07U)
57
typedef struct tagAtData_dch {
63
#define MAXVAL 20 /* maximum valence */
67
typedef struct tagAtomInvariantBytes {
68
S_CHAR cNotExactlyHillOrderNumber;
69
S_CHAR cNumberOfConnections;
70
/* S_CHAR cNumberOfNonHydrogenBonds; */
72
#if( HYDROGENS_IN_INIT_RANKS == 1 )
73
S_CHAR cNumberOfAttachedHydrogens;
75
} ATOM_INVARIANT_BYTES;
77
typedef struct tagAtomInvariant {
78
/* non-isotopic part */
79
#if( USE_DISTANCES_FOR_RANKING == 1 )
80
AT_RANK nDistanceFromTerminal;
82
ATOM_INVARIANT_BYTES b;
83
AT_RANK cNum_tautomer; /* 0 or for tautomer endpoint: number of endpoints in the group */
84
AT_RANK cNum_tautomer_num[T_NUM_NO_ISOTOPIC]; /* 0 or numbers from t_gtroup */
86
AT_ISO_SORT_KEY iso_sort_key;
87
AT_RANK cNum_tautomer_iso[T_NUM_ISOTOPIC]; /* 0 or numbers from t_group */
89
/**********************************/
90
typedef enum tagAtInvariantIndexes {
92
AT_INV_NUM_CONNECTIONS,
94
/* for endpoint + undirected graph, otherwise 0 */
95
AT_INV_NUM_TG_ENDPOINTS,
96
AT_INV_TG_NUMBERS, /* num H, num (-) */
97
AT_INV_NUM_H_FIX = AT_INV_TG_NUMBERS+T_NUM_NO_ISOTOPIC,
99
/* here compare iso sort key */
100
AT_INV_TAUT_ISO = AT_INV_BREAK1,
101
AT_INV_LENGTH = AT_INV_TAUT_ISO + T_NUM_ISOTOPIC
104
typedef struct tagAtomInvariant2 {
105
AT_NUMB val[AT_INV_LENGTH];
106
AT_ISO_SORT_KEY iso_sort_key;
110
/******************* Partition **********************************/
111
typedef struct tagPartition {
116
/********************* BFCN *************************************/
117
typedef struct tagFixHOrTautCanonNumbering {
119
int num_at_tg; /* = num_atoms for non-taut */
122
NEIGH_LIST *NeighList; /* length = num_at_tg */
123
/****************************/
125
/****************************/
126
AT_RANK *LinearCt; /* connection table atoms (+taut. groups, directed graph)*/
127
int nLenLinearCtAtOnly;
131
Partition PartitionCt; /* canonical numbering */
132
AT_RANK *nSymmRankCt; /* orbits */
134
/* orig. fixed by tautomerism H positions */
135
NUM_H *nNumHOrig; /* original H atoms positions + taut. info, excluding tautomeric H */
136
NUM_H *nNumH; /* canonical H atoms positions + taut. info, excluding tautomeric H */
137
int nLenNumH; /* length = num_atoms + 2*num_taut_groups */
139
/* fixed H: original positions of tautomeric H; exists obly for tautomeric structures */
140
NUM_H *nNumHOrigFixH; /* original fixed positions of tautomeric H */
141
NUM_H *nNumHFixH; /* canonical fixed positions of tautomeric H */
142
int nLenNumHFixH; /* length = num_atoms */
144
/*******************************************************************************/
145
/* the following exists only if isotopic and isotopic results requested */
146
/*******************************************************************************/
147
Partition PartitionCtIso; /* canonical numbering of isotopic base structure, defined later */
148
AT_RANK *nSymmRankCtIso; /* orbits of isotopic structure */
149
AT_ISO_SORT_KEY *iso_sort_keys; /* original isotopic sort keys for atoms and taut groups */
150
AT_ISO_SORT_KEY *iso_sort_keysOrig; /* canonical isotopic sort keys for atoms and taut groups */
151
int len_iso_sort_keys;
152
S_CHAR *iso_exchg_atnos; /* canonical: 0=> tautomeric or may have isotopic H exchanged */
153
S_CHAR *iso_exchg_atnosOrig; /* original: 0=> tautomeric or may have isotopic H exchanged */
157
/******************** BCN *************************************/
158
typedef struct tagBaseCanonNumbering {
160
AT_RANK **pRankStack;
161
int nMaxLenRankStack;
162
int num_max; /* allocated nRank[] arrays lengths in pRankStack */
163
int num_at_tg; /* all of the following arrays have this length */
165
struct tagInchiTime *ulTimeOutTime;
170
/***********************************
174
typedef struct tagCanonStat {
177
long lNumNeighListIter;
179
long lNumDecreasedCT;
182
struct tagInchiTime *ulTimeOutTime;
194
AT_NUMB *LinearCT; /* connection table only */
195
AT_ISOTOPIC *LinearCTIsotopic;
196
AT_ISO_TGROUP *LinearCTIsotopicTautomer;
197
AT_STEREO_DBLE *LinearCTStereoDble;
198
AT_STEREO_CARB *LinearCTStereoCarb;
199
AT_STEREO_DBLE *LinearCTStereoDbleInv;
200
AT_STEREO_CARB *LinearCTStereoCarbInv;
201
AT_STEREO_DBLE *LinearCTIsotopicStereoDble;
202
AT_STEREO_CARB *LinearCTIsotopicStereoCarb;
203
AT_STEREO_DBLE *LinearCTIsotopicStereoDbleInv;
204
AT_STEREO_CARB *LinearCTIsotopicStereoCarbInv;
205
AT_TAUTOMER *LinearCTTautomer; /* minimal */
207
/* second copies of line notation arrays */
209
AT_NUMB *LinearCT2; /* to save non-isotopic CT */
211
int nLenLinearCTStereoDble;
212
int nLenLinearCTStereoDbleInv;
213
int nMaxLenLinearCTStereoDble; /* new */
215
int bCmpStereo; /* 0 => no stereo to invert;
216
1 => StereoCtInv < StereoCt;
217
2 => StereoCtInv = StereoCt;
218
3 => StereoCtInv > StereoCt;
220
int nLenLinearCTStereoCarb;
221
int nLenLinearCTStereoCarbInv;
222
int nMaxLenLinearCTStereoCarb; /* new */
224
int nLenLinearCTIsotopic;
225
int nMaxLenLinearCTIsotopic;
227
int nLenLinearCTIsotopicTautomer;
228
int nMaxLenLinearCTIsotopicTautomer;
230
int nLenLinearCT; /* connection table only */
231
int nLenLinearCT2; /* connection table only, non-isotopic result */
232
int nLenLinearCTAtOnly; /* connection table only without tautomeric pseudoatoms */
233
int nLenLinearCTAtOnly2; /* connection table only, non-isotopic result without tautomeric pseudoatoms */
234
int nMaxLenLinearCT; /* connection table only */
236
int nLenLinearCTTautomer;
237
int nMaxLenLinearCTTautomer;
239
int bCmpIsotopicStereo; /* 0 => no stereo to invert;
240
1 => StereoCtInv < StereoCt;
241
2 => StereoCtInv = StereoCt;
242
3 => StereoCtInv > StereoCt;
244
int nLenLinearCTIsotopicStereoDble;
245
int nLenLinearCTIsotopicStereoDbleInv;
246
int nMaxLenLinearCTIsotopicStereoDble;
248
int nLenLinearCTIsotopicStereoCarb; /* new */
249
int nLenLinearCTIsotopicStereoCarbInv; /* new */
250
int nMaxLenLinearCTIsotopicStereoCarb;
251
S_CHAR *bRankUsedForStereo; /* canon. rank used for stereo mapping */
252
S_CHAR *bAtomUsedForStereo; /* 0 if not a stereo atom or during a canon. rank being mapped on this atom; */
253
/* STEREO_AT_MARK if an unpapped stereogenic atom */
254
/* or a number of stereogenic bonds adjacent to an atom */
256
AT_RANK *nPrevAtomNumber;
258
AT_RANK *nCanonOrd; /* atom numbers in order of increasing canon. ranks */
259
AT_RANK *nSymmRank; /* symmetry numbers in order of atoms */
260
AT_RANK *nCanonOrdTaut; /* t-group numbers numbers in order of increasing canon. ranks */
261
AT_RANK *nSymmRankTaut; /* t-group symmetry numbers in order of t-groups */
263
AT_RANK *nCanonOrdStereo; /* atom numbers in order of increasing canon. ranks */
264
AT_RANK *nCanonOrdStereoInv; /* atom numbers in order of increasing canon. ranks */
265
AT_RANK *nCanonOrdStereoTaut; /* t-group numbers in order of increasing canon. ranks */
267
AT_RANK *nSymmRankIsotopic;
268
AT_RANK *nCanonOrdIsotopic; /* atom numbers in order of increasing canon. ranks */
269
AT_RANK *nSymmRankIsotopicTaut; /* !!! */
270
AT_RANK *nCanonOrdIsotopicTaut; /*/ t-group numbers in order of increasing canon. ranks */
272
AT_RANK *nCanonOrdIsotopicStereo;
273
AT_RANK *nCanonOrdIsotopicStereoInv;
274
AT_RANK *nCanonOrdIsotopicStereoTaut; /* !!! */
276
/* actual lengths if successfully calculated */
278
int nLenCanonOrd; /* Superceded by any of the following > 0 */
279
int nLenCanonOrdTaut; /* !!! Superceded by any of the following > 0 */
280
int nLenCanonOrdIsotopic;
281
int nLenCanonOrdIsotopicTaut; /* !!! */
282
int nLenCanonOrdStereo;
283
int nLenCanonOrdStereoTaut; /* !!! */
284
int nLenCanonOrdIsotopicStereo;
285
int nLenCanonOrdIsotopicStereoTaut; /* !!! */
289
int bHasIsotopicInTautomerGroups;
290
T_GROUP_INFO *t_group_info;
292
int bDoubleBondSquare; /* 0 or 2 */
294
#if( bRELEASE_VERSION == 0 )
295
int bExtract; /* for debug only */
297
NEIGH_LIST *NeighList;
299
S_CHAR *nNum_H; /* number of terminal hydrogen atoms on each atom except tautomeric [num_atoms], in order of canonical numbers */
300
S_CHAR *nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms (for non-atautomeric representation) [num_atoms] */
304
/**************************************************/
305
typedef struct tagCanonData {
307
/* same names/types as in ConTable; here the order is from original numbering */
309
AT_NUMB *LinearCT; /* output ?? */
315
/* hydrogen atoms fixed in tautomeric representation:
316
compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */
318
int lenNumH; /* used length */
319
int maxlenNumH; /* n + T_NUM_NO_ISOTOPIC*(n_tg-n) + 1 */
321
/* hydrogen atoms fixed in non-tautomeric representation only:
322
compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */
324
int lenNumHfixed; /* used length */
325
int maxlenNumHfixed; /* max length = n+1 */
327
/* isotopic atoms (without tautomeric H) and isotopic tautomeric groups */
328
/* note: AT_ISO_SORT_KEY and T_GROUP_ISOWT are identical types: long */
329
AT_ISO_SORT_KEY *iso_sort_key;
330
int len_iso_sort_key; /* used length */
331
int maxlen_iso_sort_key; /* max length = n_tg+1 */
332
S_CHAR *iso_exchg_atnos;
333
int len_iso_exchg_atnos; /* used length */
334
int maxlen_iso_exchg_atnos;
336
/* isotopic hydrogen atoms fixed in non-tautomeric representation only */
337
#if ( USE_ISO_SORT_KEY_HFIXED == 1 )
338
AT_ISO_SORT_KEY *iso_sort_key_Hfixed;
339
int len_iso_sort_key_Hfixed; /* used length */
340
int maxlen_iso_sort_key_Hfixed; /* max length = n+1 */
342
/* auxiliary ranking */
346
struct tagInchiTime *ulTimeOutTime; /* timeout */
349
/**************************************************/
351
typedef struct tagCanonCounts {
353
long lNumDecreasedCT;
359
long lNumStoredIsomorphisms;
362
/***********************************************
363
tree structure: one segment
366
at.no orig. atom numbers on which the canon. rank has been successfully mapped
368
at.no except the last at.no: it is not known if it has been mapped until all atoms are mapped
369
num.at+1 number of atoms in this segment
372
typedef struct tagCurTree {
374
int max_len; /* allocated length of tree in sizeof(tree[0]) units */
375
int cur_len; /* currently used length */
376
int incr_len; /* reallocation increment */
379
#endif /* __INCHICANT_H__ */