2
* International Union of Pure and Applied Chemistry (IUPAC)
3
* International Chemical Identifier (InChI)
5
* Software version 1.01
10
int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmode );
12
/*****************************************************************************************/
13
int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *szSdfDataValue,
14
unsigned long *ulDisplTime, int bReleaseVersion, INCHI_FILE *log_file )
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;
25
/*int bNotRecognized=0;*/
26
char szNameSuffix[32], szOutputPath[512];
27
int bNameSuffix, bOutputPath;
28
int bMergeAllInputStructures;
29
int bDisconnectSalts = (DISCONNECT_SALTS==1);
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;
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;
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;
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)
57
INCHI_MODE bVer1DefaultMode = VER100_DEFAULT_MODE;
58
const char *ext[MAX_NUM_PATHS+1];
61
int bRecognizedOption;
63
int bNoStructLabels = 0;
64
int bOutputMolfileOnly = 0;
65
int bOutputMolfileDT = 0;
66
int bOutputMolfileSplit = 0;
67
int bForcedChiralFlag = 0;
68
#if( READ_INCHI_STRING == 1 )
69
int bDisplayIfRestoreWarnings = 0;
72
int bXml = INCHI_OUT_XML;
74
int bXml = INCHI_OUT_PLAIN_TEXT;
76
int bTgFlagVariableProtons = 1;
77
int bTgFlagHardAddRenProtons = 1;
78
#ifdef STEREO_WEDGE_ONLY
79
int bPointedEdgeStereo = STEREO_WEDGE_ONLY; /* NEWPS TG_FLAG_POINTED_EDGE_STEREO*/
81
#if( FIX_ADJ_RAD == 1 )
82
int bFixAdjacentRad = 0;
84
#if( ADD_PHOSPHINE_STEREO == 1 )
85
int bAddPhosphineStereo = 0;
87
#if( ADD_ARSINE_STEREO == 1 )
88
int bAddArsineStereo = 0;
94
ext[1] = bVer1Options? ".txt" : ".ich";
99
#if( MAX_NUM_PATHS < 4 )
100
#error Wrong initialization
103
/* init table parms */
104
memset ( ip, 0, sizeof(*ip) );
105
#ifndef INCHI_ANSI_ONLY
106
strcpy( ip->tdp.ReqShownFoundTxt[ilSHOWN], "Shown" );
107
ip->dp.sdp.tdp = &ip->tdp;
108
ip->dp.pdp = &ip->pdp;
110
memset( szNameSuffix, 0, sizeof(szNameSuffix) );
112
memset(szOutputPath, 0, sizeof(szOutputPath) );
114
bMergeAllInputStructures = 0;
118
ip->msec_MaxTime = 0; /* milliseconds, default = unlimited in libinchi */
120
ip->msec_MaxTime = 60000; /* milliseconds, default = 60 sec */
123
if ( bReleaseVersion ) {
126
/*ip->bINChIOutputOptions |= INCHI_OUT_PLAIN_TEXT;*/
129
ip->bCtPredecessors = 0;
136
/*bXml = INCHI_OUT_PLAIN_TEXT;*/
140
if ( bVer1Options ) {
142
szNameSuffix[0] = '\0';
146
#if( ACD_LABS_VERSION == 1 ) /* { */
149
ip->path[0] => Input -I
150
ip->path[1] => Output (INChI) -O
151
ip->path[2] => Log -L
152
ip->path[3] => Problem structures
153
ip->path[4] => Errors file (ACD( -E
156
for ( i = 1; i < argc; i ++ ) {
157
if ( *argv[i] !memicmp( argv[i], "-I", 2) ) {
158
ip->num_paths += !ip->path[0];
159
ip->path[0] = _strdup( argv[i] + 2 );
161
if ( *argv[i] !memicmp( argv[i], "-O", 2) ) {
162
ip->num_paths += !ip->path[1];
163
ip->path[1] = _strdup( argv[i] + 2 );
165
if ( *argv[i] !memicmp( argv[i], "-L", 2) ) {
166
ip->num_paths += !ip->path[2];
167
ip->path[2] = _strdup( argv[i] + 2 );
169
if ( *argv[i] !memicmp( argv[i], "-E", 2) ) {
170
ip->path[4] = _strdup( argv[i] + 2 );
172
if ( *argv[i] !stricmp( argv[i], "-Z" ) ) {
173
sprintf( stdout, "%s version %s\n", INCHI_NAME, INCHI_VERSION );
178
#else /* } ACD_LABS_VERSION { */
180
for ( i = 1; i < argc; i ++ ) {
181
if ( bVer1Options && INCHI_OPTION_PREFX == argv[i][0] && ':' == argv[i][1] && !argv[i][2] ) {
182
bVer1Options &= ~1; /* turn off ver 1 options mode */
184
if ( !(bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && INCHI_OPTION_PREFX != argv[i][1] )
186
/*============== Version 0.9xx Beta options & INCHI_LIB ==================*/
187
/***************************************************************/
189
/* Version 0.9xx Beta and INCHI_LIB (GUI) options */
191
/***************************************************************/
196
if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "MOL" ) ) {
197
ip->nInputType = INPUT_MOLFILE;
199
if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "SDF" ) ) {
200
ip->nInputType = INPUT_MOLFILE;
202
if ( INPUT_NONE == ip->nInputType &&
203
(!memicmp( pArg, "SDF", 3 )) &&
204
( pArg[3] == ':' ) ) {
206
mystrncpy( ip->szSdfDataHeader, pArg+4, MAX_SDF_HEADER+1 );
207
LtrimRtrim( ip->szSdfDataHeader, &k );
209
ip->pSdfLabel = ip->szSdfDataHeader;
210
ip->pSdfValue = szSdfDataValue;
211
ip->nInputType = INPUT_SDFILE;
213
ip->pSdfLabel = NULL;
214
ip->pSdfValue = NULL;
215
ip->nInputType = INPUT_MOLFILE;
218
#if( ADD_CMLPP == 1 )
219
if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "CML" ) ) {
221
ip->nInputType = INPUT_CMLFILE;
224
if ( !memicmp( pArg, "START:", 6 ) ) {
225
ip->first_struct_number = strtol(pArg+6, NULL, 10);
227
if ( !memicmp( pArg, "END:", 4 ) ) {
228
ip->last_struct_number = strtol(pArg+4, NULL, 10);
230
if ( !memicmp( pArg, "RSB:", 4 ) ) {
231
mdbr = (int)strtol(pArg+4, NULL, 10);
233
if ( !memicmp( pArg, "DISCONSALT:", 11 ) ) {
234
bDisconnectSalts = (0 != strtol(pArg+11, NULL, 10));
236
if ( !memicmp( pArg, "DISCONMETAL:", 12 ) ) {
237
bDisconnectCoord = (0 != strtol(pArg+12, NULL, 10));
239
if ( !memicmp( pArg, "RECONMETAL:", 11 ) ) {
240
bReconnectCoord = (0 != strtol(pArg+11, NULL, 10));
242
if ( !memicmp( pArg, "DISCONMETALCHKVAL:", 18 ) ) {
243
bDisconnectCoordChkVal = (0 != strtol(pArg+18, NULL, 10));
245
if ( !memicmp( pArg, "MOVEPOS:", 8 ) ) {
246
bMovePositiveCharges = (0 != strtol(pArg+8, NULL, 10));
248
if ( !memicmp( pArg, "MERGESALTTG:", 12 ) ) {
249
bMergeSaltTGroups = (0 != strtol(pArg+12, NULL, 10));
251
if ( !memicmp( pArg, "UNCHARGEDACIDS:", 15) ) {
252
bUnchargedAcidTaut = (0 != strtol(pArg+15, NULL, 16));;
254
if ( !memicmp( pArg, "ACIDTAUT:", 9 ) ) {
255
bAcidTautomerism = c = (int)strtol(pArg+9, NULL, 10);
256
if ( 0 <= c && c <= 2 ) bAcidTautomerism = c;
257
/*else bNotRecognized = 2*bReleaseVersion;*/
259
if ( !memicmp( pArg, "O:", 2 ) ) {
261
strncpy(szNameSuffix, pArg+2, sizeof(szNameSuffix)-1);
263
if ( !memicmp( pArg, "OP:", 3 ) ) {
265
strncpy(szOutputPath, pArg+3, sizeof(szOutputPath)-1);
267
if ( !stricmp( pArg, "ALT" ) ) {
270
if ( !stricmp( pArg, "SCT" ) ) {
271
ip->bCtPredecessors = 1;
274
if ( !stricmp( pArg, "CMP" ) ) {
275
bCompareComponents = CMP_COMPONENTS;
277
if ( !stricmp( pArg, "CMPNONISO" ) ) {
278
bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
280
if ( !stricmp( pArg, "SREL" ) ) {
281
if ( nMode & REQ_MODE_RACEMIC_STEREO ) {
282
nMode ^= REQ_MODE_RACEMIC_STEREO;
284
if ( nMode & REQ_MODE_CHIR_FLG_STEREO ) {
285
nMode ^= REQ_MODE_CHIR_FLG_STEREO;
287
nMode |= REQ_MODE_RELATIVE_STEREO;
288
nMode |= REQ_MODE_STEREO;
290
if ( !stricmp( pArg, "SRAC" ) ) {
291
if ( nMode & REQ_MODE_RELATIVE_STEREO ) {
292
nMode ^= REQ_MODE_RELATIVE_STEREO;
294
if ( nMode & REQ_MODE_CHIR_FLG_STEREO ) {
295
nMode ^= REQ_MODE_CHIR_FLG_STEREO;
297
nMode |= REQ_MODE_RACEMIC_STEREO;
298
nMode |= REQ_MODE_STEREO;
300
if ( !stricmp( pArg, "SUCF" ) ) {
301
if ( nMode & REQ_MODE_RELATIVE_STEREO ) {
302
nMode ^= REQ_MODE_RELATIVE_STEREO;
304
if ( nMode & REQ_MODE_RACEMIC_STEREO ) {
305
nMode ^= REQ_MODE_RACEMIC_STEREO;
307
nMode |= REQ_MODE_CHIR_FLG_STEREO; /* stereo defined by the Chiral flag */
308
nMode |= REQ_MODE_STEREO;
310
if ( !stricmp( pArg, "ChiralFlagON" ) ) { /* used only with /SUCF */
311
bForcedChiralFlag &= ~FLAG_SET_INP_AT_NONCHIRAL;
312
bForcedChiralFlag |= FLAG_SET_INP_AT_CHIRAL;
314
if ( !stricmp( pArg, "ChiralFlagOFF" ) ) { /* used only with /SUCF */
315
bForcedChiralFlag &= ~FLAG_SET_INP_AT_CHIRAL;
316
bForcedChiralFlag |= FLAG_SET_INP_AT_NONCHIRAL;
318
if ( !stricmp( pArg, "NOUUSB" ) ) {
319
nMode |= REQ_MODE_SB_IGN_ALL_UU;
321
if ( !stricmp( pArg, "NOUUSC" ) ) {
322
nMode |= REQ_MODE_SC_IGN_ALL_UU;
324
if ( !stricmp( pArg, "SDFID" ) ) {
325
ip->bGetSdfileId = 1;
327
if ( !stricmp( pArg, "XML" ) ) {
328
bXml &= ~INCHI_OUT_PLAIN_TEXT;
329
bXml |= INCHI_OUT_XML;
330
/*bNotRecognized = 2*bReleaseVersion;*/
332
if ( !stricmp( pArg, "PLAIN" ) ) {
333
bXml |= INCHI_OUT_PLAIN_TEXT;
334
bXml &= ~INCHI_OUT_XML;
336
#if( !defined(INCHI_LIBRARY) && !defined(INCHI_LIB) )
337
if ( !stricmp( pArg, "Tabbed" ) ) {
338
bXml |= INCHI_OUT_TABBED_OUTPUT;
341
if ( !stricmp( pArg, "ANNPLAIN" ) ) {
342
bXml |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
343
bXml &= ~INCHI_OUT_XML_TEXT_COMMENTS;
345
if ( !stricmp( pArg, "ANNXML" ) ) {
346
bXml |= INCHI_OUT_XML_TEXT_COMMENTS;
347
bXml &= ~INCHI_OUT_PLAIN_TEXT_COMMENTS;
349
if ( !stricmp( pArg, "DONOTADDH" ) ) {
352
if ( !memicmp( pArg, "AUXINFO:", 8 ) && isdigit(UCINT pArg[8]) ) {
353
k = strtol(pArg+8, NULL, 10);
355
bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
356
bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
359
bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include full aux info */
362
bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
363
bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
365
bINChIOutputOptions = k; /* override everything */
368
if ( !stricmp( pArg, "MERGE" ) ) {
369
bMergeAllInputStructures = 1;
371
if ( !stricmp( pArg, "PGO" ) ) {
372
ip->bSaveAllGoodStructsAsProblem = 1;
374
if ( !stricmp( pArg, "DCR" ) ) {
375
bDisplayCompositeResults = 1;
377
if ( !stricmp( pArg, "DSB" ) ) {
378
nMode |= REQ_MODE_NO_ALT_SBONDS;
380
if ( !stricmp( pArg, "NOHDR" ) ) {
383
if ( !stricmp( pArg, "NoVarH" ) ) {
384
bTgFlagVariableProtons = 0;
386
if ( !stricmp( pArg, "NoADP" ) ) {
387
bTgFlagHardAddRenProtons = 0;
389
if ( !stricmp( pArg, "FixSp3bug" ) ) {
392
#ifdef STEREO_WEDGE_ONLY
393
if ( !stricmp( pArg, "NEWPS" ) ) {
394
bPointedEdgeStereo = 1;
397
#if( ADD_PHOSPHINE_STEREO == 1 )
398
if ( !stricmp( pArg, "SPXYZ" ) ) {
399
bAddPhosphineStereo = 1;
402
#if( ADD_ARSINE_STEREO == 1 )
403
if ( !stricmp( pArg, "SASXYZ" ) ) {
404
bAddArsineStereo = 1;
408
if ( !stricmp( pArg, "PW" ) ) {
409
ip->bSaveWarningStructsAsProblem = 1;
411
for ( k = 0 /*1*/; c=pArg[k]; k ++ ) {
416
if ( pArg[k+1] == 'C' || pArg[k+1] == 'c' ) {
418
ip->bDisplayEachComponentINChI = 1;
421
t = strtod( pArg+k+1, (char**)&q ); /* cast deliberately discards 'const' qualifier */
422
if ( q > pArg+k && errno == ERANGE || t < 0.0 || t*1000.0 > (double)ULONG_MAX) {
425
ul = (unsigned long)(t*1000.0);
428
k = q - pArg - 1; /* k will be incremented by the for() cycle */
434
ip->msec_MaxTime = ul;
440
c = (int)strtol( pArg+k+1, (char**)&q, 10 ); /* cast deliberately discards 'const' qualifier */
444
nFontSize = -c; /* font size 5 or less is too small */
449
nMode |= REQ_MODE_BASIC;
451
/*bNotRecognized = bReleaseVersion;*/
454
nMode |= REQ_MODE_TAUT;
456
/*bNotRecognized = bReleaseVersion;*/
459
nMode |= REQ_MODE_ISO;
461
/*bNotRecognized = bReleaseVersion;*/
464
nMode |= REQ_MODE_NON_ISO;
466
/*bNotRecognized = bReleaseVersion;*/
469
nMode |= REQ_MODE_STEREO;
471
/*bNotRecognized = bReleaseVersion;*/
474
if ( nReleaseMode & REQ_MODE_STEREO ) {
475
nReleaseMode ^= REQ_MODE_STEREO;
480
my_fprintf(log_file, "Unrecognized option: \"%c\".\n", c);
484
if ( bNotRecognized && bNotRecognized == bReleaseVersion ) {
485
my_fprintf(stderr, "Unrecognized option: \"%c\".\n", c);
492
if ( bNotRecognized && bNotRecognized == 2*bReleaseVersion ) {
493
my_fprintf(stderr, "Unrecognized option: \"%s\".\n", argv[i]);
498
if ( (bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && argv[i][1] ) {
499
/***************************************************************/
501
/* Version 1.00 Beta options */
503
/***************************************************************/
504
bRecognizedOption = 2;
507
printf ("1 argv %d %s\n", i, argv[i]);
511
/* always on: REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO */
512
if ( !stricmp( pArg, "FIXEDH" ) ) {
513
bVer1DefaultMode |= REQ_MODE_BASIC; /* If tautomeric then tautomeric only */
515
if ( !stricmp( pArg, "SNON" ) ) {
516
bVer1DefaultMode &= ~REQ_MODE_STEREO; /* no stereo */
517
nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
519
if ( (!stricmp( pArg, "SABS" ) )) {
520
bVer1DefaultMode |= REQ_MODE_STEREO; /* abs stereo (default) */
521
nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
523
if ( !stricmp( pArg, "SREL" ) ) {
524
bVer1DefaultMode |= REQ_MODE_STEREO; /* relative stereo */
525
nMode &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_CHIR_FLG_STEREO);
526
nMode |= REQ_MODE_RELATIVE_STEREO;
527
} else /* REQ_MODE_CHIR_FLG_STEREO */
528
if ( !stricmp( pArg, "SRAC" ) ) {
529
bVer1DefaultMode |= REQ_MODE_STEREO; /* racemic stereo */
530
nMode &= ~(REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
531
nMode |= REQ_MODE_RACEMIC_STEREO;
533
if ( !stricmp( pArg, "SUCF" ) ) {
534
bVer1DefaultMode |= REQ_MODE_STEREO; /* stereo defined by the Chiral flag */
535
nMode &= ~(REQ_MODE_RELATIVE_STEREO | REQ_MODE_RACEMIC_STEREO);
536
nMode |= REQ_MODE_CHIR_FLG_STEREO;
538
if ( !stricmp( pArg, "ChiralFlagON" ) ) { /* used only with /SUCF */
539
bForcedChiralFlag &= ~FLAG_SET_INP_AT_NONCHIRAL;
540
bForcedChiralFlag |= FLAG_SET_INP_AT_CHIRAL;
542
if ( !stricmp( pArg, "ChiralFlagOFF" ) ) { /* used only with /SUCF */
543
bForcedChiralFlag &= ~FLAG_SET_INP_AT_CHIRAL;
544
bForcedChiralFlag |= FLAG_SET_INP_AT_NONCHIRAL;
546
if ( !stricmp( pArg, "SUU" ) ) { /* include omitted undef/unkn stereo */
547
bVer1DefaultMode &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU);
549
if ( !stricmp( pArg, "FixSp3bug" ) ) {
552
#ifdef STEREO_WEDGE_ONLY
553
if ( !stricmp( pArg, "NEWPS" ) ) {
554
bPointedEdgeStereo = 1;
557
#if( ADD_PHOSPHINE_STEREO == 1 )
558
if ( !stricmp( pArg, "SPXYZ" ) ) {
559
bAddPhosphineStereo = 1;
562
#if( ADD_ARSINE_STEREO == 1 )
563
if ( !stricmp( pArg, "SASXYZ" ) ) {
564
bAddArsineStereo = 1;
567
if ( !stricmp( pArg, "RECMET" ) ) { /* do reconnect metals */
570
if ( !stricmp( pArg, "AUXNONE" ) ) { /* no aux. info */
571
bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
572
bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
574
if ( !stricmp( pArg, "AUXFULL" ) || !stricmp( pArg, "AUXMAX" ) ) { /* full aux info */
575
bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include short aux info */
577
if ( !stricmp( pArg, "AUXMIN" ) ) { /* minimal aux info */
578
bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
579
bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
581
if ( !stricmp( pArg, "DONOTADDH" ) ) {
584
if ( !stricmp( pArg, "D" ) ) { /* display the structures */
587
#if( READ_INCHI_STRING == 1 )
588
if ( !stricmp( pArg, "DDSRC" ) ) {
589
bDisplayIfRestoreWarnings = 1; /* InChI->Structure debugging: Display Debug Structure Restore Components */
593
if ( !stricmp( pArg, "NOLABELS" ) ) {
596
if ( !stricmp( pArg, "WarnOnEmptyStructure" ) ) {
597
ip->bAllowEmptyStructure = 1;
599
if ( !stricmp( pArg, "NoVarH" ) ) {
600
bTgFlagVariableProtons = 0;
602
if ( !stricmp( pArg, "NoADP" ) ) {
603
bTgFlagHardAddRenProtons = 0;
605
if ( !stricmp( pArg, "COMPRESS" ) ) {
607
ip->bCtPredecessors = 1; /* compressed output */
609
if ( !stricmp( pArg, "FULL" ) ) {
610
bVer1DefaultMode = VER100_DEFAULT_MODE;
612
bReconnectCoord = 1; /* full output */
613
bINChIOutputOptions = ((EMBED_REC_METALS_INCHI==1)? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_SHORT_AUX_INFO;
614
ip->bCtPredecessors = 0;
616
bXml |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
617
bXml &= ~(INCHI_OUT_XML | INCHI_OUT_XML_TEXT_COMMENTS);
619
if ( !stricmp( pArg, "MIN" ) ) {
620
bVer1DefaultMode = VER100_DEFAULT_MODE;
622
bReconnectCoord = 1; /* minimal output */
623
bINChIOutputOptions = ((EMBED_REC_METALS_INCHI==1)? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_NO_AUX_INFO; /* minimal compressed output */
624
ip->bCtPredecessors = 1;
626
bXml |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
627
bXml &= ~(INCHI_OUT_XML | INCHI_OUT_XML_TEXT_COMMENTS);
629
#if( READ_INCHI_STRING == 1 )
630
if ( !stricmp( pArg, "InChI2InChI" ) ) {
631
/* Read InChI Identifiers and output InChI Identifiers */
632
ip->nInputType = INPUT_INCHI;
633
ip->bReadInChIOptions |= READ_INCHI_OUTPUT_INCHI;
634
ip->bReadInChIOptions &= ~READ_INCHI_TO_STRUCTURE;
636
if ( !stricmp( pArg, "SplitInChI" ) ) {
637
/* Split InChI Identifiers into components */
638
ip->bReadInChIOptions |= READ_INCHI_SPLIT_OUTPUT;
640
if ( !stricmp( pArg, "InChI2Struct" ) ) {
641
/* Split InChI Identifiers into components */
642
ip->bReadInChIOptions |= READ_INCHI_TO_STRUCTURE;
643
ip->bReadInChIOptions &= ~READ_INCHI_OUTPUT_INCHI;
644
ip->nInputType = INPUT_INCHI;
646
if ( !stricmp( pArg, "KeepBalanceP" ) ) {
647
/* When spliting InChI Identifiers into components: */
648
/* If MobileH output then add p to each component; */
649
/* Otherwise add one more component containing balance */
650
/* of protons and exchangeable isotopic H */
651
ip->bReadInChIOptions |= READ_INCHI_KEEP_BALANCE_P;
654
if ( /* INPUT_NONE == ip->nInputType &&*/
655
!memicmp( pArg, "SDF:", 4 ) ) {
658
mystrncpy( ip->szSdfDataHeader, pArg+4, MAX_SDF_HEADER+1 );
659
LtrimRtrim( ip->szSdfDataHeader, &k );
661
ip->pSdfLabel = ip->szSdfDataHeader;
662
ip->pSdfValue = szSdfDataValue;
663
if ( INPUT_NONE == ip->nInputType ) {
664
ip->nInputType = INPUT_SDFILE;
667
ip->pSdfLabel = NULL;
668
ip->pSdfValue = NULL;
669
if ( INPUT_NONE == ip->nInputType ) {
670
ip->nInputType = INPUT_MOLFILE;
674
#if( ADD_CMLPP == 1 )
675
if ( INPUT_NONE == ip->nInputType && !stricmp( pArg, "CML" ) ) {
677
ip->nInputType = INPUT_CMLFILE;
680
/*============= Default options =============*/
681
if ( !stricmp( pArg, "RECMET-" ) ) { /* do not reconnect metals (default) */
684
if ( !stricmp( pArg, "OUTPUTSDF" ) ) { /* output SDfile */
685
bOutputMolfileOnly = 1;
687
if ( !stricmp( pArg, "SdfAtomsDT" ) ) { /* output isotopes H as D and T in SDfile */
688
bOutputMolfileDT = 1;
690
if ( !stricmp( pArg, "SdfSplit" ) ) { /* Split single Molfiles into disconnected components */
691
bOutputMolfileSplit = 1;
693
if ( !stricmp( pArg, "STDIO" ) ) {
696
if ( !stricmp( pArg, "DCR" ) ) {
697
bDisplayCompositeResults = 1;
699
#if( FIX_ADJ_RAD == 1 )
700
if ( !stricmp( pArg, "FixRad" ) ) {
704
/*============= Additional options ==========*/
705
/* Tautomer perception off */
706
if ( !stricmp( pArg, "EXACT" ) ) {
707
bVer1DefaultMode |= REQ_MODE_BASIC;
709
if ( !stricmp( pArg, "MOLFILENUMBER" ) ) {
710
ip->bGetMolfileNumber |= 1;
712
if ( !stricmp( pArg, "OutputPLAIN" ) ) {
713
bXml |= INCHI_OUT_PLAIN_TEXT;
714
bXml &= ~INCHI_OUT_XML;
716
#if( !defined(INCHI_LIBRARY) && !defined(INCHI_LIB) )
717
if ( !stricmp( pArg, "Tabbed" ) ) {
718
bXml |= INCHI_OUT_TABBED_OUTPUT;
721
if ( !stricmp( pArg, "OutputXML" ) ) {
722
bXml |= INCHI_OUT_XML;
723
bXml &= ~INCHI_OUT_PLAIN_TEXT;
725
if ( !stricmp( pArg, "OutputANNPLAIN" ) ) {
726
bXml |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
727
bXml &= ~INCHI_OUT_XML_TEXT_COMMENTS;
728
bXml |= INCHI_OUT_WINCHI_WINDOW; /* debug */
730
if ( !stricmp( pArg, "OutputANNXML" ) ) {
731
bXml |= INCHI_OUT_XML_TEXT_COMMENTS;
732
bXml &= ~INCHI_OUT_PLAIN_TEXT_COMMENTS;
734
if ( !stricmp( pArg, "ONLYEXACT" ) || !stricmp( pArg, "ONLYFIXEDH" ) ) {
735
bVer1DefaultMode |= REQ_MODE_BASIC;
736
bVer1DefaultMode &= ~REQ_MODE_TAUT;
738
if ( !stricmp( pArg, "ONLYNONISO" ) ) {
739
bVer1DefaultMode |= REQ_MODE_NON_ISO;
740
bVer1DefaultMode &= ~REQ_MODE_ISO;
742
if ( !stricmp( pArg, "TAUT" ) ) {
743
bVer1DefaultMode &= ~REQ_MODE_BASIC;
744
bVer1DefaultMode |= REQ_MODE_TAUT;
746
if ( !stricmp( pArg, "ONLYRECMET" ) ) { /* do not disconnect metals */
747
bDisconnectCoord = 0;
749
if ( !stricmp( pArg, "ONLYRECSALT" ) ) { /* do not disconnect salts */
750
bDisconnectSalts = 0;
752
if ( !memicmp( pArg, "START:", 6 ) ) {
753
ip->first_struct_number = strtol(pArg+6, NULL, 10);
755
if ( !memicmp( pArg, "END:", 4 ) ) {
756
ip->last_struct_number = strtol(pArg+4, NULL, 10);
758
if ( !memicmp( pArg, "RSB:", 4 )) {
759
mdbr = (int)strtol(pArg+4, NULL, 10);
761
if ( !stricmp( pArg, "EQU" ) ) {
762
bCompareComponents = CMP_COMPONENTS;
764
if ( !stricmp( pArg, "EQUNONISO" ) ) {
765
bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
767
if ( !memicmp( pArg, "OP:", 3 ) ) {
769
strncpy(szOutputPath, pArg+3, sizeof(szOutputPath)-1);
771
/*============== Char+Value options ==============*/
772
if ( !memicmp( pArg, "W", 1 ) && (t = strtod( pArg+1, (char**)&q ), q > pArg+1) ) {
773
if ( errno == ERANGE || t < 0.0 || t*1000.0 > (double)ULONG_MAX) {
776
ul = (unsigned long)(t*1000.0); /* max. time per structure */
778
ip->msec_MaxTime = ul;
780
if ( !memicmp( pArg, "F", 1 ) && (c = (int)strtol( pArg+1, (char**)&q, 10 ), q > pArg+1) ) {
781
nFontSize = -c; /* struct. display font size */
783
bRecognizedOption = 0;
785
my_fprintf(log_file, "Unrecognized option: \"%s\".\n", pArg);
788
bVer1Options |= bRecognizedOption;
790
if ( ip->num_paths < MAX_NUM_PATHS ) {
792
if ( argv[i] && argv[i][0] ) {
793
if ( sz = (char*)inchi_malloc( (strlen(argv[i]) + 1)*sizeof(sz[0])) ) {
794
strcpy( sz, argv[i] );
797
printf ("1 path %d argv %d %s\n", ip -> num_paths, i, argv [i]);
799
ip->path[ip->num_paths++] = sz;
805
if ( bNameSuffix || bOutputPath ) {
806
const char *p = NULL;
810
/* find the 1st path */
811
for ( i = 0; i < MAX_NUM_PATHS; i ++ ) {
812
if ( !p && ip->path[i] && ip->path[i][0] ) {
817
/* fix output path */
818
if ( bOutputPath && szOutputPath[0] && p ) {
819
/* remove last slash */
820
len = strlen(szOutputPath);
821
if ( len > 0 && szOutputPath[len-1] != INCHI_PATH_DELIM ) {
822
szOutputPath[len++] = INCHI_PATH_DELIM;
823
szOutputPath[len] = '\0';
825
if ( len > 0 && (r = (char *)strrchr( p, INCHI_PATH_DELIM ) ) && r[1] ) {
826
strcat( szOutputPath, r+1 );
829
} /* add missing paths */
830
for ( i = 0; p && i < MAX_NUM_PATHS; i ++ ) {
831
if ( ip->path[i] && !stricmp( ip->path[i], "NUL" ) ) {
832
inchi_free( (char *)ip->path[i] ); /* cast deliberately const qualifier */
835
if ( !ip->path[i] || !ip->path[i][0] ) {
836
len = strlen( p ) + strlen(szNameSuffix) + strlen( ext[i] );
837
if ( sz = (char*)inchi_malloc( (len+1)*sizeof(sz[0]) ) ) {
839
strcat( sz, szNameSuffix );
840
strcat( sz, ext[i] );
848
#endif /* } NOT ACD_LABS_VERSION */
851
#if( READ_INCHI_STRING == 1 )
852
if ( INPUT_INCHI == ip->nInputType ) {
853
bCompareComponents = 0;
854
/*bDisplayCompositeResults = 0;*/
855
bOutputMolfileOnly = 0;
856
/*bNoStructLabels = 1;*/
857
bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO;
858
bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
859
bINChIOutputOptions &= ~INCHI_OUT_ONLY_AUX_INFO;
860
ip->bDisplayIfRestoreWarnings = bDisplayIfRestoreWarnings;
862
if ( !(bINChIOutputOptions &
864
(INCHI_OUT_SDFILE_ONLY |
866
INCHI_OUT_PLAIN_TEXT |
867
INCHI_OUT_PLAIN_TEXT_COMMENTS |
868
INCHI_OUT_XML_TEXT_COMMENTS
871
bINChIOutputOptions |= INCHI_OUT_PLAIN_TEXT;
877
if ( bVer1Options ) {
878
nMode |= bVer1DefaultMode;
880
if ( bReleaseVersion ) {
881
nMode |= nReleaseMode;
884
#if( defined(INCHI_ANSI_ONLY) || defined(INCHI_LIB) )
885
if ( bCompareComponents && !(bDisplay & 1) ) {
886
bCompareComponents = 0;
889
/* Save original options */
890
/* nOrigMode = nMode; */
891
#ifndef INCHI_ANSI_ONLY
892
ip->dp.sdp.nFontSize = nFontSize;
893
ip->dp.sdp.ulDisplTime = *ulDisplTime;
894
ip->bDisplay = bDisplay;
896
ip->bDisplayCompositeResults = bDisplay;
898
ip->bDisplayCompositeResults = bDisplayCompositeResults;
901
ip->bDisplayEachComponentINChI = 0;
902
bCompareComponents = 0;
904
ip->bMergeAllInputStructures = bMergeAllInputStructures;
905
ip->bDoNotAddH = bDoNotAddH;
906
/* set default options */
907
if ( !nMode || nMode == REQ_MODE_STEREO ) {
908
/* requested all output */
909
nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO);
911
if ( !(nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) ) {
912
nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT);
914
if ( (nMode & REQ_MODE_STEREO) && !(nMode & (REQ_MODE_ISO | REQ_MODE_NON_ISO)) ) {
915
nMode |= (REQ_MODE_ISO | REQ_MODE_NON_ISO);
918
/* if the user requested isotopic then unconditionally add non-isotopic output. */
919
if ( nMode & REQ_MODE_ISO ) {
920
nMode |= REQ_MODE_NON_ISO;
922
#if( MIN_SB_RING_SIZE > 0 )
924
nMinDbRinSize = mdbr;
926
nMode |= (nMinDbRinSize << REQ_MODE_MIN_SB_RING_SHFT) & REQ_MODE_MIN_SB_RING_MASK;
929
if ( ip->nInputType == INPUT_NONE && ip->num_paths > 0 ) {
930
ip->nInputType = INPUT_MOLFILE; /* default */
931
#if( ADD_CMLPP == 1 )
934
if ( ip->path[0] && ( p = strrchr(ip->path[0], '.' ) ) &&
935
!stricmp( p, ".cml") ) {
936
ip->nInputType = INPUT_CMLFILE;
942
if ( (bCompareComponents & CMP_COMPONENTS) && (nMode & REQ_MODE_BASIC) ) {
943
bCompareComponents |= CMP_COMPONENTS_NONTAUT; /* compare non-tautomeric */
945
ip->bCompareComponents = bCompareComponents;
947
ip->bINChIOutputOptions = bINChIOutputOptions | (bOutputMolfileOnly? INCHI_OUT_SDFILE_ONLY : 0);
948
if ( bOutputMolfileOnly ) {
949
bXml &= ~(INCHI_OUT_XML | INCHI_OUT_PLAIN_TEXT |
950
INCHI_OUT_PLAIN_TEXT_COMMENTS | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
951
#if( SDF_OUTPUT_DT == 1 )
952
ip->bINChIOutputOptions |= bOutputMolfileDT? INCHI_OUT_SDFILE_ATOMS_DT : 0;
953
ip->bINChIOutputOptions |= bOutputMolfileSplit? INCHI_OUT_SDFILE_SPLIT : 0;
956
if ( bXml & INCHI_OUT_XML ) {
957
bXml &= ~(INCHI_OUT_PLAIN_TEXT | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
960
if ( !(bDisplay & 1) ) {
961
bXml &= ~(INCHI_OUT_PLAIN_TEXT_COMMENTS | INCHI_OUT_XML_TEXT_COMMENTS); /* do not ouput comments in wINChI text file results */
963
bXml |= INCHI_OUT_WINCHI_WINDOW;
966
ip->bINChIOutputOptions |= bXml;
967
ip->bNoStructLabels = bNoStructLabels;
969
if ( bForcedChiralFlag ) {
970
ip->bChiralFlag = bForcedChiralFlag;
973
/*******************************************/
974
/* tautomeric/salts settings */
975
/*******************************************/
977
ip->bTautFlags = 0; /* initialize */
978
ip->bTautFlagsDone = 0; /* initialize */
980
/* find regular tautomerism */
981
ip->bTautFlags |= TG_FLAG_TEST_TAUT__ATOMS;
982
/* disconnect salts */
983
ip->bTautFlags |= bDisconnectSalts? TG_FLAG_DISCONNECT_SALTS : 0;
984
/* if possible find long-range H/(-) taut. on =C-OH, >C=O */
985
ip->bTautFlags |= bAcidTautomerism? TG_FLAG_TEST_TAUT__SALTS : 0;
986
/* allow long-range movement of N(+), P(+) charges */
987
ip->bTautFlags |= bMovePositiveCharges? TG_FLAG_MOVE_POS_CHARGES : 0;
988
/* multi-attachement long-range H/(-) taut. on =C-OH, >C=O */
989
ip->bTautFlags |= (bAcidTautomerism > 1)? TG_FLAG_TEST_TAUT2_SALTS : 0;
990
/* (debug) allow to find long-range H-only tautomerism on =C-OH, >C=O */
991
ip->bTautFlags |= (bUnchargedAcidTaut==1)? TG_FLAG_ALLOW_NO_NEGTV_O : 0;
992
/* merge =C-OH and >C=O containing t-groups and other =C-OH groups */
993
ip->bTautFlags |= bMergeSaltTGroups? TG_FLAG_MERGE_TAUT_SALTS : 0;
994
ip->bTautFlags |= bDisconnectCoord? TG_FLAG_DISCONNECT_COORD : 0;
995
ip->bTautFlags |=(bDisconnectCoord &&
996
bReconnectCoord)? TG_FLAG_RECONNECT_COORD : 0;
997
ip->bTautFlags |= bDisconnectCoordChkVal? TG_FLAG_CHECK_VALENCE_COORD : 0;
998
ip->bTautFlags |= bTgFlagVariableProtons? TG_FLAG_VARIABLE_PROTONS : 0;
999
ip->bTautFlags |= bTgFlagHardAddRenProtons? TG_FLAG_HARD_ADD_REM_PROTONS : 0;
1000
#ifdef STEREO_WEDGE_ONLY
1001
ip->bTautFlags |= bPointedEdgeStereo? TG_FLAG_POINTED_EDGE_STEREO : 0;
1003
#if( FIX_ADJ_RAD == 1 )
1004
ip->bTautFlags |= bFixAdjacentRad? TG_FLAG_FIX_ADJ_RADICALS : 0;
1006
#if( ADD_PHOSPHINE_STEREO == 1 )
1007
ip->bTautFlags |= bAddPhosphineStereo? TG_FLAG_PHOSPHINE_STEREO : 0;
1009
#if( ADD_ARSINE_STEREO == 1 )
1010
ip->bTautFlags |= bAddArsineStereo? TG_FLAG_ARSINE_STEREO : 0;
1012
ip->bTautFlags |= bFixSp3bug? TG_FLAG_FIX_SP3_BUG : 0;
1014
if ( !ip->nInputType ) {
1015
ip->nInputType = INPUT_MOLFILE;
1019
/*******************************************************************/
1020
int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
1022
INCHI_MODE nMode = ip->nMode;
1024
/* output options: line 1 */
1025
my_fprintf( log_file, "Options: " );
1029
if ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY ) {
1030
my_fprintf( log_file, "Output SDfile only%s\n",
1031
(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ATOMS_DT)? " (write H isotopes as D, T)":"" );
1035
if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_BASIC | REQ_MODE_TAUT) ) {
1036
my_fprintf( log_file, "Mobile H Perception OFF" );
1038
if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_TAUT) ) {
1039
my_fprintf( log_file, "Mobile H Perception ON" );
1041
if( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT )) == (REQ_MODE_BASIC) ) {
1042
my_fprintf( log_file, "Mobile H ignored" );
1044
my_fprintf( log_file, "Undefined Mobile H mode" );
1046
if ( (ip->bTautFlags & TG_FLAG_VARIABLE_PROTONS) ) {
1047
if ( !(ip->bTautFlags & TG_FLAG_HARD_ADD_REM_PROTONS) ) {
1048
my_fprintf( log_file, ", Disabled Aggressive (De)protonation" );
1051
my_fprintf( log_file, "\n");
1052
#if( FIX_ADJ_RAD == 1 )
1053
if ( ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS ) {
1054
my_fprintf( log_file, "Fix Adjacent Radicals\n" );
1059
if ( nMode & REQ_MODE_ISO ) {
1060
my_fprintf( log_file, "Isotopic ON");
1062
if ( nMode & REQ_MODE_NON_ISO ) {
1063
my_fprintf( log_file, "Isotopic OFF");
1067
if ( nMode & REQ_MODE_STEREO ) {
1068
my_fprintf( log_file, ", %s%s%s%sStereo ON",
1069
( nMode & REQ_MODE_NOEQ_STEREO )? "Slow ":"",
1070
( nMode & REQ_MODE_REDNDNT_STEREO )? "Redund. ":"",
1071
( nMode & REQ_MODE_NO_ALT_SBONDS)? "No AltBond ":"",
1073
( nMode & REQ_MODE_RACEMIC_STEREO)? "Racemic " :
1074
( nMode & REQ_MODE_RELATIVE_STEREO)? "Relative " :
1075
( nMode & REQ_MODE_CHIR_FLG_STEREO)? "Chiral Flag " : "Absolute " );
1076
if ( 0 == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
1077
my_fprintf( log_file, "\nInclude undefined/unknown stereogenic centers and bonds");
1079
if ( REQ_MODE_SC_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
1080
my_fprintf( log_file, "\nOmit undefined/unknown stereogenic centers");
1082
if ( REQ_MODE_SB_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) {
1083
my_fprintf( log_file, "\nOmit undefined/unknown stereogenic bonds");
1085
/*case REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU*/
1086
my_fprintf( log_file, "\nOmit undefined/unknown stereogenic centers and bonds");
1088
#if( defined(MIN_SB_RING_SIZE) && MIN_SB_RING_SIZE > 0 )
1089
k = (ip->nMode & REQ_MODE_MIN_SB_RING_MASK) >> REQ_MODE_MIN_SB_RING_SHFT;
1090
if ( bRELEASE_VERSION != 1 || k != MIN_SB_RING_SIZE ) {
1092
my_fprintf( log_file, "\nMin. stereobond ring size: %d\n", k );
1094
my_fprintf( log_file, "\nMin. stereobond ring size: NONE\n" );
1098
if ( TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags ) {
1099
my_fprintf( log_file, "%sOnly narrow end of wedge points to stereocenter\n", i? "\n":"" );
1102
#if( ADD_PHOSPHINE_STEREO == 1 )
1103
if ( TG_FLAG_PHOSPHINE_STEREO & ip->bTautFlags ) {
1104
my_fprintf( log_file, "%sInclude phoshine stereochemistry\n", i? "\n":"" );
1108
#if( ADD_ARSINE_STEREO == 1 )
1109
if ( TG_FLAG_ARSINE_STEREO & ip->bTautFlags ) {
1110
my_fprintf( log_file, "%sInclude arsine stereochemistry\n", i? "\n":"" );
1116
my_fprintf( log_file, ", Stereo OFF");
1119
my_fprintf( log_file, "\n");
1123
/* metals disconnection */
1124
if ( ip->bTautFlags & TG_FLAG_DISCONNECT_COORD ) {
1125
if ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD ) {
1126
my_fprintf( log_file, "Include bonds to metals\n");
1129
my_fprintf( log_file, "Do not disconnect metals\n");
1131
/* other options: line 2 */
1132
#if( bRELEASE_VERSION == 1 )
1133
if ( ip->bCtPredecessors || ip->bAbcNumbers ) {
1134
if ( ip->bCtPredecessors && ip->bAbcNumbers ) {
1135
my_fprintf( log_file, "Representation: Compressed");
1138
my_fprintf( log_file, "Connection table: %s, %s\n",
1139
ip->bCtPredecessors? "Predecessor_numbers(closures)":"Canon_numbers(branching, ring closures)",
1140
ip->bAbcNumbers? "Shorter alternative":"Numerical");
1145
if ( (bRELEASE_VERSION != 1) || ip->bCtPredecessors || ip->bAbcNumbers ) {
1146
my_fprintf( log_file, "Connection table: %s, %s\n",
1147
ip->bCtPredecessors? "Predecessor_numbers(closures)":"Canon_numbers(branching, ring closures)",
1148
ip->bAbcNumbers? "Shorter alternative":"Numerical");
1151
my_fprintf( log_file, "Representation: Numerical");
1155
if( ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) {
1156
my_fprintf( log_file, "%sAux. info suppressed", i?"; ":"");
1159
if ( ip->bINChIOutputOptions & INCHI_OUT_SHORT_AUX_INFO ) {
1160
my_fprintf( log_file, "%sMinimal Aux. info", i?"; ":"");
1163
my_fprintf( log_file, "%sFull Aux. info", i?"; ":"");
1166
if ( ip->bDoNotAddH ) {
1167
my_fprintf( log_file, "%sDo not add H", i?"; ":"");
1170
my_fprintf( log_file, "\n");
1173
if ( ip->bAllowEmptyStructure ) {
1174
my_fprintf( log_file, "Issue warning on empty structure\n" );
1177
if ( ip->szSdfDataHeader[0] && ip->nInputType != INPUT_SDFILE ) {
1178
my_fprintf( log_file, "SDfile data header: \"%s\"\n", ip->szSdfDataHeader);
1181
if ( ip->nInputType ) {
1182
my_fprintf( log_file, "Input format: %s",
1183
ip->nInputType == INPUT_MOLFILE? "MOLfile" :
1184
ip->nInputType == INPUT_SDFILE? "SDfile" :
1185
ip->nInputType == INPUT_CMLFILE? "CMLfile" :
1186
#if( READ_INCHI_STRING == 1 )
1187
ip->nInputType == INPUT_INCHI? "InChI (plain identifier)" :
1189
#if( SPECIAL_BUILD == 1 )
1190
ip->nInputType == INPUT_INCHI_XML? "MoChI (xml)" :
1191
ip->nInputType == INPUT_INCHI_PLAIN? "MoChI (plain)" : "Unknown" );
1193
ip->nInputType == INPUT_INCHI_XML? "InChI (xml)" :
1194
ip->nInputType == INPUT_INCHI_PLAIN? "InChI (plain)" : "Unknown" );
1196
if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) &&
1197
ip->bGetMolfileNumber ) {
1198
my_fprintf( log_file, " (attempting to read Molfile number)" );
1200
my_fprintf( log_file, "\n");
1203
my_fprintf( log_file, "Output format: %s%s\n",
1204
(ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT)? "Plain text" :
1205
(ip->bINChIOutputOptions & INCHI_OUT_XML)? "XML":
1206
(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY)? "SDfile only" : "Unknown",
1208
((ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT) &&
1209
(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT))? ", tabbed":"");
1211
/* other options: line 4 */
1212
if ( ip->msec_MaxTime ) {
1213
unsigned long seconds = ip->msec_MaxTime/1000;
1214
unsigned long milliseconds = (ip->msec_MaxTime%1000);
1215
my_fprintf( log_file, "Timeout per structure: %lu.%03lu sec", seconds, milliseconds);
1218
my_fprintf( log_file, "No timeout");
1221
my_fprintf( log_file, "%sUp to %d atoms per structure\n", i?"; ":"", MAX_ATOMS);
1223
if ( ip->first_struct_number > 1 ) {
1224
my_fprintf( log_file, "Skipping %ld structure%s\n", ip->first_struct_number-1, ip->first_struct_number==2? "":"s" );
1226
if ( ip->last_struct_number > 0 ) {
1227
my_fprintf( log_file, "Terminate after structure #%ld\n", ip->last_struct_number );
1229
if ( ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0] ) {
1230
my_fprintf( log_file, "Saving warning structures into the problem file\n");
1232
if ( ip->bSaveAllGoodStructsAsProblem && ip->path[3] && ip->path[3][0] ) {
1233
my_fprintf( log_file, "Saving only all good structures into the problem file\n");
1235
/* Report debug modes */
1237
#if( bRELEASE_VERSION != 1 )
1238
my_fprintf( log_file, "Release version = NO");
1242
#if( FIND_RING_SYSTEMS != 1 )
1243
my_fprintf( log_file, "%s5-, 6-, 7-memb. ring taut. ignored", i?"; ":"");
1247
#if( TRACE_MEMORY_LEAKS == 1 && defined(_DEBUG) )
1248
my_fprintf( log_file, "%sTracing memory leaks (SLOW)", i?"; ":"");
1253
my_fprintf( log_file, "\n" );
1256
#if( bRELEASE_VERSION != 1 )
1258
#if( FIND_RING_SYSTEMS == 1 )
1259
my_fprintf( log_file, "Find ring systems=Y\nTautomers:" );
1260
my_fprintf( log_file, " 4-pyridinol=%s", TAUT_4PYRIDINOL_RINGS==1? "Y":"N");
1261
my_fprintf( log_file, " pyrazole=%s", TAUT_PYRAZOLE_RINGS==1? "Y":"N");
1262
my_fprintf( log_file, " tropolone=%s", TAUT_TROPOLONE_7==1? "Y":"N");
1263
my_fprintf( log_file, " tropolone-5=%s", TAUT_TROPOLONE_5==1? "Y":"N");
1264
my_fprintf( log_file, "\n" );
1265
my_fprintf( log_file, "Only chain attachments to tautomeric rings=%s\n", TAUT_RINGS_ATTACH_CHAIN==1? "Y":"N");
1267
if ( ip->bGetSdfileId ) {
1268
my_fprintf( log_file, "Extracting SDfile IDs\n");
1270
my_fprintf( log_file, "\nDbg: MOVE_CHARGES=%d\n",
1271
0!=(ip->bTautFlags&TG_FLAG_MOVE_POS_CHARGES));
1272
my_fprintf( log_file, " REPLACE_ALT_WITH_TAUT=%d; NEUTRALIZE_ENDPOINTS=%d; BNS_PROTECT_FROM_TAUT=%d\n",
1273
REPLACE_ALT_WITH_TAUT, NEUTRALIZE_ENDPOINTS, BNS_PROTECT_FROM_TAUT);
1274
my_fprintf( log_file, " DISCONNECT_SALTS=%d; TEST_TAUT_SALTS=%d; TEST_TAUT2_SALTS=%d\n",
1275
0!=(ip->bTautFlags&TG_FLAG_DISCONNECT_SALTS),
1276
0!=(ip->bTautFlags&TG_FLAG_TEST_TAUT__SALTS),
1277
0!=(ip->bTautFlags&TG_FLAG_TEST_TAUT2_SALTS));
1279
my_fprintf( log_file, " CHARGED_ACID_TAUT_ONLY=%d MERGE_TAUT_SALTS=%d\n",
1280
0==(ip->bTautFlags&TG_FLAG_ALLOW_NO_NEGTV_O),
1281
0!=(ip->bTautFlags&TG_FLAG_MERGE_TAUT_SALTS));
1282
my_fprintf( log_file, " DISCONNECT_COORD=%d\n", 0!=(ip->bTautFlags&TG_FLAG_DISCONNECT_COORD) );
1283
#if( TEST_RENUMB_ATOMS == 1 )
1284
my_fprintf( log_file, "\nDbg: TEST_RENUMB_ATOMS=%d; TEST_RENUMB_NEIGH=%d; TEST_RENUMB_SWITCH=%d\n",
1285
TEST_RENUMB_ATOMS, TEST_RENUMB_NEIGH, TEST_RENUMB_SWITCH );
1286
my_fprintf( log_file, " TEST_RENUMB_ATOMS_SAVE_LONGEST=%d\n",
1287
TEST_RENUMB_ATOMS_SAVE_LONGEST);
1294
/************************************************************************************/
1295
void HelpCommandLineParms( INCHI_FILE *f )
1300
#if ( bRELEASE_VERSION == 1 )
1302
inchi_print_nodisplay( f, "%s ver %s%s.\n\nUsage:\nc%s-%s inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, INCHI_NAME, INCHI_VERSION, INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1303
inchi_print_nodisplay( f, "\nOptions:\n");
1304
inchi_print_nodisplay( f, " SNon Exclude stereo (Default: Include Absolute stereo)\n");
1305
inchi_print_nodisplay( f, " SRel Relative stereo\n");
1306
inchi_print_nodisplay( f, " SRac Racemic stereo\n");
1307
inchi_print_nodisplay( f, " SUCF Use Chiral Flag: On means Absolute stereo, Off - Relative\n");
1308
inchi_print_nodisplay( f, " SUU Include omitted unknown/undefined stereo\n");
1309
inchi_print_nodisplay( f, " NEWPS Narrow end of wedge points to stereocenter (default: both)\n");
1310
#if( ADD_PHOSPHINE_STEREO == 1 )
1311
inchi_print_nodisplay( f, " SPXYZ Include Phosphines Stereochemistry\n");
1313
#if( ADD_ARSINE_STEREO == 1 )
1314
inchi_print_nodisplay( f, " SAsXYZ Include Arsines Stereochemistry\n");
1316
inchi_print_nodisplay( f, " RecMet Include reconnected metals results\n");
1317
inchi_print_nodisplay( f, " FixedH Mobile H Perception Off (Default: On)\n");
1318
inchi_print_nodisplay( f, " AuxNone Omit auxiliary information (default: Include)\n");
1319
/*inchi_print_nodisplay( f, " AuxMin Output minimal auxiliary information\n");*/
1320
inchi_print_nodisplay( f, " NoADP Disable Aggressive Deprotonation (for testing only)\n");
1321
/*inchi_print_nodisplay( f, " PLAIN Plain text output (Default: XML format)\n");*/
1322
inchi_print_nodisplay( f, " Compress Compressed output\n");
1323
/*inchi_print_nodisplay( f, " FULL Standard set of options for Full Verbose Output\n");*/
1324
/*inchi_print_nodisplay( f, " MIN Standard set of options for Minimal Concise Output\n");*/
1325
inchi_print_nodisplay( f, " DoNotAddH Don't add H according to usual valences: all H are explicit\n");
1326
#if( defined(_WIN32) && defined(_MSC_VER) && !defined(INCHI_ANSI_ONLY) && !defined(INCHI_LIBRARY) )
1327
inchi_print_nodisplay( f, " D Display the structures\n");
1328
inchi_print_nodisplay( f, " EQU Display sets of identical components\n");
1329
inchi_print_nodisplay( f, " Fnumber Set display Font size in number of points\n");
1331
inchi_print_nodisplay( f, " Wnumber Set time-out per structure in seconds; W0 means unlimited\n");
1332
inchi_print_nodisplay( f, " SDF:DataHeader Read from the input SDfile the ID under this DataHeader\n");
1333
#if( ADD_CMLPP == 1 )
1334
inchi_print_nodisplay( f, " CML Input in CML format (default for input file .CML extension) \n");
1336
inchi_print_nodisplay( f, " NoLabels Omit structure number, DataHeader and ID from %s output\n", INCHI_NAME);
1337
inchi_print_nodisplay( f, " Tabbed Separate structure number, %s, and AuxIndo with tabs\n", INCHI_NAME);
1338
inchi_print_nodisplay( f, " OutputSDF Convert %s created with default aux. info to SDfile\n", INCHI_NAME);
1340
inchi_print_nodisplay( f, " InChI2Struct Test mode: Mol/SDfile->%s->Structure->%s and a structure in AuxInfo format\n", INCHI_NAME, INCHI_NAME);
1343
inchi_print_nodisplay( f, " InChI2Struct Convert %s string into a structure in AuxInfo format and its %s\n", INCHI_NAME, INCHI_NAME);
1346
inchi_print_nodisplay( f, " InChI2InChI Convert %s string into %s string for validation purposes\n", INCHI_NAME, INCHI_NAME);
1347
#if ( SDF_OUTPUT_DT == 1 )
1348
inchi_print_nodisplay( f, " SdfAtomsDT Output Hydrogen Isotopes to SDfile as Atoms D and T\n");
1350
inchi_print_nodisplay( f, " STDIO Use standard input/output streams\n");
1351
inchi_print_nodisplay( f, " WarnOnEmptyStructure Warn and produce empty %s for empty structure\n", INCHI_NAME);
1352
#if( FIX_ADJ_RAD == 1 )
1353
inchi_print_nodisplay( f, " FixRad Fix Adjacent Radicals\n");
1358
inchi_print_nodisplay( f, "%s ver %s. Special testing version 12-12-2002.\n", INCHI_NAME, INCHI_VERSION);
1360
inchi_print_nodisplay( f, "\nUsage:\ncINChI09b inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1362
inchi_print_nodisplay( f, "\nOptions:\n");
1363
inchi_print_nodisplay( f, "\tB Basic\n");
1364
inchi_print_nodisplay( f, "\tT basic Tautomeric\n");
1365
inchi_print_nodisplay( f, "\tI Isotopic\n");
1366
inchi_print_nodisplay( f, "\tN Non-isotopic\n");
1367
inchi_print_nodisplay( f, "\tS Stereo\n");
1368
inchi_print_nodisplay( f, "\tE Exclude Stereo\n");
1369
inchi_print_nodisplay( f, "\tD Display the structures\n");
1370
inchi_print_nodisplay( f, "\tALT produce shorter ALTernative representation (Abc)\n");
1371
inchi_print_nodisplay( f, "\tSCT produce shorter connection table representation\n");
1372
inchi_print_nodisplay( f, "\tXML output in xml format\n");
1373
inchi_print_nodisplay( f, "\tPLAIN output in plain format\n");
1374
inchi_print_nodisplay( f, "\tMERGE Merge all MOLfiles from the input file into one compound\n");
1375
inchi_print_nodisplay( f, "\tWnumber time-out per structure in seconds, W0 means unlimited\n");
1376
inchi_print_nodisplay( f, "\tFnumber set display Font size, points\n");
1377
inchi_print_nodisplay( f, "\tSREL Relative Stereo\n");
1378
inchi_print_nodisplay( f, "\tSRAC Racemic Stereo\n");
1379
inchi_print_nodisplay( f, "\tNOUUSB Omit stereobonds if all are unknown/undefined\n");
1380
inchi_print_nodisplay( f, "\tNOUUSC Omit stereocenters if all are unknown/undefined\n");
1381
inchi_print_nodisplay( f, "\tSS Slow Stereo: do not use stereo equivalence\n");
1382
inchi_print_nodisplay( f, "\tRS Do not test for Redundant Stereo elements\n");
1383
inchi_print_nodisplay( f, "\tPW Save warning structures in the problems file\n");
1384
inchi_print_nodisplay( f, "\tPGO Save only all good structures in the problems file\n");
1385
inchi_print_nodisplay( f, "\tDSB Double Stereo Bonds only (ignore alternating bonds stereo)\n");
1386
inchi_print_nodisplay( f, "\tRSB:n Min Ring Size for detecting for Stereo Bonds (n=1 => all)\n");
1387
inchi_print_nodisplay( f, "\tAUXINFO:0 do not output auxiliary information (default:1)\n");
1388
inchi_print_nodisplay( f, "\tDISCONSALT:0 do not disconnect salts (default:1)\n");
1389
inchi_print_nodisplay( f, "\tDISCONMETAL:0 do not disconnect metals (default:1)\n");
1390
inchi_print_nodisplay( f, "\tDISCONMETALCHKVAL:1 do not disconnect if typical valence (default:0)\n");
1391
inchi_print_nodisplay( f, "\tRECONMETAL:0 do not reconnect metals (default:1)\n");
1392
inchi_print_nodisplay( f, "\tMOVEPOS:0 do not check moveable positive charges (default:1)\n");
1393
inchi_print_nodisplay( f, "\tACIDTAUT:n n=1: one H/(-) tautomerism, 2: more (deflt), 0:none\n");
1394
inchi_print_nodisplay( f, "\tMERGESALTTG:1 merge salt t-groups (default), 0: do not merge\n");
1395
inchi_print_nodisplay( f, "\tUNCHARGEDACIDS:1 Apply salt (acid) tautomerism in neutral species\n");
1396
inchi_print_nodisplay( f, "\tO:[suffix] Open all 4 files adding suffix to the inputFile name\n");
1397
inchi_print_nodisplay( f, "\tOP:outputpath Set output path\n");
1398
inchi_print_nodisplay( f, "\tMOL input file is a MOLfile (default)\n");
1399
inchi_print_nodisplay( f, "\tSDF[:DataHeader] Include SDfile data for the header into the results\n");
1400
inchi_print_nodisplay( f, "\tSDFID extract CAS r.n. in addition to requested SDfile data\n");
1401
inchi_print_nodisplay( f, "\tSTART:number Start at the given structure ordering number\n");
1402
inchi_print_nodisplay( f, "\tEND:number Terminate after the given structure ordering number\n");
1407
#ifndef INCHI_LIBRARY
1408
/************************************************************************************/
1409
int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_file, INPUT_PARMS *ip )
1413
ip->path[0] => Input
1414
ip->path[1] => Output (INChI)
1416
ip->path[3] => Problem structures
1417
ip->path[4] => Errors file (ACD Labs)
1420
/* logfile -- open es early as possible */
1421
if ( !ip->path[2] || !ip->path[2][0] ) {
1422
my_fprintf( stderr, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1423
my_fprintf( stderr, "Log file not specified. Using standard error output.\n");
1426
if ( !(*log_file = fopen( ip->path[2], "w" ) ) ) {
1427
my_fprintf( stderr, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1428
my_fprintf( stderr, "Cannot open log file '%s'. Using standard error output.\n", ip->path[2] );
1431
my_fprintf( *log_file, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1432
my_fprintf( *log_file, "Opened log file '%s'\n", ip->path[2] );
1435
if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE ||
1436
ip->nInputType == INPUT_CMLFILE || ip->nInputType == INPUT_INCHI) && ip->num_paths > 0 ) {
1437
const char *fmode = NULL;
1438
#if( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
1439
/* compilers that definitely allow fopen "rb" (binary read) mode */
1441
if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen( ip->path[0], "rb" ) ) ) {
1442
my_fprintf( *log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0]? ip->path[0] : "<No name>" );
1445
if ( ip->nInputType == INPUT_CMLFILE ) {
1448
printf ("cr %d lf %d ret %d\n", (int) '\r', (int) '\f', (int) '\n');
1450
/* read up to the end of the first line */
1451
while( (c = fgetc( *inp_file )) && c != EOF && c != '\n' && c != '\r' )
1453
if ( c == '\r' || c == EOF ) {
1454
/* text file contains CR; close and reopen as "text" */
1455
fclose( *inp_file );
1456
if ( !(*inp_file = fopen( ip->path[0], "r" ) ) ) {
1457
my_fprintf( *log_file, "Cannot open input file '%s' (2nd attempt). Terminating.\n", ip->path[0] );
1460
my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1463
fclose( *inp_file );
1464
if ( !(*inp_file = fopen( ip->path[0], "rb" ) ) ) {
1465
my_fprintf( *log_file, "Cannot open input file '%s' (2nd attempt). Terminating.\n", ip->path[0] );
1468
my_fprintf( *log_file, "Opened input file '%s': no CR.\n", ip->path[0] );
1473
if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen( ip->path[0], "r" ) ) ) {
1474
my_fprintf( *log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0]? ip->path[0] : "<No Name>" );
1477
my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1481
DetectInputINChIFileType( inp_file, ip, fmode );
1483
if ( (ip->nInputType != INPUT_MOLFILE && ip->nInputType != INPUT_SDFILE && ip->nInputType != INPUT_CMLFILE && ip->nInputType != INPUT_INCHI) ) {
1484
my_fprintf( *log_file, "Input file type not specified. Terminating.\n");
1487
my_fprintf( *log_file, "Input file not specified. Using standard input.\n");
1491
if ( !ip->path[1] || !ip->path[1][0] ) {
1492
my_fprintf( *log_file, "Output file not specified. Using standard output.\n");
1493
*output_file = stdout;
1495
if ( !(*output_file = fopen( ip->path[1], "w" ) ) ) {
1496
my_fprintf( *log_file, "Cannot open output file '%s'. Terminating.\n", ip->path[1] );
1499
my_fprintf( *log_file, "Opened output file '%s'\n", ip->path[1] );
1500
if ( (ip->bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT)) &&
1501
*inp_file != stdin &&
1502
!(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) &&
1503
!ip->bNoStructLabels &&
1504
!(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)) {
1505
PrintFileName( "* Input_File: \"%s\"\n", *output_file, ip->path[0] );
1510
if ( ip->path[3] && ip->path[3][0] ) {
1511
const char *fmode = "w";
1512
#if( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
1513
if ( ip->nInputType != INPUT_CMLFILE ) {
1517
if ( !(*prb_file = fopen( ip->path[3], fmode ) ) ) {
1518
my_fprintf( *log_file, "Cannot open problem file '%s'. Terminating.\n", ip->path[3] );
1521
my_fprintf( *log_file, "Opened problem file '%s'\n", ip->path[3] );
1524
return 1; /* success */
1527
return 0; /* failed */
1530
#define NUM_VERSIONS 6
1531
#define LEN_VERSIONS 64
1532
/*******************************************************************/
1533
static int bMatchOnePrefix( int len, char *str, int lenPrefix[],
1534
char strPrefix[][LEN_VERSIONS], int numPrefix);
1535
/*******************************************************************/
1536
static int bMatchOnePrefix( int len, char *str, int lenPrefix[],
1537
char strPrefix[][LEN_VERSIONS], int numPrefix)
1540
for ( i = 0; i < numPrefix; i ++ ) {
1541
if ( len >= lenPrefix[i] &&
1542
!memcmp( str, strPrefix[i], lenPrefix[i] ) ) {
1548
/*******************************************************************/
1549
int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmode )
1551
char szLine[256], ret = 0;
1552
static char szPlnVersion[NUM_VERSIONS][LEN_VERSIONS]; /* = "INChI:1.1Beta/";*/
1553
static int lenPlnVersion[NUM_VERSIONS];
1554
static char szPlnAuxVer[NUM_VERSIONS][LEN_VERSIONS]; /* = "AuxInfo:1.1Beta/";*/
1555
static int lenPlnAuxVer[NUM_VERSIONS];
1556
static char szXmlVersion[NUM_VERSIONS][LEN_VERSIONS]; /* = "<INChI version=\"1.1Beta\">";*/
1557
static int lenXmlVersion[NUM_VERSIONS];
1558
static char szXmlStruct[LEN_VERSIONS] = "<structure";
1559
static int lenXmlStruct;
1560
static char szXmlIdentVer[NUM_VERSIONS][LEN_VERSIONS]; /*= "<identifier version=\"1.1Beta\"";*/
1561
static int lenXmlIdentVer[NUM_VERSIONS];
1562
static char szXmlMsgError[LEN_VERSIONS];
1563
static int lenXmlMsgError = 0;
1564
static char szXmlMsgFatal[LEN_VERSIONS]= "<message type=\"fatal (aborted)\"";
1565
static int lenXmlMsgFatal;
1566
static int bInitilized = 0;
1567
int bINChI_plain = 0, bINChI_xml = 0, len, i;
1568
if ( ip->nInputType == INPUT_INCHI_XML || ip->nInputType == INPUT_INCHI_PLAIN || ip->nInputType == INPUT_INCHI ) {
1571
if ( !bInitilized ) {
1572
lenPlnVersion[0] = sprintf( szPlnVersion[0], "%s=%s/", INCHI_NAME, INCHI_VERSION );
1573
lenPlnVersion[1] = sprintf( szPlnVersion[1], "INChI=1.12Beta/" );
1574
lenPlnVersion[2] = sprintf( szPlnVersion[2], "INChI=1.0RC/" );
1575
lenPlnVersion[3] = sprintf( szPlnVersion[3], "InChI=1.0RC/" );
1576
lenPlnVersion[4] = sprintf( szPlnVersion[4], "InChI=1/" );
1577
lenPlnVersion[5] = sprintf( szPlnVersion[5], "MoChI=1a/" );
1578
lenPlnAuxVer[0] = sprintf( szPlnAuxVer[0], "AuxInfo=%s/", INCHI_VERSION );
1579
lenPlnAuxVer[1] = sprintf( szPlnAuxVer[1], "AuxInfo=1.12Beta/" );
1580
lenPlnAuxVer[2] = sprintf( szPlnAuxVer[2], "AuxInfo=1.0RC/" );
1581
lenPlnAuxVer[3] = sprintf( szPlnAuxVer[3], "AuxInfo=1.0RC/" );
1582
lenPlnAuxVer[4] = sprintf( szPlnAuxVer[4], "AuxInfo=1/" );
1583
lenPlnAuxVer[5] = sprintf( szPlnAuxVer[5], "AuxInfo=1a/" );
1584
lenXmlVersion[0] = sprintf( szXmlVersion[0], "<%s version=\"%s\">", INCHI_NAME, INCHI_VERSION );
1585
lenXmlVersion[1] = sprintf( szXmlVersion[1], "<INChI version=\"1.12Beta\">" );
1586
lenXmlVersion[2] = sprintf( szXmlVersion[2], "<INChI version=\"1.0RC\">" );
1587
lenXmlVersion[3] = sprintf( szXmlVersion[3], "<InChI version=\"1.0RC\">" );
1588
lenXmlVersion[4] = sprintf( szXmlVersion[4], "<InChI version=\"1\">" );
1589
lenXmlVersion[5] = sprintf( szXmlVersion[5], "<MoChI version=\"1a\">" );
1590
lenXmlIdentVer[0] = sprintf( szXmlIdentVer[0], "<identifier version=\"%s\"", INCHI_VERSION );
1591
lenXmlIdentVer[1] = sprintf( szXmlIdentVer[1], "<identifier version=\"1.12Beta\"" );
1592
lenXmlIdentVer[2] = sprintf( szXmlIdentVer[2], "<identifier version=\"1.0RC\"" );
1593
lenXmlIdentVer[3] = sprintf( szXmlIdentVer[3], "<identifier version=\"1.0RC\"" );
1594
lenXmlIdentVer[4] = sprintf( szXmlIdentVer[4], "<identifier version=\"1\"" );
1595
lenXmlIdentVer[5] = sprintf( szXmlIdentVer[5], "<identifier version=\"1a\"" );
1596
lenXmlMsgError = sprintf( szXmlMsgError, "<message type=\"error (no %s)\"", INCHI_NAME );
1597
lenXmlStruct = strlen(szXmlStruct);
1598
lenXmlMsgFatal = strlen(szXmlMsgFatal);
1600
for ( i = 0; i < 4; i ++ ) {
1601
len = my_fgetsUpToLfOrTab( szLine, sizeof(szLine)-1, *inp_file );
1604
if ( bMatchOnePrefix( len, szLine, lenPlnVersion, szPlnVersion, NUM_VERSIONS ) ||
1605
bMatchOnePrefix( len, szLine, lenPlnAuxVer, szPlnAuxVer, NUM_VERSIONS ) ) {
1608
if ( bMatchOnePrefix( len, szLine, lenXmlVersion, szXmlVersion, NUM_VERSIONS ) ||
1609
bMatchOnePrefix( len, szLine, &lenXmlStruct, &szXmlStruct, 1 ) ||
1610
bMatchOnePrefix( len, szLine, lenXmlIdentVer, szXmlIdentVer, NUM_VERSIONS ) ||
1611
bMatchOnePrefix( len, szLine, &lenXmlMsgError, &szXmlMsgError, 1 ) ||
1612
bMatchOnePrefix( len, szLine, &lenXmlMsgFatal, &szXmlMsgFatal, 1 ) ) {
1616
if ( bINChI_plain >= 2 && !bINChI_xml ) {
1617
ip->nInputType = INPUT_INCHI_PLAIN;
1620
if ( !bINChI_plain && bINChI_xml >= 3 ) {
1621
ip->nInputType = INPUT_INCHI_XML;
1625
fclose ( *inp_file );
1626
*inp_file = fopen( ip->path[0], fmode );
1632
#endif /* INCHI_LIBRARY */