rino 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/Rakefile +1 -1
  2. data/ext/extconf.rb +1 -24
  3. data/ext/libinchi.so +0 -0
  4. data/ext/src/aux2atom.h +120 -39
  5. data/ext/src/comdef.h +3 -3
  6. data/ext/src/dispstru.c +2547 -0
  7. data/ext/src/dispstru.h +73 -0
  8. data/ext/src/extr_ct.h +5 -2
  9. data/ext/src/ichi.h +27 -11
  10. data/ext/src/ichi_bns.c +1800 -254
  11. data/ext/src/ichi_bns.h +205 -4
  12. data/ext/src/ichican2.c +197 -86
  13. data/ext/src/ichicano.c +8 -13
  14. data/ext/src/ichicano.h +2 -2
  15. data/ext/src/ichicans.c +11 -6
  16. data/ext/src/ichicant.h +2 -2
  17. data/ext/src/ichicomn.h +2 -2
  18. data/ext/src/ichicomp.h +19 -4
  19. data/ext/src/ichidrp.h +9 -5
  20. data/ext/src/ichierr.h +5 -3
  21. data/ext/src/ichiisot.c +2 -2
  22. data/ext/src/ichimain.c +461 -0
  23. data/ext/src/ichimain.h +23 -15
  24. data/ext/src/ichimak2.c +6 -6
  25. data/ext/src/ichimake.c +843 -42
  26. data/ext/src/ichimake.h +4 -2
  27. data/ext/src/ichimap1.c +5 -5
  28. data/ext/src/ichimap2.c +2 -2
  29. data/ext/src/ichimap4.c +34 -21
  30. data/ext/src/ichinorm.c +11 -5
  31. data/ext/src/ichinorm.h +3 -2
  32. data/ext/src/ichiparm.c +2 -2
  33. data/ext/src/ichiparm.h +232 -30
  34. data/ext/src/ichiprt1.c +35 -11
  35. data/ext/src/ichiprt2.c +78 -7
  36. data/ext/src/ichiprt3.c +300 -120
  37. data/ext/src/ichiqueu.c +17 -2
  38. data/ext/src/ichiread.c +6932 -0
  39. data/ext/src/ichiring.c +3 -2
  40. data/ext/src/ichiring.h +2 -2
  41. data/ext/src/ichirvr1.c +4891 -0
  42. data/ext/src/ichirvr2.c +6344 -0
  43. data/ext/src/ichirvr3.c +5499 -0
  44. data/ext/src/ichirvr4.c +3177 -0
  45. data/ext/src/ichirvr5.c +1166 -0
  46. data/ext/src/ichirvr6.c +1287 -0
  47. data/ext/src/ichirvr7.c +2319 -0
  48. data/ext/src/ichirvrs.h +882 -0
  49. data/ext/src/ichisize.h +2 -2
  50. data/ext/src/ichisort.c +5 -5
  51. data/ext/src/ichister.c +281 -86
  52. data/ext/src/ichister.h +9 -3
  53. data/ext/src/ichitaut.c +208 -9
  54. data/ext/src/ichitaut.h +13 -11
  55. data/ext/src/ichitime.h +16 -2
  56. data/ext/src/inchicmp.h +107 -0
  57. data/ext/src/inpdef.h +6 -3
  58. data/ext/src/libinchi_wrap.c +912 -0
  59. data/ext/src/lreadmol.h +34 -31
  60. data/ext/src/mode.h +244 -7
  61. data/ext/src/mol2atom.c +1060 -0
  62. data/ext/src/mol2atom.h +31 -0
  63. data/ext/src/readinch.c +239 -0
  64. data/ext/src/readmol.c +28 -0
  65. data/ext/src/{e_readmol.h → readmol.h} +7 -9
  66. data/ext/src/runichi.c +251 -177
  67. data/ext/src/strutil.c +444 -238
  68. data/ext/src/strutil.h +150 -11
  69. data/ext/src/util.c +176 -118
  70. data/ext/src/util.h +15 -3
  71. data/lib/rino.rb +71 -3
  72. data/test/test.rb +33 -4
  73. metadata +22 -34
  74. data/ext/ruby_inchi_main.so +0 -0
  75. data/ext/src/e_0dstereo.c +0 -3014
  76. data/ext/src/e_0dstereo.h +0 -31
  77. data/ext/src/e_comdef.h +0 -57
  78. data/ext/src/e_ctl_data.h +0 -147
  79. data/ext/src/e_ichi_io.c +0 -498
  80. data/ext/src/e_ichi_io.h +0 -40
  81. data/ext/src/e_ichi_parms.c +0 -37
  82. data/ext/src/e_ichi_parms.h +0 -41
  83. data/ext/src/e_ichicomp.h +0 -50
  84. data/ext/src/e_ichierr.h +0 -40
  85. data/ext/src/e_ichimain.c +0 -593
  86. data/ext/src/e_ichisize.h +0 -43
  87. data/ext/src/e_inchi_atom.c +0 -75
  88. data/ext/src/e_inchi_atom.h +0 -33
  89. data/ext/src/e_inpdef.h +0 -41
  90. data/ext/src/e_mode.h +0 -706
  91. data/ext/src/e_mol2atom.c +0 -649
  92. data/ext/src/e_readinch.c +0 -58
  93. data/ext/src/e_readmol.c +0 -54
  94. data/ext/src/e_readstru.c +0 -251
  95. data/ext/src/e_readstru.h +0 -33
  96. data/ext/src/e_util.c +0 -284
  97. data/ext/src/e_util.h +0 -61
  98. data/ext/src/ichilnct.c +0 -286
  99. data/ext/src/inchi_api.h +0 -670
  100. data/ext/src/inchi_dll.c +0 -1480
  101. data/ext/src/inchi_dll.h +0 -34
  102. data/ext/src/inchi_dll_main.c +0 -23
  103. data/ext/src/inchi_dll_main.h +0 -31
  104. data/ext/src/ruby_inchi_main.c +0 -558
