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