1 /* 2 * International Chemical Identifier (InChI) 3 * Version 1 4 * Software version 1.04 5 * September 9, 2011 6 * 7 * The InChI library and programs are free software developed under the 8 * auspices of the International Union of Pure and Applied Chemistry (IUPAC). 9 * Originally developed at NIST. Modifications and additions by IUPAC 10 * and the InChI Trust. 11 * 12 * IUPAC/InChI-Trust Licence for the International Chemical Identifier (InChI) 13 * Software version 1.0. 14 * Copyright (C) IUPAC and InChI Trust Limited 15 * 16 * This library is free software; you can redistribute it and/or modify it under the 17 * terms of the IUPAC/InChI Trust Licence for the International Chemical Identifier 18 * (InChI) Software version 1.0; either version 1.0 of the License, or 19 * (at your option) any later version. 20 * 21 * This library is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 24 * See the IUPAC/InChI Trust Licence for the International Chemical Identifier (InChI) 25 * Software version 1.0 for more details. 26 * 27 * You should have received a copy of the IUPAC/InChI Trust Licence for the 28 * International Chemical Identifier (InChI) Software version 1.0 along with 29 * this library; if not, write to: 30 * 31 * The InChI Trust 32 * c/o FIZ CHEMIE Berlin 33 * Franklinstrasse 11 34 * 10587 Berlin 35 * GERMANY 36 * 37 */ 38 39 40 #ifndef __INCHI_H__ 41 #define __INCHI_H__ 42 43 #include "incomdef.h" 44 45 #define REQ_MODE_BASIC 0x000001 /* B include Fixed-H layer */ 46 #define REQ_MODE_TAUT 0x000002 /* T include Mobile-H layer */ 47 #define REQ_MODE_ISO 0x000004 /* I */ 48 #define REQ_MODE_NON_ISO 0x000008 /* NI */ 49 #define REQ_MODE_STEREO 0x000010 /* S */ 50 #define REQ_MODE_ISO_STEREO 0x000020 /* IS */ 51 #define REQ_MODE_NOEQ_STEREO 0x000040 /* SS */ 52 #define REQ_MODE_REDNDNT_STEREO 0x000080 /* RS */ 53 #define REQ_MODE_NO_ALT_SBONDS 0x000100 /* NASB */ 54 /* new 10-10-2003 */ 55 #define REQ_MODE_RELATIVE_STEREO 0x000200 /* REL All Relative Stereo */ 56 #define REQ_MODE_RACEMIC_STEREO 0x000400 /* RAC All Racemic Stereo */ 57 #define REQ_MODE_SC_IGN_ALL_UU 0x000800 /* IAUSC Ignore stereocenters if All Undef/Unknown */ 58 #define REQ_MODE_SB_IGN_ALL_UU 0x001000 /* IAUSC Ignore stereobonds if All Undef/Unknown */ 59 #define REQ_MODE_CHIR_FLG_STEREO 0x002000 /* SUCF If Chiral flag then Abs otherwise Rel stereo */ 60 /* end of 10-10-2003 */ 61 62 /*^^^ 2009-12-05 */ 63 #define REQ_MODE_DIFF_UU_STEREO 0x004000 /* SLUUD Make labels for unknown and undefined stereo different */ 64 /*^^^ 2009-12-05 */ 65 #define REQ_MODE_MIN_SB_RING_MASK 0x0F0000 /* RSB */ 66 #define REQ_MODE_MIN_SB_RING_SHFT 16 67 68 #define REQ_MODE_DEFAULT (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO) 69 70 #define WARN_FAILED_STEREO 0x0001 71 #define WARN_FAILED_ISOTOPIC 0x0002 72 #define WARN_FAILED_ISOTOPIC_STEREO 0x0004 73 #define ERR_NO_CANON_RESULTS 0x0008 74 75 /*********** compare components flags **********************************/ 76 #define CMP_COMPONENTS 0x0001 /* perform compare components */ 77 #define CMP_COMPONENTS_NONISO 0x0002 /* ignore isotopic */ 78 #define CMP_COMPONENTS_NONTAUT 0x0004 /* compare non-tautomeric */ 79 /****************** chemical identifier member definitions *************/ 80 typedef struct tagINChI_IsotopicAtom { 81 AT_NUMB nAtomNumber; /* Canonical atom number */ 82 NUM_H nIsoDifference; /* 0=non-isotopic; 1=rounded avg. atomic mass */ 83 NUM_H nNum_H; /* number of 1H isotopic atoms attached */ 84 NUM_H nNum_D; /* number of 2H isotopic atoms attached */ 85 NUM_H nNum_T; /* number of 3H isotopic atoms attached */ 86 } INChI_IsotopicAtom; 87 typedef struct tagINChI_IsotopicTGroup { 88 AT_NUMB nTGroupNumber; /* Tautomeric group number */ 89 AT_NUMB nNum_H; /* number of 1H isotopic atoms */ 90 AT_NUMB nNum_D; /* number of 2H isotopic atoms */ 91 AT_NUMB nNum_T; /* number of 3H isotopic atoms */ 92 } INChI_IsotopicTGroup; 93 typedef struct tagINChI_Stereo { /* [N] = allocated length */ 94 /* ---- possibly tetrahedral stereogenic atoms */ 95 int nNumberOfStereoCenters; 96 AT_NUMB *nNumber; /* Canonical number of a possibly tetrahedral 97 * stereogenic atom or allenes [nNumberOfAtoms] */ 98 S_CHAR *t_parity; /* tetrahedral (relative, see nCompInv2Abs) atom parities [nNumberOfAtoms] */ 99 /* ---- possibly tetrahedral stereogenic atoms of the iverted structure */ 100 AT_NUMB *nNumberInv; /* Canonical number of a possibly tetrahedral 101 * stereogenic atom or allene [nNumberOfAtoms] */ 102 S_CHAR *t_parityInv; /* tetrahedral inverted atom parities [nNumberOfAtoms] */ 103 /* bFlagAbsStereoIsInverted = nCompInv2Abs==-1: Abs stereo = Inverted */ 104 int nCompInv2Abs; /* 0=>Inv = Abs stereo; -1=> Inv < Abs stereo, +1=> Inv > Abs stereo; +2=> in reading InChI: no /m was found and in /sN N>0 */ 105 int bTrivialInv; /* 1=> nCompInv2Abs!= 0 && Inverted = Abs stereo with inverted parities 1<-->2 */ 106 /* ---- possibly stereogenic bonds and tetrahedral cumuleles */ 107 int nNumberOfStereoBonds; 108 AT_NUMB *nBondAtom1; /* Canonical number of a first atom 109 * [number of bonds] */ 110 AT_NUMB *nBondAtom2; /* Canonical number of a second atom 111 * [number of bonds] */ 112 S_CHAR *b_parity; /* possibly stereogenic bond parities 113 * [number of bonds] */ 114 } INChI_Stereo; 115 #define INCHI_FLAG_ACID_TAUT 0x0001 /* tautomerism of dissociated acid invoked */ 116 #define INCHI_FLAG_REL_STEREO 0x0002 /* requested relative stereo */ 117 #define INCHI_FLAG_RAC_STEREO 0x0004 /* requested racemic stereo */ 118 #define INCHI_FLAG_SC_IGN_ALL_UU 0x0008 /* ignored all undefined/unknown stereocenters, non-isotopic */ 119 #define INCHI_FLAG_SB_IGN_ALL_UU 0x0010 /* ignored all undefined/unknown stereocenters, non-isotopic */ 120 #define INCHI_FLAG_SC_IGN_ALL_ISO_UU 0x0020 /* ignored all undefined/unknown stereocenters, isotopic */ 121 #define INCHI_FLAG_SB_IGN_ALL_ISO_UU 0x0040 /* ignored all undefined/unknown stereocenters, isotopic */ 122 #define INCHI_FLAG_HARD_ADD_REM_PROTON 0x0080 /* in normalization a proton has been added or removed along alt path */ 123 124 #define INCHI_OUT_NO_AUX_INFO 0x0001 /* do not output Aux Info */ 125 #define INCHI_OUT_SHORT_AUX_INFO 0x0002 /* output short version of Aux Info */ 126 #define INCHI_OUT_ONLY_AUX_INFO 0x0004 /* output only Aux Info */ 127 #define INCHI_OUT_EMBED_REC 0x0008 /* embed reconnected INChI into disconnected INChI */ 128 #define INCHI_OUT_SDFILE_ONLY 0x0010 /* save input data in a Molfile instead of creating INChI */ 129 #define INCHI_OUT_XML 0x0020 /* output xml INChI */ 130 #define INCHI_OUT_PLAIN_TEXT 0x0040 /* output plain text INChI */ 131 #define INCHI_OUT_PLAIN_TEXT_COMMENTS 0x0080 /* output plain text annotation */ 132 #define INCHI_OUT_XML_TEXT_COMMENTS 0x0100 /* output xml text annotation */ 133 #define INCHI_OUT_WINCHI_WINDOW 0x0200 /* output into wINChI text window */ 134 #define INCHI_OUT_TABBED_OUTPUT 0x0400 /* tab-delimited (only for plain text) */ 135 #define INCHI_OUT_SDFILE_ATOMS_DT 0x0800 /* SDfile output H isotopes as D and T */ 136 #define INCHI_OUT_SDFILE_SPLIT 0x1000 /* Split SDfile into components */ 137 138 #define INCHI_OUT_FIX_TRANSPOSITION_CHARGE_BUG 0x2000 139 /* used to accomodate FIX_TRANSPOSITION_CHARGE_BUG */ 140 141 #define INCHI_OUT_STDINCHI 0x4000 142 #define INCHI_OUT_SAVEOPT 0x8000 143 144 145 /* Bits encoding InChI creation options to be saved */ 146 #define SAVE_OPT_SLUUD 0x0001 147 #define SAVE_OPT_SUU 0x0002 148 #define SAVE_OPT_FIXEDH 0x0004 149 #define SAVE_OPT_RECMET 0x0008 150 #define SAVE_OPT_KET 0x0010 151 #define SAVE_OPT_15T 0x0020 152 153 154 #define INCHI_OUT_PRINT_OPTIONS (INCHI_OUT_EMBED_REC | \ 155 INCHI_OUT_XML | \ 156 INCHI_OUT_PLAIN_TEXT | \ 157 INCHI_OUT_PLAIN_TEXT_COMMENTS | \ 158 INCHI_OUT_XML_TEXT_COMMENTS) 159 160 161 /*******REQ_MODE_SB_IGN_ALL_UU*************** chemical identifier definition *****************/ 162 typedef struct tagINChI { /* [N] = allocated length */ 163 164 int nErrorCode; /* 0 = success */ 165 INCHI_MODE nFlags; /* INCHI_FLAG_ACID_TAUT tautomerism of dissociated acid invoked 166 INCHI_FLAG_REL_STEREO requested relative stereo 167 INCHI_FLAG_RAC_STEREO requested racemic stereo 168 INCHI_FLAG_SC_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic 169 INCHI_FLAG_SB_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic 170 INCHI_FLAG_SC_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic 171 INCHI_FLAG_SB_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic 172 INCHI_FLAG_HARD_ADD_REM_PROTON in normalization a proton has been added or removed along alt path 173 */ 174 /* ---- basic & tautomer layer */ 175 int nTotalCharge; 176 int nNumberOfAtoms; 177 char *szHillFormula; 178 U_CHAR *nAtom; /* atomic numbers [nNumberOfAtoms] from the Periodic Table */ 179 int lenConnTable; 180 AT_NUMB *nConnTable; /* Connection table [nNumberOfAtoms+NumberOfBonds] */ 181 int lenTautomer; 182 AT_NUMB *nTautomer; /* NumGroups; ((NumAt+1, NumH, At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 1} - old 183 * NumGroups; ((NumAt+2, NumH, Num(-), At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 2} - new 184 * Allocated length: [5*nNumberOfAtoms/2+1], see Alloc_INChI(...) */ 185 S_CHAR *nNum_H; /* number of terminal hydrogen atoms on each atom; in tautomeric 186 * representation these H on tautomeric atoms are not included [nNumberOfAtoms] */ 187 S_CHAR *nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms, 188 * in non-atautomeric representation only [nNumberOfAtoms] */ 189 /* ---- isotopic & isotopic tautomeric layer */ 190 int nNumberOfIsotopicAtoms; 191 INChI_IsotopicAtom *IsotopicAtom; /* [nNumberOfIsotopicAtoms] */ 192 int nNumberOfIsotopicTGroups; 193 /* in reversing InChI keeps a pointer to stolen from AuxInfo coordinates */ 194 INChI_IsotopicTGroup *IsotopicTGroup; /* [nNumberOfIsotopicAtoms] */ 195 /* ---- stereo layer */ 196 INChI_Stereo *Stereo; 197 INChI_Stereo *StereoIsotopic; 198 /* not including mobile H groups */ 199 AT_NUMB *nPossibleLocationsOfIsotopicH; /* [0]=> length including 0th element, location1,...*/ 200 int bDeleted; 201 #if ( bREUSE_INCHI == 1 ) 202 int nRefCount; 203 #endif 204 #if ( bRELEASE_VERSION == 0 ) 205 int bExtract; 206 #endif 207 #if ( READ_INCHI_STRING == 1 ) 208 int nLink; /* negative: ignore InChI; positive: index of (Reconnected component) + 1 linked to it */ 209 #endif 210 } INChI; 211 212 typedef INChI *PINChI2[TAUT_NUM]; 213 214 typedef struct tagOrigInfo { 215 S_CHAR cCharge; 216 S_CHAR cRadical; /* 0=none, 1=doublet, 2=triplet, 3=unknown */ 217 S_CHAR cUnusualValence; /* see get_unusual_el_valence() */ 218 } ORIG_INFO; 219 /******************** auxiliary chemical identifier info **************/ 220 typedef struct tagINChI_Aux { /* [N] = allocated length */ 221 222 int nErrorCode; /* 0 = success */ 223 int nNumberOfAtoms; 224 int nNumberOfTGroups; /* non-zero only in tautomeric representation */ 225 int bIsIsotopic; /* filled out even though isotopic has not been requested */ 226 int bIsTautomeric; /* filled out even though tautomeric has not been requested; non-zero if taut exists */ 227 /* canonical numbers of the atoms: nOrigAtNosInCanonOrd[i-1]+1 = */ 228 /* input atom number for the canonical number i */ 229 AT_NUMB *nOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */ 230 AT_NUMB *nIsotopicOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */ 231 /* same for the inverted structure */ 232 AT_NUMB *nOrigAtNosInCanonOrdInv; /* inveterted stereo [nNumberOfInputAtoms*1.5]; */ 233 AT_NUMB *nIsotopicOrigAtNosInCanonOrdInv; /* [nNumberOfInputAtoms*1.5]; */ 234 AT_NUMB *nConstitEquNumbers; /* [nNumberOfAtoms*1.5] */ 235 AT_NUMB *nConstitEquTGroupNumbers; /* [nNumberOfAtoms/2] */ 236 AT_NUMB *nConstitEquIsotopicNumbers; /* [nNumberOfAtoms*1.5] */ 237 AT_NUMB *nConstitEquIsotopicTGroupNumbers; /* [nNumberOfAtoms/2] */ 238 #if ( bREUSE_INCHI == 1 ) 239 int nRefCount; 240 #endif 241 #if ( TEST_RENUMB_ATOMS == 1 ) 242 unsigned long ulNormTime; 243 unsigned long ulCanonTime; 244 #endif 245 246 ORIG_INFO *OrigInfo; 247 MOL_COORD *szOrigCoord; 248 NUM_H nNumRemovedProtons; 249 NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]; /* isotopic H that may be exchanged and considered 250 randomly distributed, including removed protons; 251 order: 0=>1H, 1=>D, 2=>T */ 252 int bDeleted; 253 INCHI_MODE bTautFlags; /* t_group_info->bTautFlags */ 254 INCHI_MODE bTautFlagsDone; /* t_group_info->bTautFlagsDone */ 255 INCHI_MODE bNormalizationFlags; /* t_group_info->tni.bNormalizationFlags */ 256 int nCanonFlags; 257 } INChI_Aux; 258 259 typedef INChI_Aux *PINChI_Aux2[TAUT_NUM]; 260 261 /********************* array of pointers for sorting components and INChI output *********/ 262 typedef struct tagINChIforSort { 263 INChI *pINChI[TAUT_NUM]; 264 INChI_Aux *pINChI_Aux[TAUT_NUM]; 265 short ord_number; /* for stable sort */ 266 short n1; /* points to the original; used in structure reconstruction only */ 267 short n2; /* points to the original; used in structure reconstruction only */ 268 short n3; /* points to the original; used in structure reconstruction only */ 269 }INCHI_SORT; 270 271 #endif /* __INCHI_H__ */ 272