@@ -0,0 +1,882 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.01
6
+ * July 21, 2006
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __ICHIRVRS_H__
11
+ #define __ICHIRVRS_H__
12
+
13
+ #define ICHICONST const
14
+
15
+ #define RI_ERR_ALLOC (-1)
16
+ #define RI_ERR_SYNTAX (-2)
17
+ #define RI_ERR_PROGR (-3)
18
+ #define RI_ERR_EOL (-4)
19
+ #define RI_ERR_EOF (0)
20
+
21
+
22
+ #define NO_VALUE_INT 9999
23
+ #define NOT_READ_INT 9998 /* has not been read yet */
24
+
25
+ #define VALUE_OCTET 8 /* number of electrons in a full shell */
26
+
27
+ #define INC_EDGE_LIST_DEFAULT 64
28
+
29
+ typedef struct tagXYZCoord {
30
+ double xyz[3];
31
+ } XYZ_COORD;
32
+
33
+ typedef struct tagStructRestoreMode {
34
+ int bMetalAddFlower; /* 1 => allow adjustable metal valence and charge; 0=> use std charge/valence */
35
+ /* the following three apply only if bMetalAddFlower = 1 */
36
+ int nMetalMinBondOrder; /* edge_flow=f means bond order=cMetalMinBondOrder+f */
37
+ int nMetalInitEdgeFlow; /* one bond contribution to metal's (st-cap - st-flow) = */
38
+ /* (nMetalInitBondOrder-nMetalMinBondOrder) - nMetalInitEdgeFlow */
39
+ int nMetalInitBondOrder; /* >= nMetalMinBondOrder + nMetalInitEdgeFlow */
40
+ /* same for metal-endpoint bonds */
41
+ int nMetal2EndpointMinBondOrder;
42
+ int nMetal2EndpointInitBondOrder;
43
+ int nMetal2EndpointInitEdgeFlow;
44
+ int nMetalFlowerParam_D; /* additional edge capacity for canceling radicals */
45
+ int nMetalMaxCharge_D; /* cap and/or flow for metal charge group */
46
+ int bStereoRemovesMetalFlag; /* 1=> treat stereogenic atoms and atoms connected by a stereo bond as non-metals */
47
+
48
+ int bFixStereoBonds; /* 1=> forbid stereogenic double bonds from changing */
49
+ } SRM;
50
+
51
+ typedef struct tagReversedInChI {
52
+ PINChI2 *pINChI[INCHI_NUM];
53
+ PINChI_Aux2 *pINChI_Aux[INCHI_NUM];
54
+ int num_components[INCHI_NUM];
55
+ int nRetVal;
56
+ } REV_INCHI;
57
+
58
+ /**************************************/
59
+ #define BFS_Q_CLEAR (-1)
60
+ #define BFS_Q_FREE (-2)
61
+ typedef struct tagBfsQueue {
62
+ QUEUE *q;
63
+ AT_RANK *nAtomLevel;
64
+ S_CHAR *cSource;
65
+ int num_at;
66
+ AT_RANK min_ring_size; /* 8 => detect 7-member and smaller rings */
67
+ } BFS_Q;
68
+ /**************************************/
69
+
70
+ #define EXTRACT_STRUCT_NUMBER 1
71
+
72
+ /* additional Mobile-H parities to be added to Fixed-H parities */
73
+ /* This allows to set parities that exist in Mobile-H layer only */
74
+ typedef struct tagInpAtomAddParities {
75
+ /* cml 0D parities */
76
+ S_CHAR bUsed0DParity; /* bit=1 => stereobond; bit=2 => stereocenter */
77
+ /* cml tetrahedral parity */
78
+ S_CHAR p_parity;
79
+ AT_NUMB p_orig_at_num[MAX_NUM_STEREO_ATOM_NEIGH];
80
+ /* cml bond parities */
81
+ S_CHAR sb_ord[MAX_NUM_STEREO_BONDS]; /* stereo bond/neighbor ordering number, starts from 0 */
82
+ /* neighbors on both sides of stereobond have same sign=> trans/T/E, diff. signs => cis/C/Z */
83
+ S_CHAR sn_ord[MAX_NUM_STEREO_BONDS]; /* ord. num. of the neighbor adjacent to the SB; starts from 0;
84
+ -1 means removed explicit H */
85
+ /* neighbors on both sides of stereobond have same parity => trans/T/E/2, diff. parities => cis/C/Z/1 */
86
+ S_CHAR sb_parity[MAX_NUM_STEREO_BONDS];
87
+ AT_NUMB sn_orig_at_num[MAX_NUM_STEREO_BONDS]; /* orig. at number of sn_ord[] neighbors */
88
+ } inp_ATOM_STEREO;
89
+
90
+ #define FIX_STEREO_BOND_ORDER 0 /* 1=> fix stereobonds; treat metal as non-metal if it is stereogenic or has a stereobond */
91
+
92
+ #define METAL_FREE_CHARGE_VAL 1 /* 1=> allow free changing charges/valences of metals; initial bond order=0 or 1 */
93
+ #define ALLOW_METAL_BOND_ZERO 1 /* 1=> allow zero flow (bobd order) to metals */
94
+
95
+ #if ( ALLOW_METAL_BOND_ZERO == 1 )
96
+ /* INIT_METAL_BOND_ZERO=1 => INIT_METAL_BOND_FLOW=0 */
97
+ #define INIT_METAL_BOND_ZERO 0 /* 1=> initialize zero order bond to metals */
98
+ #define INIT_METAL_BOND_FLOW 1 /* 1=> init flow=1, 0 => init. flow = 0 */
99
+ #else
100
+ #define INIT_METAL_BOND_ZERO 0
101
+ #define INIT_METAL_BOND_FLOW 0 /* always 0 */
102
+ #endif
103
+
104
+ #define I2A_FLAG_FIXEDH 0x0001
105
+ #define I2A_FLAG_RECMET 0x0002
106
+
107
+ #define EL_NUMBER_H 1
108
+
109
+
110
+ #define ATYPE_H 1
111
+ #define ATYPE_Na 2
112
+ #define ATYPE_Mg 3
113
+ #define ATYPE_B 4
114
+ #define ATYPE_C 5
115
+ #define ATYPE_N 6
116
+ #define ATYPE_O 7
117
+ #define ATYPE_Cl 8
118
+
119
+
120
+ /* first bonds valence for charge = c is cValence[0][c+VAL_BASE]; VAL_MIN_CHARGE <= c <= VAL_MAX_CHARGE */
121
+ /* second bonds valence for charge = c is cValence[1][c+VAL_BASE]; VAL_MIN_CHARGE <= c <= VAL_MAX_CHARGE */
122
+ /* total number of valences is 2 = VAL_NUMBER */
123
+ /* neutral bond valence orders are cValence[0][VAL_NEUTR_ORDER], cValence[1][VAL_NEUTR_ORDER] */
124
+ #define VAL_BASE ( 1)
125
+ #define VAL_MIN_CHARGE (-1)
126
+ #define VAL_MAX_CHARGE ( 1)
127
+ #define VAL_NUMBER ( 2)
128
+ #define VAL_NEUTR_ORDER (VAL_MAX_CHARGE-VAL_MIN_CHARGE+1)
129
+ #define VAL_LENGTH (VAL_NEUTR_ORDER+1)
130
+ #define VAL_NEGAT_CHARGE 0
131
+ #define VAL_NEUTR_CHARGE 1
132
+ #define VAL_POSIT_CHARGE 2
133
+
134
+ typedef struct tagAtomIonPrperies {
135
+ /* char cValence[VAL_NUMBER][VAL_LENGTH]; */ /* ordering numbers of minimal valence, 0-based */
136
+ char cDoNotAddH; /* InChI does not add H to this element */
137
+ char cMetal; /* the element is a metal */
138
+ char cNumBondsToMetal; /* number of bonds to metal */
139
+ char cInitFlowToMetal; /* sum of init flow to metal atoms */
140
+ char cInitValenceToMetal; /* sum of init adjusted bond orders to metal atoms */
141
+ char cInitOrigValenceToMetal; /* sum of init bond orders to metal atoms */
142
+ char cMaxFlowToMetal; /* max total edge flow to metal atoms */
143
+ char cInitFreeValences; /* number of 'dots' to connect; charges are marked separately */
144
+ S_CHAR cInitCharge; /* initial charge on the atom (not included in ChargeStruct */
145
+ char cNumValenceElectrons;
146
+ char cPeriodicRowNumber;
147
+ char cMinRingSize; /* min ring size for atoms that have 2 bonds only */
148
+ U_CHAR cPeriodicNumber; /* number in Periodic Table of elements */
149
+ S_CHAR cnListIndex; /* (index in the cnList) + 1; 0 => none */
150
+ int nCMinusGroupEdge; /* (index of the edge to the atom's (-) group) + 1 */
151
+ int nCPlusGroupEdge; /* (index of the edge to the atom's (+) group) + 1 */
152
+ int nMetalGroupEdge; /* index of the edge to the atom's M-group + 1 */
153
+ int nTautGroupEdge; /* index of the edge from the atom to the t-group + 1 */
154
+ } VAL_AT;
155
+
156
+
157
+ /******************************************************************************************************/
158
+ #define INI_NUM_TCGROUPS 16
159
+ #define INC_NUM_TCGROUPS 16
160
+
161
+ typedef enum tagTgRestoreFlags {
162
+ TGRF_MINUS_FIRST = 1
163
+ } TGRF;
164
+ typedef struct tagTCGroup {
165
+ int type; /* group type */
166
+ int ord_num; /* ordering number within the type, typically t-group number */
167
+ int num_edges;
168
+ /* charge group specific */
169
+ int st_cap;
170
+ int st_flow;
171
+ int edges_cap;
172
+ int edges_flow;
173
+ int nVertexNumber; /* group vertex number; 0 = unassigned */
174
+ int nForwardEdge; /* edge index: from c-group to central Y-connecting vertex
175
+ or from supergroup to (+/-) vertex; 0 => unassigned */
176
+ int nBackwardEdge; /* edge index: from central Y-connecting vertex
177
+ to supergroup; 0 => unassigned */
178
+ /* tautomeric group specific */
179
+ short tg_num_H; /* number of H in a tautomeric group */
180
+ short tg_num_Minus; /* negative charge on t-group */
181
+ Vertex tg_set_Minus; /* the vertex+1 that has to have (-) */
182
+ short tg_RestoreFlags; /* Set (-) to first memberst of a t-group (usually, N) */
183
+ } TC_GROUP;
184
+
185
+ typedef enum tagTCGroupTypes {
186
+ TCG_None = -1, /* so far only ord=0 is used */
187
+ /* group type ord */
188
+ TCG_Plus0 = 0, /* BNS_VT_C_POS 0 */
189
+ TCG_Plus1, /* BNS_VT_C_POS 1 */
190
+ TCG_Minus0, /* BNS_VT_C_NEG 0 */
191
+ TCG_Minus1, /* BNS_VT_C_NEG 1 */
192
+ TCG_Plus_C0, /* BNS_VT_C_POS_C 0 */
193
+ TCG_Plus_C1, /* BNS_VT_C_POS_C 1 */
194
+ TCG_Minus_C0, /* BNS_VT_C_NEG_C 0 */
195
+ TCG_Minus_C1, /* BNS_VT_C_NEG_C 1 */
196
+ TCG_Plus_M0, /* BNS_VT_C_POS_M 0 */
197
+ TCG_Plus_M1, /* BNS_VT_C_POS_M 1 */
198
+ TCG_Minus_M0, /* BNS_VT_C_NEG_M 0 */
199
+ TCG_Minus_M1, /* BNS_VT_C_NEG_M 1 */
200
+ TCG_MeFlower0, /* BNS_VT_M_GROUP 0 */ /* base */
201
+ TCG_MeFlower1, /* BNS_VT_M_GROUP 1 */
202
+ TCG_MeFlower2, /* BNS_VT_M_GROUP 2 */
203
+ TCG_MeFlower3, /* BNS_VT_M_GROUP 3 */
204
+
205
+ TCG_Plus, /* BNS_VT_C_POS_ALL 0 */
206
+ TCG_Minus, /* BNS_VT_C_NEG_ALL 0 */
207
+
208
+ NUM_TCGROUP_TYPES /* number of group types */
209
+ }TCGR_TYPE;
210
+
211
+ typedef struct tagAllTCGroups {
212
+ TC_GROUP *pTCG;
213
+ int num_tc_groups; /* number of charge groups and metal-flower vertices */
214
+ int max_tc_groups; /* number of allocated of pTCG[] elements */
215
+ int nGroup[NUM_TCGROUP_TYPES]; /* tagTCGroupTypes */
216
+ int nVertices; /* total number of vertices */
217
+ int nEdges; /* total number of edges */
218
+ int nAddIedges; /* additional increase of number of iedges for edge switching to another group */
219
+ int num_atoms; /* number of atoms */
220
+ int num_bonds; /* number of bonds */
221
+ int num_tgroups; /* number t-groups */
222
+ int num_tgroup_edges; /* number of edges to t-groups */
223
+ /* charges */
224
+ int tgroup_charge; /* total charge of all t-groups */
225
+ int charge_on_atoms; /* charge permanently sitting on atoms */
226
+ int added_charge; /* charge added to the c-groups */
227
+ int total_charge; /* total charge of the component */
228
+ int total_electrons; /* total number of electrons on all atoms */
229
+ int total_electrons_metals; /* total number of electrons on unbonded metals */
230
+
231
+ int num_metal_atoms; /* number of metal atoms */
232
+ int num_metal_bonds; /* number of atom-metal bonds */
233
+ /* excess_charge = total_charge - added_charge - tgroup_charge: add to metals etc. */
234
+
235
+ int nEdge4charge; /* edge used to add charges; neighbor1=supercharge, another = (+/-) vertex */
236
+ int nEdgePlus; /* edge to (+) supergroup; 0 means none */
237
+ int nEdgeMinus; /* edge to (-) supergroup; 0 means none */
238
+ int iComponent; /* component number */
239
+ int iAtNoOffset; /* first atom number -- always 0 for now */
240
+ } ALL_TC_GROUPS;
241
+
242
+ /**************************************/
243
+ #define EDGE_LIST_CLEAR (-1)
244
+ #define EDGE_LIST_FREE (-2)
245
+
246
+ typedef struct tagEdgeList {
247
+ int num_alloc;
248
+ int num_edges;
249
+ EdgeIndex *pnEdges;
250
+ } EDGE_LIST;
251
+ /**************************************/
252
+
253
+ #define BOND_MARK_STEREO 0x10
254
+ #define BOND_TYPE_STEREO (BOND_TYPE_SINGLE | BOND_MARK_STEREO)
255
+
256
+ /* local */
257
+ #define RESET_EDGE_FORBIDDEN_MASK 0
258
+
259
+ #define TREAT_ATOM_AS_METAL 99
260
+
261
+
262
+ /************************************************************************************/
263
+ typedef struct tagChargeValence {
264
+ int nValence;
265
+ int nCharge;
266
+ int nValenceOrderingNumber;
267
+ } CHARGE_VAL;
268
+
269
+ #define MY_CONST const
270
+ /*************************************************************************************/
271
+ typedef struct tagChargeChangeCandidate {
272
+ Vertex iat;
273
+ char num_bonds;
274
+ char chem_valence;
275
+ char cMetal;
276
+ char cNumBondsToMetal;
277
+ char cNumValenceElectrons;
278
+ char cPeriodicRowNumber;
279
+ char cNumChargeStates;
280
+ U_CHAR el_number;
281
+ } CC_CAND;
282
+
283
+ typedef struct tagOneComponentRemovedAndExchangeableH {
284
+ NUM_H nNumRemovedProtons;
285
+ NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]; /* isotopic H that may be exchanged and considered
286
+ randomly distributed, including removed protons */
287
+ } COMPONENT_REM_PROTONS;
288
+
289
+ typedef struct tagRemovedAndExchangeableH {
290
+ /* totals for Mobile-H layer */
291
+ NUM_H nNumRemovedProtons;
292
+ NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]; /* isotopic H that may be exchanged and considered
293
+ randomly distributed, including removed protons */
294
+ /* for individual components from comparing Fixed-H vs Mobile-H formulas; NULL if not available */
295
+ COMPONENT_REM_PROTONS *pNumProtons;
296
+ } REM_PROTONS;
297
+
298
+ typedef struct tagInputInChI {
299
+ INChI *pInpInChI[INCHI_NUM][TAUT_NUM];
300
+ int nNumComponents[INCHI_NUM][TAUT_NUM];
301
+ REM_PROTONS nNumProtons[INCHI_NUM][TAUT_NUM];
302
+ int s[INCHI_NUM][TAUT_NUM][2]; /* s[0=non-iso, 1=iso] = 0,1,2,3 <= regular /s; -1=> "/s" (empty) */
303
+ long num_inp;
304
+ inp_ATOM *atom; /* the whole restored structure made out of all components */
305
+ int num_atoms; /* number of atoms including explicit H */
306
+ int num_explicit_H; /* number of explicit H in the atom */
307
+ INCHI_MODE CompareInchiFlags[INCHI_NUM][TAUT_NUM];
308
+ } InpInChI;
309
+
310
+ typedef struct tagStructFromInChI {
311
+ /* InChI component -> Structure result */
312
+ inp_ATOM *at; /* length = num_atoms + num_deleted_H, zero pint struct for BNS->struct conversion */
313
+ inp_ATOM_STEREO *st; /* additional stereo that exists only in Mobile-H layer */
314
+ inp_ATOM *at2; /* length = num_atoms + num_deleted_H, the conversion result */
315
+
316
+ /* information from InChI only */
317
+ T_GROUP_INFO ti; /* from original InChI[0] if Mobile-H from the beginning or later from InChI[1] if Fixed-H */
318
+ AT_NUMB *endpoint; /* from original InChI[1] in case of Fixed-H only */
319
+ S_CHAR *fixed_H; /* from original InChI[0] in case of Fixed-H only */
320
+ XYZ_COORD *pXYZ;
321
+ int num_atoms;
322
+ int num_deleted_H; /* if requested and Fixed-H InChI is available */
323
+ int nNumRemovedProtonsMobHInChI; /* number of protons removed from Mobile-H struct in original InChI */
324
+ S_CHAR charge;
325
+ char bIsotopic;
326
+
327
+ /* InChI -> Structure conversion parms and intermediate data */
328
+ BN_STRUCT *pBNS;
329
+ BN_DATA *pBD;
330
+ ICHICONST SRM *pSrm;
331
+
332
+ /* InChI layer to reverse */
333
+ char bMobileH;
334
+ char iINCHI;
335
+ char bFixedHExists; /* fixed-H InChI exists or not */
336
+
337
+ /* InChI -> Struct component -> Full InChI result (both disconnected and connected if exist) */
338
+ REV_INCHI RevInChI;
339
+ int nRemovedProtonsByNormFromRevrs; /* number of H(+) removed by normalization after
340
+ Struct Restore and before Add/Remove Protons */
341
+ int nNumRemovedProtonsByRevrs; /* number of H(+) removed by the reconstruction,
342
+ before Add/Remove Protons, only from TAUT_YES */
343
+
344
+ int bExtract; /* for debugging */
345
+
346
+ /* single component InChI calculation */
347
+ INChI *pOneINChI[TAUT_NUM]; /* InChI of restored structure */
348
+ INChI_Aux *pOneINChI_Aux[TAUT_NUM];
349
+ INP_ATOM_DATA *pOne_norm_data[TAUT_NUM]; /* normalized restored structure */
350
+ S_CHAR *pOne_fixed_H; /* !!! from normalized restored structure in case of Fixed-H only */
351
+ T_GROUP_INFO One_ti; /* t-groups of normalized canonicalized restored structure */
352
+ int nOneINChI_bMobileH; /* type of restored structure InChI */
353
+ int nNumRemovedProtons; /* =0 for Fixed-H, = num. removed protons in case of Mobile-H InChI */
354
+ /* in case of Fixed-H processing see pStruct->One_ti.tni.nNumRemovedProtons */
355
+ AT_NUMB *nAtno2Canon[TAUT_NUM]; /* nAtno2Canon[restored_at_no][*] = (atom canon number in restored struct)-1*/
356
+ AT_NUMB *nCanon2Atno[TAUT_NUM]; /* nCanon2Atno[(atom canon number in restored struct)-1][*] = restored_at_no; */
357
+
358
+ int nError;
359
+ /* other parms */
360
+ char iInchiRec; /* index in the original InChI array */
361
+ char iMobileH; /* index in the original InChI array */
362
+ char bDeleted; /* InChI component marked as Deleted, means a proton in Mobile-H layer */
363
+ /* struct. ordering number "Structure: nnn" if present */
364
+ long num_inp_actual;
365
+
366
+ /* utility data */
367
+ BFS_Q *pbfsq;
368
+ VAL_AT *pVA;
369
+
370
+ int nLink; /* same as in INChI */
371
+ int bPostProcessed; /* recalculate after add/remove protons */
372
+
373
+ /* TAUT_YES layer charges */
374
+ int nChargeRevrs; /* component charge of the reconstructed structure, TAUT_YES layer */
375
+ int nChargeInChI; /* component charge from the original InChI, TAUT_YES layer */
376
+ } StrFromINChI;
377
+
378
+
379
+ #define EL_TYPE_O 0x0001
380
+ #define EL_TYPE_S 0x0002
381
+ #define EL_TYPE_N 0x0004
382
+ #define EL_TYPE_P 0x0008
383
+ #define EL_TYPE_C 0x0010
384
+ #define EL_TYPE_X 0x0020 /* any not metal */
385
+ #define EL_TYPE_MASK 0x003f
386
+ #define EL_TYPE_OSt 0x0100 /* terminal -OH, -O(-), -SH, -S(-), ... from fix_special_bonds(...) */
387
+ #define EL_TYPE_PT 0x0200 /* may be a tautomeric endpoint */
388
+
389
+ /* the atom to which the node is attached has number 1; added atoms have numbers 2,3,... */
390
+ #define MAX_CN_VAL 3
391
+ typedef struct tagVertCapFlow {
392
+ S_SHORT type;
393
+ S_CHAR cap;
394
+ S_CHAR flow;
395
+ S_CHAR valence;
396
+ } VCF;
397
+ typedef struct tagEdgeCapFlow {
398
+ S_SHORT neigh;
399
+ S_CHAR cap;
400
+ S_CHAR bForbiddenEdge;
401
+ S_CHAR flow;
402
+ } ECF;
403
+ typedef struct tagChargeNodes {
404
+ VCF v;
405
+ ECF e[MAX_CN_VAL];
406
+ } C_NODE;
407
+
408
+
409
+ #define cn_bits_N 1 /* Neutral: charge = 0 */
410
+ #define cn_bits_P 2 /* Plus 1: charge = +1 */
411
+ #define cn_bits_M 4 /* Minus 1: charge = -1 */
412
+ #define cn_bits_shift 3
413
+ #define MAX_NUM_CN_BITS 4
414
+ #define MAKE_CN_BITS(A, B, C, D ) (( (( ((D) << cn_bits_shift | (C)) << cn_bits_shift ) | (B)) << cn_bits_shift ) | (A))
415
+
416
+ #define cn_bits_PNPN MAKE_CN_BITS(cn_bits_P, cn_bits_N, cn_bits_P, cn_bits_N)
417
+ #define cn_bits_NPNP MAKE_CN_BITS(cn_bits_N, cn_bits_P, cn_bits_N, cn_bits_P)
418
+ #define cn_bits_NPN MAKE_CN_BITS(cn_bits_N, cn_bits_P, cn_bits_N, 0)
419
+ #define cn_bits_PNP MAKE_CN_BITS(cn_bits_P, cn_bits_N, cn_bits_P, 0)
420
+ #define cn_bits_MNP MAKE_CN_BITS(cn_bits_M, cn_bits_N, cn_bits_P, 0)
421
+ #define cn_bits_PNM MAKE_CN_BITS(cn_bits_P, cn_bits_N, cn_bits_M, 0)
422
+ #define cn_bits_EN MAKE_CN_BITS(cn_bits_P | cn_bits_M, cn_bits_N, 0, 0)
423
+ #define cn_bits_NMN MAKE_CN_BITS(cn_bits_N, cn_bits_M, cn_bits_N, 0)
424
+ #define cn_bits_NE MAKE_CN_BITS(cn_bits_N, cn_bits_P | cn_bits_M, 0, 0)
425
+ #define cn_bits_NEN MAKE_CN_BITS(cn_bits_N, cn_bits_M | cn_bits_N, cn_bits_N, 0)
426
+ #define cn_bits_NP MAKE_CN_BITS(cn_bits_N, cn_bits_P, 0, 0)
427
+ #define cn_bits_PN MAKE_CN_BITS(cn_bits_P, cn_bits_N, 0, 0)
428
+ #define cn_bits_NM MAKE_CN_BITS(cn_bits_N, cn_bits_M, 0, 0)
429
+ #define cn_bits_MN MAKE_CN_BITS(cn_bits_M, cn_bits_N, 0, 0)
430
+ #define cn_bits_P_ MAKE_CN_BITS(cn_bits_P, 0, 0, 0)
431
+ #define cn_bits_M_ MAKE_CN_BITS(cn_bits_M, 0, 0, 0)
432
+ #define cn_bits_N_ MAKE_CN_BITS(cn_bits_N, 0, 0, 0)
433
+ #define cn_bits_Me (-1)
434
+
435
+ #define cnListIndexMe (17) /* index of {cnMe, cn_bits_Me,... } element of cnList[] */
436
+
437
+ extern int cnListNumEl; /* number of elements in cnList[] */
438
+
439
+ typedef struct tagChargeNodeList {
440
+ MY_CONST C_NODE *pCN;
441
+ int bits;
442
+ int nInitialCharge;
443
+ int len;
444
+ } CN_LIST;
445
+
446
+ extern MY_CONST CN_LIST cnList[];
447
+
448
+ /************************ fixed H comparison ******************************************************/
449
+ #define MAX_DIFF_FIXH 256
450
+ #define MAX_DIFF_MOBH 256
451
+ typedef struct tagAtomsCmpTwoFixedH {
452
+ AT_NUMB endptInChI;
453
+ AT_NUMB endptRevrs;
454
+ AT_NUMB atomNumber;
455
+ U_CHAR nValElectr;
456
+ U_CHAR nPeriodNum;
457
+ S_CHAR nFixHInChI;
458
+ S_CHAR nFixHRevrs;
459
+ S_CHAR nMobHInChI;
460
+ S_CHAR nMobHRevrs;
461
+ S_CHAR nNumHRevrs;
462
+ S_CHAR nAtChargeRevrs;
463
+ S_CHAR nValue; /* flag(s) */
464
+ } CMP2FHATOMS;
465
+
466
+ typedef struct tagStructCmpTwoFixedH {
467
+ CMP2FHATOMS c2at[MAX_DIFF_FIXH];
468
+ short len_c2at;
469
+ short nNumRemHInChI;
470
+ short nNumRemHRevrs;
471
+ short nNumTgInChI;
472
+ short nNumTgRevrs;
473
+ short nNumEndpInChI;
474
+ short nNumEndpRevrs;
475
+ short nNumTgDiffMinus; /* number of would-be-identical t-groups that have different number of (-) */
476
+ short nNumTgDiffH; /* number of would-be-identical t-groups that have different number of H */
477
+ short nNumTgMInChI; /* number of (-) in orig. InChI t-groups */
478
+ short nNumTgHInChI; /* number of H in orig. InChI t-groups */
479
+ short nNumTgMRevrs; /* number of (-) in reversed structure t-groups */
480
+ short nNumTgHRevrs; /* number of H in reversed structure t-groups */
481
+ S_CHAR nChargeFixHInChI;
482
+ S_CHAR nChargeMobHInChI;
483
+ S_CHAR nChargeFixHRevrs;
484
+ S_CHAR nChargeMobHRevrs;
485
+ S_CHAR nChargeFixHRevrsNonMetal; /* charge does not include charges on metals */
486
+ S_CHAR nChargeMobHRevrsNonMetal; /* charge does not include charges on metals */
487
+ char bFixedHLayerExistsRevrs;
488
+ char bHasDifference;
489
+ U_CHAR nNumDiffMobH;
490
+
491
+ } CMP2FHINCHI;
492
+
493
+ /************************ Mobile H comparison *********************************************/
494
+ typedef struct tagAtomsCmpTwoMobileH {
495
+ AT_NUMB endptInChI;
496
+ AT_NUMB endptRevrs;
497
+ AT_NUMB atomNumber;
498
+ U_CHAR nValElectr;
499
+ U_CHAR nPeriodNum;
500
+ S_CHAR nMobHInChI; /* number of H on the atom in the orig. InChI */
501
+ S_CHAR nMobHRevrs; /* number of H on the atom in InChI from the reconstructed structure */
502
+ S_CHAR nNumHRevrs; /* number of H on the atom in the being reconstructed structure */
503
+ S_CHAR nAtChargeRevrs;
504
+ S_CHAR nValue; /* flag(s) */
505
+ } CMP2MHATOMS;
506
+
507
+ typedef struct tagStructCmpTwoMobileH {
508
+ CMP2MHATOMS c2at[MAX_DIFF_FIXH];
509
+ short len_c2at;
510
+ short nNumRemHInChI;
511
+ short nNumRemHRevrs;
512
+ short nNumTgInChI;
513
+ short nNumTgRevrs;
514
+ short nNumEndpInChI;
515
+ short nNumEndpRevrs;
516
+ short nNumTgDiffMinus; /* number of would-be-identical t-groups that have different number of (-) */
517
+ short nNumTgDiffH; /* number of would-be-identical t-groups that have different number of H */
518
+
519
+ short nNumTgMInChI; /* number of (-) in orig. InChI t-groups */
520
+ short nNumTgHInChI; /* number of H in orig. InChI t-groups */
521
+ short nNumTgOInChI; /* number of tautomeric O,S,Se in orig. InChI t-groups */
522
+ short nNumTgNInChI; /* number of tautomeric N in orig. InChI t-groups */
523
+
524
+ short nNumTgMRevrs; /* number of (-) in reversed structure t-groups */
525
+ short nNumTgHRevrs; /* number of H in reversed structure t-groups */
526
+ short nNumTgORevrs; /* number of tautomeric O,S,Se in reversed structure t-groups */
527
+ short nNumTgNRevrs; /* number of tautomeric N in reversed structure t-groups */
528
+
529
+ short nNumTgOMinusRevrs; /* number of -O(-) on endpoints found in restored structure */
530
+ short nNumTgOHRevrs; /* number of -OH on endpoints found in restored structure */
531
+ short nNumTgDBORevrs; /* number of =O on endpoints found in restored structure */
532
+ short nNumTgNMinusRevrs; /* number of -N(-)- on endpoints found in restored structure */
533
+ short nNumTgNHMinusRevrs; /* number of -NH(-) on endpoints found in restored structure */
534
+ short nNumTgNHRevrs; /* number of -NH- on endpoints found in restored structure */
535
+ short nNumTgNH2Revrs; /* number of -NH2 on endpoints found in restored structure */
536
+ short nNumTgDBNHRevrs; /* number of =NH on endpoints found in restored structure */
537
+ short nNumTgDBNMinusRevrs; /* number of =N(-) on endpoints found in restored structure */
538
+ short nNumTgDBNRevrs; /* number of =N- on endpoints found in restored structure */
539
+
540
+ short nNumTgOMinusInChI; /* number of -O(-) on endpoints according to original InChI */
541
+ short nNumTgOHInChI; /* number of -OH on endpoints according to original InChI */
542
+ short nNumTgDBOInChI; /* number of =O on endpoints according to original InChI */
543
+ short nNumTgNMinusInChI; /* number of -N(-)- on endpoints according to original InChI */
544
+ short nNumTgNHMinusInChI; /* number of -NH(-) on endpoints according to original InChI */
545
+ short nNumTgNHInChI; /* number of -NH- on endpoints according to original InChI */
546
+ short nNumTgNH2InChI; /* number of -NH2 on endpoints according to original InChI */
547
+ short nNumTgDBNHInChI; /* number of =NH on endpoints according to original InChI */
548
+ short nNumTgDBNMinusInChI; /* number of =N(-) on endpoints according to original InChI */
549
+ short nNumTgDBNInChI; /* number of =N- on endpoints according to original InChI */
550
+
551
+ S_CHAR nChargeMobHInChI;
552
+ S_CHAR nChargeMobHRevrs;
553
+ S_CHAR nChargeMobHRevrsNonMetal; /* charge does not include charges on metals; later add ion pairs rejection */
554
+ char bFixedHLayerExistsRevrs;
555
+ char bHasDifference;
556
+ U_CHAR nNumDiffMobH;
557
+ } CMP2MHINCHI;
558
+
559
+
560
+ #ifndef INCHI_ALL_CPP
561
+ #ifdef __cplusplus
562
+ extern "C" {
563
+ #endif
564
+ #endif
565
+
566
+ int OneInChI2Atom( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, const char *szCurHdr, long num_inp,
567
+ StrFromINChI *pStruct, int iComponent, int iAtNoOffset, int bHasSomeFixedH, INChI *pInChI[]);
568
+ int get_sp_element_type( int nPeriodicNumber, int *nRow );
569
+ int get_bonds_valences( int nPeriodicNum, int bonds_valence, int num_H, VAL_AT *pVA );
570
+
571
+
572
+ /* local prototypes */
573
+ int AddExplicitDeletedH( inp_ATOM *at, int jv, int num_at, int *iDeletedH, int *iH, int nNumDeletedH, int bTwoStereo );
574
+ int bFindCumuleneChain( inp_ATOM *at, AT_NUMB i1, AT_NUMB i2, AT_NUMB nCumulene[], int nMaxLen );
575
+ int set_bond_type( inp_ATOM *at, AT_NUMB i1, AT_NUMB i2, int bType );
576
+ int set_cumulene_0D_parity( inp_ATOM *at, inp_ATOM_STEREO *st, int num_at, int idelH1, int i1, int i2, int idelH2, int parity, int len );
577
+ int set_atom_0D_parity( inp_ATOM *at, inp_ATOM_STEREO *st, int num_at, int num_deleted_H, int i1, int parity );
578
+ int GetTgroupInfoFromInChI( T_GROUP_INFO *ti, inp_ATOM *at, AT_NUMB *endpoint, INChI *pInChI );
579
+ int FillOutpStructEndpointFromInChI( INChI *pInChI, AT_NUMB **pEndpoint );
580
+ int SetStereoBondTypeFor0DParity( inp_ATOM *at, int i1, int m1 );
581
+ int SetStereoBondTypesFrom0DStereo( StrFromINChI *pStruct, INChI *pInChI);
582
+ void CopyAt2St( inp_ATOM *at, inp_ATOM_STEREO * st, int num_atoms );
583
+ void CopySt2At( inp_ATOM *at, inp_ATOM_STEREO * st, int num_atoms );
584
+ int RestoreAtomConnectionsSetStereo( StrFromINChI *pStruct, int iComponent, int iAtNoOffset, INChI *pInChI, INChI *pInChIMobH);
585
+ int RestoreAtomMakeBNS( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, StrFromINChI *pStruct, int iComponent,
586
+ int iAtNoOffset, INChI *pInChI[], const char *szCurHdr, long num_inp, int bHasSomeFixedH );
587
+ int nAddSuperCGroups( ALL_TC_GROUPS *pTCGroups );
588
+
589
+ int AddCGroups2TCGBnStruct( BN_STRUCT *pBNS, StrFromINChI *pStruct, VAL_AT *pVA,
590
+ ALL_TC_GROUPS *pTCGroups, int nMaxAddEdges );
591
+ int AddTGroups2TCGBnStruct( BN_STRUCT *pBNS, StrFromINChI *pStruct, VAL_AT *pVA,
592
+ ALL_TC_GROUPS *pTCGroups, int nMaxAddEdges );
593
+ BN_STRUCT* AllocateAndInitTCGBnStruct( StrFromINChI *pStruct, VAL_AT *pVA,
594
+ ALL_TC_GROUPS *pTCGroups,
595
+ int nMaxAddAtoms, int nMaxAddEdges,
596
+ int max_altp, int *pNum_changed_bonds );
597
+ int nCountBnsSizes( inp_ATOM *at, int num_at, int nAddEdges2eachAtom, int nAddVertices,
598
+ T_GROUP_INFO *ti, VAL_AT *pVA, ICHICONST SRM *pSrm, ALL_TC_GROUPS *pTCGroups );
599
+ int GetAtomRestoreInfo( inp_ATOM *atom, int iat, VAL_AT *pVArray, ICHICONST SRM *pSrm, int bMobileH, AT_NUMB *endpoint );
600
+ int AddEdgeFlow( int edge_cap, int edge_flow, BNS_EDGE *e01, BNS_VERTEX *pv0 /*src*/,
601
+ BNS_VERTEX *pv1/*dest*/, int *tot_st_cap, int *tot_st_flow );
602
+ void SetEdgeCapFlow( BNS_EDGE *e, int edge_cap, int edge_flow );
603
+
604
+ void AddStCapFlow( BNS_VERTEX *vert_ficpoint, int *tot_st_flow, int *tot_st_cap, int cap, int flow );
605
+ void SetStCapFlow( BNS_VERTEX *vert_ficpoint, int *tot_st_flow, int *tot_st_cap, int cap, int flow );
606
+
607
+ int ConnectSuperCGroup( int nTCG_Plus, int nAddGroups[], int num_add,
608
+ int *pcur_num_vertices, int *pcur_num_edges,
609
+ int *tot_st_cap, int *tot_st_flow,
610
+ BN_STRUCT *pBNS, ALL_TC_GROUPS *pTCGroups );
611
+ int ConnectTwoVertices( BNS_VERTEX *p1, BNS_VERTEX *p2, BNS_EDGE *e, BN_STRUCT *pBNS, int bClearEdge );
612
+
613
+ int nTautEndpointEdgeCap( inp_ATOM *at, VAL_AT *pVA, int i );
614
+
615
+ /*
616
+ int GetAtomBondFlow( inp_ATOM *atom, VAL_AT *pVA, ICHICONST SRM *pSrm, int iat, int ineigh );
617
+ void GetAtomStCapFlow( inp_ATOM *atom, VAL_AT *pVA, ICHICONST SRM *pSrm, int iat, int *pCap, int *pFlow );
618
+ int GetAtomToMCGroupInitEdgeCapFlow( EdgeFlow *nEdgeCap, EdgeFlow *nEdgeFlow, ICHICONST SRM *pSrm, inp_ATOM *at, VAL_AT *pVA, int iat );
619
+ void GetAtomToMetalInitEdgeCapFlow( EdgeFlow *nEdgeCap, EdgeFlow *nEdgeFlow );
620
+ */
621
+ int AtomStcapStflow( inp_ATOM *atom, VAL_AT *pVA, ICHICONST SRM *pSrm, int iat, int *pnStcap, int *pnStflow,
622
+ EdgeFlow *pnMGroupEdgeCap, EdgeFlow *pnMGroupEdgeFlow );
623
+ int BondFlowMaxcapMinorder( inp_ATOM *atom, VAL_AT *pVA, ICHICONST SRM *pSrm, int iat, int ineigh,
624
+ int *pnMaxcap, int *pnMinorder, int *pbNeedsFlower );
625
+
626
+
627
+
628
+ int clean_charge_val( CHARGE_VAL *pChargeVal, int len, inp_ATOM *atom, VAL_AT *pVA, int iat, int bIsMetal, int bMobileH, AT_NUMB *endpoint );
629
+ int ReallocTCGroups( ALL_TC_GROUPS *pTCGroups, int nAdd );
630
+ int RegisterTCGroup( ALL_TC_GROUPS *pTCGroups, int nGroupType, int nGroupOrdNum,
631
+ int nVertexCap, int nVertexFlow, int nEdgeCap, int nEdgeFlow, int nNumEdges);
632
+ int CopyBnsToAtom( StrFromINChI *pStruct, BN_STRUCT *pBNS, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, int bAllowZeroBondOrder );
633
+ int CheckBnsConsistency( StrFromINChI *pStruct, BN_STRUCT *pBNS, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, int bNoRad );
634
+
635
+ int RunBnsRestore1( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
636
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, INChI *pInChI[], long num_inp, int bHasSomeFixedH);
637
+ int RunBnsRestoreOnce( BN_STRUCT *pBNS, BN_DATA *pBD, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups );
638
+ int nNumEdgesToCnVertex( MY_CONST C_NODE *pCN, int len, int v );
639
+ int ConnectMetalFlower( int *pcur_num_vertices, int *pcur_num_edges,
640
+ int *tot_st_cap, int *tot_st_flow, ICHICONST SRM *pSrm,
641
+ BN_STRUCT *pBNS, ALL_TC_GROUPS *pTCGroups );
642
+ int AddRadicalToMetal( int *tot_st_cap, int *tot_st_flow, ICHICONST SRM *pSrm, BN_STRUCT *pBNS, ALL_TC_GROUPS *pTCGroups );
643
+ int bMayBeACationInMobileHLayer( inp_ATOM *at, VAL_AT *pVA, int iat, int bMobileH );
644
+
645
+ int MakeOneInChIOutOfStrFromINChI( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, StrFromINChI *pStruct, inp_ATOM *at2, inp_ATOM *at3, ALL_TC_GROUPS *pTCGroups );
646
+ void IncrZeroBondsAndClearEndpts(inp_ATOM *at, int num_at, int iComponent);
647
+ void IncrZeroBonds(inp_ATOM *at, int num_at, int iComponent );
648
+ void ClearEndpts(inp_ATOM *at, int num_at );
649
+ int DisplayRestoredComponent( StrFromINChI *pStruct, int iComponent, int iAtNoOffset, INChI *pInChI, const char *szCurHdr );
650
+ int cmp_charge_val( const void *a1, const void *a2 );
651
+
652
+ int EvaluateChargeChanges( BN_STRUCT *pBNS, VAL_AT *pVA, int *pnDeltaH, int *pnDeltaCharge, int *pnNumVisitedAtoms );
653
+ int RunBnsTestOnce( BN_STRUCT *pBNS, BN_DATA *pBD, VAL_AT *pVA, Vertex *pvFirst, Vertex *pvLast,
654
+ int *pPathLen, int *pnDeltaH, int *pnDeltaCharge, int *pnNumVisitedAtoms );
655
+ int comp_cc_cand( const void *a1, const void *a2 );
656
+ int MoveRadToAtomsAddCharges( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
657
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, int forbidden_mask );
658
+ void RemoveForbiddenBondFlowBits( BN_STRUCT *pBNS, int forbidden_edge_mask_int );
659
+ int PlusFromDB_N_DB_O_to_Metal(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
660
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
661
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
662
+ int AdjustTgroupsToForbiddenEdges2( BN_STRUCT *pBNS, inp_ATOM *at, VAL_AT *pVA, int num_atoms, int forbidden_mask );
663
+ int AllocEdgeList( EDGE_LIST *pEdges, int nLen );
664
+ int AddToEdgeList( EDGE_LIST *pEdges, int iedge, int nAddLen );
665
+ int RemoveFromEdgeListByIndex( EDGE_LIST *pEdges, int index );
666
+ int RemoveFromEdgeListByValue( EDGE_LIST *pEdges, int iedge );
667
+ int FindInEdgeList( EDGE_LIST *pEdges, int iedge );
668
+ int AllocBfsQueue( BFS_Q *pQ, int num_at, int min_ring_size );
669
+ void RemoveForbiddenEdgeMask( BN_STRUCT *pBNS, EDGE_LIST *pEdges, int forbidden_edge_mask );
670
+ void SetForbiddenEdgeMask( BN_STRUCT *pBNS, EDGE_LIST *pEdges, int forbidden_edge_mask );
671
+ int ForbidCarbonChargeEdges( BN_STRUCT *pBNS, ALL_TC_GROUPS *pTCGroups, EDGE_LIST *pCarbonChargeEdges, int forbidden_edge_mask );
672
+ int ForbidMetalCarbonEdges( BN_STRUCT *pBNS, inp_ATOM *at, int num_at, VAL_AT *pVA,
673
+ ALL_TC_GROUPS *pTCGroups, EDGE_LIST *pMetalCarbonEdges, int forbidden_edge_mask );
674
+ int ForbidNintrogenPlus2BondsInSmallRings( BN_STRUCT *pBNS, inp_ATOM *at, int num_at,
675
+ VAL_AT *pVA, int min_ring_size, ALL_TC_GROUPS *pTCGroups,
676
+ EDGE_LIST *pNplus2BondsEdges, int forbidden_edge_mask );
677
+ int RearrangePlusMinusEdgesFlow( BN_STRUCT *pBNS, BN_DATA *pBD, VAL_AT *pVA,
678
+ ALL_TC_GROUPS *pTCGroups, int forbidden_edge_mask );
679
+ int IncrementZeroOrderBondsToHeteroat( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
680
+ inp_ATOM *at, inp_ATOM *at2,
681
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
682
+ int *pnNumRunBNS, int *pnTotalDelta,
683
+ int forbidden_edge_mask);
684
+ int MoveChargeFromHeteroatomsToMetals( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
685
+ inp_ATOM *at, inp_ATOM *at2,
686
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
687
+ int *pnNumRunBNS, int *pnTotalDelta,
688
+ int forbidden_edge_mask);
689
+ int EliminateChargeSeparationOnHeteroatoms( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
690
+ inp_ATOM *at, inp_ATOM *at2,
691
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
692
+ int *pnNumRunBNS, int *pnTotalDelta,
693
+ int forbidden_edge_mask, int forbidden_stereo_edge_mask);
694
+ int MovePlusFromS2DiaminoCarbon( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
695
+ inp_ATOM *at, inp_ATOM *at2,
696
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
697
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
698
+ int RestoreCyanoGroup( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
699
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
700
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
701
+ int RestoreIsoCyanoGroup( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
702
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
703
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
704
+ int RestoreNNNgroup( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
705
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
706
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
707
+ int FixMetal_Nminus_Ominus( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
708
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
709
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
710
+ int EliminateNitrogen5Val3Bonds(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
711
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
712
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
713
+ int Convert_SIV_to_SVI(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
714
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
715
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
716
+ int MoveMobileHToAvoidFixedBonds(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
717
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
718
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
719
+ int RemoveRadFromMobileHEndpoint(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
720
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
721
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
722
+ int RemoveRadFromMobileHEndpointFixH(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
723
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
724
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
725
+ int MoveChargeToMakeCenerpoints(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
726
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
727
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
728
+ int CheckAndRefixStereobonds(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
729
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
730
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
731
+ int MoveChargeToRemoveCenerpoints(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
732
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
733
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
734
+ int MakeSingleBondsMetal2ChargedHeteroat(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
735
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
736
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
737
+ int SaltBondsToCoordBonds(BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct,
738
+ inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
739
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask);
740
+ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct, inp_ATOM *at,
741
+ inp_ATOM *at2, inp_ATOM *atf, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
742
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask );
743
+ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct, inp_ATOM *at,
744
+ inp_ATOM *at2, inp_ATOM *atf, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
745
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask );
746
+ int FixAddProtonForADP( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct, inp_ATOM *at,
747
+ inp_ATOM *at2, inp_ATOM *atf, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, ICR *picr,
748
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask );
749
+ int ConnectDisconnectedH( inp_ATOM *at, int num_atoms, int num_deleted_H );
750
+ int DisconnectedConnectedH( inp_ATOM *at, int num_atoms, int num_deleted_H );
751
+ int MakeInChIOutOfStrFromINChI2( ICHICONST INPUT_PARMS *ip_inp, STRUCT_DATA *sd_inp, StrFromINChI *pStruct,
752
+ int iComponent, int iAtNoOffset, long num_inp );
753
+ int GetChargeFlowerUpperEdge( BN_STRUCT *pBNS, VAL_AT *pVA, int nChargeEdge );
754
+ int get_pVA_atom_type( VAL_AT *pVA, inp_ATOM *at, int iat, int bond_type );
755
+
756
+ int NormalizeAndCompare(ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, BN_DATA *pBD,
757
+ StrFromINChI *pStruct, inp_ATOM *at, inp_ATOM *at2, inp_ATOM *at3, VAL_AT *pVA,
758
+ ALL_TC_GROUPS *pTCGroups, INChI *pInChI[], long num_inp, int bHasSomeFixedH,
759
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask, int forbidden_stereo_edge_mask);
760
+ /* call InChI normalization only */
761
+ int NormalizeStructure( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS,
762
+ StrFromINChI *pStruct, inp_ATOM *at, inp_ATOM *at2,
763
+ VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
764
+ inp_ATOM *at_norm, inp_ATOM *at_fixed_bonds_out, T_GROUP_INFO *t_group_info );
765
+ /* create one InChI */
766
+ int MakeOneInChIOutOfStrFromINChI2( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, StrFromINChI *pStruct,
767
+ inp_ATOM *at, inp_ATOM *at2, inp_ATOM *at3, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups,
768
+ T_GROUP_INFO **t_group_info, inp_ATOM **at_norm, inp_ATOM **at_prep );
769
+ /* fixed-H */
770
+ int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct );
771
+ int FillOutExtraFixedHDataInChI( StrFromINChI *pStruct, INChI *pInChI[] );
772
+ int FixFixedHRestoredStructure(ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, BN_DATA *pBD,
773
+ StrFromINChI *pStruct, inp_ATOM *at, inp_ATOM *at2, inp_ATOM *at3, VAL_AT *pVA,
774
+ ALL_TC_GROUPS *pTCGroups, T_GROUP_INFO **ti, inp_ATOM **at_norm, inp_ATOM **at_prep,
775
+ INChI *pInChI[], long num_inp, int bHasSomeFixedH, int *pnNumRunBNS, int *pnTotalDelta,
776
+ int forbidden_edge_mask, int forbidden_stereo_edge_mask);
777
+ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct, inp_ATOM *at,
778
+ inp_ATOM *at2, inp_ATOM *atf, inp_ATOM *atn, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, ICR *picr,
779
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask );
780
+ int FillOutCMP2FHINCHI( StrFromINChI *pStruct, inp_ATOM *at2, VAL_AT *pVA, INChI *pInChI[], CMP2FHINCHI *pc2i );
781
+ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, ALL_TC_GROUPS *pTCGroups, inp_ATOM *at2,
782
+ VAL_AT *pVA, INChI *pInChI[], CMP2MHINCHI *pc2i );
783
+
784
+ int bHas_N_V( inp_ATOM *at2, int num_atoms );
785
+
786
+ int GetPlusMinusVertex( BN_STRUCT *pBNS, ALL_TC_GROUPS *pTCGroups, int bCheckForbiddenPlus, int bCheckForbiddenMinus );
787
+ int FixMobileHRestoredStructure(ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, BN_DATA *pBD,
788
+ StrFromINChI *pStruct, inp_ATOM *at, inp_ATOM *at2, inp_ATOM *at3, VAL_AT *pVA,
789
+ ALL_TC_GROUPS *pTCGroups, T_GROUP_INFO **ppt_group_info, inp_ATOM **ppat_norm,
790
+ inp_ATOM **ppat_prep, INChI *pInChI[], long num_inp, int bHasSomeFixedH,
791
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask, int forbidden_stereo_edge_mask);
792
+
793
+ int FixRestoredStructureStereo( INCHI_MODE cmpInChI, ICR *icr, INCHI_MODE cmpInChI2, ICR *icr2,
794
+ ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, BN_STRUCT *pBNS, BN_DATA *pBD,
795
+ StrFromINChI *pStruct, inp_ATOM *at, inp_ATOM *at2, inp_ATOM *at3, VAL_AT *pVA,
796
+ ALL_TC_GROUPS *pTCGroups, T_GROUP_INFO **ppt_group_info, inp_ATOM **ppat_norm,
797
+ inp_ATOM **ppat_prep, INChI *pInChI[], long num_inp,
798
+ int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask, int forbidden_stereo_edge_mask);
799
+
800
+ int AddRemProtonsInRestrStruct( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, long num_inp,
801
+ int bHasSomeFixedH,
802
+ StrFromINChI *pStruct, int num_components,
803
+ StrFromINChI *pStructR, int num_componentsR,
804
+ NUM_H *pProtonBalance, int *recmet_change_balance );
805
+ int AllInchiToStructure( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, long num_inp, char *szCurHdr,
806
+ ICHICONST SRM *pSrm, int bReqNonTaut, StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM],
807
+ InpInChI *pOneInput );
808
+ int AddProtonAndIsoHBalanceToMobHStruct( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd,
809
+ long num_inp, int bHasSomeFixedH, char *szCurHdr,
810
+ StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], InpInChI *pOneInput);
811
+ int InChI2Atom( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, const char *szCurHdr, long num_inp,
812
+ StrFromINChI *pStruct, int iComponent, int iAtNoOffset, int bI2A_Flag, int bHasSomeFixedH, InpInChI *pOneInput);
813
+
814
+ int MarkDisconectedIdenticalToReconnected ( InpInChI *pOneInput );
815
+ void RemoveFixHInChIIdentical2MobH( InpInChI *pOneInput );
816
+ void SetUpSrm( SRM *pSrm );
817
+ void FreeInpInChI( InpInChI *pOneInput );
818
+ void FreeStrFromINChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], int nNumComponents[INCHI_NUM][TAUT_NUM] );
819
+ int OldPrintCompareOneOrigInchiToRevInChI(StrFromINChI *pStruct, INChI *pInChI[TAUT_NUM], int bMobileH,
820
+ int iComponent, long num_inp, char *szCurHdr);
821
+ int CompareOneOrigInchiToRevInChI(StrFromINChI *pStruct, INChI *pInChI[TAUT_NUM], int bMobileH, int iComponent,
822
+ long num_inp, char *szCurHdr,
823
+ COMPONENT_REM_PROTONS *nCurRemovedProtons, INCHI_MODE CompareInchiFlags[]);
824
+ int CompareTwoPairsOfInChI( INChI *pInChI1[TAUT_NUM], INChI *pInChI2[TAUT_NUM],
825
+ int bMobileH, INCHI_MODE CompareInchiFlags[] );
826
+ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, INChI *i2 /* input InChI */,
827
+ INChI_Aux *a1, INChI_Aux *a2, int *err );
828
+ INCHI_MODE CompareReversedStereoINChI3( INChI_Stereo *s1/* InChI from reversed struct */, INChI_Stereo *s2 /* input InChI */, ICR *picr);
829
+ int CompareAllOrigInchiToRevInChI(StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], InpInChI *pOneInput, int bReqNonTaut,
830
+ long num_inp, char *szCurHdr);
831
+ int CompareAllDisconnectedOrigInchiToRevInChI(StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM],
832
+ InpInChI *pOneInput, int bHasSomeFixedH,
833
+ long num_inp, char *szCurHdr);
834
+ int insertions_sort_AT_NUMB( AT_NUMB *base, int num );
835
+
836
+ int AddRemIsoProtonsInRestrStruct( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, long num_inp, int bHasSomeFixedH,
837
+ StrFromINChI *pStruct, int num_components,
838
+ StrFromINChI *pStructR, int num_componentsR,
839
+ NUM_H pProtonBalance[], NUM_H recmet_change_balance[] );
840
+ int OutputInChIOutOfStrFromINChI( ICHICONST INPUT_PARMS *ip_inp, STRUCT_DATA *sd_inp, long num_inp,
841
+ INCHI_FILE *pout, INCHI_FILE *plog, InpInChI *pOneInput, int bHasSomeFixedH );
842
+
843
+ int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, long num_inp, char *szCurHdr,
844
+ ICHICONST SRM *pSrm, int bReqNonTaut, StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM],
845
+ InpInChI *pOneInput );
846
+ int AddOneMsg( char *szMsg, int used_len, int tot_len, const char *szAddMsg, const char *szDelim );
847
+ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] );
848
+ void clear_t_group_info( T_GROUP_INFO *ti );
849
+ int bInpInchiComponentExists( InpInChI *pOneInput, int iINCHI, int bMobileH, int k );
850
+ int bInpInchiComponentDeleted( InpInChI *pOneInput, int iInChI, int bMobileH, int k );
851
+ int bRevInchiComponentExists( StrFromINChI *pStruct, int iInChI, int bMobileH, int k );
852
+ int bRevInchiComponentDeleted( StrFromINChI *pStruct, int iInChI, int bMobileH, int k );
853
+ int DetectInpInchiCreationOptions ( InpInChI *pOneInput, int *bHasReconnected, int *bHasMetal,
854
+ int *bHasFixedH, int *sFlag, int *bTautFlag );
855
+ int DisplayStructureComponents( ICHICONST INPUT_PARMS *ip, STRUCT_DATA *sd, long num_inp, char *szCurHdr,
856
+ ICHICONST SRM *pSrm, int bReqNonTaut, StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM],
857
+ InpInChI *pOneInput );
858
+ int DisplayOneRestoredComponent( StrFromINChI *pStruct, inp_ATOM *at,
859
+ int iComponent, int nNumComponents, int bMobileH,
860
+ const char *szCurHdr );
861
+ int DisplayAllRestoredComponents( inp_ATOM *at, int num_at, const char *szCurHdr );
862
+ int CountStereoTypes( INChI *pInChI, int *num_known_SB, int *num_known_SC,
863
+ int *num_unk_und_SB, int *num_unk_und_SC,
864
+ int *num_SC_PIII, int *num_SC_AsIII);
865
+ int GetNumNeighborsFromInchi( INChI *pInChI, AT_NUMB nAtNumber );
866
+ int bIsUnsatCarbonInASmallRing( inp_ATOM *at, VAL_AT *pVA, int iat, BFS_Q *pbfsq, int min_ring_size );
867
+
868
+ int MakeProtonComponent( StrFromINChI *pStruct, int iComponent, int num_prot );
869
+
870
+ /* extra configurarion */
871
+ #define KEEP_METAL_EDGE_FLOW 0 /* counterexample: mdb0-1738.sdf.txt */
872
+ #define MOVE_CHARGES_FROM_HETEREO_TO_METAL 0 /* disabled */
873
+ #define FIX_ADD_PROTON_FOR_ADP 0 /* not used */
874
+
875
+ #ifndef INCHI_ALL_CPP
876
+ #ifdef __cplusplus
877
+ }
878
+ #endif
879
+ #endif
880
+
881
+
882
+ #endif