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.
Files changed (87) hide show
  1. data/README +44 -0
  2. data/Rakefile +123 -0
  3. data/ext/extconf.rb +26 -0
  4. data/ext/ruby_inchi_main.so +0 -0
  5. data/ext/src/aux2atom.h +2786 -0
  6. data/ext/src/comdef.h +148 -0
  7. data/ext/src/e_0dstereo.c +3014 -0
  8. data/ext/src/e_0dstereo.h +31 -0
  9. data/ext/src/e_comdef.h +57 -0
  10. data/ext/src/e_ctl_data.h +147 -0
  11. data/ext/src/e_ichi_io.c +498 -0
  12. data/ext/src/e_ichi_io.h +40 -0
  13. data/ext/src/e_ichi_parms.c +37 -0
  14. data/ext/src/e_ichi_parms.h +41 -0
  15. data/ext/src/e_ichicomp.h +50 -0
  16. data/ext/src/e_ichierr.h +40 -0
  17. data/ext/src/e_ichimain.c +593 -0
  18. data/ext/src/e_ichisize.h +43 -0
  19. data/ext/src/e_inchi_atom.c +75 -0
  20. data/ext/src/e_inchi_atom.h +33 -0
  21. data/ext/src/e_inpdef.h +41 -0
  22. data/ext/src/e_mode.h +706 -0
  23. data/ext/src/e_mol2atom.c +649 -0
  24. data/ext/src/e_readinch.c +58 -0
  25. data/ext/src/e_readmol.c +54 -0
  26. data/ext/src/e_readmol.h +180 -0
  27. data/ext/src/e_readstru.c +251 -0
  28. data/ext/src/e_readstru.h +33 -0
  29. data/ext/src/e_util.c +284 -0
  30. data/ext/src/e_util.h +61 -0
  31. data/ext/src/extr_ct.h +251 -0
  32. data/ext/src/ichi.h +206 -0
  33. data/ext/src/ichi_bns.c +7999 -0
  34. data/ext/src/ichi_bns.h +231 -0
  35. data/ext/src/ichican2.c +5000 -0
  36. data/ext/src/ichicano.c +2195 -0
  37. data/ext/src/ichicano.h +49 -0
  38. data/ext/src/ichicans.c +1625 -0
  39. data/ext/src/ichicant.h +379 -0
  40. data/ext/src/ichicomn.h +260 -0
  41. data/ext/src/ichicomp.h +50 -0
  42. data/ext/src/ichidrp.h +119 -0
  43. data/ext/src/ichierr.h +124 -0
  44. data/ext/src/ichiisot.c +101 -0
  45. data/ext/src/ichilnct.c +286 -0
  46. data/ext/src/ichimain.h +132 -0
  47. data/ext/src/ichimak2.c +1189 -0
  48. data/ext/src/ichimake.c +3812 -0
  49. data/ext/src/ichimake.h +205 -0
  50. data/ext/src/ichimap1.c +851 -0
  51. data/ext/src/ichimap2.c +2856 -0
  52. data/ext/src/ichimap4.c +1609 -0
  53. data/ext/src/ichinorm.c +741 -0
  54. data/ext/src/ichinorm.h +67 -0
  55. data/ext/src/ichiparm.c +45 -0
  56. data/ext/src/ichiparm.h +1441 -0
  57. data/ext/src/ichiprt1.c +3612 -0
  58. data/ext/src/ichiprt2.c +1511 -0
  59. data/ext/src/ichiprt3.c +3011 -0
  60. data/ext/src/ichiqueu.c +1003 -0
  61. data/ext/src/ichiring.c +326 -0
  62. data/ext/src/ichiring.h +49 -0
  63. data/ext/src/ichisize.h +35 -0
  64. data/ext/src/ichisort.c +539 -0
  65. data/ext/src/ichister.c +3538 -0
  66. data/ext/src/ichister.h +35 -0
  67. data/ext/src/ichitaut.c +3843 -0
  68. data/ext/src/ichitaut.h +387 -0
  69. data/ext/src/ichitime.h +74 -0
  70. data/ext/src/inchi_api.h +670 -0
  71. data/ext/src/inchi_dll.c +1480 -0
  72. data/ext/src/inchi_dll.h +34 -0
  73. data/ext/src/inchi_dll_main.c +23 -0
  74. data/ext/src/inchi_dll_main.h +31 -0
  75. data/ext/src/inpdef.h +328 -0
  76. data/ext/src/lreadmol.h +1246 -0
  77. data/ext/src/mode.h +706 -0
  78. data/ext/src/ruby_inchi_main.c +558 -0
  79. data/ext/src/runichi.c +4179 -0
  80. data/ext/src/strutil.c +3861 -0
  81. data/ext/src/strutil.h +182 -0
  82. data/ext/src/util.c +1130 -0
  83. data/ext/src/util.h +85 -0
  84. data/lib/clean_tempfile.rb +220 -0
  85. data/lib/rino.rb +111 -0
  86. data/test/test.rb +386 -0
  87. metadata +130 -0
