InChI
 
Loading...
Searching...
No Matches
mode.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2024 IUPAC and InChI Trust
4 */
5
6
7#ifndef _MODE_H_
8#define _MODE_H_
9
10#include <stdio.h>
11#include <stdlib.h>
12#include "bcf_s.h"
13
14
15/*******************/
16/* */
17/* BUILD TARGETS */
18/* */
19/*******************/
20
21/*
22 One of targets below should be explicitly
23 indicated to compiler (makefile/directive):
24
25 TARGET_EXE_STANDALONE Stand-alone executable inchi-1[.exe]
26 TARGET_API_LIB Library (libinchi) for using InChI API
27 described in inchi_api.h
28 TARGET_EXE_USING_API Executable (INCHI_MAIN) which uses
29 API library (e.g., libinchi.dll)
30 TARGET_LIB_FOR_WINCHI library for wInChI
31*/
32
33
34#if defined(TARGET_EXE_STANDALONE)
35/* Uncomment the next line to perform atom ordering/renumbering tests (internal only) */
36#define RENUMBER_ATOMS_AND_RECALC_V106 1
37#ifdef RENUMBER_ATOMS_AND_RECALC_V106
38/* Comment the next line to print all renumbering changing the initial InChIKey */
39#define STOP_AFTER_FIRST_CHANGE_ON_RENUMBERING 1
40/* djb-rwth: adding full version number in the output -- GH issue #61 */
41#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (inchi-1 executable)"
42/*#define APP_DESCRIPTION "InChI version 1, Software v. 1.06-PT6 (inchi-1 executable) \n*** INTERNAL TEST MODE: ATOM RENUMBERING TEST IS ACTIVE ***"*/
43#else
44#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (inchi-1 executable)***"
45/*#define APP_DESCRIPTION "InChI version 1, Software v. 1.06-PT6 (inchi-1 executable) \n*** UNOFFICIAL TEST VERSION: 6 PT TAUTO RULES AVAILABLE ***"*/
46#endif
47
48#elif defined(TARGET_API_LIB)
49#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (API Library)"
50
51#elif defined(TARGET_EXE_USING_API)
52#ifndef APP_DESCRIPTION
53#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (executable calling API Library)"
54#endif
55
56#elif defined(TARGET_LIB_FOR_WINCHI)
57#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (Library for wInChI GUI executable)"
58
59#elif defined(TARGET_WINCHI)
60#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (wInChI GUI executable)"
61
62#else
63#error No build target #defined, pls check compiler options... (TARGET_EXE_STANDALONE|TARGET_API_LIB|TARGET_EXE_USING_API|TARGET_LIB_FOR_WINCHI)
64#endif
65
66
67#ifndef TARGET_PLATFORM
68#if defined(_WIN32)
69#define TARGET_PLATFORM "Windows"
70#else
71#define TARGET_PLATFORM "Linux"
72#endif
73#endif
74
75
76/****************************/
77/* */
78/* BUILD OPTIONS/FEATURES */
79/* */
80/****************************/
81
82/* Possible options are:
83
84BUILD_LINK_AS_DLL
85 Link library as a Win32 DLL or to eliminate inchi_stricmp duplication
86 (use with TARGET_API_LIB or TARGET_EXE_USING_API)
87
88BUILD_WITH_ENG_OPTIONS
89 Expose engineering options
90
91BUILD_WITH_AMI
92 Turns on AMI (Allow Multiple Inputs) mode for standalone executable
93
94 Select and uncomment whichever are necessary from the list below. */
95
96
97/* #define BUILD_LINK_AS_DLL */
98
99
100#ifndef BUILD_WITH_ENG_OPTIONS
101#define BUILD_WITH_ENG_OPTIONS 0
102#endif
103
104
105
106#ifndef BUILD_WITH_AMI
107/* this allows BUILD_WITH_AMI be #defined in a makefile */
108#define BUILD_WITH_AMI 1
109#endif
110/* NB: AMI mode is only for stand-alone executable */
111#ifndef TARGET_EXE_STANDALONE
112#ifdef BUILD_WITH_AMI
113#undef BUILD_WITH_AMI
114#endif
115#endif
116
117/* Smarter AMI for Windows */
118/* Thanks, DT (2013-12-18) */
119#if( BUILD_WITH_AMI == 1 )
120#if( defined( _MSC_VER ) )
121#define MSC_AMI 1
122/* use MSC _findfirst(...), etc. Do not link with setargv.obj */
123#endif
124#if (BUILD_WITH_ENG_OPTIONS==1)
125#define OUTPUT_FILE_EXT 1 /* options "/.": /.extOut /.extLog /.extPrb replace input file extension instead of adding .txt, .log, .prb 2013-12-18 DCh */
126#define ALLOW_EMPTY_PATHS 1 /* let command line argument "" be interpreted as path */
127
128#define DEL_EMPTY_OUTPUT 1 /* delete output file, problem file if the file is empty -- needed for /DoDrv /DoneOnly or to get rid of empty prb files */
129#define SDF_OUTPUT_HETERO_VALENCE 1 /* output all hetero atom valences to SDF -- NIST output specific */
130
131#endif
132#endif
133
134/* CML input is not supported started from v. 1.04 */
135/* set ADD_CMLPPP to zero to override possble makefile define */
136#define ADD_CMLPP 0
137
138
139/*****************************/
140/* */
141/* COMPILE OPTIONS/FEATURES */
142/* */
143/*****************************/
144
145/* Possible options are:
146
147COMPILE_ANSI_ONLY
148 Unconditionally force ANSI-89 C, no Win32 specific code
149
150COMPILE_ADD_NON_ANSI_FUNCTIONS
151 Use with COMPILE_ANSI_ONLY to add inchi_stricmp(), etc., see util.c
152
153COMPILE_ALL_CPP
154 allow C++ compilation/linkage of functions prototyped in .h files
155
156MS VC compiler pragmas
157
158 Select and uncomment whichever are necessary from the list below. */
159
160
161/* #define COMPILE_ANSI_ONLY */
162#if ( !defined(_MSC_VER) || defined(TARGET_API_LIB) || defined(TARGET_EXE_USING_API)) /* non-Microsoft GNU C, BCC, etc. compilers */
163#ifndef COMPILE_ANSI_ONLY
164#define COMPILE_ANSI_ONLY
165#endif
166#endif
167#ifdef COMPILE_ANSI_ONLY
168/*#define COMPILE_ADD_NON_ANSI_FUNCTIONS */
169#endif
170
171/*
172#define COMPILE_ALL_CPP 1
173*/
174
175#ifdef _MSC_VER
176/*
177========== disable MS VC++ 6.0 Level 4 compiler warnings: ==============
178 C4706: assignment within conditional expression
179 C4127: conditional expression is constant
180 C4244: '=' : conversion from 'int ' to '???', possible loss of data
181 C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
182 C4701: local variable '???' may be used without having been initialized (removed)
183 C4514: unreferenced inline/local function has been removed (C++)
184 C4100: 'identifier' : unreferenced formal parameter
185 C4786: 'identifier' : identifier was truncated to 'number' characters in the debug information
186 C4996: 'identifier' was declared deprecated
187========================================================================
188*/
189#pragma warning( disable : 4706 4127 4514 4100 4786 4996 4244 4267 )
190#endif
191
192
193/* To use allocator, uncomment the next line or use /D "USE_TBB_MALLOC=1" compile directive */
194/*#define USE_TBB_MALLOC 1*/
195#ifdef USE_TBB_MALLOC
196#if !defined(TARGET_EXE_STANDALONE) && !defined(TARGET_LIB_FOR_WINCHI) && defined(_WIN32)
197/* Use dynamic memory allocator from Intel(R) Threading Building Blocks */
198/* https://www.threadingbuildingblocks.org/ */
199/* see the header, tbbmalloc_proxy.h */
200/* NB: under MS Visual Studio, add paths to platform-dependent TBB 32/64 bit libs */
201/* (tbbmalloc_proxy_debug.lib tbbmalloc_proxy.lib) */
202/* also ensure that final binaries access platform-dependent TBB 32/64 bit dlls */
203/* (tbbmalloc.dll tbbmalloc_proxy.dll) and MSVCR120.dll or other corresp. to TBB compile */
204/* */
205#include "../../INCHI_API/tbb/tbbmalloc_proxy_for_inchi.h"
206#endif
207#endif
208
209
210#ifndef COMPILE_ALL_CPP
211#ifdef __cplusplus
212extern "C" {
213#endif
214#endif
215
216
217/*********************/
218/* */
219/* INCHI ALGORITHM */
220/* */
221/*********************/
222
223#define INCHI_VERSION "1"
224#define INCHI_NAME "InChI"
225#define INCHI_NAM_VER_DELIM "="
226
227#ifdef _WIN32
228#define INCHI_OPTION_PREFX '/'
229#define INCHI_PATH_DELIM '\\'
230#else
231#define INCHI_OPTION_PREFX '-'
232#define INCHI_PATH_DELIM '/'
233#endif
234
235#define INCHI_ALT_OPT_PREFIX '-'
236#define INCHI_ACD_LABS_PREFIX '-'
237
238#define bRELEASE_VERSION 1 /* 1=> release version; comment out to disable */
239#ifndef bRELEASE_VERSION
240#define bRELEASE_VERSION 0 /* 0=> debug version */
241#endif
242
243/*#define RELEASE_IS_FINAL 0*/ /* 1=> pre-release version; comment out to disable */
244#ifndef RELEASE_IS_FINAL
245#define RELEASE_IS_FINAL 1 /* final release */
246#endif
247
248/* display (non-canonical) c-groups, display orig at numbers */
249#if ( bRELEASE_VERSION == 1 )
250#define DISPLAY_DEBUG_DATA_C_POINT 0 /* disabled release version for now */
251#define DISPLAY_ORIG_AT_NUMBERS 1 /* 1 => in an uncanonicalized components display orig. atom numbers (default) */
252#else
253#define DISPLAY_DEBUG_DATA_C_POINT 1 /* debug: 1=>display (non-canonically numbered) c-groups, 0=>do not display */
254#define DISPLAY_ORIG_AT_NUMBERS 1 /* 0 => in an uncanonicalized components display ordering atom numbers (debug) */
255#endif
256
257#if ( DISPLAY_DEBUG_DATA_C_POINT > 0 )
258#define DISPLAY_DEBUG_DATA DISPLAY_DEBUG_DATA_C_POINT
259#endif
260
261
262#define DISPLAY_ZZ_AS_STAR 1
263
264#define COORDINATIVE_BOND 9 /* (@nnuk) introduction of bond_type = 9 (Coordinative Bond) */
265
266
267/* BUG FIXES */
268
269/**************************/
270/* bug fixes in v1.00 */
271/**************************/
272#define FIX_ChCh_STEREO_CANON_BUG 1 /* 1=> (NEEDED) */
273#define ADD_ChCh_STEREO_CANON_CHK 0 /* 1 is NOT needed; let it always be 0 */
274#define FIX_ChCh_CONSTIT_CANON_BUG 1 /* 1=> (NEEDED) */
275#define FIX_EITHER_STEREO_IN_AUX_INFO 1 /* 1=> fix bug: Either stereobond direction in Aux_Info; 0=> do not fix */
276#define FIX_NORM_BUG_ADD_ION_PAIR 1 /* 1=> (NEEDED) fix bug: Miscount number of charges when creating an ion pair */
277#define FIX_REM_PROTON_COUNT_BUG 1 /* 1=> (NEEDED) check for number of actually removed protons and issue an error if mismatch */
278#define FIX_READ_AUX_MEM_LEAK 1
279#define FIX_READ_LONG_LINE_BUG 1 /* 1=> (NEEDED) prevent failure when reading AuxInfo and InChI is too long */
280#define FIX_N_V_METAL_BONDS_GPF 1 /* 1=> (NEEDED) InChI v1 GPF bug fix */
281#define BNS_RAD_SEARCH 1 /* 1=> prevent normalization failures due to radical centers */
282
283/*******************************/
284/* bug fixes in post-v1.00 */
285/*******************************/
286#define FIX_ODD_THINGS_REM_Plus_BUG 0
287#define FIX_N_MINUS_NORN_BUG 0
288#define FIX_CANCEL_CHARGE_COUNT_BUG 0
289#define FIX_2D_STEREO_BORDER_CASE 0
290#define FIX_REM_ION_PAIRS_Si_BUG 0
291#define FIX_STEREO_SCALING_BUG 0
292#define FIX_EMPTY_LAYER_BUG 0
293#define FIX_EITHER_DB_AS_NONSTEREO 0
294#define FIX_BOND23_IN_TAUT 0
295#define FIX_TACN_POSSIBLE_BUG 0
296#define FIX_KEEP_H_ON_NH_ANION 0
297#define FIX_AVOID_ADP 0
298/* may change InChI */
299#define FIX_NUM_TG 0 /* increase number of t-groups for isothiocyanate */
300/* changes InChI for isothiocyanate */
301#define FIX_CPOINT_BOND_CAP2 0
302
303/*******************************/
304/* bug fixes in post-v1.02b */
305/*******************************/
306
307#define FIX_ISO_FIXEDH_BUG 1 /* (2007-09-24) 1=> Fix bug: missing fixed-H iso segment in case of single removed D(+) */
308#define FIX_ISO_FIXEDH_BUG_READ 0 /* (2007-09-24) 1=> Accommodate this InChI bug in reading InChI */
309#define FIX_DALKE_BUGS 1
310#define FIX_TRANSPOSITION_CHARGE_BUG 1 /* (2008-01-02) fix bug that leads to missed charge in some cases when /o is present */
311#define FIX_I2I_STEREOCONVERSION_BUG 1 /* (2008-03-06) 1=> Fix bug of i2i conversion SAbs-->(SRel||Srac) */
312#define FIX_I2I_STEREOCONVERSION_BUG2 1 /* (2008-04-02) 1=> Fix bug of i2i conversion (missed empty /t) */
313#define FIX_I2I_STEREOCONVERSION_BUG3 1 /* (2008-04-10) 1=> Fix bug of i2i conversion */
314 /* (missed repeating /s in FI after F for multi-component case) */
315#define FIX_TERM_H_CHRG_BUG 1 /* (2008-06-06) IPl) */
316 /* fix bug: in some cases (dependent on ordering
317 numbers), moving a charge from terminal H to heavy
318 atom resulted in neutralizing H but not adjusting
319 charge of heavy atom */
320
321#define FIX_AROM_RADICAL 1 /* (2011-05-09) 1=> Fix bug which leads for different InChI */
322 /* on atomic permitations for systems containing radical at */
323 /* atom in aromatic ring */
324
325
326/* Software version 1.07 */
327
328/* INTENTIONALLY DISABLE 1.06 FIXES */
329/*#define DISABLE_106_FIXES 1 */
330
331#ifndef DISABLE_106_FIXES
332
333#define FIX_STEREOCOUNT_ERR 1 /* (2018-01-09) Supplied by DT */
334 /* Fix for InChI Error -30010 (STEREOCOUNT_ERR) */
335 /* appeared on PubChem CIDs 124897603, 124921144 */
336 /* "The failure occurs when one of two or more */
337 /* constitutionally equivalent undefined stereocenters has */
338 /* been removed due to stereo equivalence of its two */
339 /* attachments." */
340
341#define FIX_IMPOSSIBLE_H_ISOTOPE_BUG 1 /* (2018-01-25) Bug reported by Andrew Dalke, inchi-discuss */
342 /* Unrealistic H with mass difference 30 was consumed by */
343 /* InChI and sometimes resulted in memory corruption on */
344 /* accessing array of len == NUM_H_ISOTOPES that is 3. */
345
346#define FIX_OLEAN_SPIRO_CHIRALITY_DETECTION_BUG 1
347 /* (2018-05-03) thanks, DT; fix for 'olean spiro chirality' */
348
349
350#define FIX_RENUM_BUG_FOR_CASE_OF_ACIDIC_OH_AT_P_PLUS 1
351 /* Fix renumbering instability for case of acidic group */
352 /* near charged P and some other heteroatoms */
353
354
355
356
357
358/* Fixing issues reported by "Google Autofuzz project" and CURE53 */
359
360/* internal v. 1.051, September 2019 */
361#define CHECK_STRTOL_ATNUMB 1
362#define DISABLE_READ_COMPRESSED_INCHI 1
363#define FIX_GAF_2019_1 1
364#define FIX_GAF_2019_2 1
365
366/* v. 1.06 October 2023 */
367/* Sep-Dec 2020 Fixed oss-fuzz issues:
368 25604 25607 25609 25618 25726 25727 25728 25730 25731 25735
369 25736 25737 25741 25830 25835 26514 27901 27903 27905
370 Thanks to google/oss-fuzz for detecting and reporting the issues
371 */
372
373#define FIX_GAF_2020_GENERIC 1
374#define FIX_OSS_FUZZ_25604 1
375#define FIX_GAF_2020_25607 1
376#define FIX_GAF_2020_25726 1
377#define FIX_GAF_2020_25741 1
378
379/* v. 1.061 August 2021 */
380#define FIX_OSS_FUZZ_30162_30343 1
381#define FIX_OSS_FUZZ_25734_28139 1
382
383/* internal v. 1.052, January 2020 */
384/* Thanks to CURE53 for detecting and reporting the issues */
385#define FIX_CURE53_ISSUE_OOB_ALREADY_HAVE_THIS_MESSAGE 1
386#define FIX_CURE53_ISSUE_HEAP_BUFFER_OVERFLOW_INCHITOINPATOM 1
387#define FIX_CURE53_ISSUE_NULL_DEREFERENCE_MAKE_A_COPY_OF_T_GROUP_INFO 1
388 /* NB: NO NEED IN FIX FOR CURE53 ISSUE
389 'stack_buffer_overflow__mark_alt_bonds_and_taut_groups'
390 AS IT IS COVERED BY ALREADY DEFINED
391 FIX_CURE53_ISSUE_NULL_DEREFERENCE_MAKE_A_COPY_OF_T_GROUP_INFO
392 */
393#define FIX_GAF_2019_3 1
394#define FIX_ONE_LINE_INCHI_INPUT_CONVERSION_ISSUE 1
395#endif
396
397#define ALLOW_EMPTY_INCHI_AS_INPUT 1 /* Allow "InChI=1//" and standard/beta analogues in input */
398
399
400#if ( !defined(TARGET_API_LIB) && !defined(TARGET_EXE_USING_API) )
401#define I2S_MODIFY_OUTPUT 1 /* 1=> Allow various InChI2InChI output types from cInChI */
402#else
403#define I2S_MODIFY_OUTPUT 0 /* 0=> Always */
404#endif
405
406
407#define FIX_NP_MINUS_BUG 1 /* 2010-03-11 DT Fix for bug reported by Timo Boehme */
408 /* in normalization procedure for some structures containing N2(+) fragment */
409 /* which may result in producing different InChI strings for the same */
410 /* molecule, depending on original order of the atomic numbers */
411
412/**************************/
413/* additions to v1.00 */
414/**************************/
415#define FIX_ADJ_RAD 0
416
417#define SDF_OUTPUT_V2000 1 /* 1=>always output V2000 SDfile, 0=>only if needed */
418#define SDF_OUTPUT_DT 1 /* 1=> all option -SdfAtomsDT to output D and T into SDfile */
419#define CHECK_AROMBOND2ALT 1 /* 1=> check whether arom->alt bond conversion succeeded */
420
421#define READ_INCHI_STRING 1 /* 1=> input InChI string and process it */
422#if 0
423#ifdef TARGET_LIB_FOR_WINCHI
424#define READ_INCHI_STRING 0 /* 1=> input InChI string and process it */
425#else
426#define READ_INCHI_STRING 1 /* 1=> input InChI string and process it */
427#endif
428#endif
429
430/****************************************************/
431/* disabled extra external calls to InChI algorithm */
432/****************************************************/
433#define INCLUDE_NORMALIZATION_ENTRY_POINT 0
434
435/**************************/
436/* Normalization settings */
437/**************************/
438
439/* post version 1 features */
440#define KETO_ENOL_TAUT 1 /* include keto-enol tautomerism */
441#define TAUT_15_NON_RING 1 /* 1,5 tautomerism with endpoints not in ring */
442
443#define TAUT_PT_22_00 1 /* tautomerism rule PT_22_00 */
444#define TAUT_PT_16_00 1 /* tautomerism rule PT_16_00 */
445#define TAUT_PT_06_00 1 /* tautomerism rule PT_06_00 */
446#define TAUT_PT_39_00 1 /* tautomerism rule PT_39_00 */
447#define TAUT_PT_13_00 1 /* tautomerism rule PT_13_00 */
448#define TAUT_PT_18_00 1 /* tautomerism rule PT_18_00 */
449
450#ifdef BUILD_WITH_ENG_OPTIONS
451#define UNDERIVATIZE 1 /* split to possible underivatized fragments */
452#define RING2CHAIN 1 /* open rings R-C(-OH)-O-R => R-C(=O) OH-R */
453#endif
454
455
456#if( UNDERIVATIZE == 1 )
457#define UNDERIVATIZE_REPORT 1 /* if SdfValue found, add to SdfValue a list of removed deriv. agents */
458
459#define FIX_UNDERIV_TO_SDF /* prevent bond normalization if underivatization result goes to SDF 2013-05-10 DCh */
460
461#if 0
462/*commented out 2019-08-20 as this switch caused several thousands changed InChI's for PubChem Substance (280M records) due to
463[falsely] detected stereos in boranes, etc. e.g. 431803, 7890546,
464*/
465#define ALLOW_NO_CHARGE_ON_STEREO_CENTERS /* do not require (+) on >N< for stereo, etc -- NIST output specific */
466#endif
467
468/*#define UNDERIV_SYLYL_ONLY */ /* Underiv: special case: recognize Sylyl derivatives only; typically commented out */
469
470 /* derivatives selection begin */
471
472 /* begin disabled derivatizations */
473#ifdef NEVER
474 /*#define UNDERIV_ACETATE_CnF2np1*/ /* 1r2c1-3 R-C(=O)-O---CnF2n+1 => R-C(=O)-OH, n=1..3: DERIV_BRIDGE_O - not a derivative */
475 /* Methyltion - 1 */
476#define UNDERIV_ACETATE_Me /* 1r1c3 R-C(=O)-O---Me (RCOO_Me) => R-C(=O)-OH: DERIV_BRIDGE_O */
477 /* Ethylation -1 */
478#define UNDERIV_ACETATE_Et /* 1r1c4 R-C(=O)-O---Et (RCOO_Et) => R-C(=O)-OH: DERIV_BRIDGE_O */
479 /* Propanoate - 3 */
480#define UNDERIV_RN_AcEt /* 2r1c4 R-N(-X)--C(=O)Et => R-N(-X)H: DERIV_BRIDGE_tN, X is not H */
481#define UNDERIV_RNH_AcEt /* 2r1c4 R-NH--C(=O)Et => R-NH2: DERIV_BRIDGE_NH */
482#define UNDERIV_RO_COX_Et /* 3r1c4 RO-C(=O)Et => ROH: create alcohols from acetates DERIV_RO_COX */
483#endif /* NEVER */
484 /* end disabled */
485
486 /* Acetate - 3 */
487#define UNDERIV_RN_AcMe /* 2r1c3 R-N(-X)--C(=O)Me => R-N(-X)H: DERIV_BRIDGE_tN, X is not H */
488#define UNDERIV_RNH_AcMe /* 2r1c3 R-NH--C(=O)Me => R-NH2: DERIV_BRIDGE_NH */
489#define UNDERIV_RO_COX_Me /* 3r1c1 RO-C(=O)Me => ROH: create alcohols from acetates DERIV_RO_COX */
490 /* Benzoate - 1 */
491#define UNDERIV_RO_COX_BENZOATES /* 3r1c2 create alcohols from benzoates DERIV_RO_COX */
492
493#define UNDERIV_RO_COX_PENTAFLOUROBENZOATES /* 3r1c3 create alcohols from pentafluorobenzoates DERIV_RO_COX -C(=O)C6F5*/
494#define UNDERIV_OOB_nButyl /* 4r2c1 DERIV_RING_O_OUTSIDE_PRECURSOR: 5 at, n-Butyl */
495#define UNDERIV_X_OXIME_TBDMS /* 5r2c3 DERIV_X_OXIME: >C=N--O-TBDMS */
496#define UNDERIV_X_OXIME_TMS /* 5r2c2 DERIV_X_OXIME: >C=N--O-TMS */
497#define UNDERIV_PYRROLIDIDES /* 7r1c1 DERIV_RING2_PRRLDD_OUTSIDE_PRECUR */
498
499 /* derivatives selection end*/
500
501#define UNDERIV_ADD_EXPLICIT_H /* Underiv: add removed explict H after underivatization */
502 /*#define UNDERIV_ADD_D_TO_PRECURSOR */ /* Uncomment to add Deuterium to the precursor struct -- for debugging only */
503 /* search for other Underivatize settings in ichinorm.c, lines ~802-894 */
504#endif /* UNDERIVATIZE == 1 */
505
506
507/* post-2004-04-27 features */
508#define HAL_ACID_H_XCHG 1 /* allow iso H exchange to HX (X=halogen) and H2Y (Y=halcogen) */
509#define CANON_FIXH_TRANS 1 /* produce canonical fixed-H transposition */
510#define STEREO_WEDGE_ONLY 1 /* 1=> only pointed ends stereo bonds define stereo; 0=> both ends */
511
512/* current new (with respect to v1.12 Beta) preprocessing */
513#define REMOVE_ION_PAIRS_EARLY 1 /* 1=> new preprocessing: step 1 before disconnecting metals in fix_odd_things() */
514#define REMOVE_ION_PAIRS_DISC_STRU 1 /* 1=> new post-preprocessing: remove charhes after metal disconnection */
515#define REMOVE_ION_PAIRS_FIX_BONDS 1 /* 1=> step2: set unchangeable bonds around removed ion pairs */
516#define S_VI_O_PLUS_METAL_FIX_BOND 1 /* 1=> count double bond M-O(+)=S as O=S in S(VI) ans S(VIII) fixing bonds */
517#define N_V_STEREOBONDS 1 /* 1=> detect stereobonds incident to N(V); 0 => don't */
518/* for testing */
519#define REMOVE_ION_PAIRS_ORIG_STRU 0 /* 0=> normal mode (default)
520 * 1=> testing mode only: remove ion pairs from the original structure
521 * to save the changes in the output Molfile (/OutputSDF) or AuxInfo
522 * NIP=No Ion Pairs
523 */
524/* salts treatment */
525#define DISCONNECT_SALTS 1 /* 1=>disconnect metal atoms from salts, 0=>dont */ /* djb-rwth: default 1 */
526#define TEST_REMOVE_S_ATOMS 1 /* 1=>default: after merging into one group test &
527 * remove unreachable,
528 * 0=> old version: test only before merging into one t-group */
529#define CHARGED_SALTS_ONLY 1 /* 1=>(default)do not test far salts tautomerism if
530 * no negative charge(s) present */
531#define BNS_PROTECT_FROM_TAUT 1 /* 1=> do not allow testing of bonds to acetyl or nitro */
532#define BNS_MARK_EDGE_2_DISCONNECT 1 /* 1=> mark edge as temp forbidden instead of disconnection */
534#define REPLACE_ALT_WITH_TAUT 1 /* 1 => replace alt bonds with tautomeric bonds in case of standard t-groups */
535#define MOVE_CHARGES 1 /* 1 => take moveable charges into account */
536#define NEUTRALIZE_ENDPOINTS 1 /* 1 => before checking whether an H is moveable make 2 endpoints neutral */
537 /* implemented only if CHECK_TG_ALT_PATH = 0, defined in ichi_bns.c */
538#define FIX_H_CHECKING_TAUT 1 /* 1 => Fix moveable H or (-) before checking if taut. exchange is possible */
539#define ALWAYS_ADD_TG_ON_THE_FLY 1 /* 1 => disables radical calcellation by taut-charge movement */
540#define IGNORE_SINGLE_ENDPOINTS 1 /* 1 => see FindAccessibleEndPoints() in INChITaut.c */
541
542/* recently added -- begin */
543#define INCL_NON_SALT_CANDIDATATES 1 /* 1=> allow H and (-) migrate between "acidic" O and
544 * other possible endpoints */
545#define SALT_WITH_PROTONS 1 /* 1=> (new new) include proton migrarion C-SH, =C-OH, NH+ */
546#define OPPOSITE_CHARGE_IN_CGROUP 1 /* 1=> allow N(-) in (+) c-group, 0=> disallow */
547#define MOVE_PPLUS_TO_REMOVE_PROTONS 0 /* 0=> default; 1=> (disabled) add P/P+ charge group during
548 * 'hard' proton removal */
549#define ADD_MOVEABLE_O_PLUS 1 /* 1=> allow charges on O(+) to move */
550/* recently added -- end */
551
552#define DISCONNECT_METALS 1 /* make main layer disconnected */ /* djb-rwth: default 1 */
553#define RECONNECT_METALS 0 /* 1=> by default add reconnected layer in case of coord.
554 * compound disconnection */ /* djb-rwth: default 0 */
555#define CHECK_METAL_VALENCE 0 /* 1=> disconnect only metals that have abnormal valence */
556#define bREUSE_INCHI 1 /* 1=> do not recalulate INChI for components in reconnected
557 * structure that are same as in the connected one */
558#define OUTPUT_CONNECTED_METAL_ONLY 0 /* 0=> default; 1 => (debug) create only reconnected or
559 * initial struct. output */
560#define EMBED_REC_METALS_INCHI 1 /* 1=> (default) output Reconnected embedded in Disconnected INChI;
561 * 0=> separate output */
563#define bOUTPUT_ONE_STRUCT_TIME 1 /* 1 => output each structure time (non-release only) */
565
566
567/* constants and array sizes */
569#define INCHI_NUM 2 /* = array size; member indexes: */
570#define INCHI_BAS 0 /* 0 => disconnected or normal */
571#define INCHI_REC 1 /* 1 => reconnected */
572
573#define TAUT_NUM 2 /* = array size; member indexes: */
574#define TAUT_NON 0 /* 0 => normal structure */
575#define TAUT_YES 1 /* 1 => tautomeric */
576#define TAUT_INI 2 /* 2 => intermediate tautomeric structure */
577#define ALT_TAUT(X) ((X)>TAUT_YES? TAUT_YES : 1-(X)) /* was (1-(X)) */
579/* INChI output modes */
580#define OUT_N1 0 /* non-tautomeric only */
581#define OUT_T1 1 /* tautomeric if present otherwise non-tautomeric */
582#define OUT_NT 2 /* only non-taut representations of tautomeric */
583#define OUT_TN 3 /* tautomeric if present otherwise non-tautomeric;
584 separately output non-taut representations of tautomeric if present */
585#define OUT_NN 4 /* only non-taut representations: non-taut else tautomeric */
587/* OUT_TN = OUT_T1 + OUT_NT */
589/* stereo */
591#define NEW_STEREOCENTER_CHECK 1 /* 1 => add new stereocenter categories (see bCanInpAtomBeAStereoCenter(...)) */
592#define MIN_SB_RING_SIZE 8 /* do not assume stereo bonds in rings containing 3..MIN_SB_RING_SIZE-1 atoms */
594#define REMOVE_KNOWN_NONSTEREO 1 /* 1=> check in advance known stereo to remove parities from non-stereogenic elements */
595#define REMOVE_CALC_NONSTEREO 1 /* 1=> check new stereo numberings to remove parities from non-stereogenic elements */
596#define PROPAGATE_ILL_DEF_STEREO 1 /* 1=> if at least one of the pair of constitutionally identical (far) neighbors */
597 /* (of the tested atom) has ill-defined stereo parity and another has any */
598 /* stereo parity then set the parity of the tested atom to ill-defined value. */
600#define ONLY_DOUBLE_BOND_STEREO 0 /* 1=> no alt bond stereo, no taut. bond attachment to stereo bond */
601 /* 0=> allow other definitions (below) to be active */
602#define ONE_BAD_SB_NEIGHBOR 1 /* 1 => allow 1 "bad" bond type neighbor to a stereobond atom. 2004-06-02 */
604#define ENH_STEREO_DICT_SIZE 100 /* 100 => size of the dictionary for enhanced stereo */
606/* more stereo settings */
607#define BREAK_ONE_MORE_SC_TIE 1 /* break one more tie when comparing possible stereocenter neighbors */
608#define BREAK_ALSO_NEIGH_TIE 0 /* post 1.12Beta 2004-08-20: if fixed neighbor has equ neighbors, fix the one with smaller canon. rank */
609#define BREAK_ALSO_NEIGH_TIE_ROTATE 1 /* post 1.12Beta 2004-09-02: break the second in 2nd psition; 1 works, 0 does not (example:MFCD01085607) */
610
611#define STEREO_CENTER_BONDS_NORM 1 /* set length of the bonds around a stereocenter = 1 before getting the parity */
612#define STEREO_CENTER_BOND4_NORM 0 /* set length of the added bond around a stereocenter = 1 before getting the parity */
613#define NORMALIZE_INP_COORD 0 /* 0=>keep unchanged, 1 => make atom coordinates integer by normalizing to avg bond len 20 */
614
615/* recent stereo */
616#define STEREO_WEDGE_ONLY 1 /* 1=> only pointed ends stereo bonds define stereo; 0=> both ends 1.12Beta */
617#define CHECK_C2v_S4_SYMM 0 /* post-1.12Beta 1=> check if a stereocenter has C2v or S4 symmetry; 0=>old mode */
618
619#define EQL_H_NUM_TOGETHER 1 /* 1=> output 1-3,5H2 intead of 1-3H2,5H2 (CT_MODE_EQL_H_TOGETHER) */
620#define ABC_CT_NUM_CLOSURES 1 /* 1=> in coinnections compressed format output decimal number of closures instead of '-' */
622/* temporary fix */
623#define SINGLET_IS_TRIPLET 1 /* 'singlet' means two electrons make a lone pair instead of 2 bonds
624 its effect on valence is same as the effect of a triplet */
626/* defug: find structures where canonical partition is different from equitable */
627#define FIND_CANON_NE_EQUITABLE 0 /* 0=>normal mode */
628 /* 1=> extract (set EXTR_FLAGS = (EXTR_CANON_NE_EQUITABLE)*/
629 /* set cmd line options: /onlynonTAUT /: /UNCHARGEDACIDS:1 /DISCONSALT:0 /MOVEPOS:0 /DISCONMETAL:0 */
631/* Debug: definitions for the extraction of the structures to the problem file */
633/* definition of the flags for structure extraction to the
634 problem file (for debugging and non-standard searching) */
635#define EXTR_KNOWN_USED_TO_REMOVE_PARITY 0x000001
636#define EXTR_CALC_USED_TO_REMOVE_PARITY 0x000002
637#define EXTR_2EQL2CENTER_TO_REMOVE_PARITY 0x000004
638#define EXTR_HAS_ATOM_WITH_DEFINED_PARITY 0x000008
639#define EXTR_REMOVE_PARITY_WARNING 0x000010
640#define EXTR_SALT_WAS_DISCONNECTED 0x000020
641#define EXTR_SALT_PROTON_MOVED 0x000040
642#define EXTR_SALT_PROTON_MOVE_ERR_WARN 0x000080
643#define EXTR_METAL_WAS_DISCONNECTED 0x000100
644#define EXTR_METAL_WAS_NOT_DISCONNECTED 0x000200
645#define EXTR_NON_TRIVIAL_STEREO 0x000400 /* (Inv != Abs stereo) && (parities can't be obtained by inverting them) */
646#define EXTR_UNUSUAL_VALENCES 0x000800
647#define EXTR_HAS_METAL_ATOM 0x001000
648#define EXTR_TEST_TAUT3_SALTS_DONE 0x002000 /* non-oxygen t-points used to discover tautomerism of merged t-groups */
649#define EXTR_CANON_NE_EQUITABLE 0x004000 /* find structures where canonical partition is different from equitable */
650#define EXTR_HAS_PROTON_PN 0x008000 /* has movable H+ attached to N or P */
651#define EXTR_HAS_FEATURE 0x010000 /* found a feature */
652#define EXTR_TAUT_TREATMENT_CHARGES 0x020000 /* tautomeric treatment of charges */
653#define EXTR_TRANSPOSITION_EXAMPLES 0x040000 /* extract structures that have different mobile-H and fixed-H orders */
655/* define conditions of structure extraction to the problem file */
656#define EXTR_MASK 0 /*EXTR_TAUT_TREATMENT_CHARGES*/ /*(EXTR_HAS_FEATURE)*/ /*(EXTR_UNUSUAL_VALENCES | EXTR_HAS_METAL_ATOM)*/ /* 0 to disable */
657#define EXTR_FLAGS 0 /*EXTR_TAUT_TREATMENT_CHARGES*/ /*(EXTR_HAS_FEATURE)*/ /*(EXTR_HAS_PROTON_PN)*/ /*(EXTR_UNUSUAL_VALENCES)*/ /*(EXTR_CANON_NE_EQUITABLE)*/ /*(EXTR_TEST_TAUT3_SALTS_DONE)*/ /*(EXTR_HAS_METAL_ATOM)*/ /* (EXTR_NON_TRIVIAL_STEREO)*/ /*(EXTR_METAL_WAS_DISCONNECTED)*/ /* (EXTR_REMOVE_PARITY_WARNING)*/ /*(EXTR_HAS_ATOM_WITH_DEFINED_PARITY) */
659
660
661/* added tautomeric structures */
663#define TAUT_TROPOLONE_7 1 /* 1=> tautomeric 7-member rings ON */
664#define TAUT_TROPOLONE_5 1 /* 1=> taut. similar to tropolone, 5-member ring */
665#define TAUT_4PYRIDINOL_RINGS 1 /* 1=> OH-C5H4N rings tautomerism */
666#define TAUT_PYRAZOLE_RINGS 1 /* 1=> tautomerizm in pyrazole rings */
667/* limitation on tautomerism detection: */
668#define TAUT_IGNORE_EQL_ENDPOINTS 0 /* 0=> even though 2 endpoints belong to same t-group check
669 them to find more alt bonds (new)
670 1=> ignore and do not check (old mode) */
671#define TAUT_RINGS_ATTACH_CHAIN 1 /* 1=> allow only chain attachments to tautomeric endpoints */
672 /* (except pyrazole, where is no tautomeric attachment) */
673 /* 0=> allow taut. attachments from same ring system. Default=1 */
674
675#define FIND_RING_SYSTEMS 1 /* 1 => find and mark ring systems, blocks, cut-vertices */
676 /* Needed for 5- and 6-member ring tautomers and in other places */
677
678#define FIND_RINS_SYSTEMS_DISTANCES 0 /* 1 => find ring system and atom distance from terminal */
679#define USE_DISTANCES_FOR_RANKING 0 /* 1 => rank ring systems according to distances from terminal */
680
681#define DISPLAY_RING_SYSTEMS 0 /* 1 => for debug only; displays: */
682 /* "block no"/"ring system no"/"cut-vertex (num. intersecting blocks-1)" */
683 /* instead of ranks */
684/* consistency */
685
686#if ( bRELEASE_VERSION==1 && bOUTPUT_ONE_STRUCT_TIME==1)
687#undef bOUTPUT_ONE_STRUCT_TIME
688#define bOUTPUT_ONE_STRUCT_TIME 0
689#endif
690
691/* consistency: bRELEASE_VERSION==1 needs FIND_RING_SYSTEMS=1 */
692#if ( bRELEASE_VERSION==1 && FIND_RING_SYSTEMS!=1 )
693#ifdef FIND_RING_SYSTEMS
694#undef FIND_RING_SYSTEMS
695#endif
696#define FIND_RING_SYSTEMS 1
697#endif
698
699/* consistency: FIND_RINS_SYSTEMS_DISTANCES needs FIND_RING_SYSTEMS */
700#if ( FIND_RING_SYSTEMS != 1 )
701
702#if ( FIND_RINS_SYSTEMS_DISTANCES == 1 )
703#undef FIND_RINS_SYSTEMS_DISTANCES
704#define FIND_RINS_SYSTEMS_DISTANCES 0
705#endif
706
707#endif
708
709/* consistency: USE_DISTANCES_FOR_RANKING and DISPLAY_RING_SYSTEMS need FIND_RINS_SYSTEMS_DISTANCES */
710#if ( FIND_RINS_SYSTEMS_DISTANCES != 1 )
711
712#if ( USE_DISTANCES_FOR_RANKING == 1 )
713#undef USE_DISTANCES_FOR_RANKING
714#define USE_DISTANCES_FOR_RANKING 0
715#endif
716
717#if ( DISPLAY_RING_SYSTEMS == 1 )
718#undef DISPLAY_RING_SYSTEMS
719#define DISPLAY_RING_SYSTEMS 0
720#endif
722#endif
723
725#if ( FIND_RING_SYSTEMS==1 && (TAUT_TROPOLONE_7==1 || TAUT_TROPOLONE_5==1 || TAUT_4PYRIDINOL_RINGS==1 || TAUT_PYRAZOLE_RINGS) )
726#define TAUT_OTHER 1
727#else
728#define TAUT_OTHER 0
729#endif
730
731#define APPLY_IMPLICIT_H_DOWN_RULE 0 /* 1=> if 3 non-H atoms around stereocenter are in same plane */
732 /* then add "down" hydrogen to obtain sterecenter oparity */
733 /* 0=> Implicit H stereo is unknown if all bonds to 3 non-H atoms */
734 /* are in XY plane */
735#define ALLOW_TAUT_ATTACHMENTS_TO_STEREO_BONDS 1 /* 1=> consider bond in an alternating circuit stereogenic */
736 /* even though it has adjacent tautomeric atom(s) */
737
738#define IGNORE_TGROUP_WITHOUT_H 1 /* ignore tautomeric groups containing charges only */
740#if ( DISCONNECT_SALTS == 1 )
741#define REMOVE_TGROUP_CHARGE 0 /* 0: do not remove charge information from tautomeric groups */
742#else
743#define REMOVE_TGROUP_CHARGE 1 /* 1: remove charge information from tautomeric groups */
744#endif
745
746#if ( REMOVE_TGROUP_CHARGE == 1 )
747#define INCHI_T_NUM_MOVABLE 1
748#else
749#define INCHI_T_NUM_MOVABLE 2
750#endif
752/******************************************/
753/* define canonicalization modes here */
754/******************************************/
756#define USE_AUX_RANKING 1 /* 1=> get auxiliary ranking to accelerate canonicalization of H layers */
757#define USE_AUX_RANKING_ALL 1 /* 1=> include all vertices in CellGetMinNode() selection 0=> only vertices with highest ranks */
759#define USE_ISO_SORT_KEY_HFIXED 0 /* 0=> normal mode: merge isotopic taut H to isotopic atom sorting key in
760 taut H-fixed canonicalization;
761 1=> add one more "string" iso_sort_Hfixed to the canonicalization */
763/************************
764 questionable behavior
765 ************************/
766#define REL_RAC_STEREO_IGN_1_SC 0 /* 1=> drop from InChI sp3 stereo in components that have a single stereocenter */
767 /* 0=> old-old mode (all such sp3 stereo is in the Identifier) */
768/* internal definitions; see also REQ_MODE_BASIC etc in ichi.h */
769#define CMODE_CT 0x000001
770#define CMODE_ISO 0x000002
771#define CMODE_ISO_OUT 0x000004 /* obsolete ? */
772#define CMODE_STEREO 0x000008
773#define CMODE_ISO_STEREO 0x000010
774#define CMODE_TAUT 0x000020
775#define CMODE_NOEQ_STEREO 0x000040 /* 5-24-2002: do not use stereo equivalence to accelerate */
776#define CMODE_REDNDNT_STEREO 0x000080 /* 6-11-2002: do not check for redundant stereo elements */
777#define CMODE_NO_ALT_SBONDS 0x000100 /* 6-14-2002: do not assign stereo to alternating bonds */
778/* new 10-10-2003 */
779#define CMODE_RELATIVE_STEREO 0x000200 /* REL All Relative Stereo */
780#define CMODE_RACEMIC_STEREO 0x000400 /* RAC All Racemic Stereo */
781#define CMODE_SC_IGN_ALL_UU 0x000800 /* IAUSC Ignore stereocenters if All Undef/Unknown */
782#define CMODE_SB_IGN_ALL_UU 0x001000 /* IAUSC Ignore stereobonds if All Undef/Unknown */
783/* end of 10-10-2003 */
784
785/* external definitions */
786#define CANON_MODE_CT (CMODE_CT)
787#define CANON_MODE_TAUT (CMODE_CT|CMODE_TAUT)
788#define CANON_MODE_ISO (CMODE_CT|CMODE_ISO|CMODE_ISO_OUT)
789#define CANON_MODE_STEREO (CMODE_CT|CMODE_STEREO)
790#define CANON_MODE_ISO_STEREO (CMODE_CT|CMODE_ISO|CMODE_ISO_OUT|CMODE_ISO_STEREO)
792#define CANON_MODE_MASK 0x00FF /* used to determine canonicalization mode */
793
794/*************************************************
795 * from d_norm.c
796 */
797
798/* implemented definitions for CT_ATOMID */
799#define CT_ATOMID_DONTINCLUDE 1
800#define CT_ATOMID_IS_INITRANK 2
801#define CT_ATOMID_IS_CURRANK 3
803/***************************************
804 * canonicalization settings I
805 ***************************************/
806
807#define CANON_TAUTOMERS 1 /* 1=> process tautomers */
808#define HYDROGENS_IN_INIT_RANKS 1 /* 1=> include num_H in initial ranking */
810#define DOUBLE_BOND_NEIGH_LIST 0 /* 1 => include double bond neighbor in NeighList 2 times */
811#define INCL_NON_6AROM 1 /* 1 => mark all arom. bonds; 0=>mark arom. bonds only in 6-member rings */
812
813#define CT_SMALLEST /* minimal CT */
814
815#define CT_NEIGH_SMALLER /* in CT, include neighbors with smaller ranks */
816
817#define CT_ATOMID CT_ATOMID_IS_CURRANK /*CT_ATOMID_DONTINCLUDE */
818
819#define CT_NEIGH_INCREASE /* in CT, neighbors ranks increase */
820
821#define USE_SYMMETRY_TO_ACCELERATE 1 /*1 => for fast CT canonicalization, to avoid full enumeration */
822
823/* dependent definitions due to settings */
824
825#ifdef CT_SMALLEST
826#define CT_GREATER_THAN >
827#define CT_INITVALUE ~0
828#define BEST_PARITY 1 /* odd */
829#define WORSE_PARITY 2
830#else
831#define CT_GREATER_THAN <
832#define CT_INITVALUE 0
833#define BEST_PARITY 2 /* even */
834#define WORSE_PARITY 1
835#endif
836
837#ifdef CT_NEIGH_SMALLER
838#define CT_NEIGH_SMALLER_THAN <
839#else
840#define CT_NEIGH_SMALLER_THAN >
841#endif
842
843/* verify corectness of dependent settings */
844#if !defined( CT_ATOMID )
845#error You have to #define CT_ATOMID
846#else
847#if ( defined( CT_ATOMID ) && CT_ATOMID==CT_ATOMID_DONTINCLUDE )
848#error CT_DELIMITER should be #defined if CT_ATOMID is not included
849#endif
850#endif
851
852/***************************************
853 * canonicalization settings II
854 ***************************************/
855/* from extr_ct.h */
856#define ALL_ALT_AS_AROMATIC 1 /* 1 => all altrnate bonds (even in cyclooctateraene) treat as aromatic */
857 /* and set DOUBLE_BOND_NEIGH_LIST = 0 */
858#define ANY_ATOM_IN_ALT_CYCLE 1 /* 1=> accept any atom in alternating bond circuit, 0=>only some */
860#define EXCL_ALL_AROM_BOND_PARITY 0 /* 1 => any arom atom cannot belong to stereo bond. */
861 /* This has presedence over ADD_6MEMB_AROM_BOND_PARITY=1 */
862 /* 0 => include arom bonds parities according to */
863 /* ADD_6MEMB_AROM_BOND_PARITY definition */
864
865#if ( EXCL_ALL_AROM_BOND_PARITY == 0 )
866#define ADD_6MEMB_AROM_BOND_PARITY 1 /* 1 => all arom bonds are stereo bonds */
867 /* 0 => only those arom bonds which do not belong to */
868 /* 6-member arom rings are stereo bonds */
869#else
870#define ADD_6MEMB_AROM_BOND_PARITY 0 /* 0 => standard; 1 => meaningless: ignore parities of non-6-member ring alt. bonds */
871#endif
872
873#define MAX_NUM_STEREO_BONDS 3
874#define MAX_NUM_STEREO_BOND_NEIGH 3
875#define MIN_NUM_STEREO_BOND_NEIGH 2
876
877#define MAX_NUM_STEREO_ATOM_NEIGH 4
878#define STEREO_AT_MARK 8 /* > MAX_NUM_STEREO_BONDS */
879
880#if ( ONLY_DOUBLE_BOND_STEREO == 1 ) /* { */
881
882#ifdef ALLOW_TAUT_ATTACHMENTS_TO_STEREO_BONDS
883#undef ALLOW_TAUT_ATTACHMENTS_TO_STEREO_BONDS
884#define ALLOW_TAUT_ATTACHMENTS_TO_STEREO_BONDS 0
885#endif
886
887#ifdef EXCL_ALL_AROM_BOND_PARITY
888#undef EXCL_ALL_AROM_BOND_PARITY
889#define EXCL_ALL_AROM_BOND_PARITY 1
890#endif
892#ifdef ADD_6MEMB_AROM_BOND_PARITY
893#undef ADD_6MEMB_AROM_BOND_PARITY
894#define ADD_6MEMB_AROM_BOND_PARITY 0
895#endif
896
897#endif /* } ONLY_DOUBLE_BOND_STEREO */
898
899/* dependent definitions due to settings */
900#if ( ALL_ALT_AS_AROMATIC == 1 && DOUBLE_BOND_NEIGH_LIST != 0 )
901#undef DOUBLE_BOND_NEIGH_LIST
902#define DOUBLE_BOND_NEIGH_LIST 0
903#endif
906/*************************************
907 * Drawing
908 */
909
910#define DRAW_AROM_TAUT 1 /* 1=> draw distinct aromatic & tautomer bonds, 0=> don't */
911
912/******************************************************/
913/* C O M M O N D E F I N I T I O N S */
914/******************************************************/
917/* input bTautFlags flags */
918#define TG_FLAG_TEST_TAUT__ATOMS 0x00000001 /* find regular tautomerism */
919#define TG_FLAG_DISCONNECT_SALTS 0x00000002 /* DISCONNECT_SALTS disconnect */
920#define TG_FLAG_TEST_TAUT__SALTS 0x00000004 /* DISCONNECT_SALTS if possible find long-range H/(-) taut. on =C-OH, >C=O */
921#define TG_FLAG_MOVE_POS_CHARGES 0x00000008 /* MOVE_CHARGES allow long-range movement of N(+), P(+) charges */
922#define TG_FLAG_TEST_TAUT2_SALTS 0x00000010 /* TEST_REMOVE_S_ATOMS multi-attachement long-range H/(-) taut. on =C-OH, >C=O */
923#define TG_FLAG_ALLOW_NO_NEGTV_O 0x00000020 /* CHARGED_SALTS_ONLY=0 (debug) find long-range H-only tautomerism on =C-OH, >C=O */
924#define TG_FLAG_MERGE_TAUT_SALTS 0x00000040 /* DISCONNECT_SALTS merge all "salt"-t-groups and other =C-OH into one t-group */
926#define TG_FLAG_ALL_TAUTOMERIC (TG_FLAG_TEST_TAUT__ATOMS| \
927 TG_FLAG_TEST_TAUT__SALTS| \
928 TG_FLAG_TEST_TAUT2_SALTS| \
929 TG_FLAG_MERGE_TAUT_SALTS)
930
931#define TG_FLAG_DISCONNECT_COORD 0x00000080 /* find "coord. centers" and disconnect them */
932#define TG_FLAG_RECONNECT_COORD 0x00000100 /* reconnect disconnected "coord. centers" */
933#define TG_FLAG_CHECK_VALENCE_COORD 0x00000200 /* do not disconnect "coord. centers" with usual valence */
934#define TG_FLAG_MOVE_HPLUS2NEUTR 0x00000400 /* move protons to neutralize */
935#define TG_FLAG_VARIABLE_PROTONS 0x00000800 /* add/remove protons to neutralize */
936#define TG_FLAG_HARD_ADD_REM_PROTONS 0x00001000 /* add/remove protons to neutralize in hard way */
937#define TG_FLAG_POINTED_EDGE_STEREO 0x00002000 /* only pointed edge of stereo bond defines stereo */
938#if ( FIX_ADJ_RAD == 1 )
939#define TG_FLAG_FIX_ADJ_RADICALS 0x00004000 /* remove adjacent radical-doubletes, fix valence */
940#endif
941#define TG_FLAG_PHOSPHINE_STEREO 0x00008000 /* add phosphine sp3 stereo */
942#define TG_FLAG_ARSINE_STEREO 0x00010000 /* add arsine sp3 stereo */
943#define TG_FLAG_H_ALREADY_REMOVED 0x00020000 /* processing structure restored from InChI */
944#define TG_FLAG_FIX_SP3_BUG 0x00040000 /* fix sp3 stereo bug: overlapping 2D stereo bond & coordinate scaling */
946#define TG_FLAG_KETO_ENOL_TAUT 0x00080000 /* turn on keto-enol tautomerism detection */
947#define TG_FLAG_1_5_TAUT 0x00100000 /* turn on 1,5 tautomerism detection */
949/* FB2 */
950#define TG_FLAG_FIX_ISO_FIXEDH_BUG 0x00200000 /* fix bug found after v.102b (isotopic H representation) */
951#define TG_FLAG_FIX_TERM_H_CHRG_BUG 0x00400000 /* fix bug found after v.102b (moving H charge in 'remove_terminal_HDT') */
953#define TG_FLAG_PT_22_00 0x00800000
954#define TG_FLAG_PT_16_00 0x01000000
955#define TG_FLAG_PT_06_00 0x02000000
956#define TG_FLAG_PT_39_00 0x04000000
957#define TG_FLAG_PT_13_00 0x08000000
958#define TG_FLAG_PT_18_00 0x10000000
960/* output bTautFlags flags */
962#define TG_FLAG_MOVE_HPLUS2NEUTR_DONE 0x00000001 /* protons have been moved to neutralize */
963#define TG_FLAG_TEST_TAUT__ATOMS_DONE 0x00000002
964#define TG_FLAG_DISCONNECT_SALTS_DONE 0x00000004
965#define TG_FLAG_TEST_TAUT__SALTS_DONE 0x00000008 /* multiple H tautomerism */
966#define TG_FLAG_MOVE_POS_CHARGES_DONE 0x00000010
967#define TG_FLAG_TEST_TAUT2_SALTS_DONE 0x00000020 /* merged t-groups */
968#define TG_FLAG_ALLOW_NO_NEGTV_O_DONE 0x00000040
969#define TG_FLAG_MERGE_TAUT_SALTS_DONE 0x00000080 /* added non-taut O to taut groups */
971#define TG_FLAG_ALL_SALT_DONE (TG_FLAG_TEST_TAUT__SALTS_DONE | \
972 TG_FLAG_TEST_TAUT2_SALTS_DONE | \
973 TG_FLAG_MERGE_TAUT_SALTS_DONE )
974
975#define TG_FLAG_DISCONNECT_COORD_DONE 0x00000100 /* found and disconnected "coord. centers" */
976#define TG_FLAG_CHECK_VALENCE_COORD_DONE 0x00000200 /* did not disconnect "coord. centers" with usual valence */
977#define TG_FLAG_MOVE_CHARGE_COORD_DONE 0x00000400 /* changed charge of a disconnected ligand to fit its valence */
978#define TG_FLAG_FIX_ODD_THINGS_DONE 0x00000800 /* fixed drawing ambiguities in fix_odd_things */
979#define TG_FLAG_TEST_TAUT3_SALTS_DONE 0x00001000 /* merged t-groups + non-O taut atoms */
980#define TG_FLAG_FOUND_SALT_CHARGES_DONE 0x00002000 /* not assigned: preprocessing detected possibility of salt-type tautomerism */
981#define TG_FLAG_FOUND_ISOTOPIC_H_DONE 0x00004000 /* preprocessing detected isotopic H on "good" heteroatoms or isotopic H(+) */
982#define TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE 0x00008000 /* preprocessing detected isotopic H on "good" heteroatoms or isotopic H(+) */
983#if ( FIX_ADJ_RAD == 1 )
984#define TG_FLAG_FIX_ADJ_RADICALS_DONE 0x00010000
985#endif
987#if ( READ_INCHI_STRING == 1 )
988#define READ_INCHI_OUTPUT_INCHI 0x00000001
989#define READ_INCHI_SPLIT_OUTPUT 0x00000002
990#define READ_INCHI_KEEP_BALANCE_P 0x00000004
991#define READ_INCHI_TO_STRUCTURE 0x00000008
992#endif
993
997/*********/
998/* */
999/* I/O */
1000/* */
1001/*********/
1003 typedef struct tagOutputString
1004 {
1005 char *pStr;
1006 int nAllocatedLength;
1007 int nUsedLength;
1008 int nPtr; /* expansion increment */
1010
1011
1012 /* INCHI_IOSTREAM.type values */
1013#define INCHI_IOS_TYPE_NONE 0
1014#define INCHI_IOS_TYPE_STRING 1
1015#define INCHI_IOS_TYPE_FILE 2
1016
1017 typedef struct tagOutputStream
1018 {
1019 INCHI_IOS_STRING s; /* output is directed either to resizable string buffer s */
1020 FILE *f; /* or to the plain file: */
1021 int type; /* dependent on type */
1023
1024
1025
1027 /***********/
1028 /* */
1029 /* DEBUG */
1030 /* */
1031 /***********/
1032
1033#if ( defined(_WIN32) && defined(_DEBUG) && defined(_MSC_VER) /*&& !defined(COMPILE_ANSI_ONLY)*/ )
1034/* debug: memory leaks tracking */
1035#ifndef TARGET_LIB_FOR_WINCHI
1036#ifndef DO_NOT_TRACE_MEMORY_LEAKS
1037#define TRACE_MEMORY_LEAKS 1 /* 1=>trace, 0 => do not trace (Debug only) */
1038#else
1039#define TRACE_MEMORY_LEAKS 0
1040#endif
1041#else
1042#define TRACE_MEMORY_LEAKS 1 /* 1=>trace, **ALWAYS** =1 for TARGET_LIB_FOR_WINCHI */
1043#endif
1044#else /* not MSC and not Debug */
1045#define TRACE_MEMORY_LEAKS 0 /* 0: do not change */
1046#endif
1047
1048
1049/* memory leaks tracking */
1050#define INCHI_HEAPCHK /* default: no explicit heap checking during the execution */
1051
1052#if ( TRACE_MEMORY_LEAKS == 1 )
1053#ifdef _DEBUG
1054
1055#define inchi_malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
1056#define inchi_calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
1057#define inchi_realloc(d, s) _realloc_dbg(d, s, _NORMAL_BLOCK, __FILE__, __LINE__)
1058#define inchi_free(p) _free_dbg(p, _NORMAL_BLOCK)
1059
1060#ifdef TARGET_EXE_USING_API
1061/* INChI_MAIN specific */
1062#define e_inchi_malloc(a) inchi_malloc(a)
1063#define e_inchi_calloc(a,b) inchi_calloc(a,b)
1064#define e_inchi_realloc(a,b) inchi_realloc(a,b)
1065#define e_inchi_free(a) inchi_free(a)
1066#endif
1067
1068/*#define _CRTDBG_MAP_ALLOC*/ /* standard VC++ tool -- does not work with inchi_malloc(), etc */
1069
1070#include <crtdbg.h>
1071
1072/* to enable heap checking: #define CHECK_WIN32_VC_HEAP above #include "mode.h" in each source file or here */
1073#ifdef CHECK_WIN32_VC_HEAP
1074/* -- Confirms the integrity of the memory blocks allocated in the debug heap -- */
1075#undef INCHI_HEAPCHK
1076#define INCHI_HEAPCHK \
1077do { \
1078 int tmp = _crtDbgFlag; \
1079 _crtDbgFlag |= _CRTDBG_ALLOC_MEM_DF; \
1080 _ASSERT( _CrtCheckMemory( ) ); \
1081 _crtDbgFlag = tmp; \
1082} while(0);
1083
1084/* -- less thorough than _CrtCheckMemory() check: check minimal consistency of the heap -- */
1085/*
1086#include <malloc.h>
1087#define INCHI_HEAPCHK \
1088do {\
1089 int heapstatus = _heapchk(); \
1090 _ASSERT( heapstatus != _HEAPBADBEGIN && heapstatus != _HEAPBADNODE && heapstatus != _HEAPBADPTR); \
1091} while(0);
1092*/
1093#endif
1094
1095#else
1096#undef TRACE_MEMORY_LEAKS
1097#define TRACE_MEMORY_LEAKS 0
1098#endif /* _DEBUG */
1099#endif /* TRACE_MEMORY_LEAKS */
1100
1101
1102
1103/***********/
1104/* */
1105/* ALLOC */
1106/* */
1107/***********/
1108
1109/* djb-rwth: fixing GH issue #89 */
1110#ifdef TARGET_EXE_USING_API
1111/* INChI_MAIN specific */
1112#ifndef inchi_malloc
1113#define inchi_malloc e_inchi_malloc
1114#endif
1115#ifndef inchi_calloc
1116#define inchi_calloc e_inchi_calloc
1117#endif
1118#ifndef inchi_realloc
1119#define inchi_realloc e_inchi_realloc
1120#endif
1121#ifndef inchi_free
1122#define inchi_free e_inchi_free
1123#endif
1124
1125#ifndef e_inchi_malloc
1126#define e_inchi_malloc malloc
1127#endif
1128#ifndef e_inchi_calloc
1129#define e_inchi_calloc calloc
1130#endif
1131#ifndef e_inchi_realloc
1132#define e_inchi_realloc realloc
1133#endif
1134#ifndef e_inchi_free
1135#define e_inchi_free(X) do{ if(X) free(X); }while(0)
1136#endif
1138#else /* not TARGET_EXE_USING_API */
1139
1140#ifndef inchi_malloc
1141#define inchi_malloc malloc
1142#endif
1143#ifndef inchi_calloc
1144#define inchi_calloc calloc
1145#endif
1146#ifndef inchi_realloc
1147#define inchi_realloc realloc
1148#endif
1149#ifndef inchi_free
1150#define inchi_free(X) do{ if(X) free(X); }while(0)
1151#endif
1153#endif /* TARGET_EXE_USING_API */
1154
1155/* allocation/deallocation */
1156#define USE_ALLOCA 0
1157
1158#if ( USE_ALLOCA == 1 )
1159#define qmalloc(X) _alloca(X)
1160#define qfree(X) do{(X)=NULL;}while(0)
1161#else
1162#define qmalloc(X) inchi_malloc(X)
1163#define qfree(X) do{if(X){inchi_free(X);(X)=NULL;}}while(0)
1164#endif
1165
1166#if ( defined(_MSC_VER) && _MSC_VER >= 800 )
1167#define fast_alloc(X) _alloca(X)
1168#define fast_free(X)
1169#else
1170#define fast_alloc(X) inchi_malloc(X)
1171#define fast_free(X) inchi_free(X)
1172#endif
1173
1174#define qzfree(X) do{if(X){inchi_free(X);(X)=NULL;}}while(0)
1175
1176/* rellocation */
1177/* djb-rwth: avoiding memory leaks */
1178#define MYREALLOC2(PTRTYPE1, PTRTYPE2, PTR1, PTR2, LEN1, LEN2, ERR) \
1179 do { \
1180 if( (LEN1) <= (LEN2) ) {\
1181 PTRTYPE1 * newPTR1 = (PTRTYPE1 *)inchi_calloc( (LEN2)+1, sizeof(PTRTYPE1) );\
1182 PTRTYPE2 * newPTR2 = (PTRTYPE2 *)inchi_calloc( (LEN2)+1, sizeof(PTRTYPE2) );\
1183 if ( newPTR1 && newPTR2 ) { \
1184 if ( (PTR1) && (LEN1) > 0 ) \
1185 (memcpy) ( newPTR1, (PTR1), (LEN1) * sizeof(PTRTYPE1) ); \
1186 if ( (PTR2) && (LEN1) > 0 ) \
1187 (memcpy) ( newPTR2, (PTR2), (LEN1) * sizeof(PTRTYPE2) ); \
1188 if ( PTR1 ) \
1189 inchi_free(PTR1); \
1190 if ( PTR2 ) \
1191 inchi_free(PTR2); \
1192 (PTR1) = newPTR1; \
1193 (PTR2) = newPTR2; \
1194 (LEN1) = (LEN2); \
1195 (ERR) = 0; \
1196 } else { \
1197 inchi_free(newPTR1); \
1198 inchi_free(newPTR2); \
1199 (ERR) = 1; \
1200 } \
1201 } else { (ERR) = 0; } \
1202 } while(0)
1203
1204
1205/* Solely v. 1.06 specific */
1206
1207/* comment out the next line to enable polymeric debug */
1208#define DEBUG_POLYMERS 0
1209#ifndef DEBUG_POLYMERS
1210#define DEBUG_POLYMERS 2
1211#endif
1212
1213#define POLYMERS_NO 0 /* ignore polymers */
1214#define POLYMERS_MODERN 1 /* v. 1.06+ way to treat polymers with Zz */
1215#define POLYMERS_LEGACY 2 /* v. 1.05 mode, no explicit Zz (internally they are here) */
1216#define POLYMERS_LEGACY_PLUS 3 /* v. 1.05 mode with an addition of that in all
1217 frame-shiftable-bistar-CRUs their backbone bonds
1218 are reordered in descending seniority order.
1219 Used as hidden 1st pass in 1.06 treatment */
1220
1221
1222
1223#define STEREO_AT_ZZ 0
1224/* #define STEREO_AT_ZZ 1 */
1225
1226/* Set to 1 and use in engineering mode, if necessary */
1227#define ALLOW_SUBSTRUCTURE_FILTERING 1
1228
1229
1230#ifndef COMPILE_ALL_CPP
1231#ifdef __cplusplus
1232}
1233#endif
1234#endif
1235
1236
1237#endif /* _MODE_H_ */
struct tagOutputStream INCHI_IOSTREAM
struct tagOutputString INCHI_IOS_STRING
Definition mode.h:999
FILE * f
Definition mode.h:1001
INCHI_IOS_STRING s
Definition mode.h:1000
int type
Definition mode.h:1002
Definition mode.h:985
int nPtr
Definition mode.h:989
char * pStr
Definition mode.h:986
int nUsedLength
Definition mode.h:988
int nAllocatedLength
Definition mode.h:987