rino 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +44 -0
- data/Rakefile +123 -0
- data/ext/extconf.rb +26 -0
- data/ext/ruby_inchi_main.so +0 -0
- data/ext/src/aux2atom.h +2786 -0
- data/ext/src/comdef.h +148 -0
- data/ext/src/e_0dstereo.c +3014 -0
- data/ext/src/e_0dstereo.h +31 -0
- data/ext/src/e_comdef.h +57 -0
- data/ext/src/e_ctl_data.h +147 -0
- data/ext/src/e_ichi_io.c +498 -0
- data/ext/src/e_ichi_io.h +40 -0
- data/ext/src/e_ichi_parms.c +37 -0
- data/ext/src/e_ichi_parms.h +41 -0
- data/ext/src/e_ichicomp.h +50 -0
- data/ext/src/e_ichierr.h +40 -0
- data/ext/src/e_ichimain.c +593 -0
- data/ext/src/e_ichisize.h +43 -0
- data/ext/src/e_inchi_atom.c +75 -0
- data/ext/src/e_inchi_atom.h +33 -0
- data/ext/src/e_inpdef.h +41 -0
- data/ext/src/e_mode.h +706 -0
- data/ext/src/e_mol2atom.c +649 -0
- data/ext/src/e_readinch.c +58 -0
- data/ext/src/e_readmol.c +54 -0
- data/ext/src/e_readmol.h +180 -0
- data/ext/src/e_readstru.c +251 -0
- data/ext/src/e_readstru.h +33 -0
- data/ext/src/e_util.c +284 -0
- data/ext/src/e_util.h +61 -0
- data/ext/src/extr_ct.h +251 -0
- data/ext/src/ichi.h +206 -0
- data/ext/src/ichi_bns.c +7999 -0
- data/ext/src/ichi_bns.h +231 -0
- data/ext/src/ichican2.c +5000 -0
- data/ext/src/ichicano.c +2195 -0
- data/ext/src/ichicano.h +49 -0
- data/ext/src/ichicans.c +1625 -0
- data/ext/src/ichicant.h +379 -0
- data/ext/src/ichicomn.h +260 -0
- data/ext/src/ichicomp.h +50 -0
- data/ext/src/ichidrp.h +119 -0
- data/ext/src/ichierr.h +124 -0
- data/ext/src/ichiisot.c +101 -0
- data/ext/src/ichilnct.c +286 -0
- data/ext/src/ichimain.h +132 -0
- data/ext/src/ichimak2.c +1189 -0
- data/ext/src/ichimake.c +3812 -0
- data/ext/src/ichimake.h +205 -0
- data/ext/src/ichimap1.c +851 -0
- data/ext/src/ichimap2.c +2856 -0
- data/ext/src/ichimap4.c +1609 -0
- data/ext/src/ichinorm.c +741 -0
- data/ext/src/ichinorm.h +67 -0
- data/ext/src/ichiparm.c +45 -0
- data/ext/src/ichiparm.h +1441 -0
- data/ext/src/ichiprt1.c +3612 -0
- data/ext/src/ichiprt2.c +1511 -0
- data/ext/src/ichiprt3.c +3011 -0
- data/ext/src/ichiqueu.c +1003 -0
- data/ext/src/ichiring.c +326 -0
- data/ext/src/ichiring.h +49 -0
- data/ext/src/ichisize.h +35 -0
- data/ext/src/ichisort.c +539 -0
- data/ext/src/ichister.c +3538 -0
- data/ext/src/ichister.h +35 -0
- data/ext/src/ichitaut.c +3843 -0
- data/ext/src/ichitaut.h +387 -0
- data/ext/src/ichitime.h +74 -0
- data/ext/src/inchi_api.h +670 -0
- data/ext/src/inchi_dll.c +1480 -0
- data/ext/src/inchi_dll.h +34 -0
- data/ext/src/inchi_dll_main.c +23 -0
- data/ext/src/inchi_dll_main.h +31 -0
- data/ext/src/inpdef.h +328 -0
- data/ext/src/lreadmol.h +1246 -0
- data/ext/src/mode.h +706 -0
- data/ext/src/ruby_inchi_main.c +558 -0
- data/ext/src/runichi.c +4179 -0
- data/ext/src/strutil.c +3861 -0
- data/ext/src/strutil.h +182 -0
- data/ext/src/util.c +1130 -0
- data/ext/src/util.h +85 -0
- data/lib/clean_tempfile.rb +220 -0
- data/lib/rino.rb +111 -0
- data/test/test.rb +386 -0
- metadata +130 -0
data/ext/src/ichicant.h
ADDED
@@ -0,0 +1,379 @@
|
|
1
|
+
/*
|
2
|
+
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
|
+
* International Chemical Identifier (InChI)
|
4
|
+
* Version 1
|
5
|
+
* Software version 1.00
|
6
|
+
* April 13, 2005
|
7
|
+
* Developed at NIST
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef __INCHICANT_H__
|
11
|
+
#define __INCHICANT_H__
|
12
|
+
|
13
|
+
/******************************************************/
|
14
|
+
/* */
|
15
|
+
/* Canonicalization definitions */
|
16
|
+
/* */
|
17
|
+
/******************************************************/
|
18
|
+
#include "ichisize.h"
|
19
|
+
|
20
|
+
|
21
|
+
#ifndef INCHI_US_SHORT_DEF
|
22
|
+
typedef signed short S_SHORT;
|
23
|
+
typedef unsigned short U_SHORT;
|
24
|
+
#define INCHI_US_SHORT_DEF
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/*typedef unsigned long INCHI_MODE;*/
|
28
|
+
|
29
|
+
typedef union tagSplitLong {
|
30
|
+
unsigned long ul;
|
31
|
+
U_SHORT us[2];
|
32
|
+
}SU_LONG;
|
33
|
+
|
34
|
+
#define _HI 1 /* Intel platform */
|
35
|
+
#define _LO 0
|
36
|
+
|
37
|
+
#define NEIGH_LIST_LEN 4
|
38
|
+
#define U_LONG_LEN 2
|
39
|
+
|
40
|
+
#ifndef defined_NEIGH_LIST
|
41
|
+
typedef AT_RANK *NEIGH_LIST;
|
42
|
+
#define defined_NEIGH_LIST
|
43
|
+
#endif
|
44
|
+
|
45
|
+
typedef struct tagEQUIV_INFO {
|
46
|
+
int nNumSets;
|
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 */
|
52
|
+
} EQUIV_INFO;
|
53
|
+
|
54
|
+
#define MOL_PART_MASK (~0x0U ^ 0x07U)
|
55
|
+
|
56
|
+
|
57
|
+
typedef struct tagAtData_dch {
|
58
|
+
char element[3];
|
59
|
+
int valence;
|
60
|
+
}AT_DATA;
|
61
|
+
|
62
|
+
|
63
|
+
#define MAXVAL 20 /* maximum valence */
|
64
|
+
|
65
|
+
#define ATOM_EL_LEN 6
|
66
|
+
|
67
|
+
typedef struct tagAtomInvariantBytes {
|
68
|
+
S_CHAR cNotExactlyHillOrderNumber;
|
69
|
+
S_CHAR cNumberOfConnections;
|
70
|
+
/* S_CHAR cNumberOfNonHydrogenBonds; */
|
71
|
+
S_CHAR cAtomicNumber;
|
72
|
+
#if( HYDROGENS_IN_INIT_RANKS == 1 )
|
73
|
+
S_CHAR cNumberOfAttachedHydrogens;
|
74
|
+
#endif
|
75
|
+
} ATOM_INVARIANT_BYTES;
|
76
|
+
|
77
|
+
typedef struct tagAtomInvariant {
|
78
|
+
/* non-isotopic part */
|
79
|
+
#if( USE_DISTANCES_FOR_RANKING == 1 )
|
80
|
+
AT_RANK nDistanceFromTerminal;
|
81
|
+
#endif
|
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 */
|
85
|
+
/* isotopic part */
|
86
|
+
AT_ISO_SORT_KEY iso_sort_key;
|
87
|
+
AT_RANK cNum_tautomer_iso[T_NUM_ISOTOPIC]; /* 0 or numbers from t_group */
|
88
|
+
} ATOM_INVARIANT;
|
89
|
+
/**********************************/
|
90
|
+
typedef enum tagAtInvariantIndexes {
|
91
|
+
AT_INV_HILL_ORDER,
|
92
|
+
AT_INV_NUM_CONNECTIONS,
|
93
|
+
AT_INV_NUM_H,
|
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,
|
98
|
+
AT_INV_BREAK1,
|
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
|
102
|
+
} AT_INV_INDEXES;
|
103
|
+
|
104
|
+
typedef struct tagAtomInvariant2 {
|
105
|
+
AT_NUMB val[AT_INV_LENGTH];
|
106
|
+
AT_ISO_SORT_KEY iso_sort_key;
|
107
|
+
S_CHAR iso_aux_key;
|
108
|
+
} ATOM_INVARIANT2;
|
109
|
+
|
110
|
+
/******************* Partition **********************************/
|
111
|
+
typedef struct tagPartition {
|
112
|
+
AT_RANK *Rank;
|
113
|
+
AT_NUMB *AtNumber;
|
114
|
+
} Partition;
|
115
|
+
|
116
|
+
/********************* BFCN *************************************/
|
117
|
+
typedef struct tagFixHOrTautCanonNumbering {
|
118
|
+
|
119
|
+
int num_at_tg; /* = num_atoms for non-taut */
|
120
|
+
int num_atoms;
|
121
|
+
int nCanonFlags;
|
122
|
+
NEIGH_LIST *NeighList; /* length = num_at_tg */
|
123
|
+
/****************************/
|
124
|
+
/* base structure */
|
125
|
+
/****************************/
|
126
|
+
AT_RANK *LinearCt; /* connection table atoms (+taut. groups, directed graph)*/
|
127
|
+
int nLenLinearCtAtOnly;
|
128
|
+
int nLenLinearCt;
|
129
|
+
int nMaxLenLinearCt;
|
130
|
+
|
131
|
+
Partition PartitionCt; /* canonical numbering */
|
132
|
+
AT_RANK *nSymmRankCt; /* orbits */
|
133
|
+
|
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 */
|
138
|
+
|
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 */
|
143
|
+
|
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 */
|
154
|
+
|
155
|
+
} FTCN;
|
156
|
+
|
157
|
+
/******************** BCN *************************************/
|
158
|
+
typedef struct tagBaseCanonNumbering {
|
159
|
+
|
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 */
|
164
|
+
int num_atoms;
|
165
|
+
struct tagInchiTime *ulTimeOutTime;
|
166
|
+
FTCN ftcn[TAUT_NUM];
|
167
|
+
|
168
|
+
} BCN;
|
169
|
+
|
170
|
+
/***********************************
|
171
|
+
*
|
172
|
+
* CANON_STAT
|
173
|
+
*/
|
174
|
+
typedef struct tagCanonStat {
|
175
|
+
/* statistics */
|
176
|
+
long lNumBreakTies;
|
177
|
+
long lNumNeighListIter;
|
178
|
+
long lNumTotCT;
|
179
|
+
long lNumDecreasedCT;
|
180
|
+
long lNumRejectedCT;
|
181
|
+
long lNumEqualCT;
|
182
|
+
struct tagInchiTime *ulTimeOutTime;
|
183
|
+
long lTotalTime;
|
184
|
+
|
185
|
+
/* control */
|
186
|
+
int bFirstCT;
|
187
|
+
int bKeepSymmRank;
|
188
|
+
int bStereoIsBetter;
|
189
|
+
|
190
|
+
int nCanonFlags;
|
191
|
+
|
192
|
+
/* data : */
|
193
|
+
|
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 */
|
206
|
+
|
207
|
+
/* second copies of line notation arrays */
|
208
|
+
|
209
|
+
AT_NUMB *LinearCT2; /* to save non-isotopic CT */
|
210
|
+
|
211
|
+
int nLenLinearCTStereoDble;
|
212
|
+
int nLenLinearCTStereoDbleInv;
|
213
|
+
int nMaxLenLinearCTStereoDble; /* new */
|
214
|
+
|
215
|
+
int bCmpStereo; /* 0 => no stereo to invert;
|
216
|
+
1 => StereoCtInv < StereoCt;
|
217
|
+
2 => StereoCtInv = StereoCt;
|
218
|
+
3 => StereoCtInv > StereoCt;
|
219
|
+
*/
|
220
|
+
int nLenLinearCTStereoCarb;
|
221
|
+
int nLenLinearCTStereoCarbInv;
|
222
|
+
int nMaxLenLinearCTStereoCarb; /* new */
|
223
|
+
|
224
|
+
int nLenLinearCTIsotopic;
|
225
|
+
int nMaxLenLinearCTIsotopic;
|
226
|
+
|
227
|
+
int nLenLinearCTIsotopicTautomer;
|
228
|
+
int nMaxLenLinearCTIsotopicTautomer;
|
229
|
+
|
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 */
|
235
|
+
|
236
|
+
int nLenLinearCTTautomer;
|
237
|
+
int nMaxLenLinearCTTautomer;
|
238
|
+
|
239
|
+
int bCmpIsotopicStereo; /* 0 => no stereo to invert;
|
240
|
+
1 => StereoCtInv < StereoCt;
|
241
|
+
2 => StereoCtInv = StereoCt;
|
242
|
+
3 => StereoCtInv > StereoCt;
|
243
|
+
*/
|
244
|
+
int nLenLinearCTIsotopicStereoDble;
|
245
|
+
int nLenLinearCTIsotopicStereoDbleInv;
|
246
|
+
int nMaxLenLinearCTIsotopicStereoDble;
|
247
|
+
|
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 */
|
255
|
+
|
256
|
+
AT_RANK *nPrevAtomNumber;
|
257
|
+
|
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 */
|
262
|
+
|
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 */
|
266
|
+
|
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 */
|
271
|
+
|
272
|
+
AT_RANK *nCanonOrdIsotopicStereo;
|
273
|
+
AT_RANK *nCanonOrdIsotopicStereoInv;
|
274
|
+
AT_RANK *nCanonOrdIsotopicStereoTaut; /* !!! */
|
275
|
+
|
276
|
+
/* actual lengths if successfully calculated */
|
277
|
+
|
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; /* !!! */
|
286
|
+
|
287
|
+
/* other */
|
288
|
+
|
289
|
+
int bHasIsotopicInTautomerGroups;
|
290
|
+
T_GROUP_INFO *t_group_info;
|
291
|
+
int bIgnoreIsotopic;
|
292
|
+
int bDoubleBondSquare; /* 0 or 2 */
|
293
|
+
INCHI_MODE nMode;
|
294
|
+
#if( bRELEASE_VERSION == 0 )
|
295
|
+
int bExtract; /* for debug only */
|
296
|
+
#endif
|
297
|
+
NEIGH_LIST *NeighList;
|
298
|
+
BCN *pBCN;
|
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] */
|
301
|
+
S_CHAR *nExchgIsoH;
|
302
|
+
} CANON_STAT;
|
303
|
+
|
304
|
+
/**************************************************/
|
305
|
+
typedef struct tagCanonData {
|
306
|
+
|
307
|
+
/* same names/types as in ConTable; here the order is from original numbering */
|
308
|
+
|
309
|
+
AT_NUMB *LinearCT; /* output ?? */
|
310
|
+
|
311
|
+
int nMaxLenLinearCT;
|
312
|
+
int nLenLinearCT;
|
313
|
+
int nLenCTAtOnly;
|
314
|
+
int nCanonFlags;
|
315
|
+
/* hydrogen atoms fixed in tautomeric representation:
|
316
|
+
compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */
|
317
|
+
NUM_H *NumH;
|
318
|
+
int lenNumH; /* used length */
|
319
|
+
int maxlenNumH; /* n + T_NUM_NO_ISOTOPIC*(n_tg-n) + 1 */
|
320
|
+
|
321
|
+
/* hydrogen atoms fixed in non-tautomeric representation only:
|
322
|
+
compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */
|
323
|
+
NUM_H *NumHfixed;
|
324
|
+
int lenNumHfixed; /* used length */
|
325
|
+
int maxlenNumHfixed; /* max length = n+1 */
|
326
|
+
|
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;
|
335
|
+
|
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 */
|
341
|
+
#endif
|
342
|
+
/* auxiliary ranking */
|
343
|
+
|
344
|
+
AT_RANK *nAuxRank;
|
345
|
+
|
346
|
+
struct tagInchiTime *ulTimeOutTime; /* timeout */
|
347
|
+
|
348
|
+
} CANON_DATA;
|
349
|
+
/**************************************************/
|
350
|
+
|
351
|
+
typedef struct tagCanonCounts {
|
352
|
+
long lNumBreakTies;
|
353
|
+
long lNumDecreasedCT;
|
354
|
+
long lNumRejectedCT;
|
355
|
+
long lNumEqualCT;
|
356
|
+
long lNumTotCT;
|
357
|
+
double dGroupSize;
|
358
|
+
long lNumGenerators;
|
359
|
+
long lNumStoredIsomorphisms;
|
360
|
+
|
361
|
+
} CANON_COUNTS;
|
362
|
+
/***********************************************
|
363
|
+
tree structure: one segment
|
364
|
+
|
365
|
+
canon. rank
|
366
|
+
at.no orig. atom numbers on which the canon. rank has been successfully mapped
|
367
|
+
...
|
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
|
370
|
+
*/
|
371
|
+
|
372
|
+
typedef struct tagCurTree {
|
373
|
+
AT_NUMB *tree;
|
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 */
|
377
|
+
} CUR_TREE;
|
378
|
+
|
379
|
+
#endif /* __INCHICANT_H__ */
|
data/ext/src/ichicomn.h
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
/*
|
2
|
+
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
|
+
* International Chemical Identifier (InChI)
|
4
|
+
* Version 1
|
5
|
+
* Software version 1.00
|
6
|
+
* April 13, 2005
|
7
|
+
* Developed at NIST
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef __INCHICOMN_H__
|
11
|
+
#define __INCHICOMN_H__
|
12
|
+
|
13
|
+
#include "ichierr.h"
|
14
|
+
|
15
|
+
|
16
|
+
/********************************
|
17
|
+
*
|
18
|
+
* Globals for sorting
|
19
|
+
*/
|
20
|
+
|
21
|
+
extern const NEIGH_LIST *pNeighList_RankForSort;
|
22
|
+
extern const ATOM_INVARIANT2 *pAtomInvariant2ForSort;
|
23
|
+
extern const AT_NUMB *pNeighborsForSort;
|
24
|
+
extern const AT_RANK *pn_RankForSort;
|
25
|
+
|
26
|
+
extern AT_RANK nMaxAtNeighRankForSort;
|
27
|
+
|
28
|
+
extern int nNumCompNeighborsRanksCountEql;
|
29
|
+
|
30
|
+
|
31
|
+
#define tsort insertions_sort
|
32
|
+
|
33
|
+
typedef struct tagEquNeigh {
|
34
|
+
int num_to; /* number of neighbors with equal mapping ranks; one of them has min. canon. number */
|
35
|
+
AT_RANK to_at[4]; /* to_atom neighbors #s with equal mapping ranks */
|
36
|
+
AT_RANK from_at; /* from_at neighbor # which has min. canon. number and can be mapped on any of the above to_at[] */
|
37
|
+
AT_RANK rank; /* equal mapping rank value */
|
38
|
+
AT_RANK canon_rank; /* min. canon. number */
|
39
|
+
} EQ_NEIGH;
|
40
|
+
|
41
|
+
#ifndef INCHI_ALL_CPP
|
42
|
+
#ifdef __cplusplus
|
43
|
+
extern "C" {
|
44
|
+
#endif
|
45
|
+
#endif
|
46
|
+
|
47
|
+
/*******************************************************************/
|
48
|
+
/* ichiisot.c */
|
49
|
+
int unpack_iso_sort_key( AT_ISO_SORT_KEY iso_sort_key, S_CHAR *num_1H, S_CHAR *num_2H, S_CHAR *num_3H, S_CHAR *iso_atw_diff );
|
50
|
+
AT_ISO_SORT_KEY make_iso_sort_key( int iso_atw_diff, int num_1H, int num_2H, int num_3H);
|
51
|
+
int set_atom_iso_sort_keys( int num_at, sp_ATOM *at, T_GROUP_INFO* t_group_info, int *bHasIsotopicInTautomerGroups );
|
52
|
+
/***********************************************************************/
|
53
|
+
/* ichisort.c */
|
54
|
+
|
55
|
+
void insertions_sort_NeighList_AT_NUMBERS( NEIGH_LIST base, AT_RANK *nRank );
|
56
|
+
int insertions_sort_NeighList_AT_NUMBERS3( NEIGH_LIST base, AT_RANK *nRank );
|
57
|
+
int insertions_sort_AT_RANK( AT_RANK *base, int num );
|
58
|
+
void insertions_sort_NeighListBySymmAndCanonRank( NEIGH_LIST base, const AT_RANK *nSymmRank, const AT_RANK *nCanonRank );
|
59
|
+
int CompareNeighListLex( NEIGH_LIST pp1, NEIGH_LIST pp2, const AT_RANK *nRank);
|
60
|
+
int CompareNeighListLexUpToMaxRank( NEIGH_LIST pp1, NEIGH_LIST pp2, const AT_RANK *nRank, AT_RANK nMaxAtNeighRank );
|
61
|
+
int compare_NeighLists( const NEIGH_LIST *op1, const NEIGH_LIST *op2 );
|
62
|
+
int CompNeighborsAT_NUMBER( const void* a1, const void* a2);
|
63
|
+
int comp_AT_RANK( const void* a1, const void* a2);
|
64
|
+
int CompRank(const void* a1, const void* a2 );
|
65
|
+
int CompRanksOrd( const void* a1, const void* a2 );
|
66
|
+
|
67
|
+
int CompAtomInvariants2Only( const void* a1, const void* a2 );
|
68
|
+
int CompAtomInvariants2( const void* a1, const void* a2 );
|
69
|
+
|
70
|
+
int CompNeighListRanks( const void* a1, const void* a2 );
|
71
|
+
int CompNeighListRanksOrd( const void* a1, const void* a2 );
|
72
|
+
int CompNeighLists( const void* a1, const void* a2 );
|
73
|
+
int CompNeighListsUpToMaxRank( const void* a1, const void* a2 );
|
74
|
+
int CompNeighborsRanksCountEql( const void* a1, const void* a2 );
|
75
|
+
int CompRanksInvOrd( const void* a1, const void* a2 );
|
76
|
+
int CompChemElemLex( const void *a1, const void *a2 );
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
NEIGH_LIST *CreateNeighList( int num_atoms, int num_at_tg, sp_ATOM* at, int bDoubleBondSquare, T_GROUP_INFO *t_group_info );
|
81
|
+
NEIGH_LIST *CreateNeighListFromLinearCT( AT_NUMB *LinearCT, int nLenCT, int num_atoms );
|
82
|
+
|
83
|
+
void FreeNeighList( NEIGH_LIST *pp );
|
84
|
+
int BreakAllTies( int num_atoms, int num_max, AT_RANK **pRankStack,
|
85
|
+
NEIGH_LIST *NeighList, AT_RANK *nTempRank, CANON_STAT *pCS);
|
86
|
+
|
87
|
+
/******************************************************************************/
|
88
|
+
/* ichimap.c */
|
89
|
+
void switch_ptrs( AT_RANK **p1, AT_RANK **p2 );
|
90
|
+
|
91
|
+
int SortedEquInfoToRanks( const AT_RANK* nSymmRank, AT_RANK* nRank, const AT_RANK* nAtomNumber, int num_atoms, int *bChanged );
|
92
|
+
int SortedRanksToEquInfo( AT_RANK* nSymmRank, const AT_RANK* nRank, const AT_RANK* nAtomNumber, int num_atoms );
|
93
|
+
|
94
|
+
int SetNewRanksFromNeighLists( int num_atoms, NEIGH_LIST *NeighList, AT_RANK *nRank, AT_RANK *nNewRank,
|
95
|
+
AT_RANK *nAtomNumber, int bUseAltSort, int ( *comp )(const void *, const void *) );
|
96
|
+
int SetNewRanksFromNeighLists3( int num_atoms, NEIGH_LIST *NeighList, AT_RANK *nRank, AT_RANK *nNewRank,
|
97
|
+
AT_RANK *nAtomNumber );
|
98
|
+
int SetNewRanksFromNeighLists4( int num_atoms, NEIGH_LIST *NeighList, AT_RANK *nRank, AT_RANK *nNewRank,
|
99
|
+
AT_RANK *nAtomNumber, AT_RANK nMaxAtRank );
|
100
|
+
void SortNeighListsBySymmAndCanonRank( int num_atoms, NEIGH_LIST *NeighList, const AT_RANK *nSymmRank, const AT_RANK *nCanonRank );
|
101
|
+
int SortNeighLists2( int num_atoms, AT_RANK *nRank, NEIGH_LIST *NeighList, AT_RANK *nAtomNumber );
|
102
|
+
int DifferentiateRanks2( int num_atoms, NEIGH_LIST *NeighList,
|
103
|
+
int nNumCurrRanks, AT_RANK *pnCurrRank, AT_RANK *pnPrevRank,
|
104
|
+
AT_RANK *nAtomNumber, long *lNumIter, int bUseAltSort );
|
105
|
+
|
106
|
+
int DifferentiateRanks3( int num_atoms, NEIGH_LIST *NeighList,
|
107
|
+
int nNumCurrRanks, AT_RANK *pnCurrRank, AT_RANK *pnPrevRank,
|
108
|
+
AT_RANK *nAtomNumber, long *lNumIter );
|
109
|
+
int DifferentiateRanks4( int num_atoms, NEIGH_LIST *NeighList,
|
110
|
+
int nNumCurrRanks, AT_RANK *pnCurrRank, AT_RANK *pnPrevRank,
|
111
|
+
AT_RANK *nAtomNumber, AT_RANK nMaxAtRank, long *lNumIter );
|
112
|
+
int DifferentiateRanksBasic( int num_atoms, NEIGH_LIST *NeighList,
|
113
|
+
int nNumCurrRanks, AT_RANK *pnCurrRank, AT_RANK *pnPrevRank,
|
114
|
+
AT_RANK *nAtomNumber, long *lNumIter, int bUseAltSort );
|
115
|
+
|
116
|
+
int parity_of_mapped_atom2( int from_at, int to_at, const sp_ATOM *at, EQ_NEIGH *pEN,
|
117
|
+
const AT_RANK *nCanonRankFrom, const AT_RANK *nRankFrom, const AT_RANK *nRankTo );
|
118
|
+
|
119
|
+
int parity_of_mapped_half_bond( int from_at, int to_at, int from_neigh, int to_neigh,
|
120
|
+
sp_ATOM *at, EQ_NEIGH *pEN,
|
121
|
+
const AT_RANK *nCanonRankFrom, const AT_RANK *nRankFrom, const AT_RANK *nRankTo );
|
122
|
+
|
123
|
+
int HalfStereoBondParity( sp_ATOM *at, int at_no1, int i_sb_neigh, const AT_RANK *nRank );
|
124
|
+
|
125
|
+
int NumberOfTies( AT_RANK **pRankStack1, AT_RANK **pRankStack2, int length, int at_no1, int at_no2, AT_RANK *nNewRank, int *bAddStack, int *bMapped1 );
|
126
|
+
|
127
|
+
int map_an_atom2( int num_atoms, int num_max, int at_no1/*from*/, int at_no2/*to*/,
|
128
|
+
AT_RANK *nTempRank,
|
129
|
+
int nNumMappedRanks, int *pnNewNumMappedRanks,
|
130
|
+
CANON_STAT *pCS,
|
131
|
+
NEIGH_LIST *NeighList,
|
132
|
+
AT_RANK **pRankStack1, AT_RANK **pRankStack2, int *bAddStack );
|
133
|
+
int ClearPreviousMappings( AT_RANK **pRankStack1 );
|
134
|
+
|
135
|
+
int SetOneStereoBondIllDefParity( sp_ATOM *at, int jc, /* atom number*/ int k /* stereo bond ord. number*/, int new_parity );
|
136
|
+
int RemoveOneStereoBond( sp_ATOM *at, int jc, /* atom number*/ int k /* stereo bond number*/ );
|
137
|
+
int RemoveOneStereoCenter( sp_ATOM *at, int jc /* atom number*/ );
|
138
|
+
int RemoveCalculatedNonStereo( sp_ATOM *at, int num_atoms, int num_at_tg,
|
139
|
+
AT_RANK **pRankStack1, AT_RANK **pRankStack2, AT_RANK *nTempRank, NEIGH_LIST *NeighList,
|
140
|
+
const AT_RANK *nSymmRank, AT_RANK *nCanonRank, AT_RANK *nAtomNumberCanon, CANON_STAT *pCS );
|
141
|
+
|
142
|
+
|
143
|
+
int might_change_other_atom_parity( sp_ATOM *at, int num_atoms, int at_no, AT_RANK *nRank2, AT_RANK *nRank1 );
|
144
|
+
|
145
|
+
int map_stereo_bonds4 (
|
146
|
+
sp_ATOM *at, int num_atoms, int num_at_tg, int num_max, int bAllene,
|
147
|
+
const AT_RANK *nCanonRankFrom, const AT_RANK *nAtomNumberCanonFrom, /* non-stereo canon ranking */
|
148
|
+
AT_RANK *nCanonRankTo, /* output canonical numbering*/
|
149
|
+
const AT_RANK *nSymmRank, AT_RANK **pRankStack1/*from*/, AT_RANK **pRankStack2/*to*/,
|
150
|
+
AT_RANK *nTempRank, int nNumMappedRanksInput,
|
151
|
+
AT_RANK *nSymmStereo, NEIGH_LIST *NeighList,
|
152
|
+
CANON_STAT *pCS, CUR_TREE *cur_tree, int nNumMappedBonds );
|
153
|
+
|
154
|
+
int map_stereo_atoms4 (
|
155
|
+
sp_ATOM *at, int num_atoms, int num_at_tg, int num_max,
|
156
|
+
const AT_RANK *nCanonRankFrom, const AT_RANK *nAtomNumberCanonFrom, AT_RANK *nCanonRankTo, /* canonical numbering to be mapped */
|
157
|
+
const AT_RANK *nSymmRank, AT_RANK **pRankStack1/*from*/, AT_RANK **pRankStack2/*to*/,
|
158
|
+
AT_RANK *nTempRank, int nNumMappedRanksInput,
|
159
|
+
AT_RANK *nSymmStereo, NEIGH_LIST *NeighList,
|
160
|
+
CANON_STAT *pCS, CUR_TREE *cur_tree, int nNumMappedAtoms );
|
161
|
+
|
162
|
+
|
163
|
+
int CurTreeAlloc( CUR_TREE *cur_tree, int num_atoms );
|
164
|
+
int CurTreeReAlloc( CUR_TREE *cur_tree );
|
165
|
+
void CurTreeFree( CUR_TREE *cur_tree );
|
166
|
+
int CurTreeAddRank( CUR_TREE *cur_tree, AT_NUMB rank );
|
167
|
+
int CurTreeRemoveLastRank( CUR_TREE *cur_tree );
|
168
|
+
int CurTreeReplaceLastRank( CUR_TREE *cur_tree, AT_NUMB rank );
|
169
|
+
int CurTreeFindTheRankPos( CUR_TREE *cur_tree, AT_NUMB rank );
|
170
|
+
int CurTreeGetPos( CUR_TREE *cur_tree );
|
171
|
+
int CurTreeSetPos( CUR_TREE *cur_tree, int len );
|
172
|
+
int CurTreeAddAtom( CUR_TREE *cur_tree, int at_no );
|
173
|
+
int CurTreeRemoveLastAtom( CUR_TREE *cur_tree );
|
174
|
+
int CurTreeIsLastRank( CUR_TREE *cur_tree, AT_NUMB rank );
|
175
|
+
int CurTreeIsLastAtomEqu( CUR_TREE *cur_tree, int at_no, AT_NUMB *nSymmStereo );
|
176
|
+
int CurTreeRemoveIfLastAtom( CUR_TREE *cur_tree, int at_no );
|
177
|
+
int CurTreeRemoveLastRankIfNoAtoms( CUR_TREE *cur_tree );
|
178
|
+
void CurTreeKeepLastAtomsOnly( CUR_TREE *cur_tree, int tpos, int shift );
|
179
|
+
|
180
|
+
|
181
|
+
void SetUseAtomForStereo( S_CHAR *bAtomUsedForStereo, sp_ATOM *at, int num_atoms );
|
182
|
+
|
183
|
+
int nJoin2Mcrs( AT_RANK *nEqArray, AT_RANK n1, AT_RANK n2 );
|
184
|
+
AT_RANK nGetMcr( AT_RANK *nEqArray, AT_RANK n );
|
185
|
+
int bUniqueAtNbrFromMappingRank( AT_RANK **pRankStack, AT_RANK nAtRank, AT_NUMB *nAtNumber );
|
186
|
+
|
187
|
+
int Next_SB_At_CanonRanks2( AT_RANK *canon_rank1, AT_RANK *canon_rank2, /* canonical numbers */
|
188
|
+
AT_RANK *canon_rank1_min, AT_RANK *canon_rank2_min,
|
189
|
+
int *bFirstTime, S_CHAR *bAtomUsedForStereo,
|
190
|
+
const ppAT_RANK pRankStack1, const ppAT_RANK pRankStack2,
|
191
|
+
const AT_RANK *nCanonRankFrom, const AT_RANK *nAtomNumberCanonFrom,
|
192
|
+
const sp_ATOM *at, int num_atoms, int bAllene );
|
193
|
+
|
194
|
+
int Next_SC_At_CanonRank2( AT_RANK *canon_rank1, /* 1st call input: largest canon number mapped so far or 0 */
|
195
|
+
/* output: suggested canon. rank > than input if success */
|
196
|
+
AT_RANK *canon_rank1_min, /* 1st call:0 next calls: first tried canon. number */
|
197
|
+
int *bFirstTime, /* 1 at the time of the 1st call */
|
198
|
+
S_CHAR *bAtomUsedForStereo, /* STEREO_AT_MARK if the atom has not been mapped yet */
|
199
|
+
const ppAT_RANK pRankStack1, /* mapping ranks/sort order of atoms with canon. numbers (from) */
|
200
|
+
const ppAT_RANK pRankStack2, /* mapping ranks/sort order of atoms with stereo (to) */
|
201
|
+
const AT_RANK *nAtomNumberCanonFrom, /* sorted order of the canon. numbers */
|
202
|
+
int num_atoms );
|
203
|
+
|
204
|
+
int NextStereoParity2Test( int *stereo_bond_parity, int *sb_parity_calc,
|
205
|
+
int nNumBest, int nNumWorse, int nNumUnkn, int nNumUndf, int nNumCalc);
|
206
|
+
|
207
|
+
int All_SB_Same( AT_RANK canon_rank1, AT_RANK canon_rank2, /* canonical numbers */
|
208
|
+
const ppAT_RANK pRankStack1, const ppAT_RANK pRankStack2,
|
209
|
+
const AT_RANK *nAtomNumberCanonFrom,
|
210
|
+
sp_ATOM *at );
|
211
|
+
|
212
|
+
int All_SC_Same( AT_RANK canon_rank1, /* canonical number */
|
213
|
+
const ppAT_RANK pRankStack1, const ppAT_RANK pRankStack2,
|
214
|
+
const AT_RANK *nAtomNumberCanonFrom,
|
215
|
+
const sp_ATOM *at );
|
216
|
+
|
217
|
+
|
218
|
+
int CompareLinCtStereoDoubleToValues( AT_STEREO_DBLE *LinearCTStereoDble,
|
219
|
+
AT_RANK at_rank_canon1, AT_RANK at_rank_canon2, U_CHAR bond_parity );
|
220
|
+
|
221
|
+
int CompareLinCtStereoAtomToValues( AT_STEREO_CARB *LinearCTStereoCarb,
|
222
|
+
AT_RANK at_rank_canon1, U_CHAR parity );
|
223
|
+
int CompareLinCtStereoDble ( AT_STEREO_DBLE *LinearCTStereoDble1, int nLenLinearCTStereoDble1,
|
224
|
+
AT_STEREO_DBLE *LinearCTStereoDble2, int nLenLinearCTStereoDble2 );
|
225
|
+
int CompareLinCtStereoCarb ( AT_STEREO_CARB *LinearCTStereoCarb1, int nLenLinearCTStereoCarb1,
|
226
|
+
AT_STEREO_CARB *LinearCTStereoCarb2, int nLenLinearCTStereoCarb2 );
|
227
|
+
int CompareLinCtStereo ( AT_STEREO_DBLE *LinearCTStereoDble1, int nLenLinearCTStereoDble1,
|
228
|
+
AT_STEREO_CARB *LinearCTStereoCarb1, int nLenLinearCTStereoCarb1,
|
229
|
+
AT_STEREO_DBLE *LinearCTStereoDble2, int nLenLinearCTStereoDble2,
|
230
|
+
AT_STEREO_CARB *LinearCTStereoCarb2, int nLenLinearCTStereoCarb2 );
|
231
|
+
/***************************************************************************/
|
232
|
+
/* ichicans.c */
|
233
|
+
int UnmarkNonStereo( sp_ATOM *at, int num_atoms, const AT_RANK *nRank, const AT_RANK *nAtomNumber, int bIsotopic );
|
234
|
+
int FillSingleStereoDescriptors(sp_ATOM *at, int i, int num_trans, const AT_RANK *nRank
|
235
|
+
, AT_STEREO_CARB *LinearCTStereoCarb, int *nStereoCarbLen, int nMaxStereoCarbLen
|
236
|
+
, AT_STEREO_DBLE *LinearCTStereoDble, int *nStereoDbleLen, int nMaxStereoDbleLen
|
237
|
+
, int bAllene );
|
238
|
+
void SwitchAtomStereoAndIsotopicStereo( sp_ATOM *at, int num_atoms, int *bSwitched );
|
239
|
+
void SetCtToIsotopicStereo( CANON_STAT *pCS, CANON_STAT *pCS2 );
|
240
|
+
void SetCtToNonIsotopicStereo( CANON_STAT *pCS, CANON_STAT *pCS2 );
|
241
|
+
int FillAllStereoDescriptors( sp_ATOM *at, int num_atoms, const AT_RANK *nCanonRank, const AT_RANK *nAtomNumberCanon, CANON_STAT *pCS );
|
242
|
+
int FillOutStereoParities( sp_ATOM *at, int num_atoms, const AT_RANK *nCanonRank, const AT_RANK *nAtomNumberCanon,
|
243
|
+
const AT_RANK *nRank, const AT_RANK *nAtomNumber, CANON_STAT *pCS, int bIsotopic );
|
244
|
+
int InvertStereo( sp_ATOM *at, int num_at_tg,
|
245
|
+
AT_RANK *nCanonRank, AT_RANK *nAtomNumberCanon,
|
246
|
+
CANON_STAT *pCS, int bInvertLinearCTStereo );
|
247
|
+
int find_atoms_with_parity( sp_ATOM *at, S_CHAR *visited, int from_atom, int cur_atom );
|
248
|
+
int GetStereoNeighborPos( sp_ATOM *at, int iAt1, int iAt2 );
|
249
|
+
int GetStereoBondParity(sp_ATOM *at, int i, int n, AT_RANK *nRank );
|
250
|
+
int GetStereoCenterParity(sp_ATOM *at, int i, AT_RANK *nRank );
|
251
|
+
int GetPermutationParity( sp_ATOM *at, AT_RANK nAvoidNeighbor, AT_RANK *nCanonRank );
|
252
|
+
|
253
|
+
#ifndef INCHI_ALL_CPP
|
254
|
+
#ifdef __cplusplus
|
255
|
+
}
|
256
|
+
#endif
|
257
|
+
#endif
|
258
|
+
|
259
|
+
|
260
|
+
#endif /* __INCHICOMN_H__ */
|