InChI
 
Loading...
Searching...
No Matches
ichi.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 _ICHI_H_
8#define _ICHI_H_
9
10
11#include "incomdef.h"
12#include "mode.h"
13
14
15#define REQ_MODE_BASIC 0x000001 /* B include Fixed-H layer */
16#define REQ_MODE_TAUT 0x000002 /* T include Mobile-H layer */
17#define REQ_MODE_ISO 0x000004 /* I */
18#define REQ_MODE_NON_ISO 0x000008 /* NI */
19#define REQ_MODE_STEREO 0x000010 /* S */
20#define REQ_MODE_ISO_STEREO 0x000020 /* IS */
21#define REQ_MODE_NOEQ_STEREO 0x000040 /* SS */
22#define REQ_MODE_REDNDNT_STEREO 0x000080 /* RS */
23#define REQ_MODE_NO_ALT_SBONDS 0x000100 /* NASB */
24
25/* new 10-10-2003 */
26#define REQ_MODE_RELATIVE_STEREO 0x000200 /* REL All Relative Stereo */
27
28#define REQ_MODE_RACEMIC_STEREO 0x000400 /* RAC All Racemic Stereo */
29
30#define REQ_MODE_SC_IGN_ALL_UU 0x000800 /* IAUSC Ignore stereocenters if All Undef/Unknown */
31
32#define REQ_MODE_SB_IGN_ALL_UU 0x001000 /* IAUSC Ignore stereobonds if All Undef/Unknown */
33
34#define REQ_MODE_CHIR_FLG_STEREO 0x002000 /* SUCF If Chiral flag then Abs otherwise Rel stereo */
35/* end of 10-10-2003 */
36
37
38
39/* 2009-12-05 */
40#define REQ_MODE_DIFF_UU_STEREO 0x004000 /* SLUUD Make labels for unknown and undefined stereo different */
41/* 2009-12-05 */
42
43#define REQ_MODE_MIN_SB_RING_MASK 0x0F0000 /* RSB */
44#define REQ_MODE_MIN_SB_RING_SHFT 16
45
46#define REQ_MODE_DEFAULT (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO)
47
48#define WARN_FAILED_STEREO 0x0001
49#define WARN_FAILED_ISOTOPIC 0x0002
50#define WARN_FAILED_ISOTOPIC_STEREO 0x0004
51#define ERR_NO_CANON_RESULTS 0x0008
52
53/*********** compare components flags **********************************/
54#define CMP_COMPONENTS 0x0001 /* perform compare components */
55#define CMP_COMPONENTS_NONISO 0x0002 /* ignore isotopic */
56#define CMP_COMPONENTS_NONTAUT 0x0004 /* compare non-tautomeric */
57
58/****************** chemical identifier member definitions *************/
60{
61
62 AT_NUMB nAtomNumber; /* Canonical atom number */
63
64 NUM_H nIsoDifference; /* 0=non-isotopic; 1=rounded avg. atomic mass */
65
66 NUM_H nNum_H; /* number of 1H isotopic atoms attached */
67
68 NUM_H nNum_D; /* number of 2H isotopic atoms attached */
69
70 NUM_H nNum_T; /* number of 3H isotopic atoms attached */
72
73
74
76{
77 AT_NUMB nTGroupNumber; /* Tautomeric group number */
78 AT_NUMB nNum_H; /* number of 1H isotopic atoms */
79 AT_NUMB nNum_D; /* number of 2H isotopic atoms */
80 AT_NUMB nNum_T; /* number of 3H isotopic atoms */
82
83
84
85
86typedef struct tagINChI_Stereo
87{
88 /* [N] = allocated length */
89 /* ---- possibly tetrahedral stereogenic atoms */
90
92
93 AT_NUMB *nNumber; /* Canonical number of a possibly tetrahedral
94 * stereogenic atom or allenes [nNumberOfStereoCenters] */
95
96 S_CHAR *t_parity; /* tetrahedral (relative, see nCompInv2Abs) atom parities [nNumberOfStereoCenters] */
97 /* ---- possibly tetrahedral stereogenic atoms of the inverted structure */
98
99 AT_NUMB *nNumberInv; /* Canonical number of a possibly tetrahedral
100 * stereogenic atom or allene [nNumberOfStereoCenters] */
101
102 S_CHAR *t_parityInv; /* tetrahedral inverted atom parities [nNumberOfStereoCenters]*/
103
104 /* bFlagAbsStereoIsInverted = nCompInv2Abs==-1: Abs stereo = Inverted */
105 int nCompInv2Abs; /* 0=>Inv = Abs stereo; -1=> Inv < Abs stereo,
106 +1=> Inv > Abs stereo; +2=> in reading InChI:
107 no /m was found and in /sN N>0 */
108
109 int bTrivialInv; /* 1=> nCompInv2Abs!= 0 && Inverted = Abs stereo with inverted parities 1<-->2 */
110
111 /* ---- possibly stereogenic bonds and tetrahedral cumulenes */
113 AT_NUMB *nBondAtom1; /* Canonical number of a first atom
114 * [number of bonds] */
115 AT_NUMB *nBondAtom2; /* Canonical number of a second atom
116 * [number of bonds] */
117 S_CHAR *b_parity; /* possibly stereogenic bond parities
118 * [number of bonds] */
120#define INCHI_FLAG_ACID_TAUT 0x0001 /* tautomerism of dissociated acid invoked */
121#define INCHI_FLAG_REL_STEREO 0x0002 /* requested relative stereo */
122#define INCHI_FLAG_RAC_STEREO 0x0004 /* requested racemic stereo */
123#define INCHI_FLAG_SC_IGN_ALL_UU 0x0008 /* ignored all undefined/unknown stereocenters, non-isotopic */
124#define INCHI_FLAG_SB_IGN_ALL_UU 0x0010 /* ignored all undefined/unknown stereocenters, non-isotopic */
125#define INCHI_FLAG_SC_IGN_ALL_ISO_UU 0x0020 /* ignored all undefined/unknown stereocenters, isotopic */
126#define INCHI_FLAG_SB_IGN_ALL_ISO_UU 0x0040 /* ignored all undefined/unknown stereocenters, isotopic */
127#define INCHI_FLAG_HARD_ADD_REM_PROTON 0x0080 /* in normalization a proton has been added or removed along alt path */
128
129#define INCHI_OUT_NO_AUX_INFO 0x0001 /* do not output Aux Info */
130#define INCHI_OUT_SHORT_AUX_INFO 0x0002 /* output short version of Aux Info */
131#define INCHI_OUT_ONLY_AUX_INFO 0x0004 /* output only Aux Info */
132#define INCHI_OUT_EMBED_REC 0x0008 /* embed reconnected INChI into disconnected INChI */
133#define INCHI_OUT_SDFILE_ONLY 0x0010 /* save input data in a Molfile instead of creating INChI */
134#define INCHI_OUT_XML 0x0020 /* *obsolete* output xml INChI */
135#define INCHI_OUT_PLAIN_TEXT 0x0040 /* output plain text INChI */
136#define INCHI_OUT_PLAIN_TEXT_COMMENTS 0x0080 /* output plain text annotation */
137#define INCHI_OUT_XML_TEXT_COMMENTS 0x0100 /* *obsolete* output xml text annotation */
138#define INCHI_OUT_WINCHI_WINDOW 0x0200 /* output into wINChI text window */
139#define INCHI_OUT_TABBED_OUTPUT 0x0400 /* tab-delimited (only for plain text) */
140#define INCHI_OUT_SDFILE_ATOMS_DT 0x0800 /* SDfile output H isotopes as D and T */
141#define INCHI_OUT_SDFILE_SPLIT 0x1000 /* Split SDfile into components */
142
143#define INCHI_OUT_FIX_TRANSPOSITION_CHARGE_BUG 0x2000
144 /* used to accomodate FIX_TRANSPOSITION_CHARGE_BUG */
145#define INCHI_OUT_STDINCHI 0x4000
146#define INCHI_OUT_SAVEOPT 0x8000
147
148/* bINChIOutputOptions2+ */
149#define INCHI_OUT_INCHI_GEN_ERROR 0x0001 /* v. 1.05 */
150#define INCHI_OUT_MISMATCH_AS_ERROR 0x0002 /* v. 1.05 */
151#define INCHI_OUT_REQ_LARGE_MOL 0x0004 /* v. 1.06 */
152#define INCHI_OUT_REQ_POLYMERS 0x0008 /* v. 1.06 */
153
154/* Bits encoding InChI creation options to be saved */
155#define SAVE_OPT_SLUUD 0x0001
156#define SAVE_OPT_SUU 0x0002
157#define SAVE_OPT_FIXEDH 0x0004
158#define SAVE_OPT_RECMET 0x0008
159#define SAVE_OPT_KET 0x0010
160#define SAVE_OPT_15T 0x0020
161#define SAVE_OPT_PT_22_00 0x0040
162#define SAVE_OPT_PT_16_00 0x0080
163#define SAVE_OPT_PT_06_00 0x0100
164#define SAVE_OPT_PT_39_00 0x0200
165#define SAVE_OPT_PT_13_00 0x0400
166#define SAVE_OPT_PT_18_00 0x0800
167
168#define INCHI_OUT_PRINT_OPTIONS (INCHI_OUT_EMBED_REC | \
169 INCHI_OUT_PLAIN_TEXT | \
170 INCHI_OUT_PLAIN_TEXT_COMMENTS)
171
172
173/*******REQ_MODE_SB_IGN_ALL_UU*************** chemical identifier definition *****************/
174typedef struct tagINChI { /* [N] = allocated length */
175
176 int nErrorCode; /* 0 = success */
177 INCHI_MODE nFlags; /* INCHI_FLAG_ACID_TAUT tautomerism of dissociated acid invoked
178 INCHI_FLAG_REL_STEREO requested relative stereo
179 INCHI_FLAG_RAC_STEREO requested racemic stereo
180 INCHI_FLAG_SC_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic
181 INCHI_FLAG_SB_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic
182 INCHI_FLAG_SC_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic
183 INCHI_FLAG_SB_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic
184 INCHI_FLAG_HARD_ADD_REM_PROTON in normalization a proton has been added or removed along alt path
185 */
186 /* ---- basic & tautomer layer */
190 U_CHAR *nAtom; /* atomic numbers [nNumberOfAtoms] from the Periodic Table */
192 AT_NUMB *nConnTable; /* Connection table [nNumberOfAtoms+NumberOfBonds] */
194 AT_NUMB *nTautomer; /* NumGroups; ((NumAt+1, NumH, At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 1} - old
195 * NumGroups; ((NumAt+2, NumH, Num(-), At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 2} - new
196 * Allocated length: [5*nNumberOfAtoms/2+1], see Alloc_INChI(...) */
197 S_CHAR *nNum_H; /* number of terminal hydrogen atoms on each atom; in tautomeric
198 * representation these H on tautomeric atoms are not included [nNumberOfAtoms] */
199 S_CHAR *nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms,
200 * in non-atautomeric representation only [nNumberOfAtoms] */
201 /* ---- isotopic & isotopic tautomeric layer */
203 INChI_IsotopicAtom *IsotopicAtom; /* [nNumberOfIsotopicAtoms] */
205 /* in reversing InChI keeps a pointer to stolen from AuxInfo coordinates */
206 INChI_IsotopicTGroup *IsotopicTGroup; /* [nNumberOfIsotopicAtoms] */
207 /* ---- stereo layer */
210 /* not including mobile H groups */
211 AT_NUMB *nPossibleLocationsOfIsotopicH; /* [0]=> length including 0th element, location1,...*/
213#if ( bREUSE_INCHI == 1 )
215#endif
216#if ( bRELEASE_VERSION == 0 )
217 int bExtract;
218#endif
219#if ( READ_INCHI_STRING == 1 )
220 int nLink; /* negative: ignore InChI; positive: index of (Reconnected component) + 1 linked to it */
221#endif
223
225
226typedef struct tagOrigInfo {
228 S_CHAR cRadical; /* 0=none, 1=doublet, 2=triplet, 3=unknown */
229 S_CHAR cUnusualValence; /* see get_unusual_el_valence() */
231/******************** auxiliary chemical identifier info **************/
232typedef struct tagINChI_Aux { /* [N] = allocated length */
233
234 int nErrorCode; /* 0 = success */
236 int nNumberOfTGroups; /* non-zero only in tautomeric representation */
237 int bIsIsotopic; /* filled out even though isotopic has not been requested */
238 int bIsTautomeric; /* filled out even though tautomeric has not been requested; non-zero if taut exists */
239 /* canonical numbers of the atoms: nOrigAtNosInCanonOrd[i-1]+1 = */
240 /* input atom number for the canonical number i */
241 AT_NUMB *nOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */
242 AT_NUMB *nIsotopicOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */
243 /* same for the inverted structure */
244 AT_NUMB *nOrigAtNosInCanonOrdInv; /* inverted stereo [nNumberOfInputAtoms*1.5]; */
245 AT_NUMB *nIsotopicOrigAtNosInCanonOrdInv; /* [nNumberOfInputAtoms*1.5]; */
246 AT_NUMB *nConstitEquNumbers; /* [nNumberOfAtoms*1.5] */
247 AT_NUMB *nConstitEquTGroupNumbers; /* [nNumberOfAtoms/2] */
248 AT_NUMB *nConstitEquIsotopicNumbers; /* [nNumberOfAtoms*1.5] */
249 AT_NUMB *nConstitEquIsotopicTGroupNumbers; /* [nNumberOfAtoms/2] */
250#if ( bREUSE_INCHI == 1 )
252#endif
253
257 NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]; /* isotopic H that may be exchanged and considered
258 randomly distributed, including removed protons;
259 order: 0=>1H, 1=>D, 2=>T */
261 INCHI_MODE bTautFlags; /* t_group_info->bTautFlags */
262 INCHI_MODE bTautFlagsDone; /* t_group_info->bTautFlagsDone */
263 INCHI_MODE bNormalizationFlags; /* t_group_info->tni.bNormalizationFlags */
266
268
269/********************* array of pointers for sorting components and INChI output *********/
270typedef struct tagINChIforSort {
273 short ord_number; /* for stable sort */
274 short n1; /* points to the original; used in structure reconstruction only */
275 short n2; /* points to the original; used in structure reconstruction only */
276 short n3; /* points to the original; used in structure reconstruction only */
278
279
280
281#endif /* _ICHI_H_ */
INChI * PINChI2[TAUT_NUM]
Definition ichi.h:224
INChI_Aux * PINChI_Aux2[TAUT_NUM]
Definition ichi.h:267
struct tagINChI_IsotopicTGroup INChI_IsotopicTGroup
struct tagINChI INChI
struct tagOrigInfo ORIG_INFO
struct tagINChIforSort INCHI_SORT
struct tagINChI_Stereo INChI_Stereo
struct tagINChI_Aux INChI_Aux
struct tagINChI_IsotopicAtom INChI_IsotopicAtom
unsigned short AT_NUMB
Definition ichisize.h:10
signed short NUM_H
Definition ichisize.h:14
unsigned long INCHI_MODE
Definition ichisize.h:25
char MOL_COORD[LEN_COORD *NUM_COORD+NUM_COORD - 1]
Definition ichisize.h:29
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 TAUT_NUM
Definition mode.h:560
Definition ichi.h:232
int nRefCount
Definition ichi.h:251
INCHI_MODE bNormalizationFlags
Definition ichi.h:263
AT_NUMB * nOrigAtNosInCanonOrd
Definition ichi.h:241
ORIG_INFO * OrigInfo
Definition ichi.h:254
int bDeleted
Definition ichi.h:260
AT_NUMB * nIsotopicOrigAtNosInCanonOrd
Definition ichi.h:242
AT_NUMB * nConstitEquIsotopicNumbers
Definition ichi.h:248
INCHI_MODE bTautFlagsDone
Definition ichi.h:262
MOL_COORD * szOrigCoord
Definition ichi.h:255
AT_NUMB * nOrigAtNosInCanonOrdInv
Definition ichi.h:244
NUM_H nNumRemovedProtons
Definition ichi.h:256
int bIsIsotopic
Definition ichi.h:237
int nNumberOfTGroups
Definition ichi.h:236
AT_NUMB * nConstitEquIsotopicTGroupNumbers
Definition ichi.h:249
int nNumberOfAtoms
Definition ichi.h:235
int nCanonFlags
Definition ichi.h:264
AT_NUMB * nConstitEquTGroupNumbers
Definition ichi.h:247
int bIsTautomeric
Definition ichi.h:238
AT_NUMB * nIsotopicOrigAtNosInCanonOrdInv
Definition ichi.h:245
AT_NUMB * nConstitEquNumbers
Definition ichi.h:246
INCHI_MODE bTautFlags
Definition ichi.h:261
NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]
Definition ichi.h:257
int nErrorCode
Definition ichi.h:234
Definition ichi.h:60
NUM_H nNum_H
Definition ichi.h:66
NUM_H nNum_T
Definition ichi.h:70
NUM_H nIsoDifference
Definition ichi.h:64
NUM_H nNum_D
Definition ichi.h:68
AT_NUMB nAtomNumber
Definition ichi.h:62
Definition ichi.h:76
AT_NUMB nNum_T
Definition ichi.h:80
AT_NUMB nNum_D
Definition ichi.h:79
AT_NUMB nTGroupNumber
Definition ichi.h:77
AT_NUMB nNum_H
Definition ichi.h:78
Definition ichi.h:87
AT_NUMB * nNumber
Definition ichi.h:93
int bTrivialInv
Definition ichi.h:109
S_CHAR * t_parityInv
Definition ichi.h:102
AT_NUMB * nBondAtom1
Definition ichi.h:113
AT_NUMB * nBondAtom2
Definition ichi.h:115
S_CHAR * t_parity
Definition ichi.h:96
S_CHAR * b_parity
Definition ichi.h:117
int nNumberOfStereoCenters
Definition ichi.h:91
AT_NUMB * nNumberInv
Definition ichi.h:99
int nCompInv2Abs
Definition ichi.h:105
int nNumberOfStereoBonds
Definition ichi.h:112
Definition ichi.h:174
int nNumberOfIsotopicTGroups
Definition ichi.h:204
INChI_Stereo * StereoIsotopic
Definition ichi.h:209
int nTotalCharge
Definition ichi.h:187
S_CHAR * nNum_H_fixed
Definition ichi.h:199
S_CHAR * nNum_H
Definition ichi.h:197
INChI_IsotopicAtom * IsotopicAtom
Definition ichi.h:203
AT_NUMB * nConnTable
Definition ichi.h:192
U_CHAR * nAtom
Definition ichi.h:190
char * szHillFormula
Definition ichi.h:189
INChI_IsotopicTGroup * IsotopicTGroup
Definition ichi.h:206
int nNumberOfAtoms
Definition ichi.h:188
int bDeleted
Definition ichi.h:212
INCHI_MODE nFlags
Definition ichi.h:177
int nRefCount
Definition ichi.h:214
int nNumberOfIsotopicAtoms
Definition ichi.h:202
int lenTautomer
Definition ichi.h:193
int nLink
Definition ichi.h:220
INChI_Stereo * Stereo
Definition ichi.h:208
AT_NUMB * nTautomer
Definition ichi.h:194
AT_NUMB * nPossibleLocationsOfIsotopicH
Definition ichi.h:211
int nErrorCode
Definition ichi.h:176
int lenConnTable
Definition ichi.h:191
Definition ichi.h:270
INChI * pINChI[TAUT_NUM]
Definition ichi.h:271
short ord_number
Definition ichi.h:273
short n2
Definition ichi.h:275
short n3
Definition ichi.h:276
INChI_Aux * pINChI_Aux[TAUT_NUM]
Definition ichi.h:272
short n1
Definition ichi.h:274
Definition ichi.h:226
S_CHAR cCharge
Definition ichi.h:227
S_CHAR cUnusualValence
Definition ichi.h:229
S_CHAR cRadical
Definition ichi.h:228