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