~ubuntu-branches/debian/stretch/openbabel/stretch

« back to all changes in this revision

Viewing changes to src/formats/inchi_api.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-07-22 23:54:58 UTC
  • mfrom: (3.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080722235458-3o606czluviz4akx
Tags: 2.2.0-2
* Upload to unstable.
* debian/control: Updated descriptions.
* debian/patches/gauss_cube_format.patch: New patch, makes the 
  gaussian cube format available again.
* debian/rules (DEB_DH_MAKESHLIBS_ARGS_libopenbabel3): Removed.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Likewise.
* debian/libopenbabel3.install: Adjust formats directory to single 
  version hierarchy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * International Union of Pure and Applied Chemistry (IUPAC)
3
 
 * International Chemical Identifier (InChI)
4
 
 * Version 1
5
 
 * Software version 1.01
6
 
 * May 16, 2006
7
 
 * Developed at NIST
8
 
 */
9
 
 
10
 
#ifndef __INHCH_API_H__
11
 
#define __INHCH_API_H__
12
 
 
13
 
/* radical definitions */
14
 
typedef enum tagINCHIRadical {
15
 
   INCHI_RADICAL_NONE    = 0,
16
 
   INCHI_RADICAL_SINGLET = 1,
17
 
   INCHI_RADICAL_DOUBLET = 2,
18
 
   INCHI_RADICAL_TRIPLET = 3
19
 
} inchi_Radical;
20
 
 
21
 
/* bond type definitions */
22
 
typedef enum tagINCHIBondType {
23
 
   INCHI_BOND_TYPE_NONE    =  0,
24
 
   INCHI_BOND_TYPE_SINGLE  =  1,
25
 
   INCHI_BOND_TYPE_DOUBLE  =  2,
26
 
   INCHI_BOND_TYPE_TRIPLE  =  3,
27
 
   INCHI_BOND_TYPE_ALTERN  =  4
28
 
} inchi_BondType;
29
 
/* 2D stereo definitions */
30
 
typedef enum tagINCHIBondStereo2D {
31
 
   /* stereocenter-related; positive: the sharp end points to this atom  */
32
 
   INCHI_BOND_STEREO_NONE           =  0,
33
 
   INCHI_BOND_STEREO_SINGLE_1UP     =  1,
34
 
   INCHI_BOND_STEREO_SINGLE_1EITHER =  4,
35
 
   INCHI_BOND_STEREO_SINGLE_1DOWN   =  6,
36
 
   /* stereocenter-related; negative: the sharp end points to the opposite atom  */
37
 
   INCHI_BOND_STEREO_SINGLE_2UP     = -1,
38
 
   INCHI_BOND_STEREO_SINGLE_2EITHER = -4,
39
 
   INCHI_BOND_STEREO_SINGLE_2DOWN   = -6,
40
 
   /* stereobond-related */
41
 
   INCHI_BOND_STEREO_DOUBLE_EITHER  =  3 /* unknown stereobond geometry */
42
 
} inchi_BondStereo2D;
43
 
 
44
 
/*************************************************************************
45
 
 * Notes on using INCHI_BOND_STEREO_SINGLE_*  from inchi_BondStereo2D    *
46
 
 *                                                                       *
47
 
 * These stereo markings are used by InChI to characterize a stereogenic *
48
 
 * atom if and only if all neighbors of this atom have same z-coordinate *
49
 
 * as this atom (that is, in case of 2D fragment).                       *
50
 
 * The only exception is INCHI_BOND_STEREO_SINGLE_?EITHER marking which  *
51
 
 * always assigns to the atom an "unknown" parity (u).                   *
52
 
 *                                                                       *
53
 
 * Note that the -NEWPS InChI option changes 2D stereo interpretation:   *
54
 
 * only bonds that have sharp end pointing to the stereogenic atom are   *
55
 
 * considered as being out of plane and only sharp ends of               *
56
 
 * INCHI_BOND_STEREO_SINGLE_?EITHER bonds are considered to determine    *
57
 
 * whether the stereochemistry is unknown.                               *
58
 
 *************************************************************************/
59
 
 
60
 
/* sizes definitions */
61
 
#define MAXVAL                   20 /* max number of bonds per atom                 */
62
 
#define ATOM_EL_LEN               6 /* length of ASCIIZ element symbol field        */
63
 
#define NUM_H_ISOTOPES            3 /* number of hydrogen isotopes: protium, D, T   */
64
 
#define ISOTOPIC_SHIFT_FLAG   10000 /* add to isotopic mass if isotopic_mass =      */
65
 
                                    /* (isotopic mass - average atomic mass)        */
66
 
#define ISOTOPIC_SHIFT_MAX      100 /* max abs(isotopic mass - average atomic mass) */
67
 
 
68
 
#ifndef INCHI_US_CHAR_DEF
69
 
typedef signed char   S_CHAR;
70
 
typedef unsigned char U_CHAR;
71
 
#define INCHI_US_CHAR_DEF
72
 
#endif
73
 
 
74
 
#ifndef INCHI_US_SHORT_DEF
75
 
typedef signed short   S_SHORT;
76
 
typedef unsigned short U_SHORT;
77
 
#define INCHI_US_SHORT_DEF
78
 
#endif
79
 
 
80
 
typedef  S_SHORT AT_NUM;          /* atom number; starts from 0 */
81
 
 
82
 
/*************************************************
83
 
 *
84
 
 *
85
 
 *  A T O M S   a n d   C O N N E C T I V I T Y
86
 
 *
87
 
 *
88
 
 *************************************************/
89
 
 
90
 
typedef struct tagInchiAtom {
91
 
    /* atom coordinates */
92
 
    double x;
93
 
    double y;
94
 
    double z;
95
 
    /* connectivity */
96
 
    AT_NUM  neighbor[MAXVAL];     /* adjacency list: ordering numbers of */
97
 
                                  /*            the adjacent atoms, >= 0 */
98
 
    S_CHAR  bond_type[MAXVAL];    /* inchi_BondType */
99
 
    /* 2D stereo */
100
 
    S_CHAR  bond_stereo[MAXVAL];  /* inchi_BondStereo2D; negative if the */
101
 
                                  /* sharp end points to opposite atom */
102
 
    /* other atom properties */
103
 
    char    elname[ATOM_EL_LEN];  /* zero-terminated chemical element name:*/
104
 
                                  /* "H", "Si", etc. */
105
 
    AT_NUM  num_bonds;            /* number of neighbors, bond types and bond*/
106
 
                                  /* stereo in the adjacency list */
107
 
    S_CHAR  num_iso_H[NUM_H_ISOTOPES+1]; /* implicit hydrogen atoms */
108
 
                                  /* [0]: number of implicit non-isotopic H
109
 
                                       (exception: num_iso_H[0]=-1 means INCHI
110
 
                                       adds implicit H automatically),
111
 
                                     [1]: number of implicit isotopic 1H (protium),
112
 
                                     [2]: number of implicit 2H (deuterium),
113
 
                                     [3]: number of implicit 3H (tritium) */
114
 
    AT_NUM  isotopic_mass;        /* 0 => non-isotopic; isotopic mass or  */
115
 
                                  /* ISOTOPIC_SHIFT_FLAG + mass - (average atomic mass) */
116
 
    S_CHAR  radical;              /* inchi_Radical */
117
 
    S_CHAR  charge;               /* positive or negative; 0 => no charge */
118
 
}inchi_Atom;
119
 
 
120
 
/*******************************************************************
121
 
 * Notes: 1. Atom ordering numbers (i, k, and atom[i].neighbor[j] below)
122
 
 *           start from zero; max. ordering number is (num_atoms-1).
123
 
 *        2. inchi_Atom atom[i] is connected to the atom[atom[i].neighbor[j]]
124
 
 *           by a bond that has type atom[i].bond_type[j] and 2D stereo type
125
 
 *           atom[i].bond_stereo[j] (in case of no stereo
126
 
 *           atom[i].bond_stereo[j] = INCHI_BOND_STEREO_NONE)
127
 
 *           Index j is in the range 0 <= j <= (atom[i].num_bonds-1)
128
 
 *        3. Any connection (represented by atom[i].neighbor[j],
129
 
 *           atom[i].bond_type[j], and atom[i].bond_stereo[j])
130
 
 *           should be present in one or both adjacency list:
131
 
 *             if k = atom[i].neighbor[j] then i may or may not be present in
132
 
 *           atom[k].neighbor[] list. For example, the adjacency lists may be
133
 
 *           populated with only such neighbors that atom[i].neighbor[j] < i
134
 
 *           All elements of an adjacency list must be different, that is,
135
 
 *           a bond must be specified in an adjacency list only once.
136
 
 *        4. in Molfiles usually
137
 
 *           (number of implicit H) = Valence - SUM(bond_type[])
138
 
 *        5. Seemingly illogical order of the inchi_Atom members was
139
 
 *           chosen in an attempt to avoid alignment problems when
140
 
 *           accessing inchi_Atom from unrelated to C programming
141
 
 *           languages such as Visual Basic.
142
 
 *******************************************************************/
143
 
 
144
 
/*******************************************************************
145
 
    0D Stereo Parity and Type definitions
146
 
 *******************************************************************
147
 
            Note:
148
 
            =====
149
 
            o Below #A is the ordering number of atom A, starting from 0
150
 
            o See parity values corresponding to 'o', 'e', and 'u' in
151
 
              inchi_StereoParity0D definition below)
152
 
 
153
 
           =============================================
154
 
            stereogenic bond >A=B< or cumulene >A=C=C=B<
155
 
           =============================================
156
 
 
157
 
                                 neighbor[4]  : {#X,#A,#B,#Y} in this order
158
 
     X                           central_atom : NO_ATOM
159
 
      \            X      Y      type         : INCHI_StereoType_DoubleBond
160
 
       A==B         \    /
161
 
           \         A==B
162
 
            Y
163
 
 
164
 
    parity= 'e'    parity= 'o'   unknown parity = 'u'
165
 
 
166
 
    Limitations:
167
 
    ============
168
 
    o Atoms A and B in cumulenes MUST be connected by a chain of double bonds;
169
 
      atoms A and B in a stereogenic 'double bond' may be connected by a double,
170
 
      single, or alternating bond.
171
 
    o One atom may belong to up to 3 stereogenic bonds (i.g. in a fused
172
 
      aromatic structure).
173
 
    o Multiple stereogenic bonds incident to any given atom should
174
 
      either all except possibly one have (possibly different) defined
175
 
      parities ('o' or 'e') or should all have an unknown parity 'u'.
176
 
 
177
 
      Note on parities of alternating stereobonds
178
 
      ===========================================
179
 
                                                     D--E
180
 
      In large rings  (see Fig. 1, all              //   \\
181
 
      atoms are C) all alternating bonds         B--C      F--G
182
 
      are treated as stereogenic.              //              \\
183
 
      To avoid "undefined" bond parities      A                  H
184
 
      for bonds BC, DE, FG, HI, JK, LM, AN     \               /
185
 
      it is recommended to mark them with       N==M       J==I
186
 
      parities.                                     \     /
187
 
                                                      L==K    Fig. 1
188
 
      Such a marking will make
189
 
      the stereochemical layer unambiguous
190
 
      and it will be different from the          B--C      F--G
191
 
      stereochemical layer of the second       //   \\   //    \\
192
 
      structure (Fig. 2).                     A      D--E        H
193
 
                                               \               /
194
 
                                                N==M       J==I
195
 
      By default, double and alternating            \     /
196
 
      bonds in 8-member and greater rings             L==K    Fig. 2
197
 
      are treated by InChI as stereogenic.
198
 
 
199
 
 
200
 
           =============================================
201
 
            tetrahedral atom
202
 
           =============================================
203
 
 
204
 
   4 neighbors
205
 
 
206
 
            X                    neighbor[4] : {#W, #X, #Y, #Z}
207
 
            |                    central_atom: #A
208
 
         W--A--Y                 type        : INCHI_StereoType_Tetrahedral
209
 
            |
210
 
            Z
211
 
   parity: if (X,Y,Z) are clockwize when seen from W then parity is 'e' otherwise 'o'
212
 
   Example (see AXYZW above): if W is above the plane XYZ then parity = 'e'
213
 
 
214
 
   3 neighbors
215
 
 
216
 
              Y          Y       neighbor[4] : {#A, #X, #Y, #Z}
217
 
             /          /        central_atom: #A
218
 
         X--A  (e.g. O=S   )     type        : INCHI_StereoType_Tetrahedral
219
 
             \          \
220
 
              Z          Z
221
 
 
222
 
   parity: if (X,Y,Z) are clockwize when seen from A then parity is 'e',
223
 
                                                          otherwise 'o'
224
 
   unknown parity = 'u'
225
 
   Example (see AXYZ above): if A is above the plane XYZ then parity = 'e'
226
 
   This approach may be used also in case of an implicit H attached to A.
227
 
 
228
 
           =============================================
229
 
            allene
230
 
           =============================================
231
 
 
232
 
       X       Y                 neighbor[4]  : {#X,#A,#B,#Y}
233
 
        \     /                  central_atom : #C
234
 
         A=C=B                   type         : INCHI_StereoType_Allene
235
 
 
236
 
                                      Y      X
237
 
                                      |      |
238
 
     when seen from A along A=C=B:  X-A    Y-A
239
 
 
240
 
                          parity:   'e'    'o'
241
 
 
242
 
   parity: if A, B, Y are clockwise when seen from X then parity is 'e',
243
 
                                                          otherwise 'o'
244
 
   unknown parity = 'u'
245
 
   Example (see XACBY above): if X on the diagram is above the plane ABY
246
 
                                                      then parity is 'o'
247
 
 
248
 
   Limitations
249
 
   ===========
250
 
   o Atoms A and B in allenes MUST be connected by a chain of double bonds;
251
 
 
252
 
   ==============================================
253
 
   Note. Correspondence to CML 0D stereo parities
254
 
   ==============================================
255
 
   a list of 4 atoms corresponds to CML atomRefs4
256
 
 
257
 
   tetrahedral atom
258
 
   ================
259
 
       CML atomParity > 0 <=> INCHI_PARITY_EVEN
260
 
       CML atomParity < 0 <=> INCHI_PARITY_ODD
261
 
 
262
 
                                    | 1   1   1   1  |  where xW is x-coordinate of
263
 
                                    | xW  xX  xY  xZ |  atom W, etc. (xyz is a
264
 
       CML atomParity = determinant | yW  yX  yY  yZ |  'right-handed' Cartesian
265
 
                                    | zW  zX  xY  zZ |  coordinate system)
266
 
 
267
 
   allene (not yet defined in CML)
268
 
   ===============================
269
 
   the parity corresponds to the sign of the following determinant
270
 
   in exactly same way as for tetrahedral atoms:
271
 
 
272
 
       | 1   1   1   1  |  where bonds and neighbor[4] array are
273
 
       | xX  xA  xB  xY |  same as defined above for allenes
274
 
       | yX  yA  yB  yY |  Obviously, the parity is same for
275
 
       | zX  zA  xB  zY |  {#X,#A,#B,#Y} and {#Y,#B,#A,#X}
276
 
                           because of the even number of column permutations.
277
 
 
278
 
   stereogenic double bond and (not yet defined in CML) cumulenes
279
 
   ==============================================================
280
 
       CML 'C' (cis)      <=> INCHI_PARITY_ODD
281
 
       CML 'T' (trans)    <=> INCHI_PARITY_EVEN
282
 
 
283
 
 
284
 
   How InChI uses 0D parities
285
 
   ==========================
286
 
 
287
 
   1. 0D parities are used if all atom coordinates are zeroes.
288
 
 
289
 
   In addition to that:
290
 
 
291
 
   2. 0D parities are used for Stereobonds, Allenes, or Cumulenes if:
292
 
 
293
 
   2a. A bond to the end-atom is shorter than MIN_BOND_LEN=0.000001
294
 
   2b. A ratio of two bond lengths to the end-atom is smaller than MIN_SINE=0.03
295
 
   2c. In case of a linear fragment X-A=B end-atom A is treated as satisfying 2a-b
296
 
 
297
 
       0D parities are used if 2a or 2b or 2c applies to one or both end-atoms.
298
 
 
299
 
   3. 0D parities are used for Tetrahedral Atoms if at least one of 3a-c is true:
300
 
 
301
 
   3a. One of bonds to the central atom is shorter than MIN_BOND_LEN=0.000001
302
 
   3b. A ratio of two bond lengths to the central atom is smaller than MIN_SINE=0.03
303
 
   3c. The four neighbors are almost in one plane or the central atom and
304
 
       its only 3 explicit neighbors are almost in one plane
305
 
 
306
 
   Notes on 0D parities and 'undefined' stereogenic elements
307
 
   =========================================================
308
 
 
309
 
   If 0D parity is to be used according to 1-3 but    CH3     CH3
310
 
   has not been provided then the corresponding         \    /
311
 
   stereogenic element is considered 'undefined'.        C=CH
312
 
                                                        /
313
 
   For example, if in the structure (Fig. 3)           H
314
 
   the explicit H has been moved so that it                Fig. 3
315
 
   has same coordinates as atom >C= (that is,
316
 
   the length of the bond H-C became zero)
317
 
   then the double bond is assigned 'undefined'       CH3      CH3
318
 
   parity which by default is omitted from the          \     /
319
 
   Identifier.                                           CH=CH
320
 
 
321
 
   However, the structure on Fig. 4 will have double        Fig. 4
322
 
   bond parity 'o' and its parity in the Identifier is (-).
323
 
 
324
 
   Notes on 0D parities in structures containing metals
325
 
   ====================================================
326
 
   Since InChI disconnects bonds to metals the 0D parities upon the
327
 
   disconnection may change in several different ways:
328
 
 
329
 
   1) previously non-stereogenic bond may become stereogenic:
330
 
 
331
 
         \     /                            \     /  
332
 
          CH==CH          disconnection      CH==CH  
333
 
           \ /               ======>                 
334
 
            M                                  M     
335
 
 
336
 
     before the disconnection:    after the disconnection:
337
 
     atoms C have valence=5 and   the double bond may become
338
 
     the double bond is not       stereogenic
339
 
     recognized as stereogenic
340
 
 
341
 
   2) previously stereogenic bond may become non-stereogenic:
342
 
 
343
 
       M                           M(+)       
344
 
        \    /                             / 
345
 
         N==C      disconnection    (-)N==C  
346
 
             \        ======>              \ 
347
 
 
348
 
   3) Oddball structures, usually resulting from projecting 3D
349
 
      structures on the plane, may contain fragment like that
350
 
      depicted on Fig. 5:
351
 
 
352
 
              M   A                      M   A   
353
 
              |\ /   B                      /   B 
354
 
              | X   /     disconnection    /   /  
355
 
              |/ \ /         ======>      /   /   
356
 
              C===C                      C===C    
357
 
             Fig. 5
358
 
     (X stands for bond intersection)
359
 
    
360
 
     A-C=C-B parity is              A-C=C-B parity is
361
 
     trans (e)                      cis (o) or undefined
362
 
     because the bond               because C valence = 3,
363
 
     orientation is same            not 4.
364
 
     as on Fig, 6 below:
365
 
 
366
 
          A       M
367
 
           \     /     Removal of M from the structure
368
 
            C===C      on Fig. 5 changes the geometry from trans
369
 
           /     \     to cis. 
370
 
          M'      B    Removal of M and M' from the structure
371
 
          Fig. 6       on Fig. 6 does not change the A-C=C-B
372
 
                       geometry: it is trans.
373
 
 
374
 
   To resolve the problem InChI API accepts the second parity
375
 
   corresponding to the metal-disconnected structure.
376
 
   To store both bond parities use left shift by 3 bits:
377
 
 
378
 
   inchi_Stereo0D::parity = ParityOfConnected | (ParityOfDisconnected<<3)
379
 
 
380
 
   In case when only disconnected structure parity exists set
381
 
   ParityOfConnected = INCHI_PARITY_UNDEFINED.
382
 
   This is the only case when INCHI_PARITY_UNDEFINED parity
383
 
   may be fed to the InChI.
384
 
 
385
 
   In cases when the bond parity in a disconnected structure exists and
386
 
   differs from the parity in the connected structure the atoms A and B
387
 
   should be non-metals.
388
 
 
389
 
****************************************************************************/
390
 
 
391
 
#define NO_ATOM          (-1) /* non-existent (central) atom */
392
 
 
393
 
/* 0D parity types */
394
 
typedef enum tagINCHIStereoType0D {
395
 
   INCHI_StereoType_None        = 0,
396
 
   INCHI_StereoType_DoubleBond  = 1,
397
 
   INCHI_StereoType_Tetrahedral = 2,
398
 
   INCHI_StereoType_Allene      = 3
399
 
} inchi_StereoType0D;
400
 
 
401
 
/* 0D parities */
402
 
typedef enum tagINCHIStereoParity0D {
403
 
   INCHI_PARITY_NONE      = 0,
404
 
   INCHI_PARITY_ODD       = 1,  /* 'o' */
405
 
   INCHI_PARITY_EVEN      = 2,  /* 'e' */
406
 
   INCHI_PARITY_UNKNOWN   = 3,  /* 'u' */
407
 
   INCHI_PARITY_UNDEFINED = 4   /* '?' -- should not be used; however, see Note above */
408
 
} inchi_StereoParity0D;
409
 
 
410
 
 
411
 
/*************************************************
412
 
 *
413
 
 *
414
 
 *  0D - S T E R E O  (if no coordinates given)
415
 
 *
416
 
 *
417
 
 *************************************************/
418
 
 
419
 
 
420
 
typedef struct tagINCHIStereo0D {
421
 
    AT_NUM  neighbor[4];    /* 4 atoms always */
422
 
    AT_NUM  central_atom;   /* central tetrahedral atom or a central */
423
 
                            /* atom of allene; otherwise NO_ATOM */
424
 
    S_CHAR  type;           /* inchi_StereoType0D */
425
 
    S_CHAR  parity;         /* inchi_StereoParity0D: may be a combination of two parities: */
426
 
                            /* ParityOfConnected | (ParityOfDisconnected << 3), see Note above */
427
 
}inchi_Stereo0D;
428
 
 
429
 
/*************************************************
430
 
 *
431
 
 *
432
 
 *  I N C h I    D L L     I n p u t
433
 
 *
434
 
 *
435
 
 *************************************************/
436
 
 
437
 
/* Structure -> InChI, GetINCHI() */
438
 
typedef struct tagINCHI_Input {
439
 
    /* the caller is responsible for the data allocation and deallocation */
440
 
    inchi_Atom     *atom;         /* array of num_atoms elements */
441
 
    inchi_Stereo0D *stereo0D;     /* array of num_stereo0D 0D stereo elements or NULL */
442
 
    char           *szOptions;    /* InChI options: space-delimited; each is preceded by */
443
 
                                  /* '/' or '-' depending on OS and compiler */
444
 
    AT_NUM          num_atoms;    /* number of atoms in the structure < 1024 */
445
 
    AT_NUM          num_stereo0D; /* number of 0D stereo elements */
446
 
}inchi_Input;
447
 
 
448
 
/* InChI -> Structure, GetStructFromINCHI() */
449
 
typedef struct tagINCHI_InputINCHI {
450
 
    /* the caller is responsible for the data allocation and deallocation */
451
 
    char *szInChI;     /* InChI ASCIIZ string to be converted to a strucure */
452
 
    char *szOptions;   /* InChI options: space-delimited; each is preceded by */
453
 
                       /* '/' or '-' depending on OS and compiler */
454
 
} inchi_InputINCHI;
455
 
 
456
 
 
457
 
/*************************************************
458
 
 *
459
 
 *
460
 
 *  I N C h I     D L L     O u t p u t
461
 
 *
462
 
 *
463
 
 *************************************************/
464
 
 
465
 
/* Structure -> InChI */
466
 
typedef struct tagINCHI_Output {
467
 
    /* zero-terminated C-strings allocated by GetINCHI() */
468
 
    /* to deallocate all of them call FreeINCHI() (see below) */
469
 
    char *szInChI;     /* InChI ASCIIZ string */
470
 
    char *szAuxInfo;   /* Aux info ASCIIZ string */
471
 
    char *szMessage;   /* Error/warning ASCIIZ message */
472
 
    char *szLog;       /* log-file ASCIIZ string, contains a human-readable list */
473
 
                       /* of recognized options and possibly an Error/warning message */
474
 
} inchi_Output;
475
 
 
476
 
/* InChI -> Structure */
477
 
typedef struct tagINCHI_OutputStruct {
478
 
    /* 4 pointers are allocated by GetStructFromINCHI()     */
479
 
    /* to deallocate all of them call FreeStructFromINCHI() */
480
 
    inchi_Atom     *atom;         /* array of num_atoms elements */
481
 
    inchi_Stereo0D *stereo0D;     /* array of num_stereo0D 0D stereo elements or NULL */
482
 
    AT_NUM          num_atoms;    /* number of atoms in the structure < 1024 */
483
 
    AT_NUM          num_stereo0D; /* number of 0D stereo elements */
484
 
    char           *szMessage;    /* Error/warning ASCIIZ message */
485
 
    char           *szLog;        /* log-file ASCIIZ string, contains a human-readable list */
486
 
                                  /* of recognized options and possibly an Error/warning message */
487
 
    unsigned long  WarningFlags[2][2]; /* warnings, see INCHIDIFF in inchicmp.h */
488
 
                                       /* [x][y]: x=0 => Reconnected if present in InChI otherwise Disconnected/Normal
489
 
                                                  x=1 => Disconnected layer if Reconnected layer is present
490
 
                                                  y=1 => Main layer or Mobile-H
491
 
                                                  y=0 => Fixed-H layer
492
 
                                        */
493
 
}inchi_OutputStruct;
494
 
 
495
 
/*************************************************
496
 
 *
497
 
 *
498
 
 *  I N C h I      D L L     I n t e r f a c e
499
 
 *
500
 
 *
501
 
 *************************************************/
502
 
 
503
 
#if (defined( _WIN32 ) && defined( _MSC_VER ) && defined(INCHI_LINK_AS_DLL) )
504
 
    /* Win32 & MS VC ++, compile and link as a DLL */
505
 
    #ifdef _USRDLL
506
 
        /* InChI library dll */
507
 
        #define INCHI_API __declspec(dllexport)
508
 
        #define EXPIMP_TEMPLATE
509
 
        #define INCHI_DECL __stdcall
510
 
     #else
511
 
        /* calling the InChI dll program */
512
 
        #define INCHI_API __declspec(dllimport)
513
 
        #define EXPIMP_TEMPLATE extern
514
 
        #define INCHI_DECL __stdcall
515
 
     #endif
516
 
#else
517
 
    /* create a statically linked InChI library or link to an executable */
518
 
    #define INCHI_API
519
 
    #define EXPIMP_TEMPLATE
520
 
    #define INCHI_DECL
521
 
#endif
522
 
 
523
 
/* GetINCHI(...) and Get_inchi_Input_FromAuxInfo(...) return values: */
524
 
 
525
 
typedef enum tagRetValGetINCHI {
526
 
 
527
 
    inchi_Ret_SKIP    = -2, /* not used in InChI library */
528
 
    inchi_Ret_EOF     = -1, /* no structural data has been provided */
529
 
    inchi_Ret_OKAY    =  0, /* Success; no errors or warnings */
530
 
    inchi_Ret_WARNING =  1, /* Success; warning(s) issued */
531
 
    inchi_Ret_ERROR   =  2, /* Error: no InChI has been created */
532
 
    inchi_Ret_FATAL   =  3, /* Severe error: no InChI has been created (typically, memory allocation failure) */
533
 
    inchi_Ret_UNKNOWN =  4, /* Unknown program error */
534
 
    inchi_Ret_BUSY    =  5  /* Previuos call to InChI has not returned yet */
535
 
 
536
 
} RetValGetINCHI;
537
 
 
538
 
/* to compile all InChI code as a C++ code #define INCHI_ALL_CPP */
539
 
#ifndef INCHI_ALL_CPP
540
 
#ifdef __cplusplus
541
 
extern "C" {
542
 
#endif
543
 
#endif
544
 
 
545
 
/* inchi_Input is created by the user; strings in inchi_Output are allocated and deallocated by InChI */
546
 
/* inchi_Output does not need to be initilized out to zeroes; see FreeINCHI() on how to deallocate it */
547
 
EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHI( inchi_Input *inp, inchi_Output *out );
548
 
 
549
 
/* FreeINCHI() should be called to deallocate char* pointers obtained from each GetINCHI() call */
550
 
EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeINCHI ( inchi_Output *out );
551
 
 
552
 
/* helper: get string length */
553
 
EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStringLength( char *p );
554
 
 
555
 
/* inchi_Inputinchi_InputINCHI is created by the user; pointers in inchi_OutputStruct are allocated and deallocated by InChI */
556
 
/* inchi_OutputStruct does not need to be initilized out to zeroes; see FreeStructFromINCHI() on how to deallocate it  */
557
 
/* Option /Inchi2Struct is not needed for GetStructFromINCHI(...) */
558
 
EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromINCHI( inchi_InputINCHI *inpInChI, inchi_OutputStruct *outStruct );
559
 
 
560
 
/* FreeStructFromINCHI( ) should be called to deallocate pointers obtained from each GetINCHI()GetStructFromINCHI() call */
561
 
EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromINCHI( inchi_OutputStruct *out );
562
 
 
563
 
/* GetINCHIfromINCHI does same as -InChI2InChI option: converts InChI into InChI for validation purposes */
564
 
/* It may also be used to filter out specific layers. For instance, /Snon would remove stereochemical layer */
565
 
/* Omitting /FixedH and/or /RecMet would remove Fixed-H or Reconnected layers */
566
 
/* To keep all InChI layers use options string "/FixedH /RecMet"; option /InChI2InChI is not needed */
567
 
/* inchi_InputINCHI is created by the user; strings in inchi_Output are allocated and deallocated by InChI */
568
 
/* inchi_Output does not need to be initilized out to zeroes; see FreeINCHI() on how to deallocate it */
569
 
EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIfromINCHI( inchi_InputINCHI *inpInChI, inchi_Output *out );
570
 
 
571
 
 
572
 
#ifndef INCHI_ALL_CPP
573
 
#ifdef __cplusplus
574
 
}
575
 
#endif
576
 
#endif
577
 
 
578
 
 /**********************************************************
579
 
     Using inchi_Input::szOptions related to ChiralFlag
580
 
  **********************************************************
581
 
  Awailable options (use - instead of / for O.S. other than MS Windows):
582
 
  
583
 
      /SUCF            Use Chiral Flag
584
 
      /ChiralFlagON    Set Chiral Flag
585
 
      /ChiralFlagOFF   Set Not-Chiral Flag
586
 
 
587
 
   The following table describes the effect of the options
588
 
   ---------------------------------------------------------------
589
 
   Options               Equivalent to    Chiral Flag Information
590
 
                                          stored in AuxInfo
591
 
   ---------------------------------------------------------------
592
 
   /SUCF /ChiralFlagON    /SABS             Chiral Flag
593
 
   /SUCF /ChiralFlagOFF   /SREL             Not-Chiral Flag 
594
 
   /SUCF                  /SREL             none
595
 
   /ChiralFlagON           none             Chiral Flag
596
 
   /ChiralFlagOFF          none             Not-Chiral Flag
597
 
 
598
 
  *************************************************************
599
 
    Other options available in InChI Library (case insensitive)
600
 
  *************************************************************
601
 
    /SNon        Exclude stereo (Default: Include Absolute stereo)
602
 
    /SRel        Relative stereo
603
 
    /SRac        Racemic stereo
604
 
 
605
 
    /SUU         Include omitted unknown/undefined stereo
606
 
    /NEWPS       Narrow end of wedge points to stereocenter (default: both)
607
 
    /RecMet      Include reconnected bond to metal results
608
 
    /FixedH      Mobile H Perception Off (Default: On)
609
 
    /AuxNone     Omit auxiliary information (default: Include)
610
 
    /NoADP       Disable Aggressive Deprotonation (for testing only)
611
 
    /Compress    Compressed output
612
 
    /DoNotAddH   Overrides inchi_Atom::num_iso_H[0] == -1
613
 
    /Wnumber     Set time-out per structure in seconds; W0 means unlimited
614
 
                 In InChI library the default value is unlimited
615
 
    /OutputSDF   Output SDfile instead of InChI
616
 
    /WarnOnEmptyStructure Warn and produce empty InChI for empty structure
617
 
 
618
 
    Empty InChI format:   InChI=1//
619
 
                          AuxInfo=1//
620
 
*/
621
 
 
622
 
 
623
 
/*****************************************************************
624
 
 *
625
 
 *
626
 
 *   C o n v e r s i o n:   InChI  AuxInfo string => inchi_Input
627
 
 *
628
 
 *
629
 
 *****************************************************************/
630
 
 
631
 
#ifndef STR_ERR_LEN
632
 
#define STR_ERR_LEN     256
633
 
#endif
634
 
 
635
 
typedef struct tagInchiInpData {
636
 
    inchi_Input *pInp;    /* a pointer to pInp that has all items 0 or NULL */
637
 
    int          bChiral; /* 1 => the structure was marked as chiral, 2=> not chiral, 0=> not marked */
638
 
    char         szErrMsg[STR_ERR_LEN];
639
 
} InchiInpData;
640
 
 
641
 
/* to compile all InChI code as a C++ code #define INCHI_ALL_CPP */
642
 
#ifndef INCHI_ALL_CPP
643
 
#ifdef __cplusplus
644
 
extern "C" {
645
 
#endif
646
 
#endif
647
 
 
648
 
/*  Input
649
 
    -----
650
 
    szInchiAuxInfo: contains ASCIIZ string of InChI output for a single
651
 
                   structure or only the AuxInfo line
652
 
    bDoNotAddH:    if 0 then InChI will be allowed to add implicit H
653
 
    pInchiInp:     should have a valid pointer pInchiInp->pInp to an empty 
654
 
                   (all members = 0) inchi_Input structure 
655
 
 
656
 
    Output
657
 
    ------
658
 
    pInchiInp:     The following members of pInp may be filled during the call:
659
 
                   atom, num_atoms, stereo0D, num_stereo0D
660
 
    Return value:  see RetValGetINCHI
661
 
*/
662
 
EXPIMP_TEMPLATE INCHI_API int INCHI_DECL Get_inchi_Input_FromAuxInfo
663
 
             ( char *szInchiAuxInfo, int bDoNotAddH, InchiInpData *pInchiInp );
664
 
 
665
 
/*
666
 
    To deallocate and write zeroes into the changed members of pInchiInp->pInp call
667
 
    Free_inchi_Input( inchi_Input *pInp )
668
 
*/
669
 
EXPIMP_TEMPLATE INCHI_API void INCHI_DECL Free_inchi_Input( inchi_Input *pInp );
670
 
 
671
 
#ifndef INCHI_ALL_CPP
672
 
#ifdef __cplusplus
673
 
}
674
 
#endif
675
 
#endif
676
 
 
677
 
/*
678
 
 
679
 
=======================================================================
680
 
============= prototypes for C calling conventions: ===================
681
 
=======================================================================
682
 
int  GetINCHI( inchi_Input *inp, inchi_Output *out );
683
 
void FreeINCHI( inchi_Output *out );
684
 
 
685
 
int  GetStringLength( char *p );
686
 
 
687
 
int  Get_inchi_Input_FromAuxInfo
688
 
     ( char *szInchiAuxInfo, int bDoNotAddH, InchiInpData *pInchiInp );
689
 
void Free_inchi_Input( inchi_Input *pInp );
690
 
 
691
 
int GetStructFromINCHI( inchi_InputINCHI *inpInChI, inchi_OutputStruct *outStruct );
692
 
int GetINCHIfromINCHI( inchi_InputINCHI *inpInChI, inchi_Output *out );
693
 
void FreeStructFromINCHI( inchi_OutputStruct *out );
694
 
 
695
 
======================================================================
696
 
Win32 Dumpbin export information
697
 
======================================================================  
698
 
Ordinal  Hint        Entry point
699
 
 
700
 
cdecl 
701
 
  1       0 000DB23E FreeINCHI
702
 
  7       1 000DB2A2 FreeStructFromINCHI
703
 
  2       2 000DB270 Free_inchi_Input
704
 
  3       3 000DB22C GetINCHI
705
 
  8       4 000DB290 GetINCHIfromINCHI
706
 
  4       5 000DB24C GetStringLength
707
 
  6       6 000DB27E GetStructFromINCHI
708
 
  5       7 000DB25A Get_inchi_Input_FromAuxInfo
709
 
__stdcall or PASCAL
710
 
  9       8 000D6960 _FreeINCHI@4
711
 
 10       9 000D69E9 _FreeStructFromINCHI@4
712
 
 11       A 000310FA _Free_inchi_Input@4
713
 
 12       B 000D6A99 _GetINCHI@8
714
 
 13       C 000DA1F3 _GetINCHIfromINCHI@8
715
 
 14       D 000DA1D6 _GetStringLength@4
716
 
 15       E 000DA9B7 _GetStructFromINCHI@8
717
 
 16       F 00030ED1 _Get_inchi_Input_FromAuxInfo@12
718
 
 
719
 
 
720
 
=======================================================================
721
 
 
722
 
 
723
 
*/
724
 
 
725
 
/* Currently there is no callback function for aborting, progress, etc. */
726
 
 
727
 
#endif /* __INHCH_API_H__ */