@@ -0,0 +1,1441 @@
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
+ int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmode );
11
+
12
+ /*****************************************************************************************/
13
+ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *szSdfDataValue,
14
+ unsigned long *ulDisplTime, int bReleaseVersion, INCHI_FILE *log_file )
15
+ {
16
+ int i, k, c;
17
+ const char *q;
18
+ unsigned long ul;
19
+ int nFontSize = -9;
20
+ int nMode = 0;
21
+ int nReleaseMode = nMode | (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO);
22
+ #if( MIN_SB_RING_SIZE > 0 )
23
+ int nMinDbRinSize = MIN_SB_RING_SIZE, mdbr=0;
24
+ #endif
25
+ /*int bNotRecognized=0;*/
26
+ char szNameSuffix[32], szOutputPath[512];
27
+ int bNameSuffix, bOutputPath;
28
+ int bMergeAllInputStructures;
29
+ int bDisconnectSalts = (DISCONNECT_SALTS==1);
30
+ int bDoNotAddH = 0;
31
+
32
+ #ifdef INCHI_LIB
33
+ int bVer1Options = 0;
34
+ int bReconnectCoord = 1;
35
+ int bDisconnectCoord = 1;
36
+ int bINChIOutputOptions = INCHI_OUT_EMBED_REC; /* embed reconnected & output full aux info */
37
+ int bCompareComponents = CMP_COMPONENTS;
38
+ #else
39
+ int bVer1Options = 1;
40
+ int bReconnectCoord = (RECONNECT_METALS==1);
41
+ int bDisconnectCoord = (DISCONNECT_METALS==1);
42
+ int bINChIOutputOptions = ((EMBED_REC_METALS_INCHI==1)? INCHI_OUT_EMBED_REC : 0);
43
+ /*| INCHI_OUT_NO_AUX_INFO INCHI_OUT_SHORT_AUX_INFO*/
44
+ int bCompareComponents = 0;
45
+ #endif
46
+
47
+ int bDisconnectCoordChkVal = (CHECK_METAL_VALENCE == 1);
48
+ int bMovePositiveCharges = (MOVE_CHARGES==1);
49
+ int bAcidTautomerism = (DISCONNECT_SALTS==1)? (TEST_REMOVE_S_ATOMS==1? 2:1):0;
50
+ int bUnchargedAcidTaut = (CHARGED_SALTS_ONLY==0);
51
+ int bMergeSaltTGroups = (DISCONNECT_SALTS==1);
52
+ int bDisplayCompositeResults = 0;
53
+
54
+ #define VER100_DEFAULT_MODE (REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO |\
55
+ REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)
56
+
57
+ INCHI_MODE bVer1DefaultMode = VER100_DEFAULT_MODE;
58
+ const char *ext[MAX_NUM_PATHS+1];
59
+ const char *pArg;
60
+ double t;
61
+ int bRecognizedOption;
62
+ int bDisplay = 0;
63
+ int bNoStructLabels = 0;
64
+ int bOutputMolfileOnly = 0;
65
+ int bForcedChiralFlag = 0;
66
+ #ifdef INCHI_LIB
67
+ int bXml = INCHI_OUT_XML;
68
+ #else
69
+ int bXml = INCHI_OUT_PLAIN_TEXT;
70
+ #endif
71
+ int bTgFlagVariableProtons = 1;
72
+ int bTgFlagHardAddRenProtons = 1;
73
+ #ifdef STEREO_WEDGE_ONLY
74
+ int bPointedEdgeStereo = STEREO_WEDGE_ONLY; /* NEWPS TG_FLAG_POINTED_EDGE_STEREO*/
75
+ #endif
76
+
77
+
78
+ ext[0] = ".mol";
79
+ ext[1] = bVer1Options? ".txt" : ".ich";
80
+ ext[2] = ".log";
81
+ ext[3] = ".prb";
82
+ ext[4] = "";
83
+
84
+ #if( MAX_NUM_PATHS < 4 )
85
+ #error Wrong initialization
86
+ #endif
87
+
88
+ /* init table parms */
89
+ memset ( ip, 0, sizeof(*ip) );
90
+ #ifndef INCHI_ANSI_ONLY
91
+ strcpy( ip->tdp.ReqShownFoundTxt[ilSHOWN], "Shown" );
92
+ ip->dp.sdp.tdp = &ip->tdp;
93
+ ip->dp.pdp = &ip->pdp;
94
+ #endif
95
+ memset( szNameSuffix, 0, sizeof(szNameSuffix) );
96
+ bNameSuffix = 0;
97
+ memset(szOutputPath, 0, sizeof(szOutputPath) );
98
+ bOutputPath = 0;
99
+ bMergeAllInputStructures = 0;
100
+
101
+ *ulDisplTime = 0;
102
+ #ifdef INCHI_LIBRARY
103
+ ip->msec_MaxTime = 0; /* milliseconds, default = unlimited in libinchi */
104
+ #else
105
+ ip->msec_MaxTime = 60000; /* milliseconds, default = 60 sec */
106
+ #endif
107
+
108
+ if ( bReleaseVersion ) {
109
+
110
+ /* normal */
111
+ /*ip->bINChIOutputOptions |= INCHI_OUT_PLAIN_TEXT;*/
112
+ /*ip->bXml = 1;*/
113
+ ip->bAbcNumbers = 0;
114
+ ip->bCtPredecessors = 0;
115
+ /*
116
+ -- testing --
117
+ ip->bXml = 0;
118
+ ip->bAbcNumbers = 1;
119
+ */
120
+ } else {
121
+ /*bXml = INCHI_OUT_PLAIN_TEXT;*/
122
+ nReleaseMode = 0;
123
+ }
124
+
125
+ if ( bVer1Options ) {
126
+ bNameSuffix = 1;
127
+ szNameSuffix[0] = '\0';
128
+ }
129
+
130
+
131
+ #if( ACD_LABS_VERSION == 1 ) /* { */
132
+ /*
133
+ -- Files --
134
+ ip->path[0] => Input -I
135
+ ip->path[1] => Output (INChI) -O
136
+ ip->path[2] => Log -L
137
+ ip->path[3] => Problem structures
138
+ ip->path[4] => Errors file (ACD( -E
139
+
140
+ */
141
+ for ( i = 1; i < argc; i ++ ) {
142
+ if ( *argv[i] !memicmp( argv[i], "-I", 2) ) {
143
+ ip->num_paths += !ip->path[0];
144
+ ip->path[0] = _strdup( argv[i] + 2 );
145
+ } else
146
+ if ( *argv[i] !memicmp( argv[i], "-O", 2) ) {
147
+ ip->num_paths += !ip->path[1];
148
+ ip->path[1] = _strdup( argv[i] + 2 );
149
+ } else
150
+ if ( *argv[i] !memicmp( argv[i], "-L", 2) ) {
151
+ ip->num_paths += !ip->path[2];
152
+ ip->path[2] = _strdup( argv[i] + 2 );
153
+ } else
154
+ if ( *argv[i] !memicmp( argv[i], "-E", 2) ) {
155
+ ip->path[4] = _strdup( argv[i] + 2 );
156
+ } else
157
+ if ( *argv[i] !stricmp( argv[i], "-Z" ) ) {
158
+ sprintf( stdout, "%s version %s\n", INCHI_NAME, INCHI_VERSION );
159
+ return -1;
160
+ }
161
+ }
162
+
163
+ #else /* } ACD_LABS_VERSION { */
164
+
165
+ for ( i = 1; i < argc; i ++ ) {
166
+ if ( bVer1Options && INCHI_OPTION_PREFX == argv[i][0] && ':' == argv[i][1] && !argv[i][2] ) {
167
+ bVer1Options &= ~1; /* turn off ver 1 options mode */
168
+ } else
169
+ if ( !(bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && INCHI_OPTION_PREFX != argv[i][1] )
170
+ {
171
+ /*============== Version 0.9xx Beta options & INCHI_LIB ==================*/
172
+ /***************************************************************/
173
+ /* */
174
+ /* Version 0.9xx Beta and INCHI_LIB (GUI) options */
175
+ /* */
176
+ /***************************************************************/
177
+
178
+ pArg = argv[i]+1;
179
+
180
+ /* parameter */
181
+ if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "MOL" ) ) {
182
+ ip->nInputType = INPUT_MOLFILE;
183
+ } else
184
+ if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "SDF" ) ) {
185
+ ip->nInputType = INPUT_MOLFILE;
186
+ } else
187
+ if ( INPUT_NONE == ip->nInputType &&
188
+ (!memicmp( pArg, "SDF", 3 )) &&
189
+ ( pArg[3] == ':' ) ) {
190
+ k = 0;
191
+ mystrncpy( ip->szSdfDataHeader, pArg+4, MAX_SDF_HEADER+1 );
192
+ LtrimRtrim( ip->szSdfDataHeader, &k );
193
+ if ( k ) {
194
+ ip->pSdfLabel = ip->szSdfDataHeader;
195
+ ip->pSdfValue = szSdfDataValue;
196
+ ip->nInputType = INPUT_SDFILE;
197
+ } else {
198
+ ip->pSdfLabel = NULL;
199
+ ip->pSdfValue = NULL;
200
+ ip->nInputType = INPUT_MOLFILE;
201
+ }
202
+ } else
203
+ #if( ADD_CMLPP == 1 )
204
+ if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "CML" ) ) {
205
+ /* CMLfile label */
206
+ ip->nInputType = INPUT_CMLFILE;
207
+ } else
208
+ #endif
209
+ if ( !memicmp( pArg, "START:", 6 ) ) {
210
+ ip->first_struct_number = (int)strtol(pArg+6, NULL, 10);
211
+ } else
212
+ if ( !memicmp( pArg, "END:", 4 ) ) {
213
+ ip->last_struct_number = (int)strtol(pArg+4, NULL, 10);
214
+ } else /* RSB: */
215
+ if ( !memicmp( pArg, "RSB:", 4 ) ) {
216
+ mdbr = (int)strtol(pArg+4, NULL, 10);
217
+ } else
218
+ if ( !memicmp( pArg, "DISCONSALT:", 11 ) ) {
219
+ bDisconnectSalts = (0 != strtol(pArg+11, NULL, 10));
220
+ } else
221
+ if ( !memicmp( pArg, "DISCONMETAL:", 12 ) ) {
222
+ bDisconnectCoord = (0 != strtol(pArg+12, NULL, 10));
223
+ } else
224
+ if ( !memicmp( pArg, "RECONMETAL:", 11 ) ) {
225
+ bReconnectCoord = (0 != strtol(pArg+11, NULL, 10));
226
+ } else
227
+ if ( !memicmp( pArg, "DISCONMETALCHKVAL:", 18 ) ) {
228
+ bDisconnectCoordChkVal = (0 != strtol(pArg+18, NULL, 10));
229
+ } else
230
+ if ( !memicmp( pArg, "MOVEPOS:", 8 ) ) {
231
+ bMovePositiveCharges = (0 != strtol(pArg+8, NULL, 10));
232
+ } else
233
+ if ( !memicmp( pArg, "MERGESALTTG:", 12 ) ) {
234
+ bMergeSaltTGroups = (0 != strtol(pArg+12, NULL, 10));
235
+ } else
236
+ if ( !memicmp( pArg, "UNCHARGEDACIDS:", 15) ) {
237
+ bUnchargedAcidTaut = (0 != strtol(pArg+15, NULL, 16));;
238
+ } else
239
+ if ( !memicmp( pArg, "ACIDTAUT:", 9 ) ) {
240
+ bAcidTautomerism = c = (int)strtol(pArg+9, NULL, 10);
241
+ if ( 0 <= c && c <= 2 ) bAcidTautomerism = c;
242
+ /*else bNotRecognized = 2*bReleaseVersion;*/
243
+ } else
244
+ if ( !memicmp( pArg, "O:", 2 ) ) {
245
+ bNameSuffix = 1;
246
+ strncpy(szNameSuffix, pArg+2, sizeof(szNameSuffix)-1);
247
+ } else
248
+ if ( !memicmp( pArg, "OP:", 3 ) ) {
249
+ bOutputPath = 1;
250
+ strncpy(szOutputPath, pArg+3, sizeof(szOutputPath)-1);
251
+ } else
252
+ if ( !stricmp( pArg, "ALT" ) ) {
253
+ ip->bAbcNumbers = 1;
254
+ } else
255
+ if ( !stricmp( pArg, "SCT" ) ) {
256
+ ip->bCtPredecessors = 1;
257
+ } else
258
+
259
+ if ( !stricmp( pArg, "CMP" ) ) {
260
+ bCompareComponents = CMP_COMPONENTS;
261
+ } else
262
+ if ( !stricmp( pArg, "CMPNONISO" ) ) {
263
+ bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
264
+ } else
265
+ if ( !stricmp( pArg, "SREL" ) ) {
266
+ if ( nMode & REQ_MODE_RACEMIC_STEREO ) {
267
+ nMode ^= REQ_MODE_RACEMIC_STEREO;
268
+ }
269
+ if ( nMode & REQ_MODE_CHIR_FLG_STEREO ) {
270
+ nMode ^= REQ_MODE_CHIR_FLG_STEREO;
271
+ }
272
+ nMode |= REQ_MODE_RELATIVE_STEREO;
273
+ nMode |= REQ_MODE_STEREO;
274
+ } else
275
+ if ( !stricmp( pArg, "SRAC" ) ) {
276
+ if ( nMode & REQ_MODE_RELATIVE_STEREO ) {
277
+ nMode ^= REQ_MODE_RELATIVE_STEREO;
278
+ }
279
+ if ( nMode & REQ_MODE_CHIR_FLG_STEREO ) {
280
+ nMode ^= REQ_MODE_CHIR_FLG_STEREO;
281
+ }
282
+ nMode |= REQ_MODE_RACEMIC_STEREO;
283
+ nMode |= REQ_MODE_STEREO;
284
+ } else
285
+ if ( !stricmp( pArg, "SUCF" ) ) {
286
+ if ( nMode & REQ_MODE_RELATIVE_STEREO ) {
287
+ nMode ^= REQ_MODE_RELATIVE_STEREO;
288
+ }
289
+ if ( nMode & REQ_MODE_RACEMIC_STEREO ) {
290
+ nMode ^= REQ_MODE_RACEMIC_STEREO;
291
+ }
292
+ nMode |= REQ_MODE_CHIR_FLG_STEREO; /* stereo defined by the Chiral flag */
293
+ nMode |= REQ_MODE_STEREO;
294
+ } else
295
+ if ( !stricmp( pArg, "ChiralFlagON" ) ) { /* used only with /SUCF */
296
+ bForcedChiralFlag &= ~FLAG_SET_INP_AT_NONCHIRAL;
297
+ bForcedChiralFlag |= FLAG_SET_INP_AT_CHIRAL;
298
+ } else
299
+ if ( !stricmp( pArg, "ChiralFlagOFF" ) ) { /* used only with /SUCF */
300
+ bForcedChiralFlag &= ~FLAG_SET_INP_AT_CHIRAL;
301
+ bForcedChiralFlag |= FLAG_SET_INP_AT_NONCHIRAL;
302
+ } else
303
+ if ( !stricmp( pArg, "NOUUSB" ) ) {
304
+ nMode |= REQ_MODE_SB_IGN_ALL_UU;
305
+ } else
306
+ if ( !stricmp( pArg, "NOUUSC" ) ) {
307
+ nMode |= REQ_MODE_SC_IGN_ALL_UU;
308
+ } else
309
+ if ( !stricmp( pArg, "SDFID" ) ) {
310
+ ip->bGetSdfileId = 1;
311
+ } else
312
+ if ( !stricmp( pArg, "XML" ) ) {
313
+ bXml &= ~INCHI_OUT_PLAIN_TEXT;
314
+ bXml |= INCHI_OUT_XML;
315
+ /*bNotRecognized = 2*bReleaseVersion;*/
316
+ } else
317
+ if ( !stricmp( pArg, "PLAIN" ) ) {
318
+ bXml |= INCHI_OUT_PLAIN_TEXT;
319
+ bXml &= ~INCHI_OUT_XML;
320
+ } else
321
+ #if( !defined(INCHI_LIBRARY) && !defined(INCHI_LIB) )
322
+ if ( !stricmp( pArg, "Tabbed" ) ) {
323
+ bXml |= INCHI_OUT_TABBED_OUTPUT;
324
+ } else
325
+ #endif
326
+ if ( !stricmp( pArg, "ANNPLAIN" ) ) {
327
+ bXml |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
328
+ bXml &= ~INCHI_OUT_XML_TEXT_COMMENTS;
329
+ } else
330
+ if ( !stricmp( pArg, "ANNXML" ) ) {
331
+ bXml |= INCHI_OUT_XML_TEXT_COMMENTS;
332
+ bXml &= ~INCHI_OUT_PLAIN_TEXT_COMMENTS;
333
+ } else
334
+ if ( !stricmp( pArg, "DONOTADDH" ) ) {
335
+ bDoNotAddH = 1;
336
+ } else
337
+ if ( !memicmp( pArg, "AUXINFO:", 8 ) && isdigit(UCINT pArg[8]) ) {
338
+ k = strtol(pArg+8, NULL, 10);
339
+ if ( k == 0 ) {
340
+ bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
341
+ bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
342
+ } else
343
+ if ( k == 1 ) {
344
+ bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include full aux info */
345
+ } else
346
+ if ( k == 2 ) {
347
+ bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
348
+ bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
349
+ } else {
350
+ bINChIOutputOptions = k; /* override everything */
351
+ }
352
+ } else
353
+ if ( !stricmp( pArg, "MERGE" ) ) {
354
+ bMergeAllInputStructures = 1;
355
+ } else
356
+ if ( !stricmp( pArg, "PGO" ) ) {
357
+ ip->bSaveAllGoodStructsAsProblem = 1;
358
+ } else
359
+ if ( !stricmp( pArg, "DCR" ) ) {
360
+ bDisplayCompositeResults = 1;
361
+ } else
362
+ if ( !stricmp( pArg, "DSB" ) ) {
363
+ nMode |= REQ_MODE_NO_ALT_SBONDS;
364
+ } else
365
+ if ( !stricmp( pArg, "NOHDR" ) ) {
366
+ bNoStructLabels = 1;
367
+ } else
368
+ if ( !stricmp( pArg, "NoVarH" ) ) {
369
+ bTgFlagVariableProtons = 0;
370
+ } else
371
+ if ( !stricmp( pArg, "NoADP" ) ) {
372
+ bTgFlagHardAddRenProtons = 0;
373
+ } else
374
+ #ifdef STEREO_WEDGE_ONLY
375
+ if ( !stricmp( pArg, "NEWPS" ) ) {
376
+ bPointedEdgeStereo = 1;
377
+ } else
378
+ #endif
379
+ if ( !stricmp( pArg, "PW" ) ) {
380
+ ip->bSaveWarningStructsAsProblem = 1;
381
+ } else {
382
+ for ( k = 0 /*1*/; c=pArg[k]; k ++ ) {
383
+ c = toupper( c );
384
+ switch ( c ) {
385
+ case 'D':
386
+ bDisplay |= 1;
387
+ if ( pArg[k+1] == 'C' || pArg[k+1] == 'c' ) {
388
+ k++;
389
+ ip->bDisplayEachComponentINChI = 1;
390
+ }
391
+ case 'W':
392
+ t = strtod( pArg+k+1, (char**)&q ); /* cast deliberately discards 'const' qualifier */
393
+ if ( q > pArg+k && errno == ERANGE || t < 0.0 || t*1000.0 > (double)ULONG_MAX) {
394
+ ul = 0;
395
+ } else {
396
+ ul = (unsigned long)(t*1000.0);
397
+ }
398
+ if ( q > pArg+k ) {
399
+ k = q - pArg - 1; /* k will be incremented by the for() cycle */
400
+ switch( c ) {
401
+ case 'D':
402
+ *ulDisplTime = ul;
403
+ break;
404
+ case 'W':
405
+ ip->msec_MaxTime = ul;
406
+ break;
407
+ }
408
+ }
409
+ break;
410
+ case 'F':
411
+ c = (int)strtol( pArg+k+1, (char**)&q, 10 ); /* cast deliberately discards 'const' qualifier */
412
+ if ( q > pArg+k ) {
413
+ k = q - pArg - 1;
414
+ if ( abs(c) > 5 ) {
415
+ nFontSize = -c; /* font size 5 or less is too small */
416
+ }
417
+ }
418
+ break;
419
+ case 'B':
420
+ nMode |= REQ_MODE_BASIC;
421
+ nReleaseMode = 0;
422
+ /*bNotRecognized = bReleaseVersion;*/
423
+ break;
424
+ case 'T':
425
+ nMode |= REQ_MODE_TAUT;
426
+ nReleaseMode = 0;
427
+ /*bNotRecognized = bReleaseVersion;*/
428
+ break;
429
+ case 'I':
430
+ nMode |= REQ_MODE_ISO;
431
+ nReleaseMode = 0;
432
+ /*bNotRecognized = bReleaseVersion;*/
433
+ break;
434
+ case 'N':
435
+ nMode |= REQ_MODE_NON_ISO;
436
+ nReleaseMode = 0;
437
+ /*bNotRecognized = bReleaseVersion;*/
438
+ break;
439
+ case 'S':
440
+ nMode |= REQ_MODE_STEREO;
441
+ nReleaseMode = 0;
442
+ /*bNotRecognized = bReleaseVersion;*/
443
+ break;
444
+ case 'E':
445
+ if ( nReleaseMode & REQ_MODE_STEREO ) {
446
+ nReleaseMode ^= REQ_MODE_STEREO;
447
+ }
448
+ break;
449
+ #ifndef INCHI_LIB
450
+ default:
451
+ my_fprintf(log_file, "Unrecognized option: \"%c\".\n", c);
452
+ #endif
453
+ }
454
+ /*
455
+ if ( bNotRecognized && bNotRecognized == bReleaseVersion ) {
456
+ my_fprintf(stderr, "Unrecognized option: \"%c\".\n", c);
457
+ bNotRecognized = 0;
458
+ }
459
+ */
460
+ }
461
+ }
462
+ /*
463
+ if ( bNotRecognized && bNotRecognized == 2*bReleaseVersion ) {
464
+ my_fprintf(stderr, "Unrecognized option: \"%s\".\n", argv[i]);
465
+ bNotRecognized = 0;
466
+ }
467
+ */
468
+ } else
469
+ if ( (bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && argv[i][1] ) {
470
+ /***************************************************************/
471
+ /* */
472
+ /* Version 1.00 Beta options */
473
+ /* */
474
+ /***************************************************************/
475
+ bRecognizedOption = 2;
476
+ pArg = argv[i] + 1;
477
+ #ifdef CML_DEBUG
478
+ printf ("1 argv %d %s\n", i, argv[i]);
479
+ #endif
480
+
481
+ bVer1Options += 2;
482
+ /* always on: REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO */
483
+ if ( !stricmp( pArg, "FIXEDH" ) ) {
484
+ bVer1DefaultMode |= REQ_MODE_BASIC; /* If tautomeric then tautomeric only */
485
+ } else
486
+ if ( !stricmp( pArg, "SNON" ) ) {
487
+ bVer1DefaultMode &= ~REQ_MODE_STEREO; /* no stereo */
488
+ nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
489
+ } else
490
+ if ( (!stricmp( pArg, "SABS" ) )) {
491
+ bVer1DefaultMode |= REQ_MODE_STEREO; /* abs stereo (default) */
492
+ nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
493
+ } else
494
+ if ( !stricmp( pArg, "SREL" ) ) {
495
+ bVer1DefaultMode |= REQ_MODE_STEREO; /* relative stereo */
496
+ nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_CHIR_FLG_STEREO);
497
+ nMode |= REQ_MODE_RELATIVE_STEREO;
498
+ } else /* REQ_MODE_CHIR_FLG_STEREO */
499
+ if ( !stricmp( pArg, "SRAC" ) ) {
500
+ bVer1DefaultMode |= REQ_MODE_STEREO; /* racemic stereo */
501
+ nMode &= ~(REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
502
+ nMode |= REQ_MODE_RACEMIC_STEREO;
503
+ } else
504
+ if ( !stricmp( pArg, "SUCF" ) ) {
505
+ bVer1DefaultMode |= REQ_MODE_STEREO; /* stereo defined by the Chiral flag */
506
+ nMode &= ~(REQ_MODE_RELATIVE_STEREO | REQ_MODE_RACEMIC_STEREO);
507
+ nMode |= REQ_MODE_CHIR_FLG_STEREO;
508
+ } else
509
+ if ( !stricmp( pArg, "ChiralFlagON" ) ) { /* used only with /SUCF */
510
+ bForcedChiralFlag &= ~FLAG_SET_INP_AT_NONCHIRAL;
511
+ bForcedChiralFlag |= FLAG_SET_INP_AT_CHIRAL;
512
+ } else
513
+ if ( !stricmp( pArg, "ChiralFlagOFF" ) ) { /* used only with /SUCF */
514
+ bForcedChiralFlag &= ~FLAG_SET_INP_AT_CHIRAL;
515
+ bForcedChiralFlag |= FLAG_SET_INP_AT_NONCHIRAL;
516
+ } else
517
+ if ( !stricmp( pArg, "SUU" ) ) { /* include omitted undef/unkn stereo */
518
+ bVer1DefaultMode &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU);
519
+ } else
520
+ #ifdef STEREO_WEDGE_ONLY
521
+ if ( !stricmp( pArg, "NEWPS" ) ) {
522
+ bPointedEdgeStereo = 1;
523
+ } else
524
+ #endif
525
+ if ( !stricmp( pArg, "RECMET" ) ) { /* do reconnect metals */
526
+ bReconnectCoord = 1;
527
+ } else
528
+ if ( !stricmp( pArg, "AUXNONE" ) ) { /* no aux. info */
529
+ bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
530
+ bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
531
+ } else
532
+ if ( !stricmp( pArg, "AUXFULL" ) || !stricmp( pArg, "AUXMAX" ) ) { /* full aux info */
533
+ bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include short aux info */
534
+ } else
535
+ if ( !stricmp( pArg, "AUXMIN" ) ) { /* minimal aux info */
536
+ bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
537
+ bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
538
+ } else
539
+ if ( !stricmp( pArg, "DONOTADDH" ) ) {
540
+ bDoNotAddH = 1;
541
+ } else
542
+ if ( !stricmp( pArg, "D" ) ) { /* display the structures */
543
+ bDisplay |= 1;
544
+ } else
545
+ if ( !stricmp( pArg, "NOLABELS" ) ) {
546
+ bNoStructLabels = 1;
547
+ } else
548
+ if ( !stricmp( pArg, "WarnOnEmptyStructure" ) ) {
549
+ ip->bAllowEmptyStructure = 1;
550
+ } else
551
+ if ( !stricmp( pArg, "NoVarH" ) ) {
552
+ bTgFlagVariableProtons = 0;
553
+ } else
554
+ if ( !stricmp( pArg, "NoADP" ) ) {
555
+ bTgFlagHardAddRenProtons = 0;
556
+ } else
557
+ if ( !stricmp( pArg, "COMPRESS" ) ) {
558
+ ip->bAbcNumbers = 1;
559
+ ip->bCtPredecessors = 1; /* compressed output */
560
+ } else
561
+ if ( !stricmp( pArg, "FULL" ) ) {
562
+ bVer1DefaultMode = VER100_DEFAULT_MODE;
563
+ nMode = 0;
564
+ bReconnectCoord = 1; /* full output */
565
+ bINChIOutputOptions = ((EMBED_REC_METALS_INCHI==1)? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_SHORT_AUX_INFO;
566
+ ip->bCtPredecessors = 0;
567
+ ip->bAbcNumbers = 0;
568
+ bXml |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
569
+ bXml &= ~(INCHI_OUT_XML | INCHI_OUT_XML_TEXT_COMMENTS);
570
+ } else
571
+ if ( !stricmp( pArg, "MIN" ) ) {
572
+ bVer1DefaultMode = VER100_DEFAULT_MODE;
573
+ nMode = 0;
574
+ bReconnectCoord = 1; /* minimal output */
575
+ bINChIOutputOptions = ((EMBED_REC_METALS_INCHI==1)? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_NO_AUX_INFO; /* minimal compressed output */
576
+ ip->bCtPredecessors = 1;
577
+ ip->bAbcNumbers = 1;
578
+ bXml |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
579
+ bXml &= ~(INCHI_OUT_XML | INCHI_OUT_XML_TEXT_COMMENTS);
580
+ } else
581
+ if ( INPUT_NONE == ip->nInputType &&
582
+ !memicmp( pArg, "SDF:", 4 ) ) {
583
+ /* SDfile label */
584
+ k = 0;
585
+ mystrncpy( ip->szSdfDataHeader, pArg+4, MAX_SDF_HEADER+1 );
586
+ LtrimRtrim( ip->szSdfDataHeader, &k );
587
+ if ( k ) {
588
+ ip->pSdfLabel = ip->szSdfDataHeader;
589
+ ip->pSdfValue = szSdfDataValue;
590
+ ip->nInputType = INPUT_SDFILE;
591
+ } else {
592
+ ip->pSdfLabel = NULL;
593
+ ip->pSdfValue = NULL;
594
+ ip->nInputType = INPUT_MOLFILE;
595
+ }
596
+ } else
597
+ #if( ADD_CMLPP == 1 )
598
+ if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "CML" ) ) {
599
+ /* CMLfile label */
600
+ ip->nInputType = INPUT_CMLFILE;
601
+ } else
602
+ #endif
603
+ /*============= Default options =============*/
604
+ if ( !stricmp( pArg, "RECMET-" ) ) { /* do not reconnect metals (default) */
605
+ bReconnectCoord = 0;
606
+ } else
607
+ if ( !stricmp( pArg, "OUTPUTSDF" ) ) { /* ourput SDfile */
608
+ bOutputMolfileOnly = 1;
609
+ } else
610
+ if ( !stricmp( pArg, "STDIO" ) ) {
611
+ bNameSuffix = 0;
612
+ } else
613
+ if ( !stricmp( pArg, "DCR" ) ) {
614
+ bDisplayCompositeResults = 1;
615
+ } else
616
+ /*============= Additional options ==========*/
617
+ /* Tautomer perception off */
618
+ if ( !stricmp( pArg, "EXACT" ) ) {
619
+ bVer1DefaultMode |= REQ_MODE_BASIC;
620
+ } else
621
+ if ( !stricmp( pArg, "MOLFILENUMBER" ) ) {
622
+ ip->bGetMolfileNumber |= 1;
623
+ } else
624
+ if ( !stricmp( pArg, "OutputPLAIN" ) ) {
625
+ bXml |= INCHI_OUT_PLAIN_TEXT;
626
+ bXml &= ~INCHI_OUT_XML;
627
+ } else
628
+ #if( !defined(INCHI_LIBRARY) && !defined(INCHI_LIB) )
629
+ if ( !stricmp( pArg, "Tabbed" ) ) {
630
+ bXml |= INCHI_OUT_TABBED_OUTPUT;
631
+ } else
632
+ #endif
633
+ if ( !stricmp( pArg, "OutputXML" ) ) {
634
+ bXml |= INCHI_OUT_XML;
635
+ bXml &= ~INCHI_OUT_PLAIN_TEXT;
636
+ } else
637
+ if ( !stricmp( pArg, "OutputANNPLAIN" ) ) {
638
+ bXml |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
639
+ bXml &= ~INCHI_OUT_XML_TEXT_COMMENTS;
640
+ bXml |= INCHI_OUT_WINCHI_WINDOW; /* debug */
641
+ } else
642
+ if ( !stricmp( pArg, "OutputANNXML" ) ) {
643
+ bXml |= INCHI_OUT_XML_TEXT_COMMENTS;
644
+ bXml &= ~INCHI_OUT_PLAIN_TEXT_COMMENTS;
645
+ } else
646
+ if ( !stricmp( pArg, "ONLYEXACT" ) || !stricmp( pArg, "ONLYFIXEDH" ) ) {
647
+ bVer1DefaultMode |= REQ_MODE_BASIC;
648
+ bVer1DefaultMode &= ~REQ_MODE_TAUT;
649
+ } else
650
+ if ( !stricmp( pArg, "ONLYNONISO" ) ) {
651
+ bVer1DefaultMode |= REQ_MODE_NON_ISO;
652
+ bVer1DefaultMode &= ~REQ_MODE_ISO;
653
+ } else
654
+ if ( !stricmp( pArg, "TAUT" ) ) {
655
+ bVer1DefaultMode &= ~REQ_MODE_BASIC;
656
+ bVer1DefaultMode |= REQ_MODE_TAUT;
657
+ } else
658
+ if ( !stricmp( pArg, "ONLYRECMET" ) ) { /* do not disconnect metals */
659
+ bDisconnectCoord = 0;
660
+ } else
661
+ if ( !stricmp( pArg, "ONLYRECSALT" ) ) { /* do not disconnect salts */
662
+ bDisconnectSalts = 0;
663
+ } else
664
+ if ( !memicmp( pArg, "START:", 6 ) ) {
665
+ ip->first_struct_number = (int)strtol(pArg+6, NULL, 10);
666
+ } else
667
+ if ( !memicmp( pArg, "END:", 4 ) ) {
668
+ ip->last_struct_number = (int)strtol(pArg+4, NULL, 10);
669
+ } else /* RSB: */
670
+ if ( !memicmp( pArg, "RSB:", 4 )) {
671
+ mdbr = (int)strtol(pArg+4, NULL, 10);
672
+ } else
673
+ if ( !stricmp( pArg, "EQU" ) ) {
674
+ bCompareComponents = CMP_COMPONENTS;
675
+ } else
676
+ if ( !stricmp( pArg, "EQUNONISO" ) ) {
677
+ bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
678
+ } else
679
+ if ( !memicmp( pArg, "OP:", 3 ) ) {
680
+ bOutputPath = 1;
681
+ strncpy(szOutputPath, pArg+3, sizeof(szOutputPath)-1);
682
+ } else
683
+ /*============== Char+Value options ==============*/
684
+ if ( !memicmp( pArg, "W", 1 ) && (t = strtod( pArg+1, (char**)&q ), q > pArg+1) ) {
685
+ if ( errno == ERANGE || t < 0.0 || t*1000.0 > (double)ULONG_MAX) {
686
+ ul = 0;
687
+ } else {
688
+ ul = (unsigned long)(t*1000.0); /* max. time per structure */
689
+ }
690
+ ip->msec_MaxTime = ul;
691
+ } else
692
+ if ( !memicmp( pArg, "F", 1 ) && (c = (int)strtol( pArg+1, (char**)&q, 10 ), q > pArg+1) ) {
693
+ nFontSize = -c; /* struct. display font size */
694
+ } else {
695
+ bRecognizedOption = 0;
696
+ #ifndef INCHI_LIB
697
+ my_fprintf(log_file, "Unrecognized option: \"%s\".\n", pArg);
698
+ #endif
699
+ }
700
+ bVer1Options |= bRecognizedOption;
701
+ } else
702
+ if ( ip->num_paths < MAX_NUM_PATHS ) {
703
+ char *sz;
704
+ if ( argv[i] && argv[i][0] ) {
705
+ if ( sz = (char*)inchi_malloc( (strlen(argv[i]) + 1)*sizeof(sz[0])) ) {
706
+ strcpy( sz, argv[i] );
707
+ }
708
+ #ifdef CML_DEBUG
709
+ printf ("1 path %d argv %d %s\n", ip -> num_paths, i, argv [i]);
710
+ #endif
711
+ ip->path[ip->num_paths++] = sz;
712
+ }
713
+ }
714
+ }
715
+
716
+
717
+ if ( bNameSuffix || bOutputPath ) {
718
+ const char *p = NULL;
719
+ char *r = NULL;
720
+ char *sz;
721
+ int len;
722
+ /* find the 1st path */
723
+ for ( i = 0; i < MAX_NUM_PATHS; i ++ ) {
724
+ if ( !p && ip->path[i] && ip->path[i][0] ) {
725
+ p = ip->path[i];
726
+ break;
727
+ }
728
+ }
729
+ /* fix output path */
730
+ if ( bOutputPath && szOutputPath[0] && p ) {
731
+ /* remove last slash */
732
+ len = strlen(szOutputPath);
733
+ if ( len > 0 && szOutputPath[len-1] != INCHI_PATH_DELIM ) {
734
+ szOutputPath[len++] = INCHI_PATH_DELIM;
735
+ szOutputPath[len] = '\0';
736
+ }
737
+ if ( len > 0 && (r = strrchr( p, INCHI_PATH_DELIM ) ) && r[1] ) {
738
+ strcat( szOutputPath, r+1 );
739
+ p = szOutputPath;
740
+ }
741
+ } /* add missing paths */
742
+ for ( i = 0; p && i < MAX_NUM_PATHS; i ++ ) {
743
+ if ( ip->path[i] && !stricmp( ip->path[i], "NUL" ) ) {
744
+ inchi_free( (char *)ip->path[i] ); /* cast deliberately const qualifier */
745
+ ip->path[i] = NULL;
746
+ } else
747
+ if ( !ip->path[i] || !ip->path[i][0] ) {
748
+ len = strlen( p ) + strlen(szNameSuffix) + strlen( ext[i] );
749
+ if ( sz = (char*)inchi_malloc( (len+1)*sizeof(sz[0]) ) ) {
750
+ strcpy( sz, p );
751
+ strcat( sz, szNameSuffix );
752
+ strcat( sz, ext[i] );
753
+ ip->num_paths++;
754
+ }
755
+ ip->path[i] =sz;
756
+ }
757
+ }
758
+ }
759
+
760
+ #endif /* } ACD_LABS_VERSION */
761
+
762
+
763
+ if ( bVer1Options ) {
764
+ nMode |= bVer1DefaultMode;
765
+ } else
766
+ if ( bReleaseVersion ) {
767
+ nMode |= nReleaseMode;
768
+ }
769
+
770
+ #if( defined(INCHI_ANSI_ONLY) || defined(INCHI_LIB) )
771
+ if ( bCompareComponents && !(bDisplay & 1) ) {
772
+ bCompareComponents = 0;
773
+ }
774
+ #endif
775
+ /* Save original options */
776
+ /* nOrigMode = nMode; */
777
+ #ifndef INCHI_ANSI_ONLY
778
+ ip->dp.sdp.nFontSize = nFontSize;
779
+ ip->dp.sdp.ulDisplTime = *ulDisplTime;
780
+ ip->bDisplay = bDisplay;
781
+ #ifdef INCHI_LIB
782
+ ip->bDisplayCompositeResults = bDisplay;
783
+ #else
784
+ ip->bDisplayCompositeResults = bDisplayCompositeResults;
785
+ #endif
786
+ #else
787
+ ip->bDisplayEachComponentINChI = 0;
788
+ bCompareComponents = 0;
789
+ #endif
790
+ ip->bMergeAllInputStructures = bMergeAllInputStructures;
791
+ ip->bDoNotAddH = bDoNotAddH;
792
+ /* set default options */
793
+ if ( !nMode || nMode == REQ_MODE_STEREO ) {
794
+ /* requested all output */
795
+ nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO);
796
+ } else {
797
+ if ( !(nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) ) {
798
+ nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT);
799
+ }
800
+ if ( (nMode & REQ_MODE_STEREO) && !(nMode & (REQ_MODE_ISO | REQ_MODE_NON_ISO)) ) {
801
+ nMode |= (REQ_MODE_ISO | REQ_MODE_NON_ISO);
802
+ }
803
+ }
804
+ /* if the user requested isotopic then unconditionally add non-isotopic output. */
805
+ if ( nMode & REQ_MODE_ISO ) {
806
+ nMode |= REQ_MODE_NON_ISO;
807
+ }
808
+ #if( MIN_SB_RING_SIZE > 0 )
809
+ if ( mdbr ) {
810
+ nMinDbRinSize = mdbr;
811
+ }
812
+ nMode |= (nMinDbRinSize << REQ_MODE_MIN_SB_RING_SHFT) & REQ_MODE_MIN_SB_RING_MASK;
813
+ #endif
814
+ /* input file */
815
+ if ( ip->nInputType == INPUT_NONE && ip->num_paths > 0 ) {
816
+ ip->nInputType = INPUT_MOLFILE; /* default */
817
+ #if( ADD_CMLPP == 1 )
818
+ {
819
+ const char *p;
820
+ if ( ip->path[0] && ( p = strrchr(ip->path[0], '.' ) ) &&
821
+ !stricmp( p, ".cml") ) {
822
+ ip->nInputType = INPUT_CMLFILE;
823
+ }
824
+ }
825
+ #endif
826
+ }
827
+ ip->nMode = nMode;
828
+ if ( (bCompareComponents & CMP_COMPONENTS) && (nMode & REQ_MODE_BASIC) ) {
829
+ bCompareComponents |= CMP_COMPONENTS_NONTAUT; /* compare non-tautomeric */
830
+ }
831
+ ip->bCompareComponents = bCompareComponents;
832
+
833
+ ip->bINChIOutputOptions = bINChIOutputOptions | (bOutputMolfileOnly? INCHI_OUT_SDFILE_ONLY : 0);
834
+ if ( bOutputMolfileOnly ) {
835
+ bXml &= ~(INCHI_OUT_XML | INCHI_OUT_PLAIN_TEXT |
836
+ INCHI_OUT_PLAIN_TEXT_COMMENTS | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
837
+ }
838
+ if ( bXml & INCHI_OUT_XML ) {
839
+ bXml &= ~(INCHI_OUT_PLAIN_TEXT | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
840
+ }
841
+ #ifdef INCHI_LIB
842
+ if ( !(bDisplay & 1) ) {
843
+ bXml &= ~(INCHI_OUT_PLAIN_TEXT_COMMENTS | INCHI_OUT_XML_TEXT_COMMENTS); /* do not ouput comments in wINChI text file results */
844
+ } else {
845
+ bXml |= INCHI_OUT_WINCHI_WINDOW;
846
+ }
847
+ #endif
848
+ ip->bINChIOutputOptions |= bXml;
849
+ ip->bNoStructLabels = bNoStructLabels;
850
+
851
+ if ( bForcedChiralFlag ) {
852
+ ip->bChiralFlag = bForcedChiralFlag;
853
+ }
854
+
855
+ /*******************************************/
856
+ /* tautomeric/salts settings */
857
+ /*******************************************/
858
+
859
+ ip->bTautFlags = 0; /* initialize */
860
+ ip->bTautFlagsDone = 0; /* initialize */
861
+
862
+ /* find regular tautomerism */
863
+ ip->bTautFlags |= TG_FLAG_TEST_TAUT__ATOMS;
864
+ /* disconnect salts */
865
+ ip->bTautFlags |= bDisconnectSalts? TG_FLAG_DISCONNECT_SALTS : 0;
866
+ /* if possible find long-range H/(-) taut. on =C-OH, >C=O */
867
+ ip->bTautFlags |= bAcidTautomerism? TG_FLAG_TEST_TAUT__SALTS : 0;
868
+ /* allow long-range movement of N(+), P(+) charges */
869
+ ip->bTautFlags |= bMovePositiveCharges? TG_FLAG_MOVE_POS_CHARGES : 0;
870
+ /* multi-attachement long-range H/(-) taut. on =C-OH, >C=O */
871
+ ip->bTautFlags |= (bAcidTautomerism > 1)? TG_FLAG_TEST_TAUT2_SALTS : 0;
872
+ /* (debug) allow to find long-range H-only tautomerism on =C-OH, >C=O */
873
+ ip->bTautFlags |= (bUnchargedAcidTaut==1)? TG_FLAG_ALLOW_NO_NEGTV_O : 0;
874
+ /* merge =C-OH and >C=O containing t-groups and other =C-OH groups */
875
+ ip->bTautFlags |= bMergeSaltTGroups? TG_FLAG_MERGE_TAUT_SALTS : 0;
876
+ ip->bTautFlags |= bDisconnectCoord? TG_FLAG_DISCONNECT_COORD : 0;
877
+ ip->bTautFlags |=(bDisconnectCoord &&
878
+ bReconnectCoord)? TG_FLAG_RECONNECT_COORD : 0;
879
+ ip->bTautFlags |= bDisconnectCoordChkVal? TG_FLAG_CHECK_VALENCE_COORD : 0;
880
+ ip->bTautFlags |= bTgFlagVariableProtons? TG_FLAG_VARIABLE_PROTONS : 0;
881
+ ip->bTautFlags |= bTgFlagHardAddRenProtons? TG_FLAG_HARD_ADD_REM_PROTONS : 0;
882
+ #ifdef STEREO_WEDGE_ONLY
883
+ ip->bTautFlags |= bPointedEdgeStereo? TG_FLAG_POINTED_EDGE_STEREO : 0;
884
+ #endif
885
+ if ( !ip->nInputType ) {
886
+ ip->nInputType = INPUT_MOLFILE;
887
+ }
888
+ return 0;
889
+ }
890
+ /*******************************************************************/
891
+ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
892
+ {
893
+ INCHI_MODE nMode = ip->nMode;
894
+ int i, k;
895
+ /* output options: line 1 */
896
+ my_fprintf( log_file, "Options: " );
897
+ i = 0;
898
+
899
+ /* SDfile output */
900
+ if ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY ) {
901
+ my_fprintf( log_file, "Output SDfile only\n" );
902
+ return 0;
903
+ }
904
+ /* tautomerism */
905
+ if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_BASIC | REQ_MODE_TAUT) ) {
906
+ my_fprintf( log_file, "Mobile H Perception OFF" );
907
+ } else
908
+ if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_TAUT) ) {
909
+ my_fprintf( log_file, "Mobile H Perception ON" );
910
+ } else
911
+ if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_BASIC) ) {
912
+ my_fprintf( log_file, "Mobile H ignored" );
913
+ } else {
914
+ my_fprintf( log_file, "Undefined Mobile H mode" );
915
+ }
916
+ if ( (ip->bTautFlags & TG_FLAG_VARIABLE_PROTONS) ) {
917
+ if ( !(ip->bTautFlags & TG_FLAG_HARD_ADD_REM_PROTONS) ) {
918
+ my_fprintf( log_file, ", Disabled Aggressive (De)protonation" );
919
+ }
920
+ }
921
+ my_fprintf( log_file, "\n");
922
+ i = 0;
923
+ /* isotopic */
924
+ if ( nMode & REQ_MODE_ISO ) {
925
+ my_fprintf( log_file, "Isotopic ON");
926
+ } else
927
+ if ( nMode & REQ_MODE_NON_ISO ) {
928
+ my_fprintf( log_file, "Isotopic OFF");
929
+ }
930
+ i ++;
931
+ /* stereo */
932
+ if ( nMode & REQ_MODE_STEREO ) {
933
+ my_fprintf( log_file, ", %s%s%s%sStereo ON",
934
+ ( nMode & REQ_MODE_NOEQ_STEREO )? "Slow ":"",
935
+ ( nMode & REQ_MODE_REDNDNT_STEREO )? "Redund. ":"",
936
+ ( nMode & REQ_MODE_NO_ALT_SBONDS)? "No AltBond ":"",
937
+
938
+ ( nMode & REQ_MODE_RACEMIC_STEREO)? "Racemic " :
939
+ ( nMode & REQ_MODE_RELATIVE_STEREO)? "Relative " :
940
+ ( nMode & REQ_MODE_CHIR_FLG_STEREO)? "Chiral Flag " : "Absolute " );
941
+ if ( 0 == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
942
+ my_fprintf( log_file, "\nInclude undefined/unknown stereogenic centers and bonds");
943
+ } else
944
+ if ( REQ_MODE_SC_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
945
+ my_fprintf( log_file, "\nOmit undefined/unknown stereogenic centers");
946
+ } else
947
+ if ( REQ_MODE_SB_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
948
+ my_fprintf( log_file, "\nOmit undefined/unknown stereogenic bonds");
949
+ } else {
950
+ /*case REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU*/
951
+ my_fprintf( log_file, "\nOmit undefined/unknown stereogenic centers and bonds");
952
+ }
953
+ #if( defined(MIN_SB_RING_SIZE) && MIN_SB_RING_SIZE > 0 )
954
+ k = (ip->nMode & REQ_MODE_MIN_SB_RING_MASK) >> REQ_MODE_MIN_SB_RING_SHFT;
955
+ if ( bRELEASE_VERSION != 1 || k != MIN_SB_RING_SIZE ) {
956
+ if ( k >= 3 ) {
957
+ my_fprintf( log_file, "\nMin. stereobond ring size: %d\n", k );
958
+ } else {
959
+ my_fprintf( log_file, "\nMin. stereobond ring size: NONE\n" );
960
+ }
961
+ i = 0;
962
+ }
963
+ if ( TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags ) {
964
+ my_fprintf( log_file, "%sOnly narrow end of wedge points to stereocenter\n", i? "\n":"" );
965
+ i = 0;
966
+ }
967
+ #endif
968
+ } else {
969
+ my_fprintf( log_file, ", Stereo OFF");
970
+ }
971
+ if ( i ) {
972
+ my_fprintf( log_file, "\n");
973
+ i = 0;
974
+ }
975
+
976
+ /* metals disconnection */
977
+ if ( ip->bTautFlags & TG_FLAG_DISCONNECT_COORD ) {
978
+ if ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD ) {
979
+ my_fprintf( log_file, "Include bonds to metals\n");
980
+ }
981
+ } else {
982
+ my_fprintf( log_file, "Do not disconnect metals\n");
983
+ }
984
+ /* other options: line 2 */
985
+ #if( bRELEASE_VERSION == 1 )
986
+ if ( ip->bCtPredecessors || ip->bAbcNumbers ) {
987
+ if ( ip->bCtPredecessors && ip->bAbcNumbers ) {
988
+ my_fprintf( log_file, "Representation: Compressed");
989
+ i ++;
990
+ } else {
991
+ my_fprintf( log_file, "Connection table: %s, %s\n",
992
+ ip->bCtPredecessors? "Predecessor_numbers(closures)":"Canon_numbers(branching, ring closures)",
993
+ ip->bAbcNumbers? "Shorter alternative":"Numerical");
994
+ i = 0;
995
+ }
996
+ }
997
+ #else
998
+ if ( (bRELEASE_VERSION != 1) || ip->bCtPredecessors || ip->bAbcNumbers ) {
999
+ my_fprintf( log_file, "Connection table: %s, %s\n",
1000
+ ip->bCtPredecessors? "Predecessor_numbers(closures)":"Canon_numbers(branching, ring closures)",
1001
+ ip->bAbcNumbers? "Shorter alternative":"Numerical");
1002
+ i = 0;
1003
+ } else {
1004
+ my_fprintf( log_file, "Representation: Numerical");
1005
+ i ++;
1006
+ }
1007
+ #endif
1008
+ if( ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) {
1009
+ my_fprintf( log_file, "%sAux. info suppressed", i?"; ":"");
1010
+ i ++;
1011
+ } else
1012
+ if ( ip->bINChIOutputOptions & INCHI_OUT_SHORT_AUX_INFO ) {
1013
+ my_fprintf( log_file, "%sMinimal Aux. info", i?"; ":"");
1014
+ i ++;
1015
+ } else {
1016
+ my_fprintf( log_file, "%sFull Aux. info", i?"; ":"");
1017
+ i ++;
1018
+ }
1019
+ if ( ip->bDoNotAddH ) {
1020
+ my_fprintf( log_file, "%sDo not add H", i?"; ":"");
1021
+ }
1022
+ if ( i ) {
1023
+ my_fprintf( log_file, "\n");
1024
+ i = 0;
1025
+ }
1026
+ if ( ip->bAllowEmptyStructure ) {
1027
+ my_fprintf( log_file, "Issue warning on empty structure\n" );
1028
+ }
1029
+
1030
+ if ( ip->szSdfDataHeader[0] && ip->nInputType != INPUT_SDFILE ) {
1031
+ my_fprintf( log_file, "SDfile data header: \"%s\"\n", ip->szSdfDataHeader);
1032
+ }
1033
+ /* input format */
1034
+ if ( ip->nInputType ) {
1035
+ my_fprintf( log_file, "Input format: %s",
1036
+ ip->nInputType == INPUT_MOLFILE? "MOLfile" :
1037
+ ip->nInputType == INPUT_SDFILE? "SDfile" :
1038
+ ip->nInputType == INPUT_CMLFILE? "CMLfile" :
1039
+ ip->nInputType == INPUT_INCHI_XML? "InChI (xml)" :
1040
+ ip->nInputType == INPUT_INCHI_PLAIN? "InChI (plain)" : "Unknown" );
1041
+ if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) &&
1042
+ ip->bGetMolfileNumber ) {
1043
+ my_fprintf( log_file, " (attempting to read Molfile number)" );
1044
+ }
1045
+ my_fprintf( log_file, "\n");
1046
+ }
1047
+ /* output format */
1048
+ my_fprintf( log_file, "Output format: %s%s\n",
1049
+ (ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT)? "Plain text" :
1050
+ (ip->bINChIOutputOptions & INCHI_OUT_XML)? "XML":
1051
+ (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY)? "SDfile only" : "Unknown",
1052
+
1053
+ ((ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT) &&
1054
+ (ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT))? ", tabbed":"");
1055
+ i = 0;
1056
+ /* other options: line 4 */
1057
+ if ( ip->msec_MaxTime ) {
1058
+ unsigned long seconds = ip->msec_MaxTime/1000;
1059
+ unsigned long milliseconds = (ip->msec_MaxTime%1000);
1060
+ my_fprintf( log_file, "Timeout per structure: %lu.%03lu sec", seconds, milliseconds);
1061
+ i ++;
1062
+ } else {
1063
+ my_fprintf( log_file, "No timeout");
1064
+ i ++;
1065
+ }
1066
+ my_fprintf( log_file, "%sUp to %d atoms per structure\n", i?"; ":"", MAX_ATOMS);
1067
+ i = 0;
1068
+ if ( ip->first_struct_number > 1 ) {
1069
+ my_fprintf( log_file, "Skipping %d structure%s\n", ip->first_struct_number-1, ip->first_struct_number==2? "":"s" );
1070
+ }
1071
+ if ( ip->last_struct_number > 0 ) {
1072
+ my_fprintf( log_file, "Terminate after structure #%d\n", ip->last_struct_number );
1073
+ }
1074
+ if ( ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0] ) {
1075
+ my_fprintf( log_file, "Saving warning structures into the problem file\n");
1076
+ }
1077
+ if ( ip->bSaveAllGoodStructsAsProblem && ip->path[3] && ip->path[3][0] ) {
1078
+ my_fprintf( log_file, "Saving only all good structures into the problem file\n");
1079
+ }
1080
+ /* Report debug modes */
1081
+ i = 0;
1082
+ #if( bRELEASE_VERSION != 1 )
1083
+ my_fprintf( log_file, "Release version = NO");
1084
+ i ++;
1085
+ #endif
1086
+
1087
+ #if( FIND_RING_SYSTEMS != 1 )
1088
+ my_fprintf( log_file, "%s5-, 6-, 7-memb. ring taut. ignored", i?"; ":"");
1089
+ i ++;
1090
+ #endif
1091
+
1092
+ #if( TRACE_MEMORY_LEAKS == 1 && defined(_DEBUG) )
1093
+ my_fprintf( log_file, "%sTracing memory leaks (SLOW)", i?"; ":"");
1094
+ i ++;
1095
+ #endif
1096
+
1097
+ if ( i ) {
1098
+ my_fprintf( log_file, "\n" );
1099
+ }
1100
+
1101
+ #if( bRELEASE_VERSION != 1 )
1102
+
1103
+ #if( FIND_RING_SYSTEMS == 1 )
1104
+ my_fprintf( log_file, "Find ring systems=Y\nTautomers:" );
1105
+ my_fprintf( log_file, " 4-pyridinol=%s", TAUT_4PYRIDINOL_RINGS==1? "Y":"N");
1106
+ my_fprintf( log_file, " pyrazole=%s", TAUT_PYRAZOLE_RINGS==1? "Y":"N");
1107
+ my_fprintf( log_file, " tropolone=%s", TAUT_TROPOLONE_7==1? "Y":"N");
1108
+ my_fprintf( log_file, " tropolone-5=%s", TAUT_TROPOLONE_5==1? "Y":"N");
1109
+ my_fprintf( log_file, "\n" );
1110
+ my_fprintf( log_file, "Only chain attachments to tautomeric rings=%s\n", TAUT_RINGS_ATTACH_CHAIN==1? "Y":"N");
1111
+ #endif
1112
+ if ( ip->bGetSdfileId ) {
1113
+ my_fprintf( log_file, "Extracting SDfile IDs\n");
1114
+ }
1115
+ my_fprintf( log_file, "\nDbg: MOVE_CHARGES=%d\n",
1116
+ 0!=(ip->bTautFlags&TG_FLAG_MOVE_POS_CHARGES));
1117
+ my_fprintf( log_file, " REPLACE_ALT_WITH_TAUT=%d; NEUTRALIZE_ENDPOINTS=%d; BNS_PROTECT_FROM_TAUT=%d\n",
1118
+ REPLACE_ALT_WITH_TAUT, NEUTRALIZE_ENDPOINTS, BNS_PROTECT_FROM_TAUT);
1119
+ my_fprintf( log_file, " DISCONNECT_SALTS=%d; TEST_TAUT_SALTS=%d; TEST_TAUT2_SALTS=%d\n",
1120
+ 0!=(ip->bTautFlags&TG_FLAG_DISCONNECT_SALTS),
1121
+ 0!=(ip->bTautFlags&TG_FLAG_TEST_TAUT__SALTS),
1122
+ 0!=(ip->bTautFlags&TG_FLAG_TEST_TAUT2_SALTS));
1123
+
1124
+ my_fprintf( log_file, " CHARGED_ACID_TAUT_ONLY=%d MERGE_TAUT_SALTS=%d\n",
1125
+ 0==(ip->bTautFlags&TG_FLAG_ALLOW_NO_NEGTV_O),
1126
+ 0!=(ip->bTautFlags&TG_FLAG_MERGE_TAUT_SALTS));
1127
+ my_fprintf( log_file, " DISCONNECT_COORD=%d\n", 0!=(ip->bTautFlags&TG_FLAG_DISCONNECT_COORD) );
1128
+ #if( TEST_RENUMB_ATOMS == 1 )
1129
+ my_fprintf( log_file, "\nDbg: TEST_RENUMB_ATOMS=%d; TEST_RENUMB_NEIGH=%d; TEST_RENUMB_SWITCH=%d\n",
1130
+ TEST_RENUMB_ATOMS, TEST_RENUMB_NEIGH, TEST_RENUMB_SWITCH );
1131
+ my_fprintf( log_file, " TEST_RENUMB_ATOMS_SAVE_LONGEST=%d\n",
1132
+ TEST_RENUMB_ATOMS_SAVE_LONGEST);
1133
+ #endif
1134
+
1135
+ #endif
1136
+
1137
+ return 0;
1138
+ }
1139
+ /************************************************************************************/
1140
+ void HelpCommandLineParms( INCHI_FILE *f )
1141
+ {
1142
+ if ( !f )
1143
+ return;
1144
+
1145
+ #if ( bRELEASE_VERSION == 1 )
1146
+
1147
+ inchi_print_nodisplay( f, "%s ver %s.\n\nUsage:\ncInChI-1 inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_NAME, INCHI_VERSION, INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1148
+
1149
+ inchi_print_nodisplay( f, "\nOptions:\n");
1150
+ inchi_print_nodisplay( f, " SNon Exclude stereo (Default: Include Absolute stereo)\n");
1151
+ inchi_print_nodisplay( f, " SRel Relative stereo\n");
1152
+ inchi_print_nodisplay( f, " SRac Racemic stereo\n");
1153
+ inchi_print_nodisplay( f, " SUCF Use Chiral Flag: On means Absolute stereo, Off - Relative\n");
1154
+ inchi_print_nodisplay( f, " SUU Include omitted unknown/undefined stereo\n");
1155
+ inchi_print_nodisplay( f, " NEWPS Narrow end of wedge points to stereocenter (default: both)\n");
1156
+ inchi_print_nodisplay( f, " RecMet Include reconnected metals results\n");
1157
+ inchi_print_nodisplay( f, " FixedH Mobile H Perception Off (Default: On)\n");
1158
+ inchi_print_nodisplay( f, " AuxNone Omit auxiliary information (default: Include)\n");
1159
+ /*inchi_print_nodisplay( f, " AuxMin Output minimal auxiliary information\n");*/
1160
+ inchi_print_nodisplay( f, " NoADP Disable Aggressive Deprotonation (for testing only)\n");
1161
+ /*inchi_print_nodisplay( f, " PLAIN Plain text output (Default: XML format)\n");*/
1162
+ inchi_print_nodisplay( f, " Compress Compressed output\n");
1163
+ /*inchi_print_nodisplay( f, " FULL Standard set of options for Full Verbose Output\n");*/
1164
+ /*inchi_print_nodisplay( f, " MIN Standard set of options for Minimal Concise Output\n");*/
1165
+ inchi_print_nodisplay( f, " DoNotAddH Don't add H according to usual valences: all H are explicit\n");
1166
+ #if( defined(_WIN32) && defined(_MSC_VER) && !defined(INCHI_ANSI_ONLY) && !defined(INCHI_LIBRARY) )
1167
+ inchi_print_nodisplay( f, " D Display the structures\n");
1168
+ inchi_print_nodisplay( f, " EQU Display sets of identical components\n");
1169
+ inchi_print_nodisplay( f, " Fnumber Set display Font size in number of points\n");
1170
+ #endif
1171
+ inchi_print_nodisplay( f, " Wnumber Set time-out per structure in seconds; W0 means unlimited\n");
1172
+ inchi_print_nodisplay( f, " SDF:DataHeader Read from the input SDfile the ID under this DataHeader\n");
1173
+ #if( ADD_CMLPP == 1 )
1174
+ inchi_print_nodisplay( f, " CML Input in CML format (default for input file .CML extension) \n");
1175
+ #endif
1176
+ inchi_print_nodisplay( f, " NoLabels Omit structure number, DataHeader and ID from %s output\n", INCHI_NAME);
1177
+ inchi_print_nodisplay( f, " Tabbed Separate structure number, %s, and AuxIndo with tabs\n", INCHI_NAME);
1178
+ inchi_print_nodisplay( f, " OutputSDF Convert %s created with default aux. info to SDfile\n", INCHI_NAME);
1179
+ inchi_print_nodisplay( f, " STDIO Use standard input/output streams\n");
1180
+ inchi_print_nodisplay( f, " WarnOnEmptyStructure Warn and produce empty %s for empty structure\n", INCHI_NAME);
1181
+
1182
+ #else
1183
+
1184
+ inchi_print_nodisplay( f, "%s ver %s. Special testing version 12-12-2002.\n", INCHI_NAME, INCHI_VERSION);
1185
+
1186
+ inchi_print_nodisplay( f, "\nUsage:\ncINChI09b inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1187
+
1188
+ inchi_print_nodisplay( f, "\nOptions:\n");
1189
+ inchi_print_nodisplay( f, "\tB Basic\n");
1190
+ inchi_print_nodisplay( f, "\tT basic Tautomeric\n");
1191
+ inchi_print_nodisplay( f, "\tI Isotopic\n");
1192
+ inchi_print_nodisplay( f, "\tN Non-isotopic\n");
1193
+ inchi_print_nodisplay( f, "\tS Stereo\n");
1194
+ inchi_print_nodisplay( f, "\tE Exclude Stereo\n");
1195
+ inchi_print_nodisplay( f, "\tD Display the structures\n");
1196
+ inchi_print_nodisplay( f, "\tALT produce shorter ALTernative representation (Abc)\n");
1197
+ inchi_print_nodisplay( f, "\tSCT produce shorter connection table representation\n");
1198
+ inchi_print_nodisplay( f, "\tXML output in xml format\n");
1199
+ inchi_print_nodisplay( f, "\tPLAIN output in plain format\n");
1200
+ inchi_print_nodisplay( f, "\tMERGE Merge all MOLfiles from the input file into one compound\n");
1201
+ inchi_print_nodisplay( f, "\tWnumber time-out per structure in seconds, W0 means unlimited\n");
1202
+ inchi_print_nodisplay( f, "\tFnumber set display Font size, points\n");
1203
+ inchi_print_nodisplay( f, "\tSREL Relative Stereo\n");
1204
+ inchi_print_nodisplay( f, "\tSRAC Racemic Stereo\n");
1205
+ inchi_print_nodisplay( f, "\tNOUUSB Omit stereobonds if all are unknown/undefined\n");
1206
+ inchi_print_nodisplay( f, "\tNOUUSC Omit stereocenters if all are unknown/undefined\n");
1207
+ inchi_print_nodisplay( f, "\tSS Slow Stereo: do not use stereo equivalence\n");
1208
+ inchi_print_nodisplay( f, "\tRS Do not test for Redundant Stereo elements\n");
1209
+ inchi_print_nodisplay( f, "\tPW Save warning structures in the problems file\n");
1210
+ inchi_print_nodisplay( f, "\tPGO Save only all good structures in the problems file\n");
1211
+ inchi_print_nodisplay( f, "\tDSB Double Stereo Bonds only (ignore alternating bonds stereo)\n");
1212
+ inchi_print_nodisplay( f, "\tRSB:n Min Ring Size for detecting for Stereo Bonds (n=1 => all)\n");
1213
+ inchi_print_nodisplay( f, "\tAUXINFO:0 do not output auxiliary information (default:1)\n");
1214
+ inchi_print_nodisplay( f, "\tDISCONSALT:0 do not disconnect salts (default:1)\n");
1215
+ inchi_print_nodisplay( f, "\tDISCONMETAL:0 do not disconnect metals (default:1)\n");
1216
+ inchi_print_nodisplay( f, "\tDISCONMETALCHKVAL:1 do not disconnect if typical valence (default:0)\n");
1217
+ inchi_print_nodisplay( f, "\tRECONMETAL:0 do not reconnect metals (default:1)\n");
1218
+ inchi_print_nodisplay( f, "\tMOVEPOS:0 do not check moveable positive charges (default:1)\n");
1219
+ inchi_print_nodisplay( f, "\tACIDTAUT:n n=1: one H/(-) tautomerism, 2: more (deflt), 0:none\n");
1220
+ inchi_print_nodisplay( f, "\tMERGESALTTG:1 merge salt t-groups (default), 0: do not merge\n");
1221
+ inchi_print_nodisplay( f, "\tUNCHARGEDACIDS:1 Apply salt (acid) tautomerism in neutral species\n");
1222
+ inchi_print_nodisplay( f, "\tO:[suffix] Open all 4 files adding suffix to the inputFile name\n");
1223
+ inchi_print_nodisplay( f, "\tOP:outputpath Set output path\n");
1224
+ inchi_print_nodisplay( f, "\tMOL input file is a MOLfile (default)\n");
1225
+ inchi_print_nodisplay( f, "\tSDF[:DataHeader] Include SDfile data for the header into the results\n");
1226
+ inchi_print_nodisplay( f, "\tSDFID extract CAS r.n. in addition to requested SDfile data\n");
1227
+ inchi_print_nodisplay( f, "\tSTART:number Start at the given structure ordering number\n");
1228
+ inchi_print_nodisplay( f, "\tEND:number Terminate after the given structure ordering number\n");
1229
+ #endif
1230
+ }
1231
+
1232
+
1233
+ #ifndef INCHI_LIBRARY
1234
+ /************************************************************************************/
1235
+ int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_file, INPUT_PARMS *ip )
1236
+ {
1237
+ /*
1238
+ -- Files --
1239
+ ip->path[0] => Input
1240
+ ip->path[1] => Output (INChI)
1241
+ ip->path[2] => Log
1242
+ ip->path[3] => Problem structures
1243
+ ip->path[4] => Errors file (ACD Labs)
1244
+
1245
+ */
1246
+ /* logfile -- open es early as possible */
1247
+ if ( !ip->path[2] || !ip->path[2][0] ) {
1248
+ my_fprintf( stderr, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1249
+ my_fprintf( stderr, "Log file not specified. Using standard error output.\n");
1250
+ *log_file = stderr;
1251
+ } else
1252
+ if ( !(*log_file = fopen( ip->path[2], "w" ) ) ) {
1253
+ //my_fprintf( stderr, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1254
+ //my_fprintf( stderr, "Cannot open log file '%s'. Using standard error output.\n", ip->path[2] );
1255
+ *log_file = stderr;
1256
+ } else {
1257
+ my_fprintf( *log_file, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1258
+ //my_fprintf( *log_file, "Opened log file '%s'\n", ip->path[2] );
1259
+ }
1260
+ /* input file */
1261
+ if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE || ip->nInputType == INPUT_CMLFILE) && ip->num_paths > 0 ) {
1262
+ const char *fmode = NULL;
1263
+ #if( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
1264
+ /* compilers that definitely allow fopen "rb" (binary read) mode */
1265
+ if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen( ip->path[0], "rb" ) ) ) {
1266
+ my_fprintf( *log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0]? ip->path[0] : "<No name>" );
1267
+ goto exit_function;
1268
+ } else {
1269
+ int c;
1270
+ #ifdef CML_DEBUG
1271
+ printf ("cr %d lf %d ret %d\n", (int) '\r', (int) '\f', (int) '\n');
1272
+ #endif
1273
+ /* read up to the end of the first line */
1274
+ while( (c = fgetc( *inp_file )) && c != EOF && c != '\n' && c != '\r' )
1275
+ ;
1276
+ if ( c == '\r' || c == EOF ) {
1277
+ /* text file contains CR; close and reopen as "text" */
1278
+ fclose( *inp_file );
1279
+ if ( !(*inp_file = fopen( ip->path[0], "r" ) ) ) {
1280
+ my_fprintf( *log_file, "Cannot open input file '%s' (2nd attempt). Terminating.\n", ip->path[0] );
1281
+ goto exit_function;
1282
+ }
1283
+ //my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1284
+ fmode = "r";
1285
+ } else {
1286
+ fclose( *inp_file );
1287
+ if ( !(*inp_file = fopen( ip->path[0], "rb" ) ) ) {
1288
+ my_fprintf( *log_file, "Cannot open input file '%s' (2nd attempt). Terminating.\n", ip->path[0] );
1289
+ goto exit_function;
1290
+ }
1291
+ //my_fprintf( *log_file, "Opened input file '%s': no CR.\n", ip->path[0] );
1292
+ fmode = "rb";
1293
+ }
1294
+ }
1295
+ #else
1296
+ if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen( ip->path[0], "r" ) ) ) {
1297
+ my_fprintf( *log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0]? ip->path[0] : "<No Name>" );
1298
+ goto exit_function;
1299
+ } else {
1300
+ //my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1301
+ }
1302
+ fmode = "r";
1303
+ #endif
1304
+ DetectInputINChIFileType( inp_file, ip, fmode );
1305
+ } else
1306
+ if ( (ip->nInputType != INPUT_MOLFILE && ip->nInputType != INPUT_SDFILE && ip->nInputType != INPUT_CMLFILE) ) {
1307
+ my_fprintf( *log_file, "Input file type not specified. Terminating.\n");
1308
+ goto exit_function;
1309
+ } else {
1310
+ my_fprintf( *log_file, "Input file not specified. Using standard input.\n");
1311
+ *inp_file = stdin;
1312
+ }
1313
+ /* output file */
1314
+ if ( !ip->path[1] || !ip->path[1][0] ) {
1315
+ my_fprintf( *log_file, "Output file not specified. Using standard output.\n");
1316
+ *output_file = stdout;
1317
+ } else {
1318
+ if ( !(*output_file = fopen( ip->path[1], "w" ) ) ) {
1319
+ my_fprintf( *log_file, "Cannot open output file '%s'. Terminating.\n", ip->path[1] );
1320
+ goto exit_function;
1321
+ } else {
1322
+ //my_fprintf( *log_file, "Opened output file '%s'\n", ip->path[1] );
1323
+ if ( (ip->bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT)) &&
1324
+ *inp_file != stdin &&
1325
+ !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) &&
1326
+ !ip->bNoStructLabels &&
1327
+ !(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)) {
1328
+ PrintFileName( "* Input_File: \"%s\"\n", *output_file, ip->path[0] );
1329
+ }
1330
+ }
1331
+ }
1332
+ /* problem file */
1333
+ if ( ip->path[3] && ip->path[3][0] ) {
1334
+ if ( !(*prb_file = fopen( ip->path[3], "w" ) ) ) {
1335
+ my_fprintf( *log_file, "Cannot open problem file '%s'. Terminating.\n", ip->path[3] );
1336
+ goto exit_function;
1337
+ } else {
1338
+ //my_fprintf( *log_file, "Opened problem file '%s'\n", ip->path[3] );
1339
+ }
1340
+ }
1341
+ return 1; /* success */
1342
+
1343
+ exit_function:
1344
+ return 0; /* failed */
1345
+
1346
+ }
1347
+ #define NUM_VERSIONS 4
1348
+ #define LEN_VERSIONS 64
1349
+ /*******************************************************************/
1350
+ static int bMatchOnePrefix( int len, char *str, int lenPrefix[],
1351
+ char strPrefix[][LEN_VERSIONS], int numPrefix);
1352
+ /*******************************************************************/
1353
+ static int bMatchOnePrefix( int len, char *str, int lenPrefix[],
1354
+ char strPrefix[][LEN_VERSIONS], int numPrefix)
1355
+ {
1356
+ int i;
1357
+ for ( i = 0; i < numPrefix; i ++ ) {
1358
+ if ( len >= lenPrefix[i] &&
1359
+ !memcmp( str, strPrefix[i], lenPrefix[i] ) ) {
1360
+ return 1;
1361
+ }
1362
+ }
1363
+ return 0;
1364
+ }
1365
+ /*******************************************************************/
1366
+ int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmode )
1367
+ {
1368
+ char szLine[256], ret = 0;
1369
+ static char szPlnVersion[NUM_VERSIONS][LEN_VERSIONS]; /* = "INChI:1.1Beta/";*/
1370
+ static int lenPlnVersion[NUM_VERSIONS];
1371
+ static char szPlnAuxVer[NUM_VERSIONS][LEN_VERSIONS]; /* = "AuxInfo:1.1Beta/";*/
1372
+ static int lenPlnAuxVer[NUM_VERSIONS];
1373
+ static char szXmlVersion[NUM_VERSIONS][LEN_VERSIONS]; /* = "<INChI version=\"1.1Beta\">";*/
1374
+ static int lenXmlVersion[NUM_VERSIONS];
1375
+ static char szXmlStruct[LEN_VERSIONS] = "<structure";
1376
+ static int lenXmlStruct;
1377
+ static char szXmlIdentVer[NUM_VERSIONS][LEN_VERSIONS]; /*= "<identifier version=\"1.1Beta\"";*/
1378
+ static int lenXmlIdentVer[NUM_VERSIONS];
1379
+ static char szXmlMsgError[LEN_VERSIONS];
1380
+ static int lenXmlMsgError = 0;
1381
+ static char szXmlMsgFatal[LEN_VERSIONS]= "<message type=\"fatal (aborted)\"";
1382
+ static int lenXmlMsgFatal;
1383
+ static int bInitilized = 0;
1384
+ int bINChI_plain = 0, bINChI_xml = 0, len, i;
1385
+ if ( ip->nInputType == INPUT_INCHI_XML || ip->nInputType == INPUT_INCHI_PLAIN ) {
1386
+ return 1;
1387
+ }
1388
+ if ( !bInitilized ) {
1389
+ lenPlnVersion[0] = sprintf( szPlnVersion[0], "%s=%s/", INCHI_NAME, INCHI_VERSION );
1390
+ lenPlnVersion[1] = sprintf( szPlnVersion[1], "INChI=1.12Beta/" );
1391
+ lenPlnVersion[2] = sprintf( szPlnVersion[2], "INChI=1.0RC/" );
1392
+ lenPlnVersion[3] = sprintf( szPlnVersion[3], "InChI=1.0RC/" );
1393
+ lenPlnAuxVer[0] = sprintf( szPlnAuxVer[0], "AuxInfo=%s/", INCHI_VERSION );
1394
+ lenPlnAuxVer[1] = sprintf( szPlnAuxVer[1], "AuxInfo=1.12Beta/" );
1395
+ lenPlnAuxVer[2] = sprintf( szPlnAuxVer[2], "AuxInfo=1.0RC/" );
1396
+ lenPlnAuxVer[3] = sprintf( szPlnAuxVer[3], "AuxInfo=1.0RC/" );
1397
+ lenXmlVersion[0] = sprintf( szXmlVersion[0], "<%s version=\"%s\">", INCHI_NAME, INCHI_VERSION );
1398
+ lenXmlVersion[1] = sprintf( szXmlVersion[1], "<INChI version=\"1.12Beta\">" );
1399
+ lenXmlVersion[2] = sprintf( szXmlVersion[2], "<INChI version=\"1.0RC\">" );
1400
+ lenXmlVersion[3] = sprintf( szXmlVersion[3], "<InChI version=\"1.0RC\">" );
1401
+ lenXmlIdentVer[0] = sprintf( szXmlIdentVer[0], "<identifier version=\"%s\"", INCHI_VERSION );
1402
+ lenXmlIdentVer[1] = sprintf( szXmlIdentVer[1], "<identifier version=\"1.12Beta\"" );
1403
+ lenXmlIdentVer[2] = sprintf( szXmlIdentVer[2], "<identifier version=\"1.0RC\"" );
1404
+ lenXmlIdentVer[3] = sprintf( szXmlIdentVer[3], "<identifier version=\"1.0RC\"" );
1405
+ lenXmlMsgError = sprintf( szXmlMsgError, "<message type=\"error (no %s)\"", INCHI_NAME );
1406
+ lenXmlStruct = strlen(szXmlStruct);
1407
+ lenXmlMsgFatal = strlen(szXmlMsgFatal);
1408
+ }
1409
+ for ( i = 0; i < 4; i ++ ) {
1410
+ len = my_fgetsUpToLfOrTab( szLine, sizeof(szLine)-1, *inp_file );
1411
+ if ( len < 0 )
1412
+ break;
1413
+ if ( bMatchOnePrefix( len, szLine, lenPlnVersion, szPlnVersion, NUM_VERSIONS ) ||
1414
+ bMatchOnePrefix( len, szLine, lenPlnAuxVer, szPlnAuxVer, NUM_VERSIONS ) ) {
1415
+ bINChI_plain ++;
1416
+ } else
1417
+ if ( bMatchOnePrefix( len, szLine, lenXmlVersion, szXmlVersion, NUM_VERSIONS ) ||
1418
+ bMatchOnePrefix( len, szLine, &lenXmlStruct, &szXmlStruct, 1 ) ||
1419
+ bMatchOnePrefix( len, szLine, lenXmlIdentVer, szXmlIdentVer, NUM_VERSIONS ) ||
1420
+ bMatchOnePrefix( len, szLine, &lenXmlMsgError, &szXmlMsgError, 1 ) ||
1421
+ bMatchOnePrefix( len, szLine, &lenXmlMsgFatal, &szXmlMsgFatal, 1 ) ) {
1422
+ bINChI_xml ++;
1423
+ }
1424
+ }
1425
+ if ( bINChI_plain >= 2 && !bINChI_xml ) {
1426
+ ip->nInputType = INPUT_INCHI_PLAIN;
1427
+ ret = 1;
1428
+ } else
1429
+ if ( !bINChI_plain && bINChI_xml >= 3 ) {
1430
+ ip->nInputType = INPUT_INCHI_XML;
1431
+ ret = 1;
1432
+ }
1433
+ /*exit_function:*/
1434
+ fclose ( *inp_file );
1435
+ *inp_file = fopen( ip->path[0], fmode );
1436
+ return ret;
1437
+ }
1438
+ #undef NUM_VERSIONS
1439
+ #undef LEN_VERSIONS
1440
+
1441
+ #endif /* INCHI_LIBRARY */