diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichicant.h b/INCHI-1-SRC/INCHI_BASE/src/ichicant.h index ab0ab7d7..77dda61c 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichicant.h +++ b/INCHI-1-SRC/INCHI_BASE/src/ichicant.h @@ -71,17 +71,17 @@ typedef union tagSplitLong { #define U_LONG_LEN 2 #ifndef defined_NEIGH_LIST -typedef AT_RANK *NEIGH_LIST; +typedef AT_RANK* NEIGH_LIST; #define defined_NEIGH_LIST #endif typedef struct tagEQUIV_INFO { int nNumSets; - int *nCutVertexAtom; /* cut-vertex atom for the set of equivalent atoms */ - int *nFirstInSet; /* first of equivalent atoms in the connected to the cut-vertex atom parts of the structure */ - int *nNumInSet; /* number of the equivalent atoms connected to the cut-vertex atom */ - int *nAtomNo; /* eqivalent atom number */ - int *nAddToRank; /* number to add to the rank to normalize */ + int* nCutVertexAtom; /* cut-vertex atom for the set of equivalent atoms */ + int* nFirstInSet; /* first of equivalent atoms in the connected to the cut-vertex atom parts of the structure */ + int* nNumInSet; /* number of the equivalent atoms connected to the cut-vertex atom */ + int* nAtomNo; /* eqivalent atom number */ + int* nAddToRank; /* number to add to the rank to normalize */ } EQUIV_INFO; #define MOL_PART_MASK (~0x0U ^ 0x07U) @@ -92,7 +92,7 @@ typedef struct tagAtData_dch { }AT_DATA; -#define MAXVAL 20 /* maximum valence */ +#define MAXVAL 50 /* maximum valence */ /* @nnuk : Changed from 20 -> 50 for testing purposes, to account for some structures with one atom having more than 20 bonds */ #define ATOM_EL_LEN 6 @@ -141,8 +141,8 @@ typedef struct tagAtomInvariant2 { /******************* Partition **********************************/ typedef struct tagPartition { - AT_RANK *Rank; - AT_NUMB *AtNumber; + AT_RANK* Rank; + AT_NUMB* AtNumber; } Partition; /********************* BFCN *************************************/ @@ -151,49 +151,49 @@ typedef struct tagFixHOrTautCanonNumbering { int num_at_tg; /* = num_atoms for non-taut */ int num_atoms; int nCanonFlags; - NEIGH_LIST *NeighList; /* length = num_at_tg */ + NEIGH_LIST* NeighList; /* length = num_at_tg */ /****************************/ /* base structure */ /****************************/ - AT_RANK *LinearCt; /* connection table atoms (+taut. groups, directed graph)*/ + AT_RANK* LinearCt; /* connection table atoms (+taut. groups, directed graph)*/ int nLenLinearCtAtOnly; int nLenLinearCt; int nMaxLenLinearCt; Partition PartitionCt; /* canonical numbering */ - AT_RANK *nSymmRankCt; /* orbits */ + AT_RANK* nSymmRankCt; /* orbits */ /* orig. fixed by tautomerism H positions */ - NUM_H *nNumHOrig; /* original H atoms positions + taut. info, excluding tautomeric H */ - NUM_H *nNumH; /* canonical H atoms positions + taut. info, excluding tautomeric H */ + NUM_H* nNumHOrig; /* original H atoms positions + taut. info, excluding tautomeric H */ + NUM_H* nNumH; /* canonical H atoms positions + taut. info, excluding tautomeric H */ int nLenNumH; /* length = num_atoms + 2*num_taut_groups */ /* fixed H: original positions of tautomeric H; exists obly for tautomeric structures */ - NUM_H *nNumHOrigFixH; /* original fixed positions of tautomeric H */ - NUM_H *nNumHFixH; /* canonical fixed positions of tautomeric H */ + NUM_H* nNumHOrigFixH; /* original fixed positions of tautomeric H */ + NUM_H* nNumHFixH; /* canonical fixed positions of tautomeric H */ int nLenNumHFixH; /* length = num_atoms */ /*******************************************************************************/ /* the following exists only if isotopic and isotopic results requested */ /*******************************************************************************/ Partition PartitionCtIso; /* canonical numbering of isotopic base structure, defined later */ - AT_RANK *nSymmRankCtIso; /* orbits of isotopic structure */ - AT_ISO_SORT_KEY *iso_sort_keys; /* original isotopic sort keys for atoms and taut groups */ - AT_ISO_SORT_KEY *iso_sort_keysOrig; /* canonical isotopic sort keys for atoms and taut groups */ + AT_RANK* nSymmRankCtIso; /* orbits of isotopic structure */ + AT_ISO_SORT_KEY* iso_sort_keys; /* original isotopic sort keys for atoms and taut groups */ + AT_ISO_SORT_KEY* iso_sort_keysOrig; /* canonical isotopic sort keys for atoms and taut groups */ int len_iso_sort_keys; - S_CHAR *iso_exchg_atnos; /* canonical: 0=> tautomeric or may have isotopic H exchanged */ - S_CHAR *iso_exchg_atnosOrig; /* original: 0=> tautomeric or may have isotopic H exchanged */ + S_CHAR* iso_exchg_atnos; /* canonical: 0=> tautomeric or may have isotopic H exchanged */ + S_CHAR* iso_exchg_atnosOrig; /* original: 0=> tautomeric or may have isotopic H exchanged */ } FTCN; /******************** BCN *************************************/ typedef struct tagBaseCanonNumbering { - AT_RANK **pRankStack; + AT_RANK** pRankStack; int nMaxLenRankStack; int num_max; /* allocated nRank[] arrays lengths in pRankStack */ int num_at_tg; /* all of the following arrays have this length */ int num_atoms; - struct tagInchiTime *ulTimeOutTime; + struct tagInchiTime* ulTimeOutTime; FTCN ftcn[TAUT_NUM]; } BCN; @@ -209,7 +209,7 @@ typedef struct tagCanonStat { long lNumDecreasedCT; long lNumRejectedCT; long lNumEqualCT; - struct tagInchiTime *ulTimeOutTime; + struct tagInchiTime* ulTimeOutTime; long lTotalTime; /* control */ @@ -221,22 +221,22 @@ typedef struct tagCanonStat { /* data : */ - AT_NUMB *LinearCT; /* connection table only */ - AT_ISOTOPIC *LinearCTIsotopic; - AT_ISO_TGROUP *LinearCTIsotopicTautomer; - AT_STEREO_DBLE *LinearCTStereoDble; - AT_STEREO_CARB *LinearCTStereoCarb; - AT_STEREO_DBLE *LinearCTStereoDbleInv; - AT_STEREO_CARB *LinearCTStereoCarbInv; - AT_STEREO_DBLE *LinearCTIsotopicStereoDble; - AT_STEREO_CARB *LinearCTIsotopicStereoCarb; - AT_STEREO_DBLE *LinearCTIsotopicStereoDbleInv; - AT_STEREO_CARB *LinearCTIsotopicStereoCarbInv; - AT_TAUTOMER *LinearCTTautomer; /* minimal */ + AT_NUMB* LinearCT; /* connection table only */ + AT_ISOTOPIC* LinearCTIsotopic; + AT_ISO_TGROUP* LinearCTIsotopicTautomer; + AT_STEREO_DBLE* LinearCTStereoDble; + AT_STEREO_CARB* LinearCTStereoCarb; + AT_STEREO_DBLE* LinearCTStereoDbleInv; + AT_STEREO_CARB* LinearCTStereoCarbInv; + AT_STEREO_DBLE* LinearCTIsotopicStereoDble; + AT_STEREO_CARB* LinearCTIsotopicStereoCarb; + AT_STEREO_DBLE* LinearCTIsotopicStereoDbleInv; + AT_STEREO_CARB* LinearCTIsotopicStereoCarbInv; + AT_TAUTOMER* LinearCTTautomer; /* minimal */ -/* second copies of line notation arrays */ + /* second copies of line notation arrays */ - AT_NUMB *LinearCT2; /* to save non-isotopic CT */ + AT_NUMB* LinearCT2; /* to save non-isotopic CT */ int nLenLinearCTStereoDble; int nLenLinearCTStereoDbleInv; @@ -278,32 +278,32 @@ typedef struct tagCanonStat { int nLenLinearCTIsotopicStereoCarb; /* new */ int nLenLinearCTIsotopicStereoCarbInv; /* new */ int nMaxLenLinearCTIsotopicStereoCarb; - S_CHAR *bRankUsedForStereo; /* canon. rank used for stereo mapping */ - S_CHAR *bAtomUsedForStereo; /* 0 if not a stereo atom or during a canon. rank being mapped on this atom; */ - /* STEREO_AT_MARK if an unpapped stereogenic atom */ - /* or a number of stereogenic bonds adjacent to an atom */ + S_CHAR* bRankUsedForStereo; /* canon. rank used for stereo mapping */ + S_CHAR* bAtomUsedForStereo; /* 0 if not a stereo atom or during a canon. rank being mapped on this atom; */ + /* STEREO_AT_MARK if an unpapped stereogenic atom */ + /* or a number of stereogenic bonds adjacent to an atom */ - AT_RANK *nPrevAtomNumber; + AT_RANK* nPrevAtomNumber; - AT_RANK *nCanonOrd; /* atom numbers in order of increasing canon. ranks */ - AT_RANK *nSymmRank; /* symmetry numbers in order of atoms */ - AT_RANK *nCanonOrdTaut; /* t-group numbers numbers in order of increasing canon. ranks */ - AT_RANK *nSymmRankTaut; /* t-group symmetry numbers in order of t-groups */ + AT_RANK* nCanonOrd; /* atom numbers in order of increasing canon. ranks */ + AT_RANK* nSymmRank; /* symmetry numbers in order of atoms */ + AT_RANK* nCanonOrdTaut; /* t-group numbers numbers in order of increasing canon. ranks */ + AT_RANK* nSymmRankTaut; /* t-group symmetry numbers in order of t-groups */ - AT_RANK *nCanonOrdStereo; /* atom numbers in order of increasing canon. ranks */ - AT_RANK *nCanonOrdStereoInv; /* atom numbers in order of increasing canon. ranks */ - AT_RANK *nCanonOrdStereoTaut; /* t-group numbers in order of increasing canon. ranks */ + AT_RANK* nCanonOrdStereo; /* atom numbers in order of increasing canon. ranks */ + AT_RANK* nCanonOrdStereoInv; /* atom numbers in order of increasing canon. ranks */ + AT_RANK* nCanonOrdStereoTaut; /* t-group numbers in order of increasing canon. ranks */ - AT_RANK *nSymmRankIsotopic; - AT_RANK *nCanonOrdIsotopic; /* atom numbers in order of increasing canon. ranks */ - AT_RANK *nSymmRankIsotopicTaut; /* !!! */ - AT_RANK *nCanonOrdIsotopicTaut; /*/ t-group numbers in order of increasing canon. ranks */ + AT_RANK* nSymmRankIsotopic; + AT_RANK* nCanonOrdIsotopic; /* atom numbers in order of increasing canon. ranks */ + AT_RANK* nSymmRankIsotopicTaut; /* !!! */ + AT_RANK* nCanonOrdIsotopicTaut; /*/ t-group numbers in order of increasing canon. ranks */ - AT_RANK *nCanonOrdIsotopicStereo; - AT_RANK *nCanonOrdIsotopicStereoInv; - AT_RANK *nCanonOrdIsotopicStereoTaut; /* !!! */ + AT_RANK* nCanonOrdIsotopicStereo; + AT_RANK* nCanonOrdIsotopicStereoInv; + AT_RANK* nCanonOrdIsotopicStereoTaut; /* !!! */ - /* actual lengths if successfully calculated */ + /* actual lengths if successfully calculated */ int nLenCanonOrd; /* Superceded by any of the following > 0 */ int nLenCanonOrdTaut; /* !!! Superceded by any of the following > 0 */ @@ -314,21 +314,21 @@ typedef struct tagCanonStat { int nLenCanonOrdIsotopicStereo; int nLenCanonOrdIsotopicStereoTaut; /* !!! */ - /* other */ + /* other */ int bHasIsotopicInTautomerGroups; - T_GROUP_INFO *t_group_info; + T_GROUP_INFO* t_group_info; int bIgnoreIsotopic; int bDoubleBondSquare; /* 0 or 2 */ INCHI_MODE nMode; #if ( bRELEASE_VERSION == 0 ) int bExtract; /* for debug only */ #endif - NEIGH_LIST *NeighList; - BCN *pBCN; - S_CHAR *nNum_H; /* number of terminal hydrogen atoms on each atom except tautomeric [num_atoms], in order of canonical numbers */ - S_CHAR *nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms (for non-atautomeric representation) [num_atoms] */ - S_CHAR *nExchgIsoH; + NEIGH_LIST* NeighList; + BCN* pBCN; + S_CHAR* nNum_H; /* number of terminal hydrogen atoms on each atom except tautomeric [num_atoms], in order of canonical numbers */ + S_CHAR* nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms (for non-atautomeric representation) [num_atoms] */ + S_CHAR* nExchgIsoH; } CANON_STAT; @@ -336,20 +336,20 @@ typedef struct tagCanonStat { typedef struct tagCANON_GLOBALS { - const NEIGH_LIST *m_pNeighList_RankForSort; - const ATOM_INVARIANT2 *m_pAtomInvariant2ForSort; - const AT_NUMB *m_pNeighborsForSort; - const AT_RANK *m_pn_RankForSort; + const NEIGH_LIST* m_pNeighList_RankForSort; + const ATOM_INVARIANT2* m_pAtomInvariant2ForSort; + const AT_NUMB* m_pNeighborsForSort; + const AT_RANK* m_pn_RankForSort; AT_RANK m_nMaxAtNeighRankForSort; int m_nNumCompNeighborsRanksCountEql; - bitWord *m_bBit; + bitWord* m_bBit; int m_bBitInitialized; int m_num_bit; } CANON_GLOBALS; -int SetBitCreate( struct tagCANON_GLOBALS *pCG ); +int SetBitCreate(struct tagCANON_GLOBALS* pCG); -void inchi_qsort( void *pParam, void *base, size_t num, size_t width, int( *comp )( const void *, const void *, void * ) ); +void inchi_qsort(void* pParam, void* base, size_t num, size_t width, int(*comp)(const void*, const void*, void*)); @@ -360,7 +360,7 @@ typedef struct tagCanonData { /* same names/types as in ConTable; here the order is from original numbering */ - AT_NUMB *LinearCT; /* output ?? */ + AT_NUMB* LinearCT; /* output ?? */ int nMaxLenLinearCT; int nLenLinearCT; @@ -368,36 +368,36 @@ typedef struct tagCanonData { int nCanonFlags; /* hydrogen atoms fixed in tautomeric representation: compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */ - NUM_H *NumH; + NUM_H* NumH; int lenNumH; /* used length */ int maxlenNumH; /* n + T_NUM_NO_ISOTOPIC*(n_tg-n) + 1 */ /* hydrogen atoms fixed in non-tautomeric representation only: compare before diff sign inversion: (+) <=> Ct1->() > Ct2->() */ - NUM_H *NumHfixed; + NUM_H* NumHfixed; int lenNumHfixed; /* used length */ int maxlenNumHfixed; /* max length = n+1 */ /* isotopic atoms (without tautomeric H) and isotopic tautomeric groups */ /* note: AT_ISO_SORT_KEY and T_GROUP_ISOWT are identical types: long */ - AT_ISO_SORT_KEY *iso_sort_key; + AT_ISO_SORT_KEY* iso_sort_key; int len_iso_sort_key; /* used length */ int maxlen_iso_sort_key; /* max length = n_tg+1 */ - S_CHAR *iso_exchg_atnos; + S_CHAR* iso_exchg_atnos; int len_iso_exchg_atnos; /* used length */ int maxlen_iso_exchg_atnos; /* isotopic hydrogen atoms fixed in non-tautomeric representation only */ #if ( USE_ISO_SORT_KEY_HFIXED == 1 ) - AT_ISO_SORT_KEY *iso_sort_key_Hfixed; + AT_ISO_SORT_KEY* iso_sort_key_Hfixed; int len_iso_sort_key_Hfixed; /* used length */ int maxlen_iso_sort_key_Hfixed; /* max length = n+1 */ #endif /* auxiliary ranking */ - AT_RANK *nAuxRank; + AT_RANK* nAuxRank; - struct tagInchiTime *ulTimeOutTime; /* timeout */ + struct tagInchiTime* ulTimeOutTime; /* timeout */ } CANON_DATA; /**************************************************/ @@ -422,7 +422,7 @@ typedef struct tagCanonCounts { */ typedef struct tagCurTree { - AT_NUMB *tree; + AT_NUMB* tree; int max_len; /* allocated length of tree in sizeof(tree[0]) units */ int cur_len; /* currently used length */ int incr_len; /* reallocation increment */ diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichidrp.h b/INCHI-1-SRC/INCHI_BASE/src/ichidrp.h index ff555c93..c92ef090 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichidrp.h +++ b/INCHI-1-SRC/INCHI_BASE/src/ichidrp.h @@ -186,6 +186,8 @@ typedef struct tagInputParms { int bMergeHash; /* v. 1.06+ Combine InChIKey with extra hash(es) if present */ int bNoWarnings; /* v. 1.06+ suppress warning messages */ int bHideInChI; /* v. 1.06+ Do not print InChI itself */ + int bMolecularInorganics; /* (@nnuk : Nauman Ullah Khan) :: Varaible for Molecular Inorganics parameter */ + int bMolecularInorganicsReconnectedInChI; /* (@nnuk : Nauman Ullah Khan) :: Custom flag to indicate reconnected InChI requirement */ /* */ diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c b/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c index ffc6e1a9..c1bdcc96 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c @@ -38,7 +38,7 @@ * */ - /* djb-rwth: used for strdup function */ +/* djb-rwth: used for strdup function */ #ifndef _WIN32 #if defined(__STDC_ALLOC_LIB__) #define __STDC_WANT_LIB_EXT2__ 1 @@ -122,7 +122,8 @@ int set_common_options_by_parg(const char* pArg, int* pbNPZz, int* pbNoWarnings, int* pbMergeHash, - int* pbHideInChI); + int* pbHideInChI, + int* pbMolecularInorganics); /* @nnuk */ /**************************************************************************** @@ -165,31 +166,32 @@ int set_common_options_by_parg(const char* pArg, int* pbNPZz, int* pbNoWarnings, int* pbMergeHash, - int* pbHideInChI + int* pbHideInChI, + int* pbMolecularInorganics /*@nnuk*/ ) { int got = 0; /* Input */ - if (!inchi_stricmp(pArg, "INPAUX")) + if ( !inchi_stricmp(pArg, "INPAUX") ) { - if (INPUT_NONE == ip->nInputType) + if ( INPUT_NONE == ip->nInputType ) { ip->nInputType = INPUT_INCHI_PLAIN; } got = 1; } - else if (!inchi_memicmp(pArg, "START:", 6)) + else if ( !inchi_memicmp(pArg, "START:", 6) ) { ip->first_struct_number = strtol(pArg + 6, NULL, 10); got = 1; } - else if (!inchi_memicmp(pArg, "END:", 4)) + else if ( !inchi_memicmp(pArg, "END:", 4) ) { ip->last_struct_number = strtol(pArg + 4, NULL, 10); got = 1; } - else if (!inchi_memicmp(pArg, "RECORD:", 7)) + else if ( !inchi_memicmp(pArg, "RECORD:", 7) ) { long num = strtol(pArg + 7, NULL, 10); /* djb-rwth: removing redundant code */ @@ -197,71 +199,71 @@ int set_common_options_by_parg(const char* pArg, ip->last_struct_number = num; got = 1; } - else if (!inchi_stricmp(pArg, "NOLABELS")) + else if ( !inchi_stricmp(pArg, "NOLABELS") ) { *pbNoStructLabels = 1; got = 1; } - else if (!inchi_stricmp(pArg, "SAVEOPT")) + else if ( !inchi_stricmp(pArg, "SAVEOPT") ) { (*pbINChIOutputOptions) |= INCHI_OUT_SAVEOPT; got = 1; } /* Generation */ - else if (!inchi_stricmp(pArg, "AUXNONE")) + else if ( !inchi_stricmp(pArg, "AUXNONE") ) { /* no aux. info */ (*pbINChIOutputOptions) |= INCHI_OUT_NO_AUX_INFO; /* no aux info */ (*pbINChIOutputOptions) &= ~INCHI_OUT_SHORT_AUX_INFO; got = 1; } - else if (!inchi_stricmp(pArg, "MISMATCHISERROR")) + else if ( !inchi_stricmp(pArg, "MISMATCHISERROR") ) { /* Consider InChI conversion "problem/mismatch" as error */ (*pbINChIOutputOptions2) |= INCHI_OUT_MISMATCH_AS_ERROR; got = 1; } - else if (!inchi_stricmp(pArg, "OUTERRINCHI")) + else if ( !inchi_stricmp(pArg, "OUTERRINCHI") ) { /* Signify InChI error generation on InChI strings output, not only report to log file */ (*pbINChIOutputOptions2) |= INCHI_OUT_INCHI_GEN_ERROR; got = 1; } /* InChIKey/InChI hash */ - else if (!inchi_stricmp(pArg, "Key")) + else if ( !inchi_stricmp(pArg, "Key") ) { *pbHashKey = 1; got = 1; } - else if (!inchi_stricmp(pArg, "XHash1")) + else if ( !inchi_stricmp(pArg, "XHash1") ) { *pbHashXtra1 = 1; got = 1; } - else if (!inchi_stricmp(pArg, "XHash2")) + else if ( !inchi_stricmp(pArg, "XHash2") ) { *pbHashXtra2 = 1; got = 1; } /* All modes (std and non-std InChI) structure perception options */ /* These options DO NOT TURN OFF Std flag */ - else if (!inchi_stricmp(pArg, "SNON")) + else if ( !inchi_stricmp(pArg, "SNON") ) { (*pbVer1DefaultMode) &= ~REQ_MODE_STEREO; /* no stereo */ (*pnMode) &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO); got = 1; } - else if (!inchi_stricmp(pArg, "NEWPSOFF")) + else if ( !inchi_stricmp(pArg, "NEWPSOFF") ) { *pbPointedEdgeStereo = 0; got = 1; } - else if (!inchi_stricmp(pArg, "DONOTADDH")) + else if ( !inchi_stricmp(pArg, "DONOTADDH") ) { *pbDoNotAddH = 1; got = 1; } - else if (!inchi_stricmp(pArg, "LooseTSACheck")) + else if ( !inchi_stricmp(pArg, "LooseTSACheck") ) { (*pbLooseTSACheck) = 1; got = 1; @@ -269,13 +271,13 @@ int set_common_options_by_parg(const char* pArg, #ifndef USE_STDINCHI_API /* These options DO TURN OFF Std flag */ - else if (!inchi_stricmp(pArg, "SREL")) + else if ( !inchi_stricmp(pArg, "SREL") ) { - if ((*pnMode) & REQ_MODE_RACEMIC_STEREO) + if ( (*pnMode) & REQ_MODE_RACEMIC_STEREO ) { (*pnMode) ^= REQ_MODE_RACEMIC_STEREO; } - if ((*pnMode) & REQ_MODE_CHIR_FLG_STEREO) + if ( (*pnMode) & REQ_MODE_CHIR_FLG_STEREO ) { (*pnMode) ^= REQ_MODE_CHIR_FLG_STEREO; } @@ -284,13 +286,13 @@ int set_common_options_by_parg(const char* pArg, *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "SRAC")) + else if ( !inchi_stricmp(pArg, "SRAC") ) { - if ((*pnMode) & REQ_MODE_RELATIVE_STEREO) + if ( (*pnMode) & REQ_MODE_RELATIVE_STEREO ) { (*pnMode) ^= REQ_MODE_RELATIVE_STEREO; } - if ((*pnMode) & REQ_MODE_CHIR_FLG_STEREO) + if ( (*pnMode) & REQ_MODE_CHIR_FLG_STEREO ) { (*pnMode) ^= REQ_MODE_CHIR_FLG_STEREO; } @@ -299,13 +301,13 @@ int set_common_options_by_parg(const char* pArg, *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "SUCF")) + else if ( !inchi_stricmp(pArg, "SUCF") ) { - if ((*pnMode) & REQ_MODE_RELATIVE_STEREO) + if ( (*pnMode) & REQ_MODE_RELATIVE_STEREO ) { (*pnMode) ^= REQ_MODE_RELATIVE_STEREO; } - if ((*pnMode) & REQ_MODE_RACEMIC_STEREO) + if ( (*pnMode) & REQ_MODE_RACEMIC_STEREO ) { (*pnMode) ^= REQ_MODE_RACEMIC_STEREO; } @@ -314,7 +316,7 @@ int set_common_options_by_parg(const char* pArg, *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "ChiralFlagON")) + else if ( !inchi_stricmp(pArg, "ChiralFlagON") ) { /* used only with /SUCF */ /* NB: do not toggle off bStdFormat! (if necessary SUCF will do) */ @@ -322,7 +324,7 @@ int set_common_options_by_parg(const char* pArg, (*pbForcedChiralFlag) |= FLAG_SET_INP_AT_CHIRAL; got = 1; } - else if (!inchi_stricmp(pArg, "ChiralFlagOFF")) + else if ( !inchi_stricmp(pArg, "ChiralFlagOFF") ) { /* used only with /SUCF */ /* NB: do not toggle off bStdFormat! (if necessary SUCF will do) */ @@ -333,14 +335,24 @@ int set_common_options_by_parg(const char* pArg, /*--- Non-std InChI creation options ---*/ /* These options DO TURN OFF Std flag */ - else if (!inchi_stricmp(pArg, "SUU")) + else if ( !inchi_stricmp(pArg, "SUU") ) { /* include omitted undef/unknown stereo */ (*pbVer1DefaultMode) &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU); *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "SLUUD")) + /* (@nnuk :: NaumanUllahKhan) + * Parameter option that deals with Molecular Inorganics + */ + else if ( !inchi_stricmp(pArg, "MolecularInorganics") ) + { + *pbMolecularInorganics = 1; + *pbNPZz = 1; + *pbStdFormat = 0; + got = 1; + } + else if ( !inchi_stricmp(pArg, "SLUUD") ) { /* make labels for unknown and undefined stereo different */ (*pbVer1DefaultMode) |= REQ_MODE_DIFF_UU_STEREO; @@ -348,14 +360,14 @@ int set_common_options_by_parg(const char* pArg, got = 1; } /* FixedH */ - else if (!inchi_stricmp(pArg, "FIXEDH")) + else if ( !inchi_stricmp(pArg, "FIXEDH") ) { (*pbVer1DefaultMode) |= REQ_MODE_BASIC; /* tautomeric */ *pbStdFormat = 0; got = 1; } /* RecMet */ - else if (!inchi_stricmp(pArg, "RECMET")) + else if ( !inchi_stricmp(pArg, "RECMET") ) { /* reconnect metals */ *pbReconnectCoord = 1; @@ -363,7 +375,7 @@ int set_common_options_by_parg(const char* pArg, got = 1; } #if ( KETO_ENOL_TAUT == 1 ) - else if (!inchi_stricmp(pArg, "KET")) + else if ( !inchi_stricmp(pArg, "KET") ) { *pbKetoEnolTaut = 1; *pbStdFormat = 0; @@ -371,7 +383,7 @@ int set_common_options_by_parg(const char* pArg, } #endif #if ( TAUT_15_NON_RING == 1 ) - else if (!inchi_stricmp(pArg, "15T")) + else if ( !inchi_stricmp(pArg, "15T") ) { *pb15TautNonRing = 1; *pbStdFormat = 0; @@ -380,7 +392,7 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_22_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_22_00")) + else if ( !inchi_stricmp(pArg, "PT_22_00") ) { *pbPT_22_00_Taut = 1; *pbStdFormat = 0; @@ -388,7 +400,7 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_16_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_16_00")) + else if ( !inchi_stricmp(pArg, "PT_16_00") ) { *pbPT_16_00_Taut = 1; *pbStdFormat = 0; @@ -396,7 +408,7 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_06_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_06_00")) + else if ( !inchi_stricmp(pArg, "PT_06_00") ) { *pbPT_06_00_Taut = 1; *pbStdFormat = 0; @@ -404,7 +416,7 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_39_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_39_00")) + else if ( !inchi_stricmp(pArg, "PT_39_00") ) { *pbPT_39_00_Taut = 1; *pbStdFormat = 0; @@ -412,7 +424,7 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_13_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_13_00")) + else if ( !inchi_stricmp(pArg, "PT_13_00") ) { *pbPT_13_00_Taut = 1; *pbStdFormat = 0; @@ -420,80 +432,81 @@ int set_common_options_by_parg(const char* pArg, #endif #if ( TAUT_PT_18_00 == 1 ) - else if (!inchi_stricmp(pArg, "PT_18_00")) + else if ( !inchi_stricmp(pArg, "PT_18_00") ) { *pbPT_18_00_Taut = 1; *pbStdFormat = 0; } #endif - else if (!inchi_stricmp(pArg, "LargeMolecules")) + else if ( !inchi_stricmp(pArg, "LargeMolecules") ) { *pbLargeMolecules = 1; got = 1; } - else if (!inchi_stricmp(pArg, "Polymers")) + else if ( !inchi_stricmp(pArg, "Polymers") ) { *pbPolymers = POLYMERS_MODERN; got = 1; } - else if (!inchi_stricmp(pArg, "Polymers105")) + else if ( !inchi_stricmp(pArg, "Polymers105") ) { *pbPolymers = POLYMERS_LEGACY; got = 1; } - else if (!inchi_stricmp(pArg, "NPZz")) + else if ( !inchi_stricmp(pArg, "NPZz") ) { *pbNPZz = 1; + *pbMolecularInorganics = 1; got = 1; } - else if (!inchi_stricmp(pArg, "NoWarnings")) + else if ( !inchi_stricmp(pArg, "NoWarnings") ) { *pbNoWarnings = 1; got = 1; } - else if (!inchi_stricmp(pArg, "MergeHash")) + else if ( !inchi_stricmp(pArg, "MergeHash") ) { *pbMergeHash = 1; got = 1; } - else if (!inchi_stricmp(pArg, "NoInChI") || !inchi_stricmp(pArg, "HideInChI")) + else if ( !inchi_stricmp(pArg, "NoInChI") || !inchi_stricmp(pArg, "HideInChI") ) { *pbHideInChI = 1; got = 1; } - else if (!inchi_stricmp(pArg, "FoldCRU")) /* v. 1.06 */ + else if ( !inchi_stricmp(pArg, "FoldCRU") ) /* v. 1.06 */ { *pbFoldPolymerSRU = 1; got = 1; } - else if (!inchi_stricmp(pArg, "FoldSRU")) /* v. 1.06 */ + else if ( !inchi_stricmp(pArg, "FoldSRU") ) /* v. 1.06 */ { *pbFoldPolymerSRU = 1; got = 1; } - else if (!inchi_memicmp(pArg, "FrameShift:", 11)) + else if ( !inchi_memicmp(pArg, "FrameShift:", 11) ) { int k; char wrd[256]; k = 0; mystrncpy(wrd, pArg + 11, 256); lrtrim(wrd, &k); - if (k) + if ( k ) { - if (!inchi_stricmp(wrd, "None")) + if ( !inchi_stricmp(wrd, "None") ) { *pbFrameShiftScheme = FSS_NONE; } - else if (!inchi_stricmp(wrd, "Cyclize")) + else if ( !inchi_stricmp(wrd, "Cyclize") ) { *pbFrameShiftScheme = FSS_STARS_CYCLED; } - else if (!inchi_stricmp(wrd, "MoveStars")) + else if ( !inchi_stricmp(wrd, "MoveStars") ) { *pbFrameShiftScheme = FSS_STARS_OPENED; } - else if (!inchi_stricmp(wrd, "MoveBrackets")) + else if ( !inchi_stricmp(wrd, "MoveBrackets") ) { *pbFrameShiftScheme = FSS_STARS_ENDS_OPENED; } @@ -504,18 +517,18 @@ int set_common_options_by_parg(const char* pArg, } got = 1; } - else if (!inchi_stricmp(pArg, "NoFrameShift")) + else if ( !inchi_stricmp(pArg, "NoFrameShift") ) { *pbFrameShiftScheme = FSS_NONE; got = 1; } - else if (!inchi_stricmp(pArg, "NoEdits")) + else if ( !inchi_stricmp(pArg, "NoEdits") ) { *pbFoldPolymerSRU = 0; *pbFrameShiftScheme = FSS_NONE; got = 1; } - else if (!inchi_stricmp(pArg, "SATZZ")) + else if ( !inchi_stricmp(pArg, "SATZZ") ) { *pbStereoAtZz = 1; got = 1; @@ -524,65 +537,65 @@ int set_common_options_by_parg(const char* pArg, #endif /* ifndef USE_STDINCHI_API */ - if (!got && developer_options) + if ( !got && developer_options ) { - if (!inchi_stricmp(pArg, "PGO")) + if ( !inchi_stricmp(pArg, "PGO") ) { /* PGO : extract all good MOLfiles into the problem file */ ip->bSaveAllGoodStructsAsProblem = 1; got = 1; } #if ( ALLOW_SUBSTRUCTURE_FILTERING== 1 ) - else if (!inchi_stricmp(pArg, "FilterSS")) + else if ( !inchi_stricmp(pArg, "FilterSS") ) { ip->bFilterSS = 1; got = 1; } - else if (!inchi_stricmp(pArg, "InvFilterSS")) + else if ( !inchi_stricmp(pArg, "InvFilterSS") ) { ip->bFilterSS = -1; got = 1; } #endif /* Options below DO TURN OFF Std flag */ - if (!inchi_stricmp(pArg, "FNUDOFF")) + if ( !inchi_stricmp(pArg, "FNUDOFF") ) { ip->bFixNonUniformDraw = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "FixSp3bugOFF")) + else if ( !inchi_stricmp(pArg, "FixSp3bugOFF") ) { *pbFixSp3bug = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "FBOFF")) + else if ( !inchi_stricmp(pArg, "FBOFF") ) { *pbFixSp3bug = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "FB2OFF")) + else if ( !inchi_stricmp(pArg, "FB2OFF") ) { *pbFixFB2 = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "SPXYZOFF")) + else if ( !inchi_stricmp(pArg, "SPXYZOFF") ) { *pbAddPhosphineStereo = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "SASXYZOFF")) + else if ( !inchi_stricmp(pArg, "SASXYZOFF") ) { *pbAddArsineStereo = 0; *pbStdFormat = 0; got = 1; } - else if (!inchi_stricmp(pArg, "Polymers105+")) + else if ( !inchi_stricmp(pArg, "Polymers105+") ) { *pbPolymers = POLYMERS_LEGACY_PLUS; *pbStdFormat = 0; @@ -683,7 +696,7 @@ int ReadCommandLineParms(int argc, int bNoWarnings = 0; int bMergeHash = 0; int bHideInChI = 0; - + int bMolecularInorganics = 0; /* @nnuk */ int bOutputStyle = INCHI_OUT_PLAIN_TEXT; int bDisplay = 0; int bNoStructLabels = 0; @@ -750,7 +763,7 @@ int ReadCommandLineParms(int argc, #endif * ulDisplTime = 0; - if (bReleaseVersion) + if ( bReleaseVersion ) { /* normal */ ip->bAbcNumbers = 0; @@ -760,7 +773,7 @@ int ReadCommandLineParms(int argc, { nReleaseMode = 0; } - if (bVer1Options) + if ( bVer1Options ) { bNameSuffix = 1; szNameSuffix[0] = '\0'; @@ -773,10 +786,10 @@ int ReadCommandLineParms(int argc, /* Analyze command line switches */ - for (i = 1; i < argc; i++) + for ( i = 1; i < argc; i++ ) { - if (is_gui && INCHI_OPTION_PREFX == argv[i][0] && INCHI_OPTION_PREFX != argv[i][1]) + if ( is_gui && INCHI_OPTION_PREFX == argv[i][0] && INCHI_OPTION_PREFX != argv[i][1] ) { /* Parsing TARGET_LIB_FOR_WINCHI GUI options (and v. 0.9xx Beta as well) */ pArg = argv[i] + 1; @@ -795,19 +808,19 @@ int ReadCommandLineParms(int argc, &bLargeMolecules, &bPolymers, &bFoldPolymerSRU, &bFrameShiftScheme, &bStereoAtZz, &bNPZz, - &bNoWarnings, &bMergeHash, &bHideInChI); - if (got) + &bNoWarnings, &bMergeHash, &bHideInChI, &bMolecularInorganics); + if ( got ) { ; } - else if (INPUT_NONE == ip->nInputType && + else if ( INPUT_NONE == ip->nInputType && (!inchi_memicmp(pArg, "SDF", 3)) && - (pArg[3] == ':')) + (pArg[3] == ':') ) { k = 0; mystrncpy(ip->szSdfDataHeader, pArg + 4, MAX_SDF_HEADER + 1); lrtrim(ip->szSdfDataHeader, &k); - if (k) + if ( k ) { ip->pSdfLabel = ip->szSdfDataHeader; ip->pSdfValue = szSdfDataValue; @@ -820,17 +833,17 @@ int ReadCommandLineParms(int argc, ip->nInputType = INPUT_MOLFILE; } } - else if (INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "MOL")) + else if ( INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "MOL") ) { ip->nInputType = INPUT_MOLFILE; } - else if (INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "SDF")) + else if ( INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "SDF") ) { ip->nInputType = INPUT_MOLFILE; } /*--- Output options ---*/ #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) ) - else if (!inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab")) + else if ( !inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab") ) { bOutputStyle |= INCHI_OUT_TABBED_OUTPUT; } @@ -842,31 +855,31 @@ int ReadCommandLineParms(int argc, 'if ( is_gui && ...)' and is_gui==1 means TARGET_LIB_FOR_WINCHI */ /* #if ( defined(BUILD_WITH_ENG_OPTIONS) || defined(TARGET_LIB_FOR_WINCHI) ) */ - else if (!inchi_stricmp(pArg, "SDFID")) + else if ( !inchi_stricmp(pArg, "SDFID") ) { ip->bGetSdfileId = 1; } - else if (!inchi_stricmp(pArg, "PLAIN")) + else if ( !inchi_stricmp(pArg, "PLAIN") ) { bOutputStyle |= INCHI_OUT_PLAIN_TEXT; } - else if (!inchi_stricmp(pArg, "ANNPLAIN")) + else if ( !inchi_stricmp(pArg, "ANNPLAIN") ) { bOutputStyle |= INCHI_OUT_PLAIN_TEXT_COMMENTS; } - else if (!inchi_memicmp(pArg, "AUXINFO:", 8) && isdigit(UCINT pArg[8])) + else if ( !inchi_memicmp(pArg, "AUXINFO:", 8) && isdigit(UCINT pArg[8]) ) { k = strtol(pArg + 8, NULL, 10); - if (k == 0) + if ( k == 0 ) { bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */ bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO; } - else if (k == 1) + else if ( k == 1 ) { bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include full aux info */ } - else if (k == 2) + else if ( k == 2 ) { bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */ bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO; @@ -876,46 +889,46 @@ int ReadCommandLineParms(int argc, bINChIOutputOptions = k; /* override everything */ } } - else if (!inchi_stricmp(pArg, "MERGE")) + else if ( !inchi_stricmp(pArg, "MERGE") ) { bMergeAllInputStructures = 1; } - else if (!inchi_stricmp(pArg, "PGO")) + else if ( !inchi_stricmp(pArg, "PGO") ) { ip->bSaveAllGoodStructsAsProblem = 1; } - else if (!inchi_stricmp(pArg, "DCR")) + else if ( !inchi_stricmp(pArg, "DCR") ) { bDisplayCompositeResults = 1; } - else if (!inchi_stricmp(pArg, "DSB")) + else if ( !inchi_stricmp(pArg, "DSB") ) { nMode |= REQ_MODE_NO_ALT_SBONDS; } - else if (!inchi_stricmp(pArg, "NOHDR")) + else if ( !inchi_stricmp(pArg, "NOHDR") ) { bNoStructLabels = 1; } - else if (!inchi_stricmp(pArg, "NoVarH")) + else if ( !inchi_stricmp(pArg, "NoVarH") ) { bTgFlagVariableProtons = 0; } /*--- (hidden) Old structure-perception and InChI creation options ---*/ /*--- (engineering) Old structure-perception and InChI creation options ---*/ - else if (!inchi_stricmp(pArg, "NOUUSB")) + else if ( !inchi_stricmp(pArg, "NOUUSB") ) { nMode |= REQ_MODE_SB_IGN_ALL_UU; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "NOUUSC")) + else if ( !inchi_stricmp(pArg, "NOUUSC") ) { nMode |= REQ_MODE_SC_IGN_ALL_UU; bStdFormat = 0; } #if ( FIX_ADJ_RAD == 1 ) - else if (!inchi_stricmp(pArg, "FixRad")) + else if ( !inchi_stricmp(pArg, "FixRad") ) { bFixAdjacentRad = 1; bStdFormat = 0; @@ -923,20 +936,20 @@ int ReadCommandLineParms(int argc, #endif #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 ) - else if (!inchi_stricmp(pArg, "TestRenum") && developer_options) + else if ( !inchi_stricmp(pArg, "TestRenum") && developer_options ) { ip->bRenumber = 1; } #endif #if ( UNDERIVATIZE == 1 ) - else if (!inchi_stricmp(pArg, "DoDRV")) + else if ( !inchi_stricmp(pArg, "DoDRV") ) { ip->bUnderivatize = 1; bStdFormat = 0; } #if( UNDERIVATIZE_REPORT == 1 ) - else if (!inchi_stricmp(pArg, "DoDrvReport")) + else if ( !inchi_stricmp(pArg, "DoDrvReport") ) { ip->bUnderivatize = 3; bStdFormat = 0; @@ -944,136 +957,136 @@ int ReadCommandLineParms(int argc, #endif #endif #if ( RING2CHAIN == 1 ) - else if (!inchi_stricmp(pArg, "DoR2C")) + else if ( !inchi_stricmp(pArg, "DoR2C") ) { ip->bRing2Chain = 1; bStdFormat = 0; } #endif #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 ) - else if (!inchi_stricmp(pArg, "DoneOnly")) + else if ( !inchi_stricmp(pArg, "DoneOnly") ) { ip->bIgnoreUnchanged = 1; bStdFormat = 0; } #endif - else if (!inchi_stricmp(pArg, "NoADP")) + else if ( !inchi_stricmp(pArg, "NoADP") ) { bTgFlagHardAddRenProtons = 0; bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "DISCONSALT:", 11)) + else if ( !inchi_memicmp(pArg, "DISCONSALT:", 11) ) { bDisconnectSalts = (0 != strtol(pArg + 11, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "DISCONMETAL:", 12)) + else if ( !inchi_memicmp(pArg, "DISCONMETAL:", 12) ) { bDisconnectCoord = (0 != strtol(pArg + 12, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "RECONMETAL:", 11)) + else if ( !inchi_memicmp(pArg, "RECONMETAL:", 11) ) { bReconnectCoord = (0 != strtol(pArg + 11, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18)) + else if ( !inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18) ) { bDisconnectCoordChkVal = (0 != strtol(pArg + 18, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "MOVEPOS:", 8)) + else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) ) { bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "MERGESALTTG:", 12)) + else if ( !inchi_memicmp(pArg, "MERGESALTTG:", 12) ) { bMergeSaltTGroups = (0 != strtol(pArg + 12, NULL, 10)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15)) + else if ( !inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15) ) { bUnchargedAcidTaut = (0 != strtol(pArg + 15, NULL, 16)); bStdFormat = 0; } - else if (!inchi_memicmp(pArg, "ACIDTAUT:", 9)) + else if ( !inchi_memicmp(pArg, "ACIDTAUT:", 9) ) { bAcidTautomerism = c = (int)strtol(pArg + 9, NULL, 10); - if (0 <= c && c <= 2) bAcidTautomerism = c; + if ( 0 <= c && c <= 2 ) bAcidTautomerism = c; /*else bNotRecognized = 2*bReleaseVersion;*/ bStdFormat = 0; } /*--- (hidden) Old output and other options ---*/ - else if (!inchi_memicmp(pArg, "O:", 2)) + else if ( !inchi_memicmp(pArg, "O:", 2) ) { bNameSuffix = 1; strncpy(szNameSuffix, pArg + 2, sizeof(szNameSuffix) - 1); } - else if (!inchi_memicmp(pArg, "OP:", 3)) + else if ( !inchi_memicmp(pArg, "OP:", 3) ) { bOutputPath = 1; strncpy(szOutputPath, pArg + 3, sizeof(szOutputPath) - 1); - } - else if (!inchi_stricmp(pArg, "ALT")) + } + else if ( !inchi_stricmp(pArg, "ALT") ) { ip->bAbcNumbers = 1; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "SCT")) + else if ( !inchi_stricmp(pArg, "SCT") ) { ip->bCtPredecessors = 1; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "CMP")) + else if ( !inchi_stricmp(pArg, "CMP") ) { bCompareComponents = CMP_COMPONENTS; } - else if (!inchi_stricmp(pArg, "CMPNONISO")) + else if ( !inchi_stricmp(pArg, "CMPNONISO") ) { bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO; } - else if (!inchi_stricmp(pArg, "PW")) + else if ( !inchi_stricmp(pArg, "PW") ) { ip->bSaveWarningStructsAsProblem = 1; } - else if (!inchi_memicmp(pArg, "RSB:", 4) && developer_options) + else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options ) { mdbr = (int)strtol(pArg + 4, NULL, 10); } - else if (!inchi_memicmp(pArg, "DISCONSALT:", 11) && developer_options) + else if ( !inchi_memicmp(pArg, "DISCONSALT:", 11) && developer_options ) { bDisconnectSalts = (0 != strtol(pArg + 11, NULL, 10)); } - else if (!inchi_memicmp(pArg, "DISCONMETAL:", 12) && developer_options) + else if ( !inchi_memicmp(pArg, "DISCONMETAL:", 12) && developer_options ) { bDisconnectCoord = (0 != strtol(pArg + 12, NULL, 10)); } - else if (!inchi_memicmp(pArg, "RECONMETAL:", 11) && developer_options) + else if ( !inchi_memicmp(pArg, "RECONMETAL:", 11) && developer_options ) { bReconnectCoord = (0 != strtol(pArg + 11, NULL, 10)); } - else if (!inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18) && developer_options) + else if ( !inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18) && developer_options ) { bDisconnectCoordChkVal = (0 != strtol(pArg + 18, NULL, 10)); } - else if (!inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options) + else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options ) { bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10)); } - else if (!inchi_memicmp(pArg, "MERGESALTTG:", 12) && developer_options) + else if ( !inchi_memicmp(pArg, "MERGESALTTG:", 12) && developer_options ) { bMergeSaltTGroups = (0 != strtol(pArg + 12, NULL, 10)); } - else if (!inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15) && developer_options) + else if ( !inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15) && developer_options ) { bUnchargedAcidTaut = (0 != strtol(pArg + 15, NULL, 16));; } - else if (!inchi_memicmp(pArg, "ACIDTAUT:", 9) && developer_options) + else if ( !inchi_memicmp(pArg, "ACIDTAUT:", 9) && developer_options ) { bAcidTautomerism = c = (int)strtol(pArg + 9, NULL, 10); - if (0 <= c && c <= 2) + if ( 0 <= c && c <= 2 ) { bAcidTautomerism = c; } @@ -1087,30 +1100,30 @@ int ReadCommandLineParms(int argc, c = pArg[k]; /* prohibit multiple option concatenations, strict syntax check 2008-11-05 DT */ { c = toupper(c); - switch (c) + switch ( c ) { case 'D': bDisplay |= 1; - if ((pArg[k + 1] == 'C' || pArg[k + 1] == 'c') && !pArg[k + 2]) + if ( (pArg[k + 1] == 'C' || pArg[k + 1] == 'c') && !pArg[k + 2] ) { bDisplay |= 1; k++; ip->bDisplayEachComponentINChI = 1; } - else if (!pArg[k + 1]) + else if ( !pArg[k + 1] ) { bDisplay |= 1; } break; case 'W': - if (pArg[k + 1] == 'D') + if ( pArg[k + 1] == 'D' ) { /* restore Display Time functionality */ c = 'D'; k++; } t = strtod(pArg + k + 1, (char**)&q); /* cast deliberately discards 'const' qualifier */ - if ((q > pArg + k + 1 && errno == ERANGE) || t < 0.0 || t * 1000.0 >(double)ULONG_MAX) /* djb-rwth: addressing LLVM warning */ + if ( (q > pArg + k + 1 && errno == ERANGE) || t < 0.0 || t * 1000.0 >(double)ULONG_MAX ) /* djb-rwth: addressing LLVM warning */ { ul = 0; } @@ -1118,10 +1131,10 @@ int ReadCommandLineParms(int argc, { ul = (unsigned long)(t * 1000.0); } - if ( /*q > pArg+k &&*/ !*q) + if ( /*q > pArg+k &&*/ !*q ) { k = q - pArg - 1; /* k will be incremented by the for() cycle */ - switch (c) + switch ( c ) { case 'D': *ulDisplTime = ul; @@ -1134,19 +1147,19 @@ int ReadCommandLineParms(int argc, break; case 'F': c = (int)strtol(pArg + k + 1, (char**)&q, 10); /* cast deliberately discards 'const' qualifier */ - if (q > pArg + k && !*q) + if ( q > pArg + k && !*q ) { k = q - pArg - 1; - if (abs(c) > 5) + if ( abs(c) > 5 ) { nFontSize = -c; /* font size 5 or less is too small */ } } break; default: - if (!pArg[k + 1]) + if ( !pArg[k + 1] ) { - switch (c) + switch ( c ) { case 'B': nMode |= REQ_MODE_BASIC; @@ -1176,7 +1189,7 @@ int ReadCommandLineParms(int argc, /*bNotRecognized = bReleaseVersion;*/ break; case 'E': - if (nReleaseMode & REQ_MODE_STEREO) + if ( nReleaseMode & REQ_MODE_STEREO ) { nReleaseMode ^= REQ_MODE_STEREO; bStdFormat = 0; @@ -1218,7 +1231,7 @@ int ReadCommandLineParms(int argc, } /* eof Parsing TARGET_LIB_FOR_WINCHI GUI options (and v. 0.9xx Beta as well) */ - else if ((bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && argv[i][1]) + else if ( (bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && argv[i][1] ) { /* Parsing stand-alone executable/libinchi options */ @@ -1243,29 +1256,29 @@ int ReadCommandLineParms(int argc, &bLargeMolecules, &bPolymers, &bFoldPolymerSRU, &bFrameShiftScheme, &bStereoAtZz, &bNPZz, - &bNoWarnings, &bMergeHash, &bHideInChI); + &bNoWarnings, &bMergeHash, &bHideInChI, &bMolecularInorganics); - if (got) + if ( got ) { ; } /* Input */ - else if (!inchi_stricmp(pArg, "STDIO")) + else if ( !inchi_stricmp(pArg, "STDIO") ) { bNameSuffix = 0; } else if ( /* INPUT_NONE == ip->nInputType &&*/ - !inchi_memicmp(pArg, "SDF:", 4)) + !inchi_memicmp(pArg, "SDF:", 4) ) { /* SDfile label */ k = 0; mystrncpy(ip->szSdfDataHeader, pArg + 4, MAX_SDF_HEADER + 1); lrtrim(ip->szSdfDataHeader, &k); - if (k) + if ( k ) { ip->pSdfLabel = ip->szSdfDataHeader; ip->pSdfValue = szSdfDataValue; - if (INPUT_NONE == ip->nInputType) + if ( INPUT_NONE == ip->nInputType ) { ip->nInputType = INPUT_SDFILE; } @@ -1274,77 +1287,77 @@ int ReadCommandLineParms(int argc, { ip->pSdfLabel = NULL; ip->pSdfValue = NULL; - if (INPUT_NONE == ip->nInputType) + if ( INPUT_NONE == ip->nInputType ) { ip->nInputType = INPUT_MOLFILE; } } } - else if (!inchi_memicmp(pArg, "RSB:", 4) && developer_options) + else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options ) { mdbr = (int)strtol(pArg + 4, NULL, 10); } /* Output */ #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) ) - else if (!inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab")) + else if ( !inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab") ) { bOutputStyle |= INCHI_OUT_TABBED_OUTPUT; } #endif - else if (!inchi_stricmp(pArg, "OUTPUTSDF")) + else if ( !inchi_stricmp(pArg, "OUTPUTSDF") ) { /* output SDfile */ bOutputMolfileOnly = 1; } - else if (!inchi_stricmp(pArg, "SdfAtomsDT")) + else if ( !inchi_stricmp(pArg, "SdfAtomsDT") ) { /* output isotopes H as D and T in SDfile */ bOutputMolfileDT = 1; } - else if (!inchi_stricmp(pArg, "D")) + else if ( !inchi_stricmp(pArg, "D") ) { /* display the structures */ bDisplay |= 1; } - else if (!inchi_memicmp(pArg, "F", 1) && (c = (int)strtol(pArg + 1, (char**)&q, 10), q > pArg + 1)) + else if ( !inchi_memicmp(pArg, "F", 1) && (c = (int)strtol(pArg + 1, (char**)&q, 10), q > pArg + 1) ) { nFontSize = -c; /* struct. display font size */ } - else if (!inchi_stricmp(pArg, "EQU")) + else if ( !inchi_stricmp(pArg, "EQU") ) { bCompareComponents = CMP_COMPONENTS; } #if( OUTPUT_FILE_EXT == 1 ) - else if (pArg[0] == '.' && numOutNameExt < (int)(sizeof(szOutNameExt) / sizeof(szOutNameExt[0]))) + else if ( pArg[0] == '.' && numOutNameExt < (int)(sizeof(szOutNameExt) / sizeof(szOutNameExt[0])) ) { strncpy(szOutNameExt[numOutNameExt], pArg, sizeof(szOutNameExt[0]) - 1); numOutNameExt++; - if (ip->path[numOutNameExt]) + if ( ip->path[numOutNameExt] ) { ip->path[numOutNameExt] = ""; /*strcpy( ip->path[numOutNameExt], "");*/ } } #endif /* djb-rwth: avoiding Error 98 for empty .mol files -- GH issue #25, thanks to @wijnand1 */ - else if (!inchi_stricmp(pArg, "WarnOnEmptyStructure")) + else if ( !inchi_stricmp(pArg, "WarnOnEmptyStructure") ) { ip->bAllowEmptyStructure = 1; } /* Generation options */ - else if (!inchi_memicmp(pArg, "W", 1)) + else if ( !inchi_memicmp(pArg, "W", 1) ) { long timeout_value; const char c1 = *(pArg + 1); - if (c1 && (c1 == 'M' || c1 == 'm')) + if ( c1 && (c1 == 'M' || c1 == 'm') ) { /* "WMnumber", milliseconds */ timeout_value = strtol(pArg + 2, (char**)&q, 10); - if (timeout_value && q > pArg + 2 && *q == '\0') + if ( timeout_value && q > pArg + 2 && *q == '\0' ) { - if (errno == ERANGE || timeout_value < 0.0 || timeout_value>LONG_MAX) + if ( errno == ERANGE || timeout_value < 0.0 || timeout_value>LONG_MAX ) { timeout_value = 0; timeout_set_warning = 1; @@ -1360,13 +1373,13 @@ int ReadCommandLineParms(int argc, { /* expect "Wnumber", seconds */ t = strtod(pArg + 1, (char**)&q); - if (t && q > pArg + 1) + if ( t && q > pArg + 1 ) { - if (*q != '\0') + if ( *q != '\0' ) { timeout_set_warning = 1; } - if (errno == ERANGE || t < 0.0 || t * 1000.0 >(double)LONG_MAX) + if ( errno == ERANGE || t < 0.0 || t * 1000.0 >(double)LONG_MAX ) { timeout_value = 0; timeout_set_warning = 1; @@ -1382,7 +1395,7 @@ int ReadCommandLineParms(int argc, timeout_set_error = 1; } } - if (timeout_set_error == 0) + if ( timeout_set_error == 0 ) { ip->msec_MaxTime = timeout_value; } @@ -1392,7 +1405,7 @@ int ReadCommandLineParms(int argc, #if ( READ_INCHI_STRING == 1 ) /*#if (BUILD_WITH_ENG_OPTIONS==1)*/ - else if (!inchi_stricmp(pArg, "InChI2InChI")) + else if ( !inchi_stricmp(pArg, "InChI2InChI") ) { /* Read InChI Identifiers and output InChI Identifiers */ ip->nInputType = INPUT_INCHI; @@ -1401,7 +1414,7 @@ int ReadCommandLineParms(int argc, } /*#endif*/ - else if (!inchi_stricmp(pArg, "InChI2Struct")) + else if ( !inchi_stricmp(pArg, "InChI2Struct") ) { /* Split InChI Identifiers into components */ ip->bReadInChIOptions |= READ_INCHI_TO_STRUCTURE; @@ -1409,7 +1422,7 @@ int ReadCommandLineParms(int argc, ip->nInputType = INPUT_INCHI; } - else if (!inchi_stricmp(pArg, "KeepBalanceP") && developer_options) + else if ( !inchi_stricmp(pArg, "KeepBalanceP") && developer_options ) { /* When spliting InChI Identifiers into components: */ /* If MobileH output then add p to each component; */ @@ -1424,7 +1437,7 @@ int ReadCommandLineParms(int argc, /* (developer_options) Old structure-perception and InChI creation options */ #if ( FIX_ADJ_RAD == 1 ) - else if (!inchi_stricmp(pArg, "FixRad") && developer_options) + else if ( !inchi_stricmp(pArg, "FixRad") && developer_options ) { bFixAdjacentRad = 1; bStdFormat = 0; @@ -1433,20 +1446,20 @@ int ReadCommandLineParms(int argc, #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 ) - else if (!inchi_stricmp(pArg, "TestRenum") && developer_options) + else if ( !inchi_stricmp(pArg, "TestRenum") && developer_options ) { ip->bRenumber = 1; } #endif #if ( UNDERIVATIZE == 1 ) - else if (!inchi_stricmp(pArg, "DoDRV") && developer_options) + else if ( !inchi_stricmp(pArg, "DoDRV") && developer_options ) { ip->bUnderivatize = 1; bStdFormat = 0; } #if( UNDERIVATIZE_REPORT == 1 ) - else if (!inchi_stricmp(pArg, "DoDrvReport")) + else if ( !inchi_stricmp(pArg, "DoDrvReport") ) { ip->bUnderivatize = 3; bStdFormat = 0; @@ -1454,60 +1467,60 @@ int ReadCommandLineParms(int argc, #endif #endif #if ( RING2CHAIN == 1 ) - else if (!inchi_stricmp(pArg, "DoR2C") && developer_options) + else if ( !inchi_stricmp(pArg, "DoR2C") && developer_options ) { ip->bRing2Chain = 1; bStdFormat = 0; } #endif #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 ) - else if (!inchi_stricmp(pArg, "DoneOnly") && developer_options) + else if ( !inchi_stricmp(pArg, "DoneOnly") && developer_options ) { ip->bIgnoreUnchanged = 1; bStdFormat = 0; } #endif - else if (!inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options) + else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options ) { bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10)); bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "NoADP") && developer_options) + else if ( !inchi_stricmp(pArg, "NoADP") && developer_options ) { bTgFlagHardAddRenProtons = 0; bStdFormat = 0; } /* Tautomer perception off */ - else if (!inchi_stricmp(pArg, "EXACT") && developer_options) + else if ( !inchi_stricmp(pArg, "EXACT") && developer_options ) { bVer1DefaultMode |= REQ_MODE_BASIC; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "ONLYRECSALT") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYRECSALT") && developer_options ) { /* do not disconnect salts */ bDisconnectSalts = 0; bStdFormat = 0; } - else if ((!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options) + else if ( (!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options ) { bVer1DefaultMode |= REQ_MODE_BASIC; bVer1DefaultMode &= ~REQ_MODE_TAUT; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "ONLYNONISO") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYNONISO") && developer_options ) { bVer1DefaultMode |= REQ_MODE_NON_ISO; bVer1DefaultMode &= ~REQ_MODE_ISO; bStdFormat = 0; } - else if (!inchi_stricmp(pArg, "TAUT") && developer_options) + else if ( !inchi_stricmp(pArg, "TAUT") && developer_options ) { bVer1DefaultMode &= ~REQ_MODE_BASIC; bVer1DefaultMode |= REQ_MODE_TAUT; } - else if (!inchi_stricmp(pArg, "ONLYRECMET") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYRECMET") && developer_options ) { /* do not disconnect metals */ bDisconnectCoord = 0; @@ -1516,21 +1529,21 @@ int ReadCommandLineParms(int argc, /*--- (hidden) Old output and other options ---*/ - else if (!inchi_stricmp(pArg, "SdfSplit") && developer_options) + else if ( !inchi_stricmp(pArg, "SdfSplit") && developer_options ) { /* Split single Molfiles into disconnected components */ bOutputMolfileSplit = 1; } - else if (!inchi_stricmp(pArg, "DCR") && developer_options) + else if ( !inchi_stricmp(pArg, "DCR") && developer_options ) { bDisplayCompositeResults = 1; } - else if ((!inchi_stricmp(pArg, "AUXFULL") || !inchi_stricmp(pArg, "AUXMAX")) && developer_options) + else if ( (!inchi_stricmp(pArg, "AUXFULL") || !inchi_stricmp(pArg, "AUXMAX")) && developer_options ) { /* full aux info */ bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include short aux info */ } - else if (!inchi_stricmp(pArg, "AUXMIN") && developer_options) + else if ( !inchi_stricmp(pArg, "AUXMIN") && developer_options ) { /* minimal aux info */ bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */ @@ -1538,17 +1551,17 @@ int ReadCommandLineParms(int argc, } #if ( READ_INCHI_STRING == 1 ) - else if (!inchi_stricmp(pArg, "DDSRC") && developer_options) + else if ( !inchi_stricmp(pArg, "DDSRC") && developer_options ) { bDisplayIfRestoreWarnings = 1; /* InChI->Structure debugging: Display Debug Structure Restore Components */ } #endif - else if (!inchi_stricmp(pArg, "NoVarH") && developer_options) + else if ( !inchi_stricmp(pArg, "NoVarH") && developer_options ) { bTgFlagVariableProtons = 0; } - else if (!inchi_stricmp(pArg, "FULL") && developer_options) + else if ( !inchi_stricmp(pArg, "FULL") && developer_options ) { bVer1DefaultMode = VER103_DEFAULT_MODE; nMode = 0; @@ -1558,7 +1571,7 @@ int ReadCommandLineParms(int argc, ip->bAbcNumbers = 0; bOutputStyle |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS; } - else if (!inchi_stricmp(pArg, "MIN") && developer_options) + else if ( !inchi_stricmp(pArg, "MIN") && developer_options ) { bVer1DefaultMode = VER103_DEFAULT_MODE; nMode = 0; @@ -1568,14 +1581,14 @@ int ReadCommandLineParms(int argc, ip->bAbcNumbers = 1; bOutputStyle |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS; } - else if (!inchi_stricmp(pArg, "COMPRESS") && developer_options) + else if ( !inchi_stricmp(pArg, "COMPRESS") && developer_options ) { ip->bAbcNumbers = 1; ip->bCtPredecessors = 1; /* compressed output */ } #if ( READ_INCHI_STRING == 1 ) - else if (!inchi_stricmp(pArg, "InChI2InChI")) /*&& developer_options)*/ + else if ( !inchi_stricmp(pArg, "InChI2InChI") ) /*&& developer_options)*/ { /* Read InChI Identifiers and output InChI Identifiers */ ip->nInputType = INPUT_INCHI; @@ -1583,66 +1596,66 @@ int ReadCommandLineParms(int argc, ip->bReadInChIOptions &= ~READ_INCHI_TO_STRUCTURE; } - else if (!inchi_stricmp(pArg, "SplitInChI") && developer_options) + else if ( !inchi_stricmp(pArg, "SplitInChI") && developer_options ) { /* Split InChI Identifiers into components */ ip->bReadInChIOptions |= READ_INCHI_SPLIT_OUTPUT; } #endif - else if (!inchi_stricmp(pArg, "MOLFILENUMBER") && developer_options) + else if ( !inchi_stricmp(pArg, "MOLFILENUMBER") && developer_options ) { ip->bGetMolfileNumber |= 1; } - else if (!inchi_stricmp(pArg, "OutputPLAIN") && developer_options) + else if ( !inchi_stricmp(pArg, "OutputPLAIN") && developer_options ) { bOutputStyle |= INCHI_OUT_PLAIN_TEXT; } - else if (!inchi_stricmp(pArg, "OutputANNPLAIN") && developer_options) + else if ( !inchi_stricmp(pArg, "OutputANNPLAIN") && developer_options ) { bOutputStyle |= INCHI_OUT_PLAIN_TEXT_COMMENTS; bOutputStyle |= INCHI_OUT_WINCHI_WINDOW; /* debug */ } - else if ((!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options) + else if ( (!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options ) { bVer1DefaultMode |= REQ_MODE_BASIC; bVer1DefaultMode &= ~REQ_MODE_TAUT; } - else if (!inchi_stricmp(pArg, "ONLYNONISO") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYNONISO") && developer_options ) { bVer1DefaultMode |= REQ_MODE_NON_ISO; bVer1DefaultMode &= ~REQ_MODE_ISO; } - else if (!inchi_stricmp(pArg, "TAUT") && developer_options) + else if ( !inchi_stricmp(pArg, "TAUT") && developer_options ) { bVer1DefaultMode &= ~REQ_MODE_BASIC; bVer1DefaultMode |= REQ_MODE_TAUT; } - else if (!inchi_stricmp(pArg, "ONLYRECMET") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYRECMET") && developer_options ) { /* do not disconnect metals */ bDisconnectCoord = 0; } - else if (!inchi_stricmp(pArg, "ONLYRECSALT") && developer_options) + else if ( !inchi_stricmp(pArg, "ONLYRECSALT") && developer_options ) { /* do not disconnect salts */ bDisconnectSalts = 0; } - else if (!inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options) + else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options ) { /* added -- 2010-03-01 DT */ bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10)); } - else if (!inchi_memicmp(pArg, "RSB:", 4) && developer_options) + else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options ) { mdbr = (int)strtol(pArg + 4, NULL, 10); } - else if (!inchi_stricmp(pArg, "EQU") && developer_options) + else if ( !inchi_stricmp(pArg, "EQU") && developer_options ) { bCompareComponents = CMP_COMPONENTS; } - else if (!inchi_stricmp(pArg, "EQUNONISO") && developer_options) + else if ( !inchi_stricmp(pArg, "EQUNONISO") && developer_options ) { bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO; } - else if (!inchi_memicmp(pArg, "OP:", 3) && developer_options) + else if ( !inchi_memicmp(pArg, "OP:", 3) && developer_options ) { bOutputPath = 1; strncpy(szOutputPath, pArg + 3, sizeof(szOutputPath) - 1); @@ -1662,16 +1675,16 @@ int ReadCommandLineParms(int argc, } /* eof Parsing stand-alone executable/libinchi options */ - else if (ip->num_paths < MAX_NUM_PATHS) + else if ( ip->num_paths < MAX_NUM_PATHS ) { char* sz; #if( ALLOW_EMPTY_PATHS == 1 ) - if (argv[i]) + if ( argv[i] ) #else - if (argv[i] && argv[i][0]) + if ( argv[i] && argv[i][0] ) #endif { - if ((sz = (char*)inchi_malloc((strlen(argv[i]) + 1) * sizeof(sz[0])))) /* djb-rwth: addressing LLVM warning */ + if ( (sz = (char*)inchi_malloc((strlen(argv[i]) + 1) * sizeof(sz[0]))) ) /* djb-rwth: addressing LLVM warning */ { strcpy(sz, argv[i]); } @@ -1685,21 +1698,21 @@ int ReadCommandLineParms(int argc, /* Print messages and set controil variables according to just parsed options */ /* Timeout option(s) */ - if (timeout_set_warning) + if ( timeout_set_warning ) { inchi_ios_eprint(log_file, "Warning: timeout value may have been modified (truncated?) due to number formatting issues;\n"); } - if (timeout_set_error) + if ( timeout_set_error ) { inchi_ios_eprint(log_file, "Warning: specified timeout value was ignored due to invalid number format, using the default;\n"); } /* InChIKey option(s) */ - if (bHashKey != 0) + if ( bHashKey != 0 ) { /* Suppress InChIKey calculation if: */ /* compressed output OR Inchi2Struct OR Inchi2Inchi */ - if ((ip->bAbcNumbers == 1) && (ip->bCtPredecessors == 1)) + if ( (ip->bAbcNumbers == 1) && (ip->bCtPredecessors == 1) ) { bHashKey = 0; #ifndef TARGET_LIB_FOR_WINCHI @@ -1707,7 +1720,7 @@ int ReadCommandLineParms(int argc, return -1; #endif } - if (ip->nInputType == INPUT_INCHI) + if ( ip->nInputType == INPUT_INCHI ) { bHashKey = 0; #ifndef TARGET_LIB_FOR_WINCHI @@ -1717,7 +1730,7 @@ int ReadCommandLineParms(int argc, } else { - if (bOutputMolfileOnly == 1) + if ( bOutputMolfileOnly == 1 ) { bHashKey = 0; #ifndef TARGET_LIB_FOR_WINCHI @@ -1728,7 +1741,7 @@ int ReadCommandLineParms(int argc, } } - if (bNameSuffix || bOutputPath) + if ( bNameSuffix || bOutputPath ) { const char szNUL[] = "NUL"; /* fix for AMD processor: use const char[] instead of just "NUL" constant 2008-11-5 DT */ @@ -1738,31 +1751,31 @@ int ReadCommandLineParms(int argc, char* sz; int len; /* find the 1st path */ - for (i = 0; i < MAX_NUM_PATHS; i++) + for ( i = 0; i < MAX_NUM_PATHS; i++ ) { - if (!p && ip->path[i] && ip->path[i][0]) + if ( !p && ip->path[i] && ip->path[i][0] ) { p = ip->path[i]; break; } } /* fix output path */ - if (bOutputPath && szOutputPath[0] && p) + if ( bOutputPath && szOutputPath[0] && p ) { /* remove last slash */ len = (int)strlen(szOutputPath); - if (len > 0 && szOutputPath[len - 1] != INCHI_PATH_DELIM) + if ( len > 0 && szOutputPath[len - 1] != INCHI_PATH_DELIM ) { szOutputPath[len++] = INCHI_PATH_DELIM; szOutputPath[len] = '\0'; } - if (len > 0 && (r = (char*)strrchr(p, INCHI_PATH_DELIM)) && r[1]) + if ( len > 0 && (r = (char*)strrchr(p, INCHI_PATH_DELIM)) && r[1] ) { strcat(szOutputPath, r + 1); p = szOutputPath; } } -/* djb-rwth: copying the value of p */ + /* djb-rwth: copying the value of p */ #ifdef _WIN32 p_prev = _strdup(p); #else @@ -1770,15 +1783,15 @@ int ReadCommandLineParms(int argc, #endif /* add missing paths */ /* djb-rwth: this whole block had to be rewritten to avoid use of memory after it is freed */ - for (i = 0; p_prev && i < MAX_NUM_PATHS; i++) + for ( i = 0; p_prev && i < MAX_NUM_PATHS; i++ ) { /* fix for AMD processor: changed order 2008-11-5 DT */ - if (!ip->path[i] || !ip->path[i][0]) + if ( !ip->path[i] || !ip->path[i][0] ) { #if ( BUILD_WITH_AMI == 1 ) && ( OUTPUT_FILE_EXT == 1 ) char* pLastExt = (i && numOutNameExt >= i) ? strrchr((char*)p_prev, '.') : 0; char* pLastSlash = (i && numOutNameExt >= i) ? strrchr((char*)p_prev, INCHI_PATH_DELIM) : 0; - if (pLastExt && pLastSlash && pLastSlash > pLastExt) + if ( pLastExt && pLastSlash && pLastSlash > pLastExt ) pLastExt = NULL; #else char* pLastExt = NULL; @@ -1788,23 +1801,23 @@ int ReadCommandLineParms(int argc, { strcpy(sz, p_prev); /* djb-rwth: fix for use of memory after being freed */ #if ( BUILD_WITH_AMI == 1 ) && ( OUTPUT_FILE_EXT == 1 ) - if (pLastExt) + if ( pLastExt ) { strcpy(sz + (pLastExt - p), szOutNameExt[i - 1]); } #endif strcat(sz, szNameSuffix); - if (!pLastExt) + if ( !pLastExt ) strcat(sz, ext[i]); ip->num_paths++; - if (ip->path[i]) + if ( ip->path[i] ) { inchi_free((char*)ip->path[i]); /* eliminate memory leak 2013-12-18 DCh */ } ip->path[i] = sz; } } - else if (!inchi_stricmp(ip->path[i], szNUL)) + else if ( !inchi_stricmp(ip->path[i], szNUL) ) { inchi_free((char*)ip->path[i]); /* cast deliberately const qualifier */ ip->path[i] = NULL; @@ -1815,12 +1828,12 @@ int ReadCommandLineParms(int argc, /* inchi2inchi and inchi2struct option(s) */ #if ( READ_INCHI_STRING == 1 ) - if (INPUT_INCHI == ip->nInputType) + if ( INPUT_INCHI == ip->nInputType ) { bCompareComponents = 0; /*bDisplayCompositeResults = 0;*/ #if ( I2S_MODIFY_OUTPUT == 1 ) - if (!(ip->bReadInChIOptions & READ_INCHI_TO_STRUCTURE)) + if ( !(ip->bReadInChIOptions & READ_INCHI_TO_STRUCTURE) ) #endif { bOutputMolfileOnly = 0; @@ -1830,7 +1843,7 @@ int ReadCommandLineParms(int argc, /* bNoStructLabels = 1; */ } ip->bDisplayIfRestoreWarnings = bDisplayIfRestoreWarnings; - if (!(bINChIOutputOptions & + if ( !(bINChIOutputOptions & (INCHI_OUT_SDFILE_ONLY | /* not in bINChIOutputOptions yet */ INCHI_OUT_PLAIN_TEXT | /* not in bINChIOutputOptions yet */ INCHI_OUT_PLAIN_TEXT_COMMENTS /* not in bINChIOutputOptions yet */ @@ -1847,17 +1860,17 @@ int ReadCommandLineParms(int argc, } #endif - if (bVer1Options) + if ( bVer1Options ) { nMode |= bVer1DefaultMode; } - else if (bReleaseVersion) + else if ( bReleaseVersion ) { nMode |= nReleaseMode; } #if ( defined(COMPILE_ANSI_ONLY) || defined(TARGET_LIB_FOR_WINCHI) ) - if (bCompareComponents && !(bDisplay & 1)) + if ( bCompareComponents && !(bDisplay & 1) ) { bCompareComponents = 0; } @@ -1883,30 +1896,30 @@ int ReadCommandLineParms(int argc, ip->bDoNotAddH = bDoNotAddH; /* Set default options */ - if (!nMode || nMode == REQ_MODE_STEREO) + if ( !nMode || nMode == REQ_MODE_STEREO ) { /* requested all output */ nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO); } else { - if (!(nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT))) + if ( !(nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) ) { nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT); } - if ((nMode & REQ_MODE_STEREO) && !(nMode & (REQ_MODE_ISO | REQ_MODE_NON_ISO))) + if ( (nMode & REQ_MODE_STEREO) && !(nMode & (REQ_MODE_ISO | REQ_MODE_NON_ISO)) ) { nMode |= (REQ_MODE_ISO | REQ_MODE_NON_ISO); } } /* if the user requested isotopic then unconditionally add non-isotopic output. */ - if (nMode & REQ_MODE_ISO) + if ( nMode & REQ_MODE_ISO ) { nMode |= REQ_MODE_NON_ISO; } #if ( MIN_SB_RING_SIZE > 0 ) - if (mdbr) + if ( mdbr ) { nMinDbRinSize = mdbr; } @@ -1914,20 +1927,20 @@ int ReadCommandLineParms(int argc, #endif /* Input file */ - if (ip->nInputType == INPUT_NONE && ip->num_paths > 0) + if ( ip->nInputType == INPUT_NONE && ip->num_paths > 0 ) { ip->nInputType = INPUT_MOLFILE; /* default */ } ip->nMode = nMode; /* Compare components */ - if ((bCompareComponents & CMP_COMPONENTS) && (nMode & REQ_MODE_BASIC)) + if ( (bCompareComponents & CMP_COMPONENTS) && (nMode & REQ_MODE_BASIC) ) { bCompareComponents |= CMP_COMPONENTS_NONTAUT; /* compare non-tautomeric */ } ip->bCompareComponents = bCompareComponents; /* Output */ ip->bINChIOutputOptions = bINChIOutputOptions | (bOutputMolfileOnly ? INCHI_OUT_SDFILE_ONLY : 0); - if (bOutputMolfileOnly) + if ( bOutputMolfileOnly ) { bOutputStyle &= ~(INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS | @@ -1938,7 +1951,7 @@ int ReadCommandLineParms(int argc, #endif } #ifdef TARGET_LIB_FOR_WINCHI - if (!(bDisplay & 1)) + if ( !(bDisplay & 1) ) { bOutputStyle &= ~(INCHI_OUT_PLAIN_TEXT_COMMENTS); /* do not ouput comments in wINChI text file results */ } @@ -1951,7 +1964,7 @@ int ReadCommandLineParms(int argc, ip->bNoStructLabels = bNoStructLabels; /* Processing options */ - if (bForcedChiralFlag) + if ( bForcedChiralFlag ) { ip->bChiralFlag = bForcedChiralFlag; } @@ -2015,7 +2028,7 @@ int ReadCommandLineParms(int argc, ip->bTautFlags |= bFixSp3bug ? TG_FLAG_FIX_SP3_BUG : 0; /* Bug fixes */ - if (bFixFB2) + if ( bFixFB2 ) { #if ( FIX_ISO_FIXEDH_BUG == 1 ) ip->bTautFlags |= TG_FLAG_FIX_ISO_FIXEDH_BUG; /* accomodate FIX_ISO_FIXEDH_BUG */ @@ -2030,26 +2043,26 @@ int ReadCommandLineParms(int argc, #endif } - if (!ip->nInputType) + if ( !ip->nInputType ) { ip->nInputType = INPUT_MOLFILE; } /* Check if /SNon requested turn OFF SUU/SLUUD */ - if (!(ip->nMode & REQ_MODE_STEREO)) + if ( !(ip->nMode & REQ_MODE_STEREO) ) { ip->nMode &= ~REQ_MODE_DIFF_UU_STEREO; ip->nMode &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU); } /* Standard InChI ? */ - if (bStdFormat) + if ( bStdFormat ) { ip->bINChIOutputOptions |= INCHI_OUT_STDINCHI; } /* InChIKey ? */ - if (!bHashKey) + if ( !bHashKey ) { ip->bCalcInChIHash = INCHIHASH_NONE; } @@ -2058,18 +2071,18 @@ int ReadCommandLineParms(int argc, ip->bCalcInChIHash = INCHIHASH_KEY; } /* Extension(s) to hash (in non-std mode only) ? */ - if (!bHashKey) + if ( !bHashKey ) { - if ((bHashXtra1 != 0) || (bHashXtra2 != 0)) + if ( (bHashXtra1 != 0) || (bHashXtra2 != 0) ) { inchi_ios_eprint(log_file, "Hash extension(s) not generated: InChIKey not requested"); } } else { - if (bHashXtra1) + if ( bHashXtra1 ) { - if (bHashXtra2) + if ( bHashXtra2 ) { ip->bCalcInChIHash = INCHIHASH_KEY_XTRA1_XTRA2; } @@ -2078,7 +2091,7 @@ int ReadCommandLineParms(int argc, ip->bCalcInChIHash = INCHIHASH_KEY_XTRA1; } } - else if (bHashXtra2) + else if ( bHashXtra2 ) { ip->bCalcInChIHash = INCHIHASH_KEY_XTRA2; } @@ -2089,7 +2102,7 @@ int ReadCommandLineParms(int argc, ip->bNPZz = bNPZz; ip->bStereoAtZz = bStereoAtZz; /*STEREO_AT_ZZ;*/ - + ip->bMolecularInorganics = bMolecularInorganics; /* @nnuk */ ip->bNoWarnings = bNoWarnings; ip->bMergeHash = bMergeHash; ip->bHideInChI = bHideInChI; @@ -2107,7 +2120,7 @@ int ReadCommandLineParms(int argc, #if ( UNDERIVATIZE == 1 ) ip->bUnderivatize = 1; - if (ip->bUnderivatize) + if ( ip->bUnderivatize ) { ip->bINChIOutputOptions &= ~INCHI_OUT_STDINCHI; } @@ -2148,12 +2161,12 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, int first = 1; - if (!(ip->bINChIOutputOptions & INCHI_OUT_STDINCHI)) + if ( !(ip->bINChIOutputOptions & INCHI_OUT_STDINCHI) ) { bStdFormat = 0; } /* Some stereo */ - if (!(nMode & REQ_MODE_STEREO)) + if ( !(nMode & REQ_MODE_STEREO) ) { inchi_ios_eprint(log_file, "Using specific structure perception features:\n"); first = 0; @@ -2161,9 +2174,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } else { - if (!(TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags)) + if ( !(TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags) ) { - if (first) + if ( first ) { inchi_ios_eprint(log_file, "Using specific structure perception features:\n"); first = 0; @@ -2171,9 +2184,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, " Both ends of wedge point to stereocenters\n"); } } - if (ip->bDoNotAddH) + if ( ip->bDoNotAddH ) { - if (first) + if ( first ) { inchi_ios_eprint(log_file, "Using specific structure perception features:\n"); } @@ -2182,18 +2195,18 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 ) - if (ip->bRenumber == 1) + if ( ip->bRenumber == 1 ) { inchi_ios_eprint(log_file, "\nGenerate InChI upon random atom renumbering\n\n"); } #endif #if ( UNDERIVATIZE == 1 ) - if (ip->bUnderivatize == 1) + if ( ip->bUnderivatize == 1 ) { inchi_ios_eprint(log_file, "\nConvert input structure to derivative precursor before InChI calculation\n\n"); } - else if (ip->bUnderivatize == 3) + else if ( ip->bUnderivatize == 3 ) { inchi_ios_eprint(log_file, "\nOutputs derivative information for the input structure\n\n"); } @@ -2202,16 +2215,16 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, /* Generation/conversion indicator */ - if (bStdFormat) + if ( bStdFormat ) { - if (!(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && !bInChI2Struct) + if ( !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && !bInChI2Struct ) { inchi_ios_eprint(log_file, "Generating standard InChI\n"); } #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) && !defined(TARGET_EXE_USING_API) ) /* effective only in command line program InChI or stdInChI */ - else if (bInChI2Struct) + else if ( bInChI2Struct ) { inchi_ios_eprint(log_file, "Converting InChI(s) to structure(s) in %s\n", (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) ? @@ -2225,7 +2238,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } /* SDfile output */ - if (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) + if ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY ) { inchi_ios_eprint(log_file, "Output SDfile only without stereochemical information and atom coordinates%s\n", @@ -2234,17 +2247,17 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } /* Fixed/Mobile H */ - if (!bStdFormat) + if ( !bStdFormat ) { - if ((nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC | REQ_MODE_TAUT)) + if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC | REQ_MODE_TAUT) ) { inchi_ios_eprint(log_file, " Mobile H Perception OFF (include FixedH layer)\n"); } - else if ((nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_TAUT)) + else if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_TAUT) ) { inchi_ios_eprint(log_file, " Mobile H Perception ON (omit FixedH layer)\n"); } - else if ((nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC)) + else if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC) ) { inchi_ios_eprint(log_file, " Mobile H ignored\n"); } @@ -2253,9 +2266,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, " Undefined Mobile H mode\n"); } - if ((ip->bTautFlags & TG_FLAG_VARIABLE_PROTONS)) + if ( (ip->bTautFlags & TG_FLAG_VARIABLE_PROTONS) ) { - if (!(ip->bTautFlags & TG_FLAG_HARD_ADD_REM_PROTONS)) + if ( !(ip->bTautFlags & TG_FLAG_HARD_ADD_REM_PROTONS) ) { inchi_ios_eprint(log_file, " Disabled Aggressive (De)protonation\n"); } @@ -2266,9 +2279,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, #endif /* RecMet */ - if (ip->bTautFlags & TG_FLAG_DISCONNECT_COORD) + if ( ip->bTautFlags & TG_FLAG_DISCONNECT_COORD ) { - if (ip->bTautFlags & TG_FLAG_RECONNECT_COORD) + if ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD ) { inchi_ios_eprint(log_file, " Include bonds to metals\n"); } @@ -2291,14 +2304,14 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, */ #if ( FIX_ADJ_RAD == 1 ) - if (ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS) + if ( ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS ) { inchi_ios_eprint(log_file, "Fix Adjacent Radicals\n"); } #endif /* Stereo */ - if (nMode & REQ_MODE_STEREO) + if ( nMode & REQ_MODE_STEREO ) { inchi_ios_eprint(log_file, " %s%s%s%sStereo ON\n", (nMode & REQ_MODE_NOEQ_STEREO) ? "Slow " : "", @@ -2309,15 +2322,15 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, (nMode & REQ_MODE_RELATIVE_STEREO) ? "Relative " : (nMode & REQ_MODE_CHIR_FLG_STEREO) ? "Chiral Flag " : "Absolute "); - if (0 == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU))) + if ( 0 == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) { inchi_ios_eprint(log_file, " Include undefined/unknown stereogenic centers and bonds\n"); } - else if (REQ_MODE_SC_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU))) + else if ( REQ_MODE_SC_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) { inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic centers\n"); } - else if (REQ_MODE_SB_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU))) + else if ( REQ_MODE_SB_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) { inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic bonds\n"); } @@ -2326,16 +2339,16 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, /*case REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU*/ inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic centers and bonds\n"); } - if (0 != (nMode & REQ_MODE_DIFF_UU_STEREO)) + if ( 0 != (nMode & REQ_MODE_DIFF_UU_STEREO) ) { inchi_ios_eprint(log_file, " Make labels for unknown and undefined stereo different\n"); } #if ( defined(MIN_SB_RING_SIZE) && MIN_SB_RING_SIZE > 0 ) k = (ip->nMode & REQ_MODE_MIN_SB_RING_MASK) >> REQ_MODE_MIN_SB_RING_SHFT; - if (bRELEASE_VERSION != 1 || k != MIN_SB_RING_SIZE) + if ( bRELEASE_VERSION != 1 || k != MIN_SB_RING_SIZE ) { - if (k >= 3) + if ( k >= 3 ) { inchi_ios_eprint(log_file, " Min. stereobond ring size: %d\n", k); } @@ -2348,9 +2361,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } /* Stereo */ } /* !bStdFormat */ - if (!bStdFormat) + if ( !bStdFormat ) { - if (TG_FLAG_KETO_ENOL_TAUT & ip->bTautFlags) + if ( TG_FLAG_KETO_ENOL_TAUT & ip->bTautFlags ) { inchi_ios_eprint(log_file, " Account for keto-enol tautomerism\n"); } @@ -2358,7 +2371,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, { inchi_ios_eprint(log_file, " Do not account for keto-enol tautomerism\n"); } - if (TG_FLAG_1_5_TAUT & ip->bTautFlags) + if ( TG_FLAG_1_5_TAUT & ip->bTautFlags ) { inchi_ios_eprint(log_file, " Account for 1,5-tautomerism\n"); } @@ -2367,34 +2380,34 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, " Do not account for 1,5-tautomerism\n"); } - if (TG_FLAG_PT_22_00 & ip->bTautFlags) + if ( TG_FLAG_PT_22_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_22_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_22_00 tautomerism\n"); - if (TG_FLAG_PT_16_00 & ip->bTautFlags) + if ( TG_FLAG_PT_16_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_16_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_16_00 tautomerism\n"); - if (TG_FLAG_PT_06_00 & ip->bTautFlags) + if ( TG_FLAG_PT_06_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_06_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_06_00 tautomerism\n"); - if (TG_FLAG_PT_39_00 & ip->bTautFlags) + if ( TG_FLAG_PT_39_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_39_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_39_00 tautomerism\n"); - if (TG_FLAG_PT_13_00 & ip->bTautFlags) + if ( TG_FLAG_PT_13_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_13_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_13_00 tautomerism\n"); - if (TG_FLAG_PT_18_00 & ip->bTautFlags) + if ( TG_FLAG_PT_18_00 & ip->bTautFlags ) inchi_ios_eprint(log_file, " Account for PT_18_00 tautomerism\n"); else inchi_ios_eprint(log_file, " Do not account for PT_18_00 tautomerism\n"); - if (developer_options) + if ( developer_options ) { - if (TG_FLAG_PHOSPHINE_STEREO & ip->bTautFlags) + if ( TG_FLAG_PHOSPHINE_STEREO & ip->bTautFlags ) { inchi_ios_eprint(log_file, " Include phosphine stereochemistry\n"); } @@ -2402,7 +2415,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, { inchi_ios_eprint(log_file, " Do not include phosphine stereochemistry\n"); } - if (TG_FLAG_ARSINE_STEREO & ip->bTautFlags) + if ( TG_FLAG_ARSINE_STEREO & ip->bTautFlags ) { inchi_ios_eprint(log_file, " Include arsine stereochemistry\n"); } @@ -2410,19 +2423,19 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, { inchi_ios_eprint(log_file, " Do not include arsine stereochemistry\n"); } - if (!(TG_FLAG_FIX_SP3_BUG & ip->bTautFlags)) + if ( !(TG_FLAG_FIX_SP3_BUG & ip->bTautFlags) ) { inchi_ios_eprint(log_file, " Turned OFF fix of bug leading to missing or undefined sp3 parity\n"); } - if (!(TG_FLAG_FIX_ISO_FIXEDH_BUG & ip->bTautFlags)) + if ( !(TG_FLAG_FIX_ISO_FIXEDH_BUG & ip->bTautFlags) ) { inchi_ios_eprint(log_file, " Turned OFF bug-fixes found after v.1.02b release\n"); } - if (!(ip->bFixNonUniformDraw)) + if ( !(ip->bFixNonUniformDraw) ) { inchi_ios_eprint(log_file, " Turned OFF fixes of non-uniform drawing issues\n"); } - if (!(TG_FLAG_MOVE_POS_CHARGES & ip->bTautFlags)) + if ( !(TG_FLAG_MOVE_POS_CHARGES & ip->bTautFlags) ) { inchi_ios_eprint(log_file, " MovePos turned OFF\n"); } @@ -2430,9 +2443,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } /* !bStdFormat */ - if (ip->bCalcInChIHash != INCHIHASH_NONE) + if ( ip->bCalcInChIHash != INCHIHASH_NONE ) { - if (bStdFormat) + if ( bStdFormat ) { inchi_ios_eprint(log_file, "Generating standard InChIKey\n"); } @@ -2440,24 +2453,24 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, { inchi_ios_eprint(log_file, "Generating InChIKey\n"); } - if (ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1) + if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1 ) { inchi_ios_eprint(log_file, "Generating hash extension (1st block)\n"); } - else if (ip->bCalcInChIHash == INCHIHASH_KEY_XTRA2) + else if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA2 ) { inchi_ios_eprint(log_file, "Generating hash extension (2nd block)\n"); } - else if (ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2) + else if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ) { inchi_ios_eprint(log_file, "Generating hash extension (two blocks)\n"); } } - if (ip->bINChIOutputOptions & INCHI_OUT_SAVEOPT) + if ( ip->bINChIOutputOptions & INCHI_OUT_SAVEOPT ) { inchi_ios_eprint(log_file, "Saving InChI creation options"); - if (bStdFormat) + if ( bStdFormat ) { inchi_ios_eprint(log_file, " suppressed for standard InChI"); /* NB: actual suppression takes place on InChI serialization */ @@ -2467,13 +2480,13 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, "\n"); } - if (ip->bAllowEmptyStructure) + if ( ip->bAllowEmptyStructure ) { inchi_ios_eprint(log_file, "Issue warning on empty structure\n"); } /* Input */ - if (ip->nInputType) + if ( ip->nInputType ) { inchi_ios_eprint(log_file, "Input format: %s", ip->nInputType == INPUT_MOLFILE ? "MOLfile" : @@ -2482,15 +2495,15 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, ip->nInputType == INPUT_INCHI ? "InChI (plain identifier)" : #endif ip->nInputType == INPUT_INCHI_PLAIN ? "InChI AuxInfo (plain)" : "Unknown"); - if ((ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) && - ip->bGetMolfileNumber) + if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) && + ip->bGetMolfileNumber ) { inchi_ios_eprint(log_file, " (attempting to read Molfile number)"); } inchi_ios_eprint(log_file, "\n"); } - if (ip->szSdfDataHeader[0] && ip->nInputType != INPUT_SDFILE) + if ( ip->szSdfDataHeader[0] && ip->nInputType != INPUT_SDFILE ) { inchi_ios_eprint(log_file, " SDfile data header: \"%s\"\n", ip->szSdfDataHeader); } @@ -2506,9 +2519,9 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, (ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)) ? ", tabbed" : ""); #if ( bRELEASE_VERSION == 1 ) - if (ip->bCtPredecessors || ip->bAbcNumbers) + if ( ip->bCtPredecessors || ip->bAbcNumbers ) { - if (ip->bCtPredecessors && ip->bAbcNumbers) + if ( ip->bCtPredecessors && ip->bAbcNumbers ) { inchi_ios_eprint(log_file, "Representation: Compressed\n"); } @@ -2520,7 +2533,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } } #else - if ((bRELEASE_VERSION != 1) || ip->bCtPredecessors || ip->bAbcNumbers) + if ( (bRELEASE_VERSION != 1) || ip->bCtPredecessors || ip->bAbcNumbers ) { inchi_ios_eprint(log_file, "Connection table: %s, %s\n", ip->bCtPredecessors ? "Predecessor_numbers(closures)" : "Canon_numbers(branching, ring closures)", @@ -2532,29 +2545,29 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, } #endif - if (ip->bNoWarnings) + if ( ip->bNoWarnings ) { inchi_ios_eprint(log_file, "Warnings suppressed\n"); } - if (ip->bHideInChI) + if ( ip->bHideInChI ) { inchi_ios_eprint(log_file, "Printing InChI string itself suppressed\n"); } - if (ip->bMergeHash) + if ( ip->bMergeHash ) { inchi_ios_eprint(log_file, "InChIKey combined with extra hash(es)\n"); } - if (!(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY)) + if ( !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) ) { - if (ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) + if ( ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) { inchi_ios_eprint(log_file, "Aux. info suppressed\n"); } - else if (ip->bINChIOutputOptions & INCHI_OUT_SHORT_AUX_INFO) + else if ( ip->bINChIOutputOptions & INCHI_OUT_SHORT_AUX_INFO ) { inchi_ios_eprint(log_file, "Minimal Aux. info\n"); } @@ -2563,32 +2576,32 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, "Full Aux. info\n"); } } - if (ip->first_struct_number > 1) + if ( ip->first_struct_number > 1 ) { inchi_ios_eprint(log_file, "Skipping %ld structure%s\n", ip->first_struct_number - 1, ip->first_struct_number == 2 ? "" : "s"); } - if (ip->last_struct_number > 0) + if ( ip->last_struct_number > 0 ) { inchi_ios_eprint(log_file, "Terminate after structure #%ld\n", ip->last_struct_number); } - if (ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0]) + if ( ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0] ) { inchi_ios_eprint(log_file, "Saving warning structures into the problem file\n"); } - if (ip->bSaveAllGoodStructsAsProblem && ip->path[3] && ip->path[3][0]) + if ( ip->bSaveAllGoodStructsAsProblem && ip->path[3] && ip->path[3][0] ) { inchi_ios_eprint(log_file, "Saving only all good structures into the problem file\n"); } - if (ip->bINChIOutputOptions2 & INCHI_OUT_INCHI_GEN_ERROR) + if ( ip->bINChIOutputOptions2 & INCHI_OUT_INCHI_GEN_ERROR ) { inchi_ios_eprint(log_file, "Print empty InChI if generation fails\n"); } - if (ip->bINChIOutputOptions2 & INCHI_OUT_MISMATCH_AS_ERROR) + if ( ip->bINChIOutputOptions2 & INCHI_OUT_MISMATCH_AS_ERROR ) { inchi_ios_eprint(log_file, "Consider problem/mismatch on InChI conversion as error\n"); } - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { inchi_ios_eprint(log_file, "Timeout per structure: %ld msec\n", ip->msec_MaxTime); /* @@ -2603,14 +2616,14 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, "No timeout\n"); } - if (ip->bLooseTSACheck) + if ( ip->bLooseTSACheck ) { inchi_ios_eprint(log_file, "Relax criteria of ambiguous drawing for in-ring stereo centers\n"); } { int maxna = NORMALLY_ALLOWED_INP_MAX_ATOMS; - if (ip->bLargeMolecules) + if ( ip->bLargeMolecules ) { inchi_ios_eprint(log_file, "Experimental mode: "); maxna = MAX_ATOMS; @@ -2618,37 +2631,42 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, "Up to %d atoms per structure\n", maxna); } - if (ip->bPolymers != POLYMERS_NO) + if ( ip->bPolymers != POLYMERS_NO ) { inchi_ios_eprint(log_file, "Experimental mode: Treating polymers"); - if (ip->bPolymers == POLYMERS_MODERN) + if ( ip->bPolymers == POLYMERS_MODERN ) { ; } - else if (ip->bPolymers == POLYMERS_LEGACY) + else if ( ip->bPolymers == POLYMERS_LEGACY ) { inchi_ios_eprint(log_file, " (v. 1.05 legacy mode)"); } - else if (ip->bPolymers == POLYMERS_LEGACY_PLUS) + else if ( ip->bPolymers == POLYMERS_LEGACY_PLUS ) { inchi_ios_eprint(log_file, " (v. 1.05 legacy mode with senior link placed at start)"); } - if (ip->bFoldPolymerSRU) + if ( ip->bFoldPolymerSRU ) { inchi_ios_eprint(log_file, "; CRU folding enabled"); } } inchi_ios_eprint(log_file, "\n"); - if (ip->bNPZz == 1) + if ( ip->bNPZz == 1 ) { inchi_ios_eprint(log_file, "Allowing non-polymer Zz pseudo atoms\n"); } - if (ip->bStereoAtZz == 1) + if ( ip->bStereoAtZz == 1 ) { inchi_ios_eprint(log_file, "Allowing stereo at atoms connected to Zz\n"); } + /* @nnuk */ + if (ip->bMolecularInorganics == 1) + { + inchi_ios_eprint(log_file, "Molecular Inorganics mode enabled\n"); + } /* Report debug modes */ #if ( bRELEASE_VERSION != 1 ) @@ -2673,7 +2691,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, inchi_ios_eprint(log_file, "Only chain attachments to tautomeric rings=%s\n", TAUT_RINGS_ATTACH_CHAIN == 1 ? "Y" : "N"); #endif - if (ip->bGetSdfileId) + if ( ip->bGetSdfileId ) { inchi_ios_eprint(log_file, "Extracting SDfile IDs\n"); } @@ -2699,7 +2717,7 @@ int PrintInputParms(INCHI_IOSTREAM* log_file, /****************************************************************************/ void HelpCommandLineParms(INCHI_IOSTREAM* f) { - if (!f) + if ( !f ) { return; } @@ -2717,7 +2735,7 @@ void HelpCommandLineParms(INCHI_IOSTREAM* f) APP_DESCRIPTION, INCHI_SRC_REV, INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__, RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***", - INCHI_OPTION_PREFX, INCHI_OPTION_PREFX ); + INCHI_OPTION_PREFX, INCHI_OPTION_PREFX); #if ( BUILD_WITH_AMI == 1 ) inchi_ios_print_nodisplay(f, @@ -2767,6 +2785,7 @@ void HelpCommandLineParms(INCHI_IOSTREAM* f) #endif inchi_ios_print_nodisplay(f, "Structure perception\n"); + inchi_ios_print_nodisplay(f, " MolecularInorganics Parameter deals with Molecular Inorganics (initial testing phase)\n"); /*(@nnuk : Nauman Ullah Khan) :: Parameter for Molecular Inorganics added*/ inchi_ios_print_nodisplay(f, " SNon Exclude stereo (default: include absolute stereo)\n"); inchi_ios_print_nodisplay(f, " NEWPSOFF Both ends of wedge point to stereocenters (default: a narrow end)\n"); inchi_ios_print_nodisplay(f, " LooseTSACheck Relax criteria of ambiguous drawing for in-ring tetrahedral stereo\n"); @@ -2894,7 +2913,7 @@ int OpenFiles(FILE** inp_file, */ /* Logfile (open as early as possible) */ - if (!ip->path[2] || !ip->path[2][0]) + if ( !ip->path[2] || !ip->path[2][0] ) { fprintf2(stderr, "%s %-s\n%-s Build (%-s%-s) of %s %s %-s\n\n", APP_DESCRIPTION, INCHI_SRC_REV, @@ -2903,7 +2922,7 @@ int OpenFiles(FILE** inp_file, fprintf2(stderr, "Log file not specified. Using standard error output.\n"); *log_file = stderr; } - else if (!(*log_file = fopen(ip->path[2], "w"))) + else if ( !(*log_file = fopen(ip->path[2], "w")) ) { fprintf2(stderr, "%s %-s\n%-s Build (%-s%-s) of %s %s%-s\n\n", APP_DESCRIPTION, INCHI_SRC_REV, @@ -2922,17 +2941,17 @@ int OpenFiles(FILE** inp_file, } /* Input file */ - if ((ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE || + if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE || ip->nInputType == INPUT_INCHI || ip->nInputType == INPUT_INCHI_PLAIN) && - ip->num_paths > 0) + ip->num_paths > 0 ) { const char* fmode = NULL; #if ( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) ) /* compilers that definitely allow fopen "rb" (binary read) mode */ fmode = "rb"; - if (!ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "rb"))) + if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "rb")) ) { fprintf2(*log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0] ? ip->path[0] : ""); goto exit_function; @@ -2944,7 +2963,7 @@ int OpenFiles(FILE** inp_file, #else - if (!ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "r"))) + if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "r")) ) { fprintf2(*log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0] ? ip->path[0] : ""); goto exit_function; @@ -2959,11 +2978,11 @@ int OpenFiles(FILE** inp_file, DetectInputINChIFileType(inp_file, ip, fmode); } - else if ((ip->nInputType != INPUT_MOLFILE && + else if ( (ip->nInputType != INPUT_MOLFILE && ip->nInputType != INPUT_SDFILE && ip->nInputType != INPUT_INCHI && /* post-1.02b */ - ip->nInputType != INPUT_INCHI_PLAIN)) + ip->nInputType != INPUT_INCHI_PLAIN) ) { fprintf2(*log_file, "Input file type not specified. Terminating.\n"); goto exit_function; @@ -2975,14 +2994,14 @@ int OpenFiles(FILE** inp_file, } /* Output file */ - if (!ip->path[1] || !ip->path[1][0]) + if ( !ip->path[1] || !ip->path[1][0] ) { fprintf2(*log_file, "Output file not specified. Using standard output.\n"); *out_file = stdout; } else { - if (!(*out_file = fopen(ip->path[1], "w"))) + if ( !(*out_file = fopen(ip->path[1], "w")) ) { fprintf2(*log_file, "Cannot open output file '%s'. Terminating.\n", ip->path[1]); goto exit_function; @@ -2990,11 +3009,11 @@ int OpenFiles(FILE** inp_file, else { fprintf2(*log_file, "Opened output file '%s'\n", ip->path[1]); - if ((ip->bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT)) && + if ( (ip->bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT)) && *inp_file != stdin && !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && !ip->bNoStructLabels && - !(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)) + !(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT) ) { PrintFileName("* Input_File: \"%s\"\n", *out_file, ip->path[0]); } @@ -3002,7 +3021,7 @@ int OpenFiles(FILE** inp_file, } /* Problem file */ - if (ip->path[3] && ip->path[3][0]) + if ( ip->path[3] && ip->path[3][0] ) { const char* fmode = "w"; @@ -3010,7 +3029,7 @@ int OpenFiles(FILE** inp_file, fmode = "wb"; #endif - if (!(*prb_file = fopen(ip->path[3], fmode))) + if ( !(*prb_file = fopen(ip->path[3], fmode)) ) { fprintf2(*log_file, "Cannot open problem file '%s'. Terminating.\n", ip->path[3]); goto exit_function; @@ -3046,10 +3065,10 @@ static int bMatchOnePrefix(int len, char* str, int numPrefix) { int i; - for (i = 0; i < numPrefix; i++) + for ( i = 0; i < numPrefix; i++ ) { - if (len >= lenPrefix[i] && - !memcmp(str, strPrefix[i], lenPrefix[i])) + if ( len >= lenPrefix[i] && + !memcmp(str, strPrefix[i], lenPrefix[i]) ) { return 1; } @@ -3072,12 +3091,12 @@ int DetectInputINChIFileType(FILE** inp_file, int bINChI_plain = 0, len, i; - if (ip->nInputType == INPUT_INCHI_PLAIN || ip->nInputType == INPUT_INCHI) + if ( ip->nInputType == INPUT_INCHI_PLAIN || ip->nInputType == INPUT_INCHI ) { return 1; } - if (!bInitialized) + if ( !bInitialized ) { lenPlnVersion[0] = sprintf(szPlnVersion[0], "%s=%s/", INCHI_NAME, INCHI_VERSION); lenPlnVersion[1] = sprintf(szPlnVersion[1], "INChI=1.12Beta/"); @@ -3098,21 +3117,21 @@ int DetectInputINChIFileType(FILE** inp_file, #endif } - for (i = 0; i < 4; i++) + for ( i = 0; i < 4; i++ ) { len = inchi_fgetsLfTab(szLine, sizeof(szLine) - 1, *inp_file); - if (len < 0) + if ( len < 0 ) { break; } - if (bMatchOnePrefix(len, szLine, lenPlnVersion, szPlnVersion, NUM_VERSIONS) || - bMatchOnePrefix(len, szLine, lenPlnAuxVer, szPlnAuxVer, NUM_VERSIONS)) + if ( bMatchOnePrefix(len, szLine, lenPlnVersion, szPlnVersion, NUM_VERSIONS) || + bMatchOnePrefix(len, szLine, lenPlnAuxVer, szPlnAuxVer, NUM_VERSIONS) ) { bINChI_plain++; } } - if (bINChI_plain >= 2) + if ( bINChI_plain >= 2 ) { ip->nInputType = INPUT_INCHI_PLAIN; ret = 1; diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c b/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c index 38f7debe..18a0f059 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. -* -* The InChI library and programs are free software developed under the + * + * The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,7 +36,7 @@ * * info@inchi-trust.org * -*/ + */ #include #include @@ -52,190 +52,189 @@ #include "bcf_s.h" -#include "logging.h" /*(@nnuk : Nauman Ullah Khan) :: Needed for logging functionality*/ +#include "logging.h" /*(@nnuk : Nauman Ullah Khan) :: Needed for logging functionality*/ /* Local functions */ /* djb-rwth: removing redundant code */ -static int str_LineEnd( const char *tag, - int *bOverflow, - INCHI_IOS_STRING *buf, - int ind, - int bPlainTextTags ); -static int CleanOrigCoord( MOL_COORD szCoord, int delim ); -static int WriteOrigCoord( int num_inp_atoms, - MOL_COORD *szMolCoord, - int *i, - char *szBuf, - int buf_len ); -static int WriteOrigAtoms( CANON_GLOBALS *pCG, - int num_inp_atoms, - inp_ATOM *at, - int *i, - char *szBuf, - int buf_len, - STRUCT_DATA *sd ); -static int WriteOrigBonds( CANON_GLOBALS *pCG, - int num_inp_atoms, - inp_ATOM *at, - int *i, - char *szBuf, - int buf_len, - STRUCT_DATA *sd ); -static void GetSaveOptLetters( unsigned char save_opt_bits, - char* let1, - char* let2 ); -static int OutputINCHI_VersionAndKind( INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int bINChIOutputOptions, - int is_beta, - char *pLF, - char *pTAB ); -static int OutputINCHI_MainLayerFormula( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputINCHI_MainLayerConnections( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputINCHI_MainLayerHydrogens( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputINCHI_ChargeAndRemovedAddedProtonsLayers( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputINCHI_StereoLayer( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, +static int str_LineEnd(const char *tag, + int *bOverflow, + INCHI_IOS_STRING *buf, + int ind, + int bPlainTextTags); +static int CleanOrigCoord(MOL_COORD szCoord, int delim); +static int WriteOrigCoord(int num_inp_atoms, + MOL_COORD *szMolCoord, + int *i, + char *szBuf, + int buf_len); +static int WriteOrigAtoms(CANON_GLOBALS *pCG, + int num_inp_atoms, + inp_ATOM *at, + int *i, + char *szBuf, + int buf_len, + STRUCT_DATA *sd); +static int WriteOrigBonds(CANON_GLOBALS *pCG, + int num_inp_atoms, + inp_ATOM *at, + int *i, + char *szBuf, + int buf_len, + STRUCT_DATA *sd); +static void GetSaveOptLetters(unsigned char save_opt_bits, + char *let1, + char *let2); +static int OutputINCHI_VersionAndKind(INCHI_IOSTREAM *out_file, INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, + int bINChIOutputOptions, + int is_beta, char *pLF, - char *pTAB ); -static int OutputINCHI_FixedHLayerWithSublayers( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB, - int *then_goto_repeat ); -static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, INCHI_IOSTREAM *out_file, INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - ORIG_ATOM_DATA *orig_inp_data, ORIG_STRUCT *pOrigStruct, - INCHI_OUT_CTL *io, char *pLF, char *pTAB ); -static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, - int bPolymers, - int total_star_atoms, - int *n_used_stars, - OAD_AtProps *aprops, - int *cano_nums, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - INCHI_IOS_STRING *strbuf ); -static int OutputAUXINFO_HeaderAndNormalization_type( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int bINChIOutputOptions, - int *INCHI_basic_or_INCHI_reconnected, - int num_components2[], - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputAUXINFO_OriginalNumbersAndEquivalenceClasses( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputAUXINFO_TautomericGroupsEquivalence( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io ); -static int OutputAUXINFO_Stereo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, char *pTAB ); -/* djb-rwth: removing redundant code */ -static int OutputAUXINFO_ChargesRadicalsAndUnusualValences( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); -static int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, + char *pTAB); +static int OutputINCHI_MainLayerFormula(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputINCHI_MainLayerConnections(CANON_GLOBALS *pCG, INCHI_IOSTREAM *out_file, INCHI_IOS_STRING *strbuf, - ORIG_STRUCT *pOrigStruct, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, INCHI_OUT_CTL *io, char *pLF, - char *pTAB ); - -static int OutputAUXINFO_PolymerInfo( CANON_GLOBALS *pCG, + char *pTAB); +static int OutputINCHI_MainLayerHydrogens(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputINCHI_ChargeAndRemovedAddedProtonsLayers(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputINCHI_StereoLayer(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputINCHI_IsotopicLayer(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputINCHI_FixedHLayerWithSublayers(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB, + int *then_goto_repeat); +static int OutputINCHI_PolymerLayer(CANON_GLOBALS *pCG, INCHI_IOSTREAM *out_file, INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + ORIG_ATOM_DATA *orig_inp_data, ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, char *pLF, char *pTAB); +static int OutputINCHI_PolymerLayer_SingleUnit(OAD_PolymerUnit *u, + int bPolymers, + int total_star_atoms, + int *n_used_stars, + OAD_AtProps *aprops, + int *cano_nums, + ORIG_ATOM_DATA *orig_inp_data, + ORIG_STRUCT *pOrigStruct, + INCHI_IOS_STRING *strbuf); +static int OutputAUXINFO_HeaderAndNormalization_type(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int bINChIOutputOptions, + int *INCHI_basic_or_INCHI_reconnected, + int num_components2[], + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputAUXINFO_OriginalNumbersAndEquivalenceClasses(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputAUXINFO_TautomericGroupsEquivalence(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io); +static int OutputAUXINFO_Stereo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputAUXINFO_IsotopicInfo(CANON_GLOBALS *pCG, INCHI_IOSTREAM *out_file, INCHI_IOS_STRING *strbuf, - ORIG_STRUCT *pOrigStruct, + int *INCHI_basic_or_INCHI_reconnected, INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ); + char *pLF, char *pTAB); +/* djb-rwth: removing redundant code */ +static int OutputAUXINFO_ChargesRadicalsAndUnusualValences(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); +static int OutputAUXINFO_ReversibilityInfo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); -static int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - int nat, - int *cano_nums, - int *compnt_nums ); +static int OutputAUXINFO_PolymerInfo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB); -static int CountPseudoElementInFormula( const char *pseudo, char *s ); -static int IsBondAtomNumsLesser( int *bond1, int* bond2 ); +static int InternallyGetCanoNumsAndComponentNums(CANON_GLOBALS *pCG, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + int nat, + int *cano_nums, + int *compnt_nums); -static void inchi_sort_int_pair_ascending( int* a, int* b ); +static int CountPseudoElementInFormula(const char *pseudo, char *s); +static int IsBondAtomNumsLesser(int *bond1, int *bond2); + +static void inchi_sort_int_pair_ascending(int *a, int *b); /* djb-rwth: removing redundant code */ -static void MergeZzInStrHillFormulaComponent( char *s ); +static void MergeZzInStrHillFormulaComponent(char *s); /* Local constants */ -const char sCompDelim[] = ";"; /* component delimiter */ +const char sCompDelim[] = ";"; /* component delimiter */ const char sIdenticalValues[] = "*"; /* identical component */ const char x_space[] = " "; - /* Output: words & additional tags */ @@ -279,41 +278,39 @@ typedef struct tagInchiTag const char *szPlainLabel; const char *szPlainComment; const char *szXmlLabel; - int bAlwaysOutput; + int bAlwaysOutput; } INCHI_TAG; - /* Identifier */ const INCHI_TAG IdentLbl[] = -{ - /* prefixes: may be combined in this order */ - /* IL_FIXH_ORD, */ { "/", "fixed_H", "fixed-H", 0 }, /* fixed H */ - /* IL_ISOT_ORD, */ { "/", "isotopic", "isotopic", 0 }, /* isotopic */ - /* IL_STER_ORD, */ { "/", "stereo", "stereo", 0 }, /* stereo */ - /* items */ - /* IL_VERS_ORD, */ { "" , "version", "version", 1 }, - /* IL_FML__ORD, */ { "/", "formula", "formula", 1 }, /* basic part formula */ - /* IL_CONN_ORD, */ { "/c", "connections", "connections", 1 }, - /* IL_ALLH_ORD, */ { "/h", "H_atoms", "H", 1 }, - /* IL_CHRG_ORD, */ { "/q", "charge", "charge", 1 }, - /* IL_PROT_ORD, */ { "/p", "protons", "protons", 0 }, - /* stereo */ - /* IL_DBND_ORD, */ { "/b", "dbond", "dbond", 0 }, - /* IL_SP3S_ORD, */ { "/t", "sp3", "sp3", 0 }, - /* IL_INVS_ORD, */ { "/m", "sp3:inverted", "abs.inverted", 0 }, /* mirrored */ - /* IL_TYPS_ORD, */ { "/s", "type (1=abs, 2=rel, 3=rac)", "type", 0 }, /* stereo type */ - /* isotopic */ - /* IL_ATMS_ORD, */ { "/i", "atoms", "atoms", 1 }, - /* isotopic mobile H only */ - /* IL_XCGA_ORD, */ { "/h", "exchangeable_H", "H-isotopic", 1 }, - /* fixed H only */ - /* IL_FMLF_ORD, */ { "/f", "formula", "formula", 1 }, /* fixed H formula */ - /* IL_HFIX_ORD, */ { "/h", "H_fixed" , "H-fixed" , 1 }, /* fixed-H */ - /* IL_TRNS_ORD, */ { "/o", "transposition", "transposition", 0 }, /* order */ - /* IL_REC__ORD, */ { "/r", "reconnected bond(s) to metal(s) formula", "formula", 0 } -}; + { + /* prefixes: may be combined in this order */ + /* IL_FIXH_ORD, */ {"/", "fixed_H", "fixed-H", 0}, /* fixed H */ + /* IL_ISOT_ORD, */ {"/", "isotopic", "isotopic", 0}, /* isotopic */ + /* IL_STER_ORD, */ {"/", "stereo", "stereo", 0}, /* stereo */ + /* items */ + /* IL_VERS_ORD, */ {"", "version", "version", 1}, + /* IL_FML__ORD, */ {"/", "formula", "formula", 1}, /* basic part formula */ + /* IL_CONN_ORD, */ {"/c", "connections", "connections", 1}, + /* IL_ALLH_ORD, */ {"/h", "H_atoms", "H", 1}, + /* IL_CHRG_ORD, */ {"/q", "charge", "charge", 1}, + /* IL_PROT_ORD, */ {"/p", "protons", "protons", 0}, + /* stereo */ + /* IL_DBND_ORD, */ {"/b", "dbond", "dbond", 0}, + /* IL_SP3S_ORD, */ {"/t", "sp3", "sp3", 0}, + /* IL_INVS_ORD, */ {"/m", "sp3:inverted", "abs.inverted", 0}, /* mirrored */ + /* IL_TYPS_ORD, */ {"/s", "type (1=abs, 2=rel, 3=rac)", "type", 0}, /* stereo type */ + /* isotopic */ + /* IL_ATMS_ORD, */ {"/i", "atoms", "atoms", 1}, + /* isotopic mobile H only */ + /* IL_XCGA_ORD, */ {"/h", "exchangeable_H", "H-isotopic", 1}, + /* fixed H only */ + /* IL_FMLF_ORD, */ {"/f", "formula", "formula", 1}, /* fixed H formula */ + /* IL_HFIX_ORD, */ {"/h", "H_fixed", "H-fixed", 1}, /* fixed-H */ + /* IL_TRNS_ORD, */ {"/o", "transposition", "transposition", 0}, /* order */ + /* IL_REC__ORD, */ {"/r", "reconnected bond(s) to metal(s) formula", "formula", 0}}; /* @@ -371,7 +368,6 @@ typedef enum tagIdentLblOrd IL_MAX_ORD /* max number of tags */ } IDENT_LBL_ORD; - typedef enum tagIdentLblBit { IL_FIXH = 1 << IL_FIXH_ORD, @@ -400,41 +396,37 @@ typedef enum tagIdentLblBit IL_REC_ = 1 << IL_REC__ORD } IDENT_LBL_BIT; - - /* Aux Info constants */ const INCHI_TAG AuxLbl[] = -{ -/* prefixes may be combined in this order */ - /* AL_FIXH_ORD, */ { "/", "fixed_H", "fixed-H", 0 }, /* fixed-H */ - /* AL_ISOT_ORD, */ { "/", "isotopic", "isotopic", 0 }, /* isotopic */ - /* AL_STER_ORD, */ { "/", "abs_stereo_inverted", "stereo.abs.inverted", 0 }, /* inv abs sp3 stereo */ - /* AL_REVR_ORD, */ { "/", "reversibility", "reversibility", 0 }, /* reversibility */ - /* items */ - /* AL_VERS_ORD, */ { "", "version", "version", 1 }, - /* AL_NORM_ORD, */ { "/", "normalization_type", "norm-type", 1 }, - /* AL_ANBR_ORD, */ { "/N:", "original_atom_numbers", "atom.orig-nbr", 1 }, - /* AL_AEQU_ORD, */ { "/E:", "atom_equivalence", "atom.equivalence", 0 }, - /* AL_GEQU_ORD, */ { "/gE:", "group_equivalence", "group.equivalence", 0 }, - /* inv abs sp3 stereo */ - /* AL_SP3I_ORD, */ { "/it:", "sp3", "sp3", 0 }, - /* AL_SP3N_ORD, */ { "/iN:", "original_atom_numbers", "atom.orig-nbr", 0 }, - - /* AL_CRV__ORD, */ { "/CRV:", "charge_radical_valence", "charges-rad-val", 0 }, - /* reversibility */ - /* AL_ATMR_ORD, */ { "/rA:", "atoms", "atoms", 0 }, - /* AL_BNDR_ORD, */ { "/rB:", "bonds", "bonds", 0 }, - /* AL_XYZR_ORD, */ { "/rC:", "xyz", "xyz", 0 }, - /* fixed-H only */ - /* AL_FIXN_ORD, */ { "/F:", "original_atom_numbers", "atom.orig-nbr", 1 }, - /* isotopic only */ - /* AL_ISON_ORD, */ { "/I:", "original_atom_numbers", "atom.orig-nbr", 1 }, - - /* AL_REC__ORD, */ { "/R:", "reconnected bond(s) to metal(s) part", "", 1 } -}; - + { + /* prefixes may be combined in this order */ + /* AL_FIXH_ORD, */ {"/", "fixed_H", "fixed-H", 0}, /* fixed-H */ + /* AL_ISOT_ORD, */ {"/", "isotopic", "isotopic", 0}, /* isotopic */ + /* AL_STER_ORD, */ {"/", "abs_stereo_inverted", "stereo.abs.inverted", 0}, /* inv abs sp3 stereo */ + /* AL_REVR_ORD, */ {"/", "reversibility", "reversibility", 0}, /* reversibility */ + /* items */ + /* AL_VERS_ORD, */ {"", "version", "version", 1}, + /* AL_NORM_ORD, */ {"/", "normalization_type", "norm-type", 1}, + /* AL_ANBR_ORD, */ {"/N:", "original_atom_numbers", "atom.orig-nbr", 1}, + /* AL_AEQU_ORD, */ {"/E:", "atom_equivalence", "atom.equivalence", 0}, + /* AL_GEQU_ORD, */ {"/gE:", "group_equivalence", "group.equivalence", 0}, + /* inv abs sp3 stereo */ + /* AL_SP3I_ORD, */ {"/it:", "sp3", "sp3", 0}, + /* AL_SP3N_ORD, */ {"/iN:", "original_atom_numbers", "atom.orig-nbr", 0}, + + /* AL_CRV__ORD, */ {"/CRV:", "charge_radical_valence", "charges-rad-val", 0}, + /* reversibility */ + /* AL_ATMR_ORD, */ {"/rA:", "atoms", "atoms", 0}, + /* AL_BNDR_ORD, */ {"/rB:", "bonds", "bonds", 0}, + /* AL_XYZR_ORD, */ {"/rC:", "xyz", "xyz", 0}, + /* fixed-H only */ + /* AL_FIXN_ORD, */ {"/F:", "original_atom_numbers", "atom.orig-nbr", 1}, + /* isotopic only */ + /* AL_ISON_ORD, */ {"/I:", "original_atom_numbers", "atom.orig-nbr", 1}, + + /* AL_REC__ORD, */ {"/R:", "reconnected bond(s) to metal(s) part", "", 1}}; typedef enum tagAuxLblOrd { @@ -464,10 +456,9 @@ typedef enum tagAuxLblOrd AL_REC__ORD, - AL_MAX_ORD /* max number of tags */ + AL_MAX_ORD /* max number of tags */ } AUX_LBL_ORD; - typedef enum tagAuxLblBit { AL_FIXH = 1 << AL_FIXH_ORD, @@ -499,21 +490,18 @@ typedef enum tagAuxLblBit /* const int MAX_TAG_NUM = inchi_max((short)IL_MAX_ORD, (short)AL_MAX_ORD); */ /* djb-rwth: fixing MSVC warning C5287 */ -char *szGetTag( const INCHI_TAG *Tag, int nTag, int bTag, char *szTag, int *bAlways, short tag_flag ); /* djb-rwth: fixing GHI #160 */ - -#define SP(N) (x_space+sizeof(x_space)-1-(N)) - +char *szGetTag(const INCHI_TAG *Tag, int nTag, int bTag, char *szTag, int *bAlways, short tag_flag); /* djb-rwth: fixing GHI #160 */ +#define SP(N) (x_space + sizeof(x_space) - 1 - (N)) #define NOT_YET_I2I_FOR_POLYMERS 40 - /**************************************************************************** Print error message (plain text) ****************************************************************************/ -int OutputINChIPlainError( INCHI_IOSTREAM *out_file, - char *pErrorText, - int bError ) +int OutputINChIPlainError(INCHI_IOSTREAM *out_file, + char *pErrorText, + int bError) { /* char szBuf[64]; */ const char *pErr; @@ -522,53 +510,51 @@ int OutputINChIPlainError( INCHI_IOSTREAM *out_file, switch (bError) { - case _IS_WARNING: - pErr = x_warn; - break; - case _IS_ERROR: - pErr = x_err; - break; - default: /* _IS_FATAL */ - pErr = x_ferr; - break; + case _IS_WARNING: + pErr = x_warn; + break; + case _IS_ERROR: + pErr = x_err; + break; + default: /* _IS_FATAL */ + pErr = x_ferr; + break; } /* djb-rwth: removing redundant code */ - inchi_ios_print( out_file, - "%s: %s=\"%s\" %s=\"%s\"", - x_message, x_type, pErr, x_text, szErrorText ); + inchi_ios_print(out_file, + "%s: %s=\"%s\" %s=\"%s\"", + x_message, x_type, pErr, x_text, szErrorText); #ifdef TARGET_LIB_FOR_WINCHI - inchi_ios_print( out_file, "\n" ); + inchi_ios_print(out_file, "\n"); #endif ret = 1; return ret; } +#ifndef OUT_TN /* defined in mode.h; quoted here for reference purposes only */ -#ifndef OUT_TN /* defined in mode.h; quoted here for reference purposes only */ - -#define OUT_N1 0 /* non-tautomeric only */ -#define OUT_T1 1 /* tautomeric if present otherwise non-tautomeric */ -#define OUT_NT 2 /* only non-taut representations of tautomeric */ -#define OUT_TN 3 /* tautomeric if present otherwise non-tautomeric; - sepatately output non-taut representations of tautomeric if present */ +#define OUT_N1 0 /* non-tautomeric only */ +#define OUT_T1 1 /* tautomeric if present otherwise non-tautomeric */ +#define OUT_NT 2 /* only non-taut representations of tautomeric */ +#define OUT_TN 3 /* tautomeric if present otherwise non-tautomeric; \ + sepatately output non-taut representations of tautomeric if present */ /* OUT_TN = OUT_T1 + OUT_NT */ #endif - /**************************************************************************** Calculate equivalence mark (used to check for repeating (sub)layer(s) ) ****************************************************************************/ -const char *EquString( int EquVal ) +const char *EquString(int EquVal) { - int bFrom = EquVal & ( iiSTEREO | iiSTEREO_INV | iiNUMB | iiEQU ); - int bType = EquVal & ( iitISO | iitNONTAUT ); - int bEq2 = EquVal & ( iiEq2NONTAUT | iiEq2ISO | iiEq2INV ); + int bFrom = EquVal & (iiSTEREO | iiSTEREO_INV | iiNUMB | iiEQU); + int bType = EquVal & (iitISO | iitNONTAUT); + int bEq2 = EquVal & (iiEq2NONTAUT | iiEq2ISO | iiEq2INV); const char *r = ""; -#if ( FIX_EMPTY_LAYER_BUG == 1 ) +#if (FIX_EMPTY_LAYER_BUG == 1) int bEmpty = EquVal & iiEmpty; if (bEmpty) { @@ -580,409 +566,409 @@ const char *EquString( int EquVal ) switch (bFrom) { - case iiSTEREO: /* ------------ Stereo --------------------*/ - switch (bType) + case iiSTEREO: /* ------------ Stereo --------------------*/ + switch (bType) + { + case iitISO: /* iso main stereo =... */ + switch (bEq2) { - case iitISO: /* iso main stereo =... */ - switch (bEq2) - { - case 0: - r = "m"; /* iso main stereo = main stereo */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case iitNONTAUT: /* non-taut stereo =... */ - switch (bEq2) - { - case 0: - r = "m"; /* non-taut stereo = main stereo */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case ( iitNONTAUT | iitISO ): /* iso non-taut stereo = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* iso non-taut stereo = main stereo */ - break; - case iiEq2ISO: - r = "M"; /* iso non-taut stereo = main iso stereo */ - break; - case iiEq2NONTAUT: - r = "n"; /* iso non-taut stereo = non-taut stereo */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - default: - r = "??"; /* should not happen */ - break; + case 0: + r = "m"; /* iso main stereo = main stereo */ + break; + default: + r = "??"; /* should not happen */ + break; } break; - - case iiSTEREO_INV: /*---------- Inverted Aux Stereo ------*/ - if (bEq2 & iiEq2INV) - { /* stereo = Inverted(another stereo) */ - bEq2 &= ~iiEq2INV; - switch (bType) - { - case 0: /* main = ...*/ - switch (bEq2) - { - case 0: - r = "im"; /* main = Inv(main) */ - break; - case iiEq2ISO: - r = "iM"; /* main = Inv(main iso) */ - break; - case iiEq2NONTAUT: - r = "in"; /* maim = Inv(non-taut) */ - break; - case ( iiEq2NONTAUT | iiEq2ISO ): - r = "iN"; /* maim = Inv(non-taut iso ) */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case iitISO: /* main iso = ...*/ - switch (bEq2) - { - case 0: - r = "im"; /* main iso = Inv(main) */ - break; - case iiEq2ISO: - r = "iM"; /* main iso = Inv(main iso) */ - break; - case iiEq2NONTAUT: - r = "in"; /* maim iso = Inv(non-taut) */ - break; - case ( iiEq2NONTAUT | iiEq2ISO ): - r = "iN"; /* maim = Inv(non-taut iso ) */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case iitNONTAUT: /* non-taut = ... */ - switch (bEq2) - { - case 0: - r = "im"; /* non-taut = Inv(main) */ - break; - case iiEq2ISO: - r = "iM"; /* non-taut = Inv(main iso) */ - break; - case iiEq2NONTAUT: - r = "in"; /* non-taut = Inv(non-taut) */ - break; - case ( iiEq2NONTAUT | iiEq2ISO ): - r = "iN"; /* non-taut = Inv(non-taut iso ) */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case ( iitNONTAUT | iitISO ): - switch (bEq2) - { - case 0: - r = "im"; /* non-taut iso = Inv(main) */ - break; - case iiEq2ISO: - r = "iM"; /* non-taut iso = Inv(main iso) */ - break; - case iiEq2NONTAUT: - r = "in"; /* non-taut iso = Inv(non-taut) */ - break; - case ( iiEq2NONTAUT | iiEq2ISO ): - r = "iN"; /* non-taut iso = Inv(non-taut iso ) */ - break; - default: - r = "??"; /* should not happen */ - } - break; - default: - r = "??"; /* should not happen */ - break; - } + case iitNONTAUT: /* non-taut stereo =... */ + switch (bEq2) + { + case 0: + r = "m"; /* non-taut stereo = main stereo */ + break; + default: + r = "??"; /* should not happen */ + break; } - else - { /* Inv stereo = another (non-inverted) stereo */ - - switch (bType) - { - case iitISO: /* main iso = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* main = (inverted aux) main */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case iitNONTAUT: /* non-taut = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* non-taut = (inverted aux) main */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - case ( iitNONTAUT | iitISO ): /* non-taut iso = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* non-taut iso = (inverted aux) main */ - break; - case iiEq2ISO: - r = "M"; /* non-taut iso = (inverted aux) main iso */ - break; - case iiEq2NONTAUT: - r = "n"; /* non-taut iso = (inverted aux) non-taut */ - break; - default: - r = "??"; /* should not happen */ - break; - } - break; - default: - r = "??"; /* should not happen */ - break; - } + break; + case (iitNONTAUT | iitISO): /* iso non-taut stereo = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* iso non-taut stereo = main stereo */ + break; + case iiEq2ISO: + r = "M"; /* iso non-taut stereo = main iso stereo */ + break; + case iiEq2NONTAUT: + r = "n"; /* iso non-taut stereo = non-taut stereo */ + break; + default: + r = "??"; /* should not happen */ + break; } break; + default: + r = "??"; /* should not happen */ + break; + } + break; - case ( iiNUMB | iiSTEREO_INV ): /*------------- Inv Stereo Numbering ------------*/ + case iiSTEREO_INV: /*---------- Inverted Aux Stereo ------*/ + if (bEq2 & iiEq2INV) + { /* stereo = Inverted(another stereo) */ + bEq2 &= ~iiEq2INV; switch (bType) { - case 0: /* inv stereo numb main = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* inv stereo numb main = main numb */ - break; - default: - r = "??"; /* should not happen */ - break; - } + case 0: /* main = ...*/ + switch (bEq2) + { + case 0: + r = "im"; /* main = Inv(main) */ break; - case iitISO: /* inv stereo iso numb main = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* inv stereo iso numb main = main numb */ - break; - case iiEq2INV: - r = "im"; /* inv stereo iso numb main = InvStereo(main) numb */ - break; - case iiEq2ISO: - r = "M"; /* inv stereo iso numb main = isotopic main numb */ - break; - default: - r = "??"; /* should not happen */ - break; - } + case iiEq2ISO: + r = "iM"; /* main = Inv(main iso) */ break; - case iitNONTAUT: /* inv stereo numb non-taut = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* inv stereo numb non-taut = main numb */ - break; - case iiEq2NONTAUT: - r = "n"; /* inv stereo numb non-taut = non-taut numb */ - break; - case iiEq2INV: - r = "im"; /* inv stereo numb non-taut = InvStereo(main) numb */ - break; - default: - r = "??"; /* should not happen */ - break; - } + case iiEq2NONTAUT: + r = "in"; /* maim = Inv(non-taut) */ break; - case ( iitNONTAUT | iitISO ): /* inv stereo numb non-taut iso = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* inv stereo numb non-taut iso = main numb */ - break; - case iiEq2ISO: - r = "M"; /* inv stereo numb non-taut iso = main numb iso */ - break; - case ( iiEq2ISO | iiEq2INV ): - r = "iM"; /* inv stereo numb non-taut iso = InvStereo(main iso) numb */ - break; - case iiEq2NONTAUT: - r = "n"; /* inv stereo numb non-taut iso = non-taut numb */ - break; - case ( iiEq2NONTAUT | iiEq2ISO ): - r = "N"; /* inv stereo numb non-taut iso = non-taut iso numb */ - break; - case iiEq2INV: - r = "im"; /* inv stereo numb non-taut iso = InvStereo(main) numb */ - break; - case ( iiEq2NONTAUT | iiEq2INV ): - r = "in"; /* inv stereo numb non-taut iso = InvStereo(non-taut) numb ) */ - break; - default: - r = "??"; /* should not happen */ - break; - } + case (iiEq2NONTAUT | iiEq2ISO): + r = "iN"; /* maim = Inv(non-taut iso ) */ break; default: - r = "??"; /* should not happen */ + r = "??"; /* should not happen */ break; - } - break; - - case iiNUMB: /*------------- Canonical Numbering ------------*/ - switch (bType) - { - case 0: /* numb main = ...*/ - r = "??"; /* should not happen */ + } + break; + case iitISO: /* main iso = ...*/ + switch (bEq2) + { + case 0: + r = "im"; /* main iso = Inv(main) */ break; - case iitISO: /* iso numb main = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* iso numb main = main numb */ - break; - default: - r = "??"; /* should not happen */ - } + case iiEq2ISO: + r = "iM"; /* main iso = Inv(main iso) */ break; - case iitNONTAUT: /* numb non-taut = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* numb non-taut = main numb */ - break; - default: - r = "??"; /* should not happen */ - } + case iiEq2NONTAUT: + r = "in"; /* maim iso = Inv(non-taut) */ break; - case ( iitNONTAUT | iitISO ): /* numb non-taut iso = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* numb non-taut iso = main numb */ - break; - case iiEq2ISO: - r = "M"; /* numb non-taut iso = main numb iso */ - break; - case iiEq2NONTAUT: - r = "n"; /* numb non-taut iso = non-taut numb */ - break; - default: - r = "??"; /* should not happen */ - break; - } + case (iiEq2NONTAUT | iiEq2ISO): + r = "iN"; /* maim = Inv(non-taut iso ) */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case iitNONTAUT: /* non-taut = ... */ + switch (bEq2) + { + case 0: + r = "im"; /* non-taut = Inv(main) */ + break; + case iiEq2ISO: + r = "iM"; /* non-taut = Inv(main iso) */ + break; + case iiEq2NONTAUT: + r = "in"; /* non-taut = Inv(non-taut) */ + break; + case (iiEq2NONTAUT | iiEq2ISO): + r = "iN"; /* non-taut = Inv(non-taut iso ) */ break; default: - r = "??"; /* should not happen */ + r = "??"; /* should not happen */ + break; + } + break; + case (iitNONTAUT | iitISO): + switch (bEq2) + { + case 0: + r = "im"; /* non-taut iso = Inv(main) */ + break; + case iiEq2ISO: + r = "iM"; /* non-taut iso = Inv(main iso) */ break; + case iiEq2NONTAUT: + r = "in"; /* non-taut iso = Inv(non-taut) */ + break; + case (iiEq2NONTAUT | iiEq2ISO): + r = "iN"; /* non-taut iso = Inv(non-taut iso ) */ + break; + default: + r = "??"; /* should not happen */ + } + break; + default: + r = "??"; /* should not happen */ + break; } - break; + } + else + { /* Inv stereo = another (non-inverted) stereo */ - case iiEQU: /*------------- Atom Equivalence ------------*/ switch (bType) { - case 0: /* equivalence main = ...*/ - r = "??"; /* should not happen */ + case iitISO: /* main iso = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* main = (inverted aux) main */ break; - case iitISO: /* equivalence main iso = ...*/ - switch (bEq2) - { - case 0: - r = "m"; /* equivalence main = main equ */ - break; - default: - r = "??"; /* should not happen */ - break; - } + default: + r = "??"; /* should not happen */ break; - case iitNONTAUT: /* equivalence non-taut = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* equivalence non-taut = main equ */ - break; - default: - r = "??"; /* should not happen */ - break; - } + } + break; + case iitNONTAUT: /* non-taut = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* non-taut = (inverted aux) main */ break; - case ( iitNONTAUT | iitISO ): /* equivalence non-taut iso = ... */ - switch (bEq2) - { - case 0: - r = "m"; /* equivalence non-taut iso = main equ */ - break; - case iiEq2ISO: - r = "M"; /* equivalence non-taut iso = main iso equ */ - break; - case iiEq2NONTAUT: - r = "n"; /* equivalence non-taut iso = non-taut equ */ - break; - default: - r = "??"; /* should not happen */ - break; - } + default: + r = "??"; /* should not happen */ + break; + } + break; + case (iitNONTAUT | iitISO): /* non-taut iso = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* non-taut iso = (inverted aux) main */ + break; + case iiEq2ISO: + r = "M"; /* non-taut iso = (inverted aux) main iso */ + break; + case iiEq2NONTAUT: + r = "n"; /* non-taut iso = (inverted aux) non-taut */ break; default: - r = "??"; /* should not happen */ + r = "??"; /* should not happen */ break; + } + break; + default: + r = "??"; /* should not happen */ + break; + } + } + break; + + case (iiNUMB | iiSTEREO_INV): /*------------- Inv Stereo Numbering ------------*/ + switch (bType) + { + case 0: /* inv stereo numb main = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* inv stereo numb main = main numb */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case iitISO: /* inv stereo iso numb main = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* inv stereo iso numb main = main numb */ + break; + case iiEq2INV: + r = "im"; /* inv stereo iso numb main = InvStereo(main) numb */ + break; + case iiEq2ISO: + r = "M"; /* inv stereo iso numb main = isotopic main numb */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case iitNONTAUT: /* inv stereo numb non-taut = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* inv stereo numb non-taut = main numb */ + break; + case iiEq2NONTAUT: + r = "n"; /* inv stereo numb non-taut = non-taut numb */ + break; + case iiEq2INV: + r = "im"; /* inv stereo numb non-taut = InvStereo(main) numb */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case (iitNONTAUT | iitISO): /* inv stereo numb non-taut iso = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* inv stereo numb non-taut iso = main numb */ + break; + case iiEq2ISO: + r = "M"; /* inv stereo numb non-taut iso = main numb iso */ + break; + case (iiEq2ISO | iiEq2INV): + r = "iM"; /* inv stereo numb non-taut iso = InvStereo(main iso) numb */ + break; + case iiEq2NONTAUT: + r = "n"; /* inv stereo numb non-taut iso = non-taut numb */ + break; + case (iiEq2NONTAUT | iiEq2ISO): + r = "N"; /* inv stereo numb non-taut iso = non-taut iso numb */ + break; + case iiEq2INV: + r = "im"; /* inv stereo numb non-taut iso = InvStereo(main) numb */ + break; + case (iiEq2NONTAUT | iiEq2INV): + r = "in"; /* inv stereo numb non-taut iso = InvStereo(non-taut) numb ) */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + + case iiNUMB: /*------------- Canonical Numbering ------------*/ + switch (bType) + { + case 0: /* numb main = ...*/ + r = "??"; /* should not happen */ + break; + case iitISO: /* iso numb main = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* iso numb main = main numb */ + break; + default: + r = "??"; /* should not happen */ + } + break; + case iitNONTAUT: /* numb non-taut = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* numb non-taut = main numb */ + break; + default: + r = "??"; /* should not happen */ + } + break; + case (iitNONTAUT | iitISO): /* numb non-taut iso = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* numb non-taut iso = main numb */ + break; + case iiEq2ISO: + r = "M"; /* numb non-taut iso = main numb iso */ + break; + case iiEq2NONTAUT: + r = "n"; /* numb non-taut iso = non-taut numb */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + + case iiEQU: /*------------- Atom Equivalence ------------*/ + switch (bType) + { + case 0: /* equivalence main = ...*/ + r = "??"; /* should not happen */ + break; + case iitISO: /* equivalence main iso = ...*/ + switch (bEq2) + { + case 0: + r = "m"; /* equivalence main = main equ */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case iitNONTAUT: /* equivalence non-taut = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* equivalence non-taut = main equ */ + break; + default: + r = "??"; /* should not happen */ + break; + } + break; + case (iitNONTAUT | iitISO): /* equivalence non-taut iso = ... */ + switch (bEq2) + { + case 0: + r = "m"; /* equivalence non-taut iso = main equ */ + break; + case iiEq2ISO: + r = "M"; /* equivalence non-taut iso = main iso equ */ + break; + case iiEq2NONTAUT: + r = "n"; /* equivalence non-taut iso = non-taut equ */ + break; + default: + r = "??"; /* should not happen */ + break; } break; default: - r = "??"; /* should not happen */ + r = "??"; /* should not happen */ break; + } + break; + default: + r = "??"; /* should not happen */ + break; } return r; } -#define OUT_NONTAUT OUT_NN /* was OUT_NT until 2004-04-07 */ +#define OUT_NONTAUT OUT_NN /* was OUT_NT until 2004-04-07 */ /**************************************************************************** OutputINChI2( ... ) is called from SortAndPrintINChI( ... ) ****************************************************************************/ -int OutputINChI2( CANON_GLOBALS *pCG, - INCHI_IOS_STRING *strbuf, - INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM], - int INCHI_basic_or_INCHI_reconnected, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - INPUT_PARMS *ip, - int bDisconnectedCoord, - int bOutputType, - int bINChIOutputOptions, - int num_components2[], - int num_non_taut2[], - int num_taut2[], - INCHI_IOSTREAM *output_file, - INCHI_IOSTREAM *log_file, - int num_input_struct, - int *pSortPrintINChIFlags, - unsigned char save_opt_bits ) +int OutputINChI2(CANON_GLOBALS *pCG, + INCHI_IOS_STRING *strbuf, + INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM], + int INCHI_basic_or_INCHI_reconnected, + ORIG_ATOM_DATA *orig_inp_data, + ORIG_STRUCT *pOrigStruct, + INPUT_PARMS *ip, + int bDisconnectedCoord, + int bOutputType, + int bINChIOutputOptions, + int num_components2[], + int num_non_taut2[], + int num_taut2[], + INCHI_IOSTREAM *output_file, + INCHI_IOSTREAM *log_file, + int num_input_struct, + int *pSortPrintINChIFlags, + unsigned char save_opt_bits) { - int bINChIOutputOptions0 = bINChIOutputOptions & ~( INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS ); + int bINChIOutputOptions0 = bINChIOutputOptions & ~(INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS); int bINChIOutputOptionsCur; int bCurOption, ret, i; @@ -992,14 +978,14 @@ int OutputINChI2( CANON_GLOBALS *pCG, { switch (i) { - case 1: - bCurOption = INCHI_OUT_PLAIN_TEXT; - break; - case 2: - bCurOption = INCHI_OUT_PLAIN_TEXT_COMMENTS; - break; - default: - continue; + case 1: + bCurOption = INCHI_OUT_PLAIN_TEXT; + break; + case 2: + bCurOption = INCHI_OUT_PLAIN_TEXT_COMMENTS; + break; + default: + continue; } if (bINChIOutputOptions & bCurOption) { @@ -1008,31 +994,30 @@ int OutputINChI2( CANON_GLOBALS *pCG, { bINChIOutputOptionsCur &= ~INCHI_OUT_TABBED_OUTPUT; } - ret |= OutputINChI1( pCG, - strbuf, - pINChISortTautAndNonTaut2, - INCHI_basic_or_INCHI_reconnected, - orig_inp_data, - pOrigStruct, - ip, - bDisconnectedCoord, - bOutputType, - bINChIOutputOptionsCur, - num_components2, - num_non_taut2, - num_taut2, - output_file, - log_file, - num_input_struct, - pSortPrintINChIFlags, - save_opt_bits ); + ret |= OutputINChI1(pCG, + strbuf, + pINChISortTautAndNonTaut2, + INCHI_basic_or_INCHI_reconnected, + orig_inp_data, + pOrigStruct, + ip, + bDisconnectedCoord, + bOutputType, + bINChIOutputOptionsCur, + num_components2, + num_non_taut2, + num_taut2, + output_file, + log_file, + num_input_struct, + pSortPrintINChIFlags, + save_opt_bits); } } return ret; } - /* */ /* OutputINChI1( ... ) */ /* */ @@ -1040,24 +1025,24 @@ int OutputINChI2( CANON_GLOBALS *pCG, /* */ /* Called from OutputINChI2( ... ) and from itself */ /* */ -int OutputINChI1( CANON_GLOBALS *pCG, - INCHI_IOS_STRING *strbuf, - INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM], - int INCHI_basic_or_INCHI_reconnected, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - INPUT_PARMS *ip, - int bDisconnectedCoord, - int bOutputType, - int bINChIOutputOptions, - int num_components2[], - int num_non_taut2[], - int num_taut2[], - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *log_file, - int num_input_struct, - int *pSortPrintINChIFlags, - unsigned char save_opt_bits ) +int OutputINChI1(CANON_GLOBALS *pCG, + INCHI_IOS_STRING *strbuf, + INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM], + int INCHI_basic_or_INCHI_reconnected, + ORIG_ATOM_DATA *orig_inp_data, + ORIG_STRUCT *pOrigStruct, + INPUT_PARMS *ip, + int bDisconnectedCoord, + int bOutputType, + int bINChIOutputOptions, + int num_components2[], + int num_non_taut2[], + int num_taut2[], + INCHI_IOSTREAM *out_file, + INCHI_IOSTREAM *log_file, + int num_input_struct, + int *pSortPrintINChIFlags, + unsigned char save_opt_bits) { INCHI_OUT_CTL io; /* @@ -1072,31 +1057,31 @@ int OutputINChI1( CANON_GLOBALS *pCG, TAUT_NON => only non-tautomeric output (if no non-taut present then no output; TAUT_BOTH => tautomeric and non-tautomeric */ - int i, j, ii, jj, /*ii2, jj2,*/ bEmbeddedOutputCalled = 0; - int bTautIsoHNum, bTautIsoAt, bHasIsotopicAtoms[TAUT_NUM]; - int bStereoSp2[TAUT_NUM], bStereoSp3[TAUT_NUM]; - int bIsotopicStereoSp2[TAUT_NUM], bIsotopicStereoSp3[TAUT_NUM]; - int bStereoAbsInverted[TAUT_NUM], bIsotopicStereoAbsInverted[TAUT_NUM]; - int bStereoAbs[TAUT_NUM], bIsotopicStereoAbs[TAUT_NUM]; - int bTautomericAcid, bHardAddRemProton; - int bRequestedRacemicStereo = 0, bRequestedRelativeStereo = 0; - int npass = 0; /* djb-rwth: removing redundant variables */ - - INCHI_SORT *is, *is2; - INChI *pINChI /*, *pINChI2*/; - INChI_Aux *pINChI_Aux = NULL; - - int ret = 0; /* 0 failed, 1 success */ - int intermediate_result = 0; + int i, j, ii, jj, /*ii2, jj2,*/ bEmbeddedOutputCalled = 0; + int bTautIsoHNum, bTautIsoAt, bHasIsotopicAtoms[TAUT_NUM]; + int bStereoSp2[TAUT_NUM], bStereoSp3[TAUT_NUM]; + int bIsotopicStereoSp2[TAUT_NUM], bIsotopicStereoSp3[TAUT_NUM]; + int bStereoAbsInverted[TAUT_NUM], bIsotopicStereoAbsInverted[TAUT_NUM]; + int bStereoAbs[TAUT_NUM], bIsotopicStereoAbs[TAUT_NUM]; + int bTautomericAcid, bHardAddRemProton; + int bRequestedRacemicStereo = 0, bRequestedRelativeStereo = 0; + int npass = 0; /* djb-rwth: removing redundant variables */ + + INCHI_SORT *is, *is2; + INChI *pINChI /*, *pINChI2*/; + INChI_Aux *pINChI_Aux = NULL; + + int ret = 0; /* 0 failed, 1 success */ + int intermediate_result = 0; int then_goto_repeat = 0; /* djb-rwth: removing redundant variables */ - int bHasIsoH; + int bHasIsoH; /* djb-rwth: removing redundant variables */ - int bTautAndNonTaut, bTautIsNonTaut; - int nAtomsAllComp1, nAtomsAllComp2; /* v. 1.05 Total atoms in all components */ + int bTautAndNonTaut, bTautIsNonTaut; + int nAtomsAllComp1, nAtomsAllComp2; /* v. 1.05 Total atoms in all components */ - int bPlainText = 0 != ( bINChIOutputOptions & ( INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS ) ); - int bPlainTextCommnts = 0 != ( bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT_COMMENTS ); + int bPlainText = 0 != (bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS)); + int bPlainTextCommnts = 0 != (bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT_COMMENTS); char *pLF, *pTAB; #ifdef TARGET_LIB_FOR_WINCHI @@ -1104,25 +1089,23 @@ int OutputINChI1( CANON_GLOBALS *pCG, #endif int bFixTranspChargeBug = 0; -#if ( FIX_TRANSPOSITION_CHARGE_BUG == 1 ) /* 2008-01-02 */ +#if (FIX_TRANSPOSITION_CHARGE_BUG == 1) /* 2008-01-02 */ if (INCHI_OUT_FIX_TRANSPOSITION_CHARGE_BUG & bINChIOutputOptions) bFixTranspChargeBug = 1; #endif io.bAbcNumbers = ip->bAbcNumbers; - io.ATOM_MODE = ( ( io.bAbcNumbers ? CT_MODE_ABC_NUMBERS : 0 ) - | CT_MODE_ATOM_COUNTS - | CT_MODE_NO_ORPHANS -#if ( EQL_H_NUM_TOGETHER == 1 ) + io.ATOM_MODE = ((io.bAbcNumbers ? CT_MODE_ABC_NUMBERS : 0) | CT_MODE_ATOM_COUNTS | CT_MODE_NO_ORPHANS +#if (EQL_H_NUM_TOGETHER == 1) | CT_MODE_EQL_H_TOGETHER #endif -#if ( ABC_CT_NUM_CLOSURES == 1 ) - | ( io.bAbcNumbers && ip->bCtPredecessors ? CT_MODE_ABC_NUM_CLOSURES : 0 ) +#if (ABC_CT_NUM_CLOSURES == 1) + | (io.bAbcNumbers && ip->bCtPredecessors ? CT_MODE_ABC_NUM_CLOSURES : 0) #endif - | ( ip->bCtPredecessors ? CT_MODE_PREDECESSORS : 0 ) ); + | (ip->bCtPredecessors ? CT_MODE_PREDECESSORS : 0)); - io.TAUT_MODE = ( io.bAbcNumbers ? CT_MODE_ABC_NUMBERS : 0 ); + io.TAUT_MODE = (io.bAbcNumbers ? CT_MODE_ABC_NUMBERS : 0); io.pSortPrintINChIFlags = pSortPrintINChIFlags; io.num_components = num_components2[INCHI_basic_or_INCHI_reconnected]; io.pINChISortTautAndNonTaut = pINChISortTautAndNonTaut2[INCHI_basic_or_INCHI_reconnected]; @@ -1131,7 +1114,7 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.bAlways = 0; io.bUseMulipliers = 1; io.bOmitRepetitions = 1; - io.bPlainTextTags = 2; /* 0 => no plain tags, 1=> plain text tags, 2=>plaintext tags without consecutive // */ + io.bPlainTextTags = 2; /* 0 => no plain tags, 1=> plain text tags, 2=>plaintext tags without consecutive // */ io.bOutputType = bOutputType; /* remains constant */ io.bOutType = bOutputType; /* will change! */ io.bOverflow = 0; @@ -1140,16 +1123,16 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.bNonTautNonIsoIdentifierNotEmpty = 0; io.bNonTautIsIdenticalToTaut = 1; io.bFhTag = 0; - io.nTag = bPlainTextCommnts ? 3 : bPlainText ? 2 : 0; /* tag type */ + io.nTag = bPlainTextCommnts ? 3 : bPlainText ? 2 + : 0; /* tag type */ - - if (NULL==orig_inp_data) + if (NULL == orig_inp_data) { /*intermediate_result = 1; goto exit_function;*/ - io.n_zy = 0; - io.n_pzz = 0; - io.n_pzz = 0; + io.n_zy = 0; + io.n_pzz = 0; + io.n_pzz = 0; } else { @@ -1160,7 +1143,6 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.n_pzz = orig_inp_data->polymer->n_pzz; } } - io.bPolymers = ip->bPolymers; @@ -1173,12 +1155,12 @@ int OutputINChI1( CANON_GLOBALS *pCG, /* Analyze layers, make adjustments and fixes, etc. */ - set_line_separators( bINChIOutputOptions, &pLF, &pTAB ); - memset( io.sDifSegs, DIFV_BOTH_EMPTY, sizeof( io.sDifSegs ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - if (!strbuf || !( strbuf->pStr ) || strbuf->nAllocatedLength <= 0) + set_line_separators(bINChIOutputOptions, &pLF, &pTAB); + memset(io.sDifSegs, DIFV_BOTH_EMPTY, sizeof(io.sDifSegs)); /* djb-rwth: memset_s C11/Annex K variant? */ + if (!strbuf || !(strbuf->pStr) || strbuf->nAllocatedLength <= 0) { - inchi_ios_eprint( log_file, "Cannot allocate output buffer. No output for structure #%d.%s%s%s%s\n", - num_input_struct, SDF_LBL_VAL( ip->pSdfLabel, ip->pSdfValue ) ); + inchi_ios_eprint(log_file, "Cannot allocate output buffer. No output for structure #%d.%s%s%s%s\n", + num_input_struct, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); return ret; } @@ -1190,79 +1172,78 @@ int OutputINChI1( CANON_GLOBALS *pCG, { bHasIsotopicAtoms[i] = io.num_comp[i] = - bStereoSp2[i] = - bStereoSp3[i] = - bIsotopicStereoSp2[i] = - bIsotopicStereoSp3[i] = - io.bIsotopicOrigNumb[i] = - bStereoAbs[i] = - bIsotopicStereoAbs[i] = - bStereoAbsInverted[i] = - bIsotopicStereoAbsInverted[i] = - io.bRacemicStereo[i] = - io.bRelativeStereo[i] = - io.bIsotopicRacemicStereo[i] = - io.bIsotopicRelativeStereo[i] = - io.bAtomEqu[i] = - io.bTautEqu[i] = - io.bIsotopicAtomEqu[i] = - io.bIsotopicTautEqu[i] = - io.bInvStereo[i] = - io.bInvIsotopicStereo[i] = - io.bInvStereoOrigNumb[i] = - io.bInvIsotopicStereoOrigNumb[i] = - io.bIgn_UU_Sp3[i] = - io.bIgn_UU_Sp2[i] = - io.bIgn_UU_Sp3_Iso[i] = - io.bIgn_UU_Sp2_Iso[i] = - io.bChargesRadVal[i] = - io.bOrigCoord[i] = 0; + bStereoSp2[i] = + bStereoSp3[i] = + bIsotopicStereoSp2[i] = + bIsotopicStereoSp3[i] = + io.bIsotopicOrigNumb[i] = + bStereoAbs[i] = + bIsotopicStereoAbs[i] = + bStereoAbsInverted[i] = + bIsotopicStereoAbsInverted[i] = + io.bRacemicStereo[i] = + io.bRelativeStereo[i] = + io.bIsotopicRacemicStereo[i] = + io.bIsotopicRelativeStereo[i] = + io.bAtomEqu[i] = + io.bTautEqu[i] = + io.bIsotopicAtomEqu[i] = + io.bIsotopicTautEqu[i] = + io.bInvStereo[i] = + io.bInvIsotopicStereo[i] = + io.bInvStereoOrigNumb[i] = + io.bInvIsotopicStereoOrigNumb[i] = + io.bIgn_UU_Sp3[i] = + io.bIgn_UU_Sp2[i] = + io.bIgn_UU_Sp3_Iso[i] = + io.bIgn_UU_Sp2_Iso[i] = + io.bChargesRadVal[i] = + io.bOrigCoord[i] = 0; } /* Find if it is isotopic */ - io.bIsotopic = + io.bIsotopic = io.bTautomeric = - io.bNonTautomeric = - bTautomericAcid = - bHardAddRemProton = - bTautIsoHNum = - bTautIsoAt = - bTautAndNonTaut = - bTautIsNonTaut = 0; + io.bNonTautomeric = + bTautomericAcid = + bHardAddRemProton = + bTautIsoHNum = + bTautIsoAt = + bTautAndNonTaut = + bTautIsNonTaut = 0; - /* - x = bStereo, bStereoSp2, bStereoSp3, bStereoAbsInverted, - bIsotopicStereo, bIsotopicStereoSp2, bIsotopicStereoSp3, bIsotopicStereoAbsInverted - - OUT_N1: x[TAUT_NON] refers to non-tautomeric only - OUT_T1: x[TAUT_YES] refers to tautomeric if exists otherwise non-tautomeric - OUT_NT: x[TAUT_NON] refers to non-taut representations of tautomeric - OUT_TN: x[TAUT_YES] refers to tautomeric if exists otherwise non-tautomeric - x[TAUT_NON] refers to non-taut representations of tautomeric - */ + /* + x = bStereo, bStereoSp2, bStereoSp3, bStereoAbsInverted, + bIsotopicStereo, bIsotopicStereoSp2, bIsotopicStereoSp3, bIsotopicStereoAbsInverted - memset( io.num_iso_H, 0, sizeof( io.num_iso_H ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + OUT_N1: x[TAUT_NON] refers to non-tautomeric only + OUT_T1: x[TAUT_YES] refers to tautomeric if exists otherwise non-tautomeric + OUT_NT: x[TAUT_NON] refers to non-taut representations of tautomeric + OUT_TN: x[TAUT_YES] refers to tautomeric if exists otherwise non-tautomeric + x[TAUT_NON] refers to non-taut representations of tautomeric + */ + + memset(io.num_iso_H, 0, sizeof(io.num_iso_H)); /* djb-rwth: memset_s C11/Annex K variant? */ io.nNumRemovedProtons = 0; /* djb-rwth: removing redundant code */ bHasIsoH = 0; - io.bTautomericOutputAllowed = ( io.bOutType == OUT_T1 || io.bOutType == OUT_TN ); + io.bTautomericOutputAllowed = (io.bOutType == OUT_T1 || io.bOutType == OUT_TN); io.pINChISort = io.pINChISortTautAndNonTaut[io.bTautomericOutputAllowed ? TAUT_YES : TAUT_NON]; is = io.pINChISort; /* djb-rwth: removing redundant variables/code */ - for (i = 0, is2 = io.pINChISortTautAndNonTaut[TAUT_NON]; i < io.num_components; i++, is++, is2 ? is2++ : NULL) { - CompINChILayers( is, is2, io.sDifSegs, bFixTranspChargeBug ); + CompINChILayers(is, is2, io.sDifSegs, bFixTranspChargeBug); - io.bNonTautIsIdenticalToTaut = io.bNonTautIsIdenticalToTaut && !CompINChITautVsNonTaut( is, is2, 1 ); + io.bNonTautIsIdenticalToTaut = io.bNonTautIsIdenticalToTaut && !CompINChITautVsNonTaut(is, is2, 1); - if (is && ( pINChI_Aux = is->pINChI_Aux[TAUT_YES] )) + if (is && (pINChI_Aux = is->pINChI_Aux[TAUT_YES])) { for (j = 0; j < NUM_H_ISOTOPES; j++) { - bHasIsoH += abs( pINChI_Aux->nNumRemovedIsotopicH[j] ); + bHasIsoH += abs(pINChI_Aux->nNumRemovedIsotopicH[j]); io.num_iso_H[j] += pINChI_Aux->nNumRemovedIsotopicH[j]; } io.nNumRemovedProtons += pINChI_Aux->nNumRemovedProtons; @@ -1276,55 +1257,56 @@ int OutputINChI1( CANON_GLOBALS *pCG, { switch (io.bOutType) { - case OUT_N1: /* x[TAUT_NON]: non-tautomeric only -- never happens */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - /* djb-rwth: removing redundant code */ - break; - case OUT_T1: /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - /* djb-rwth: removing redundant code */ - break; - case OUT_NT: /* x[TAUT_NON]: only non-taut representations of tautomeric -- never happens */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - /* djb-rwth: removing redundant code */ - break; - /* main path of control flow */ - case OUT_TN: /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric; - * x[TAUT_NON]: non-taut only if tautomeric is present */ - jj = ( j == TAUT_YES ) ? GET_II( OUT_T1, is ) : ( j == TAUT_NON ) ? GET_II( OUT_NT, is ) : -1; - if (jj == TAUT_YES) + case OUT_N1: /* x[TAUT_NON]: non-tautomeric only -- never happens */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + /* djb-rwth: removing redundant code */ + break; + case OUT_T1: /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + /* djb-rwth: removing redundant code */ + break; + case OUT_NT: /* x[TAUT_NON]: only non-taut representations of tautomeric -- never happens */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + /* djb-rwth: removing redundant code */ + break; + /* main path of control flow */ + case OUT_TN: /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric; + * x[TAUT_NON]: non-taut only if tautomeric is present */ + jj = (j == TAUT_YES) ? GET_II(OUT_T1, is) : (j == TAUT_NON) ? GET_II(OUT_NT, is) + : -1; + if (jj == TAUT_YES) + { + /* Fix12 */ + if (is->pINChI[jj]->lenTautomer > 0) { - /* Fix12 */ - if (is->pINChI[jj]->lenTautomer > 0) - { - bTautAndNonTaut += ( !is->pINChI[jj]->bDeleted && HAS_N( is ) ); - } - else - { - bTautIsNonTaut++; - } + bTautAndNonTaut += (!is->pINChI[jj]->bDeleted && HAS_N(is)); } - if (jj < 0) - continue; - /* djb-rwth: removing redundant code */ - break; - default: + else + { + bTautIsNonTaut++; + } + } + if (jj < 0) continue; + /* djb-rwth: removing redundant code */ + break; + default: + continue; } if (jj != j) continue; - if (( pINChI = is->pINChI[jj] ) && pINChI->nNumberOfAtoms > 0 && ( pINChI_Aux = is->pINChI_Aux[jj] )) + if ((pINChI = is->pINChI[jj]) && pINChI->nNumberOfAtoms > 0 && (pINChI_Aux = is->pINChI_Aux[jj])) { - bTautIsoHNum += ( pINChI_Aux->nNumRemovedIsotopicH[0] + + bTautIsoHNum += (pINChI_Aux->nNumRemovedIsotopicH[0] + pINChI_Aux->nNumRemovedIsotopicH[1] + - pINChI_Aux->nNumRemovedIsotopicH[2] ); - bTautIsoAt += ( pINChI->nNumberOfIsotopicAtoms > 0 || pINChI->nNumberOfIsotopicTGroups > 0 ); + pINChI_Aux->nNumRemovedIsotopicH[2]); + bTautIsoAt += (pINChI->nNumberOfIsotopicAtoms > 0 || pINChI->nNumberOfIsotopicTGroups > 0); } } } @@ -1333,7 +1315,7 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.sDifSegs[DIFL_M][DIFS_p_PROTONS] = io.nNumRemovedProtons ? DIFV_NEQ2PRECED : DIFV_BOTH_EMPTY; io.sDifSegs[DIFL_MI][DIFS_h_H_ATOMS] = bHasIsoH ? DIFV_NEQ2PRECED : DIFV_BOTH_EMPTY; - MarkUnusedAndEmptyLayers( io.sDifSegs ); + MarkUnusedAndEmptyLayers(io.sDifSegs); io.bNonTautIsIdenticalToTaut = io.bNonTautIsIdenticalToTaut && !bTautIsoHNum; nAtomsAllComp1 = nAtomsAllComp2 = 0; @@ -1350,70 +1332,71 @@ int OutputINChI1( CANON_GLOBALS *pCG, { switch (io.bOutType) { - case OUT_N1: - /* x[TAUT_NON]: non-tautomeric only */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - ii = TAUT_NON; - break; - case OUT_T1: - /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - ii = TAUT_YES; - break; - case OUT_NT: - /* x[TAUT_NON]: only non-taut representations of tautomeric */ - jj = GET_II( io.bOutType, is ); - if (jj != j) - continue; - ii = TAUT_NON; - break; - /* main control flow comes here: requested both mobile and fixed H results */ - case OUT_TN: - /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric; */ - /* x[TAUT_NON]: non-taut only if tautomeric is present */ - jj = ( j == TAUT_YES ) ? GET_II( OUT_T1, is ) : ( j == TAUT_NON ) ? GET_II( OUT_NT, is ) : -1; - if (jj < 0) + case OUT_N1: + /* x[TAUT_NON]: non-tautomeric only */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + ii = TAUT_NON; + break; + case OUT_T1: + /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + ii = TAUT_YES; + break; + case OUT_NT: + /* x[TAUT_NON]: only non-taut representations of tautomeric */ + jj = GET_II(io.bOutType, is); + if (jj != j) + continue; + ii = TAUT_NON; + break; + /* main control flow comes here: requested both mobile and fixed H results */ + case OUT_TN: + /* x[TAUT_YES]: tautomeric if present otherwise non-tautomeric; */ + /* x[TAUT_NON]: non-taut only if tautomeric is present */ + jj = (j == TAUT_YES) ? GET_II(OUT_T1, is) : (j == TAUT_NON) ? GET_II(OUT_NT, is) + : -1; + if (jj < 0) + { + /* Fix12 */ + if (bTautAndNonTaut && bTautIsNonTaut && + j == TAUT_NON && 0 <= (jj = GET_II(OUT_T1, is)) && + !is->pINChI[jj]->bDeleted && !is->pINChI[jj]->lenTautomer) { - /* Fix12 */ - if (bTautAndNonTaut && bTautIsNonTaut && - j == TAUT_NON && 0 <= ( jj = GET_II( OUT_T1, is ) ) && - !is->pINChI[jj]->bDeleted && !is->pINChI[jj]->lenTautomer) - { - ; /* the requested non-tautomeric component is in tautomeric position */ - /* (is->pINChI[TAUT_YES]); */ - /* process it also as non-tautomeric if Fixed-H layer was requested */ - } - else - { - continue; - } + ; /* the requested non-tautomeric component is in tautomeric position */ + /* (is->pINChI[TAUT_YES]); */ + /* process it also as non-tautomeric if Fixed-H layer was requested */ + } + else + { + continue; } + } - ii = j; /* ii is what we wanted; jj is what we found (0 = TAUT_NON: fixed_H, 1 = TAUT_YES: mobile_H) */ + ii = j; /* ii is what we wanted; jj is what we found (0 = TAUT_NON: fixed_H, 1 = TAUT_YES: mobile_H) */ - /* -- not used 2004-09-16 --- - if ( is2 ) { - jj2 = ( j == TAUT_YES )? GET_II(OUT_T1,is2) : ( j == TAUT_NON )? GET_II(OUT_NT,is2) : -1; - if ( jj2 >= 0 ) { - ii2 = j; - } else { - ii2 = -1; - } + /* -- not used 2004-09-16 --- + if ( is2 ) { + jj2 = ( j == TAUT_YES )? GET_II(OUT_T1,is2) : ( j == TAUT_NON )? GET_II(OUT_NT,is2) : -1; + if ( jj2 >= 0 ) { + ii2 = j; } else { - jj2 = ii2 = -1; + ii2 = -1; } - -----------------------------*/ - break; + } else { + jj2 = ii2 = -1; + } + -----------------------------*/ + break; - default: - continue; + default: + continue; } - if (( pINChI = is->pINChI[jj] ) && pINChI->nNumberOfAtoms > 0) + if ((pINChI = is->pINChI[jj]) && pINChI->nNumberOfAtoms > 0) { /*pINChI_Aux = is->pINChI_Aux[jj];*/ bCompExists++; @@ -1423,94 +1406,92 @@ int OutputINChI1( CANON_GLOBALS *pCG, else if (j == TAUT_YES) nAtomsAllComp2 += pINChI->nNumberOfAtoms; - - bCurTaut = ( pINChI->lenTautomer > 0 ); - bCurIso = ( pINChI->nNumberOfIsotopicAtoms > 0 || pINChI->nNumberOfIsotopicTGroups > 0 ); - bCurIsoHPos = ( (pINChI->nPossibleLocationsOfIsotopicH && pINChI->nPossibleLocationsOfIsotopicH[0] > 1) || pINChI->lenTautomer > 1 ); /* djb-rwth: addressing LLVM warning */ + bCurTaut = (pINChI->lenTautomer > 0); + bCurIso = (pINChI->nNumberOfIsotopicAtoms > 0 || pINChI->nNumberOfIsotopicTGroups > 0); + bCurIsoHPos = ((pINChI->nPossibleLocationsOfIsotopicH && pINChI->nPossibleLocationsOfIsotopicH[0] > 1) || pINChI->lenTautomer > 1); /* djb-rwth: addressing LLVM warning */ /* present isotopic H + their possible positions AND/OR isotopic atoms */ - bCurIsoHStereo = (bCurIsoHPos && ( bTautIsoHNum || bTautIsoAt )) || bCurIso; /* djb-rwth: addressing LLVM warning */ + bCurIsoHStereo = (bCurIsoHPos && (bTautIsoHNum || bTautIsoAt)) || bCurIso; /* djb-rwth: addressing LLVM warning */ if (jj == j && pINChI->bDeleted) { - io.num_comp[j] --; + io.num_comp[j]--; if (bCurTaut) { io.bTautomeric |= 1; /* tautomeric representation is present */ - io.bNonTautomeric |= HAS_N( is ); + io.bNonTautomeric |= HAS_N(is); } io.bIsotopic |= bCurIso; continue; /* deleted H(+) in tautomeric representation */ } - bCurStereoSp2 = pINChI->Stereo && ( pINChI->Stereo->nNumberOfStereoBonds > 0 ); + bCurStereoSp2 = pINChI->Stereo && (pINChI->Stereo->nNumberOfStereoBonds > 0); bCurHasIsoStereo = - bCurStereoSp3 = pINChI->Stereo && ( pINChI->Stereo->nNumberOfStereoCenters > 0 ); + bCurStereoSp3 = pINChI->Stereo && (pINChI->Stereo->nNumberOfStereoCenters > 0); - bCurIsoStereoSp2 = bCurIsoHStereo && pINChI->StereoIsotopic && ( pINChI->StereoIsotopic->nNumberOfStereoBonds > 0 ); - bCurIsoStereoSp3 = bCurIsoHStereo && pINChI->StereoIsotopic && ( pINChI->StereoIsotopic->nNumberOfStereoCenters > 0 ); + bCurIsoStereoSp2 = bCurIsoHStereo && pINChI->StereoIsotopic && (pINChI->StereoIsotopic->nNumberOfStereoBonds > 0); + bCurIsoStereoSp3 = bCurIsoHStereo && pINChI->StereoIsotopic && (pINChI->StereoIsotopic->nNumberOfStereoCenters > 0); bCurIsoStereoSp3Inv = bCurIsoStereoSp3 && pINChI->StereoIsotopic->nCompInv2Abs; /* inversion changes sp3 stereo */ - bRequestedRacemicStereo |= ( 0 != ( pINChI->nFlags & INCHI_FLAG_RAC_STEREO ) ); - bRequestedRelativeStereo |= ( 0 != ( pINChI->nFlags & INCHI_FLAG_REL_STEREO ) ); + bRequestedRacemicStereo |= (0 != (pINChI->nFlags & INCHI_FLAG_RAC_STEREO)); + bRequestedRelativeStereo |= (0 != (pINChI->nFlags & INCHI_FLAG_REL_STEREO)); /* Check whether isotopic stereo is same as non-isotopic; if same than do not output isotopic stereo */ if (bCurStereoSp2 && bCurIsoStereoSp2) { - bCurIsoStereoSp2 = !Eql_INChI_Stereo( pINChI->Stereo, EQL_SP2, pINChI->StereoIsotopic, EQL_SP2, 0 ); + bCurIsoStereoSp2 = !Eql_INChI_Stereo(pINChI->Stereo, EQL_SP2, pINChI->StereoIsotopic, EQL_SP2, 0); } if (bCurStereoSp3 && bCurIsoStereoSp3) { /* bCurIsoStereoSp3=0 means (iso stereo sp3) = (non-iso stereo sp3) or (iso stereo sp3) = Inv(non-iso stereo sp3) */ - bCurIsoStereoSp3 = !Eql_INChI_Stereo( pINChI->Stereo, EQL_SP3, pINChI->StereoIsotopic, EQL_SP3, - ( pINChI->nFlags & INCHI_FLAG_RAC_STEREO ) || ( pINChI->nFlags & INCHI_FLAG_REL_STEREO ) ); + bCurIsoStereoSp3 = !Eql_INChI_Stereo(pINChI->Stereo, EQL_SP3, pINChI->StereoIsotopic, EQL_SP3, + (pINChI->nFlags & INCHI_FLAG_RAC_STEREO) || (pINChI->nFlags & INCHI_FLAG_REL_STEREO)); if (!bCurIsoStereoSp3) { /* Inversion changes iso sp3 differently from non-iso sp3 Fix11 */ - bCurIsoStereoSp3Inv &= ( pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs ); + bCurIsoStereoSp3Inv &= (pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs); } } bCurRelative = bRequestedRelativeStereo && bCurStereoSp3; -#if ( REL_RAC_STEREO_IGN_1_SC == 1 ) +#if (REL_RAC_STEREO_IGN_1_SC == 1) bCurRelative = bCurRelative && - ( pINChI->Stereo->nNumberOfStereoCenters > 1 ) && - ( pINChI->Stereo->nCompInv2Abs != 0 ) && + (pINChI->Stereo->nNumberOfStereoCenters > 1) && + (pINChI->Stereo->nCompInv2Abs != 0) && #endif - - - bCurIsoRelative = bRequestedRelativeStereo && ( bCurIsoStereoSp3 || bCurIsoStereoSp3Inv ); -#if ( REL_RAC_STEREO_IGN_1_SC == 1 ) + bCurIsoRelative = bRequestedRelativeStereo && (bCurIsoStereoSp3 || bCurIsoStereoSp3Inv); +#if (REL_RAC_STEREO_IGN_1_SC == 1) bCurIsoRelative = bCurIsoRelative && - ( pINChI->StereoIsotopic->nNumberOfStereoCenters > 1 ) && - ( pINChI->StereoIsotopic->nCompInv2Abs != 0 ) && + (pINChI->StereoIsotopic->nNumberOfStereoCenters > 1) && + (pINChI->StereoIsotopic->nCompInv2Abs != 0) && #endif - - bCurRacemic = bRequestedRacemicStereo && bCurStereoSp3; -#if ( REL_RAC_STEREO_IGN_1_SC == 1 ) + bCurRacemic = bRequestedRacemicStereo && bCurStereoSp3; +#if (REL_RAC_STEREO_IGN_1_SC == 1) bCurRacemic = bCurRacemic && - ( pINChI->Stereo->nCompInv2Abs != 0 ) && - ( pINChI->Stereo->nNumberOfStereoCenters > 0 ) ? - pINChI->Stereo->nNumberOfStereoCenters : 0; + (pINChI->Stereo->nCompInv2Abs != 0) && + (pINChI->Stereo->nNumberOfStereoCenters > 0) + ? pINChI->Stereo->nNumberOfStereoCenters + : 0; #endif - bCurIsoRacemic = bRequestedRacemicStereo && ( bCurIsoStereoSp3 || bCurIsoStereoSp3Inv ); -#if ( REL_RAC_STEREO_IGN_1_SC == 1 ) + bCurIsoRacemic = bRequestedRacemicStereo && (bCurIsoStereoSp3 || bCurIsoStereoSp3Inv); +#if (REL_RAC_STEREO_IGN_1_SC == 1) bCurIsoRacemic = bCurIsoRacemic & - ( pINChI->StereoIsotopic->nCompInv2Abs != 0 ) && - ( pINChI->StereoIsotopic->nNumberOfStereoCenters > 0 ) ? - pINChI->StereoIsotopic->nNumberOfStereoCenters : 0; + (pINChI->StereoIsotopic->nCompInv2Abs != 0) && + (pINChI->StereoIsotopic->nNumberOfStereoCenters > 0) + ? pINChI->StereoIsotopic->nNumberOfStereoCenters + : 0; #endif if (bRequestedRelativeStereo) { - bCurStereoSp3 = bCurRelative || (bCurStereoSp3 && ( pINChI->Stereo->nNumberOfStereoCenters > 1 )); /* Fix11 */ /* djb-rwth: addressing LLVM warning */ + bCurStereoSp3 = bCurRelative || (bCurStereoSp3 && (pINChI->Stereo->nNumberOfStereoCenters > 1)); /* Fix11 */ /* djb-rwth: addressing LLVM warning */ bCurIsoStereoSp3 = bCurIsoRelative ? bCurIsoStereoSp3 : 0; } else { if (bRequestedRacemicStereo) { - bCurStereoSp3 = bCurRacemic > 1 || (bCurStereoSp3 && ( pINChI->Stereo->nNumberOfStereoCenters > 1 )); /* Fix11 */ /* djb-rwth: addressing LLVM warning */ + bCurStereoSp3 = bCurRacemic > 1 || (bCurStereoSp3 && (pINChI->Stereo->nNumberOfStereoCenters > 1)); /* Fix11 */ /* djb-rwth: addressing LLVM warning */ bCurIsoStereoSp3 = bCurIsoRacemic > 1 ? bCurIsoStereoSp3 : 0; } } @@ -1520,81 +1501,80 @@ int OutputINChI1( CANON_GLOBALS *pCG, bHasIsotopicAtoms[ii] |= bCurIso; bStereoSp2[ii] |= bCurStereoSp2; bStereoSp3[ii] |= bCurStereoSp3; - io.bIgn_UU_Sp3[ii] |= !bCurStereoSp3 && ( pINChI->nFlags & INCHI_FLAG_SC_IGN_ALL_UU ); - io.bIgn_UU_Sp2[ii] |= !bCurStereoSp2 && ( pINChI->nFlags & INCHI_FLAG_SB_IGN_ALL_UU ); + io.bIgn_UU_Sp3[ii] |= !bCurStereoSp3 && (pINChI->nFlags & INCHI_FLAG_SC_IGN_ALL_UU); + io.bIgn_UU_Sp2[ii] |= !bCurStereoSp2 && (pINChI->nFlags & INCHI_FLAG_SB_IGN_ALL_UU); bIsotopicStereoSp2[ii] |= bCurIsoStereoSp2; bIsotopicStereoSp3[ii] |= bCurIsoStereoSp3; - io.bIgn_UU_Sp3_Iso[ii] |= !bCurIsoStereoSp3 && ( pINChI->nFlags & INCHI_FLAG_SC_IGN_ALL_ISO_UU ); - io.bIgn_UU_Sp2_Iso[ii] |= !bCurIsoStereoSp2 && ( pINChI->nFlags & INCHI_FLAG_SB_IGN_ALL_ISO_UU ); - bStereoAbs[ii] |= bCurStereoSp3 && ( pINChI->Stereo->nCompInv2Abs != 0 ); + io.bIgn_UU_Sp3_Iso[ii] |= !bCurIsoStereoSp3 && (pINChI->nFlags & INCHI_FLAG_SC_IGN_ALL_ISO_UU); + io.bIgn_UU_Sp2_Iso[ii] |= !bCurIsoStereoSp2 && (pINChI->nFlags & INCHI_FLAG_SB_IGN_ALL_ISO_UU); + bStereoAbs[ii] |= bCurStereoSp3 && (pINChI->Stereo->nCompInv2Abs != 0); - bStereoAbsInverted[ii] |= bCurStereoSp3 && ( pINChI->Stereo->nCompInv2Abs < 0 ); + bStereoAbsInverted[ii] |= bCurStereoSp3 && (pINChI->Stereo->nCompInv2Abs < 0); /* Fix08: missing isotopic inverted flag if isotopic = inverted non-isotopic */ - bIsotopicStereoAbsInverted[ii] |= (bCurIsoStereoSp3 && ( pINChI->StereoIsotopic->nCompInv2Abs < 0 )) || - (!bCurIsoStereoSp3 && pINChI->StereoIsotopic && pINChI->Stereo && - pINChI->StereoIsotopic->nCompInv2Abs && - pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs); /* djb-rwth: addressing LLVM warnings */ + bIsotopicStereoAbsInverted[ii] |= (bCurIsoStereoSp3 && (pINChI->StereoIsotopic->nCompInv2Abs < 0)) || + (!bCurIsoStereoSp3 && pINChI->StereoIsotopic && pINChI->Stereo && + pINChI->StereoIsotopic->nCompInv2Abs && + pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs); /* djb-rwth: addressing LLVM warnings */ /* Fix 11: missing /s1 if only isotopic stereo is inverted */ - bIsotopicStereoAbs[ii] |= (bCurIsoStereoSp3 && ( pINChI->StereoIsotopic->nCompInv2Abs != 0 )) || - (!bCurIsoStereoSp3 && pINChI->StereoIsotopic && pINChI->Stereo && - pINChI->StereoIsotopic->nCompInv2Abs && - pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs); /* djb-rwth: addressing LLVM warnings */ + bIsotopicStereoAbs[ii] |= (bCurIsoStereoSp3 && (pINChI->StereoIsotopic->nCompInv2Abs != 0)) || + (!bCurIsoStereoSp3 && pINChI->StereoIsotopic && pINChI->Stereo && + pINChI->StereoIsotopic->nCompInv2Abs && + pINChI->StereoIsotopic->nCompInv2Abs != pINChI->Stereo->nCompInv2Abs); /* djb-rwth: addressing LLVM warnings */ io.bRelativeStereo[ii] |= bCurRelative; io.bIsotopicRelativeStereo[ii] |= bCurIsoRelative; io.bRacemicStereo[ii] |= bCurRacemic; io.bIsotopicRacemicStereo[ii] |= bCurIsoRacemic; - - bTautomericAcid |= ( 0 != ( pINChI->nFlags & INCHI_FLAG_ACID_TAUT ) ); - bHardAddRemProton |= ( 0 != ( pINChI->nFlags & INCHI_FLAG_HARD_ADD_REM_PROTON ) ); + bTautomericAcid |= (0 != (pINChI->nFlags & INCHI_FLAG_ACID_TAUT)); + bHardAddRemProton |= (0 != (pINChI->nFlags & INCHI_FLAG_HARD_ADD_REM_PROTON)); if (bCurTaut) { io.bTautomeric |= 1; /* tautomeric representation is present */ /* does tautomeric structure have also a non-tautomeric repesentation? */ - io.bNonTautomeric |= HAS_N( is ); + io.bNonTautomeric |= HAS_N(is); } /* Auxiliary info */ - if (!( bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) && ( pINChI_Aux = is->pINChI_Aux[jj] )) + if (!(bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) && (pINChI_Aux = is->pINChI_Aux[jj])) { /* detect presence of constitutional equivalence onfo */ int bCurEqu, bCurTautEqu = 0, bCurIsoEqu = 0, bCurIsoTautEqu = 0; /* Fix15-disabled */ - io.bAtomEqu[ii] |= ( bCurEqu = bHasEquString( pINChI_Aux->nConstitEquNumbers, - pINChI_Aux->nNumberOfAtoms ) ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + io.bAtomEqu[ii] |= (bCurEqu = bHasEquString(pINChI_Aux->nConstitEquNumbers, + pINChI_Aux->nNumberOfAtoms)); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ if (bCurTaut) { - io.bTautEqu[ii] |= ( bCurTautEqu = bHasEquString( pINChI_Aux->nConstitEquTGroupNumbers, - pINChI_Aux->nNumberOfTGroups ) ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + io.bTautEqu[ii] |= (bCurTautEqu = bHasEquString(pINChI_Aux->nConstitEquTGroupNumbers, + pINChI_Aux->nNumberOfTGroups)); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ } if (bCurIso) { - io.bIsotopicAtomEqu[ii] |= ( bCurIsoEqu = bHasEquString( pINChI_Aux->nConstitEquIsotopicNumbers, - pINChI_Aux->nNumberOfAtoms ) ) /*|| bCurEqu*/; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + io.bIsotopicAtomEqu[ii] |= (bCurIsoEqu = bHasEquString(pINChI_Aux->nConstitEquIsotopicNumbers, + pINChI_Aux->nNumberOfAtoms)) /*|| bCurEqu*/; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ if (bCurTaut) { - io.bIsotopicTautEqu[ii] |= ( bCurIsoTautEqu = bHasEquString( pINChI_Aux->nConstitEquIsotopicTGroupNumbers, - pINChI_Aux->nNumberOfTGroups ) ) /*|| bCurTautEqu*/; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + io.bIsotopicTautEqu[ii] |= (bCurIsoTautEqu = bHasEquString(pINChI_Aux->nConstitEquIsotopicTGroupNumbers, + pINChI_Aux->nNumberOfTGroups)) /*|| bCurTautEqu*/; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ } /* non-zero if isotopic numbering for inverted isotopic stereo is different */ io.bIsotopicOrigNumb[ii] |= bCurHasIsoStereo && /* Fix14 */ - pINChI_Aux->nOrigAtNosInCanonOrdInv && - pINChI_Aux->nIsotopicOrigAtNosInCanonOrd && - ( 0 != memcmp( pINChI_Aux->nOrigAtNosInCanonOrdInv, - pINChI_Aux->nIsotopicOrigAtNosInCanonOrd, - sizeof( pINChI_Aux->nOrigAtNosInCanonOrdInv[0] ) * pINChI_Aux->nNumberOfAtoms ) ); + pINChI_Aux->nOrigAtNosInCanonOrdInv && + pINChI_Aux->nIsotopicOrigAtNosInCanonOrd && + (0 != memcmp(pINChI_Aux->nOrigAtNosInCanonOrdInv, + pINChI_Aux->nIsotopicOrigAtNosInCanonOrd, + sizeof(pINChI_Aux->nOrigAtNosInCanonOrdInv[0]) * pINChI_Aux->nNumberOfAtoms)); } /* Inverted stereo */ if (bCurStereoSp3 && pINChI->Stereo->nCompInv2Abs) { io.bInvStereo[ii] |= 1; io.bInvStereoOrigNumb[ii] |= pINChI_Aux->nOrigAtNosInCanonOrd && - pINChI_Aux->nOrigAtNosInCanonOrdInv && - ( 0 != memcmp( pINChI_Aux->nOrigAtNosInCanonOrd, - pINChI_Aux->nOrigAtNosInCanonOrdInv, - sizeof( pINChI_Aux->nOrigAtNosInCanonOrd[0] ) * pINChI_Aux->nNumberOfAtoms ) ); + pINChI_Aux->nOrigAtNosInCanonOrdInv && + (0 != memcmp(pINChI_Aux->nOrigAtNosInCanonOrd, + pINChI_Aux->nOrigAtNosInCanonOrdInv, + sizeof(pINChI_Aux->nOrigAtNosInCanonOrd[0]) * pINChI_Aux->nNumberOfAtoms)); } /* Inverted isotopic stereo */ @@ -1602,15 +1582,14 @@ int OutputINChI1( CANON_GLOBALS *pCG, { io.bInvIsotopicStereo[ii] |= 1; - io.bInvIsotopicStereoOrigNumb[ii] - |= pINChI_Aux->nIsotopicOrigAtNosInCanonOrd && - pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv && - ( 0 != memcmp( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd, - pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv, - sizeof( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0] ) * pINChI_Aux->nNumberOfAtoms ) ); + io.bInvIsotopicStereoOrigNumb[ii] |= pINChI_Aux->nIsotopicOrigAtNosInCanonOrd && + pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv && + (0 != memcmp(pINChI_Aux->nIsotopicOrigAtNosInCanonOrd, + pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv, + sizeof(pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0]) * pINChI_Aux->nNumberOfAtoms)); } - if (pINChI_Aux->OrigInfo && bHasOrigInfo( pINChI_Aux->OrigInfo, pINChI_Aux->nNumberOfAtoms )) + if (pINChI_Aux->OrigInfo && bHasOrigInfo(pINChI_Aux->OrigInfo, pINChI_Aux->nNumberOfAtoms)) { io.bChargesRadVal[ii] |= 1; } @@ -1621,14 +1600,14 @@ int OutputINChI1( CANON_GLOBALS *pCG, { for (j = TAUT_NON; j < TAUT_NUM; j++) { - io.num_comp[j] ++; + io.num_comp[j]++; } } } if (io.bTautomeric /*&& bTautomericAcid*/) /* "&& bTautomericAcid" commented out 2004-06-02 */ { io.bTautomeric += bTautomericAcid; /* long-range tautomerism */ - io.bTautomeric += ( bHardAddRemProton ? 4 : 0 ); + io.bTautomeric += (bHardAddRemProton ? 4 : 0); } if (bRequestedRacemicStereo || bRequestedRelativeStereo) { @@ -1638,30 +1617,31 @@ int OutputINChI1( CANON_GLOBALS *pCG, /* Fix11 */ bStereoAbsInverted[i] = bStereoAbs[i] = - io.bInvStereo[i] = - io.bInvStereoOrigNumb[i] = 0; - /* io.bIsotopicRelativeStereo[i]=0 may happen because iso stereo is same or inverted non-iso stereo */ + io.bInvStereo[i] = + io.bInvStereoOrigNumb[i] = 0; + /* io.bIsotopicRelativeStereo[i]=0 may happen because iso stereo is same or inverted non-iso stereo */ bIsotopicStereoAbsInverted[i] = bIsotopicStereoAbs[i] = - io.bInvIsotopicStereo[i] = - io.bInvIsotopicStereoOrigNumb[i] = 0; + io.bInvIsotopicStereo[i] = + io.bInvIsotopicStereoOrigNumb[i] = 0; } } + io.iCurTautMode = io.bOutType == OUT_N1 ? TAUT_NON : /* only non-taut */ - io.iCurTautMode = io.bOutType == OUT_N1 ? TAUT_NON : /* only non-taut */ - - io.bOutType == OUT_T1 ? TAUT_YES : /* tautomeric if present, otherwise non-tautomeric */ - io.bOutType == OUT_NT ? TAUT_NON : /* only non-taut representations of tautomeric */ - io.bOutType == OUT_TN ? TAUT_YES : /* tautomeric if present otherwise non-tautomeric; */ - -1; /* separately output non-taut representations of tautomeric if present */ + io.bOutType == OUT_T1 ? TAUT_YES + : /* tautomeric if present, otherwise non-tautomeric */ + io.bOutType == OUT_NT ? TAUT_NON + : /* only non-taut representations of tautomeric */ + io.bOutType == OUT_TN ? TAUT_YES + : /* tautomeric if present otherwise non-tautomeric; */ + -1; /* separately output non-taut representations of tautomeric if present */ if (io.iCurTautMode < 0) { - return 0; /* error */ + return 0; /* error */ } - /* Now print out */ io.bOverflow = 0; @@ -1676,10 +1656,10 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.nCurINChISegment = DIFL_M; /* InChI output: version and kind */ - if (INCHI_basic_or_INCHI_reconnected == INCHI_BAS || !( bINChIOutputOptions & INCHI_OUT_EMBED_REC )) + if (INCHI_basic_or_INCHI_reconnected == INCHI_BAS || !(bINChIOutputOptions & INCHI_OUT_EMBED_REC)) { int is_beta = 0; - int nAtomsAllComp = inchi_max( nAtomsAllComp1, nAtomsAllComp2 ); + int nAtomsAllComp = inchi_max(nAtomsAllComp1, nAtomsAllComp2); if (nAtomsAllComp > NORMALLY_ALLOWED_INP_MAX_ATOMS) { @@ -1693,7 +1673,7 @@ int OutputINChI1( CANON_GLOBALS *pCG, } /* specifically put 'B' for empty structure InChI */ /* if "Polymers" or "LargeMolecules" requested */ - else if (!pOrigStruct && ( ip->bLargeMolecules || ip->bPolymers )) + else if (!pOrigStruct && (ip->bLargeMolecules || ip->bPolymers)) { is_beta = 1; } @@ -1701,78 +1681,76 @@ int OutputINChI1( CANON_GLOBALS *pCG, { is_beta = 1; } + else if (ip->bMolecularInorganics) + { + is_beta = 1; + } - OutputINCHI_VersionAndKind( out_file, strbuf, bINChIOutputOptions, is_beta, pLF, pTAB ); + OutputINCHI_VersionAndKind(out_file, strbuf, bINChIOutputOptions, is_beta, pLF, pTAB); } - - /* InChI output: atoms */ - intermediate_result = OutputINCHI_MainLayerFormula( pCG, out_file, strbuf, - num_components2, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_MainLayerFormula(pCG, out_file, strbuf, + num_components2, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; /* InChI output: connection table */ - intermediate_result = OutputINCHI_MainLayerConnections( pCG, out_file, strbuf, num_components2, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_MainLayerConnections(pCG, out_file, strbuf, num_components2, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; /* InChI output: hydrogens (with tautomeric info) */ - intermediate_result = OutputINCHI_MainLayerHydrogens( pCG, out_file, strbuf, num_components2, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_MainLayerHydrogens(pCG, out_file, strbuf, num_components2, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; io.bFhTag = 0; npass = 0; - repeat_INChI_output: /* InChI output: charge and removed protons */ - intermediate_result = OutputINCHI_ChargeAndRemovedAddedProtonsLayers( pCG, out_file, strbuf, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_ChargeAndRemovedAddedProtonsLayers(pCG, out_file, strbuf, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; /* InChI output: polymer layer */ if (npass == 0) { - intermediate_result = OutputINCHI_PolymerLayer( pCG, out_file, strbuf, - &INCHI_basic_or_INCHI_reconnected, - orig_inp_data, pOrigStruct, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_PolymerLayer(pCG, out_file, strbuf, + &INCHI_basic_or_INCHI_reconnected, + orig_inp_data, pOrigStruct, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; } /* InChI output: stereo (non-isotopic) */ - intermediate_result = OutputINCHI_StereoLayer( pCG, out_file, strbuf, &io, pLF, pTAB ); + intermediate_result = OutputINCHI_StereoLayer(pCG, out_file, strbuf, &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; - /* Switch from M to MI or from F to FI */ io.nCurINChISegment++; /* InChI output: isotopic */ - intermediate_result = OutputINCHI_IsotopicLayer( pCG, out_file, strbuf, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB ); + intermediate_result = OutputINCHI_IsotopicLayer(pCG, out_file, strbuf, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB); if (intermediate_result != 0) { goto exit_function; } - - /* At this point the INChI part of the output has been done. If this INChI is tautomeric and non-tautomeric results exist, @@ -1783,12 +1761,11 @@ int OutputINChI1( CANON_GLOBALS *pCG, isotopic stereo */ - /* InChI output: FixedH and sublayers */ - intermediate_result = OutputINCHI_FixedHLayerWithSublayers( pCG, out_file, strbuf, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB, - &then_goto_repeat ); + intermediate_result = OutputINCHI_FixedHLayerWithSublayers(pCG, out_file, strbuf, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB, + &then_goto_repeat); if (intermediate_result != 0) { goto exit_function; @@ -1799,40 +1776,39 @@ int OutputINChI1( CANON_GLOBALS *pCG, goto repeat_INChI_output; } - /* InChI output: reconnected structure */ bEmbeddedOutputCalled = 0; if (bDisconnectedCoord && INCHI_basic_or_INCHI_reconnected == INCHI_BAS && - ( bINChIOutputOptions & INCHI_OUT_EMBED_REC ) && num_components2[INCHI_REC]) + (bINChIOutputOptions & INCHI_OUT_EMBED_REC) && num_components2[INCHI_REC]) { int nRet; bEmbeddedOutputCalled = 1; /* output blank line before /R: in case of bPlainTextCommnts=1 */ - inchi_ios_print_nodisplay( out_file, "%s", pLF ); + inchi_ios_print_nodisplay(out_file, "%s", pLF); /* end of disconnected INChI output */ - nRet = OutputINChI1( pCG, - strbuf, - pINChISortTautAndNonTaut2, - INCHI_REC, - orig_inp_data, - pOrigStruct, - ip, - 0 /*bDisconnectedCoord*/, - bOutputType, - bINChIOutputOptions | INCHI_OUT_NO_AUX_INFO, - num_components2, - num_non_taut2, - num_taut2, - out_file, - log_file, - num_input_struct, - pSortPrintINChIFlags, - save_opt_bits ); + nRet = OutputINChI1(pCG, + strbuf, + pINChISortTautAndNonTaut2, + INCHI_REC, + orig_inp_data, + pOrigStruct, + ip, + 0 /*bDisconnectedCoord*/, + bOutputType, + bINChIOutputOptions | INCHI_OUT_NO_AUX_INFO, + num_components2, + num_non_taut2, + num_taut2, + out_file, + log_file, + num_input_struct, + pSortPrintINChIFlags, + save_opt_bits); if (!nRet) { @@ -1842,82 +1818,78 @@ int OutputINChI1( CANON_GLOBALS *pCG, /* InChI output: save InChI creation options if requested */ if (!bEmbeddedOutputCalled && - ( bINChIOutputOptions & INCHI_OUT_SAVEOPT ) && - ( 0 == ( bINChIOutputOptions & INCHI_OUT_STDINCHI ) ) /* not std-InChI output */ - ) + (bINChIOutputOptions & INCHI_OUT_SAVEOPT) && + (0 == (bINChIOutputOptions & INCHI_OUT_STDINCHI)) /* not std-InChI output */ + ) { char let1, let2; - GetSaveOptLetters( save_opt_bits, &let1, &let2 ); - inchi_ios_print_nodisplay( out_file, "\\%c%c", let1, let2 ); + GetSaveOptLetters(save_opt_bits, &let1, &let2); + inchi_ios_print_nodisplay(out_file, "\\%c%c", let1, let2); } if (!bEmbeddedOutputCalled && !bPlainTextCommnts) { /* plain text comment earlier ended with LF */ - inchi_ios_print_nodisplay( out_file, "%s%s", - ( !num_components2[0] && !num_components2[1] ) ? "//" : "", /* empty InChI=// */ - ( bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) ? "\n" : pTAB ); -/* end of INChI= output */ + inchi_ios_print_nodisplay(out_file, "%s%s", + (!num_components2[0] && !num_components2[1]) ? "//" : "", /* empty InChI=// */ + (bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) ? "\n" : pTAB); + /* end of INChI= output */ } - inchi_strbuf_reset( strbuf ); + inchi_strbuf_reset(strbuf); #ifdef TARGET_LIB_FOR_WINCHI /* @@@ Here we end up with silent output: display previously hidden output */ - if (inchi_ios_flush_not_displayed( out_file ) != -1) + if (inchi_ios_flush_not_displayed(out_file) != -1) silent = 0; #endif - - output_aux_info: /* Output Aux Info */ io.bFhTag = 0; - if (( bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO ) == 0) + if ((bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) == 0) { io.num_components = io.num_comp[io.iCurTautMode]; /* AuxInfo: header and normalization type */ - intermediate_result = OutputAUXINFO_HeaderAndNormalization_type( pCG, out_file, strbuf, - bINChIOutputOptions, - &INCHI_basic_or_INCHI_reconnected, - num_components2, - &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_HeaderAndNormalization_type(pCG, out_file, strbuf, + bINChIOutputOptions, + &INCHI_basic_or_INCHI_reconnected, + num_components2, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; - repeat_INChI_Aux_output: /* AuxInfo: original atom numbers and symmetry numbers (constit. equivalence /E: ) */ - intermediate_result = OutputAUXINFO_OriginalNumbersAndEquivalenceClasses( pCG, out_file, strbuf, - num_components2, - &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_OriginalNumbersAndEquivalenceClasses(pCG, out_file, strbuf, + num_components2, + &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; /* AuxInfo: tautomeric groups equivalence */ - intermediate_result = OutputAUXINFO_TautomericGroupsEquivalence( pCG, out_file, strbuf, &io ); + intermediate_result = OutputAUXINFO_TautomericGroupsEquivalence(pCG, out_file, strbuf, &io); if (intermediate_result != 0) goto exit_function; /* AuxInfo: stereo data */ - intermediate_result = OutputAUXINFO_Stereo( pCG, out_file, strbuf, &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_Stereo(pCG, out_file, strbuf, &io, pLF, pTAB); if (intermediate_result != 0) goto exit_function; repeat_INChI_Aux_Iso_output: - /* AuxInfo: isotopic info */ - intermediate_result = OutputAUXINFO_IsotopicInfo( pCG, out_file, strbuf, - &INCHI_basic_or_INCHI_reconnected, - &io, pLF, pTAB ); + /* AuxInfo: isotopic info */ + intermediate_result = OutputAUXINFO_IsotopicInfo(pCG, out_file, strbuf, + &INCHI_basic_or_INCHI_reconnected, + &io, pLF, pTAB); if (intermediate_result != 0) { goto exit_function; } - /* At this point the INChI_Aux part of the output has been completed. If this INChI is tautomeric and non-tautomeric results exist, @@ -1928,11 +1900,8 @@ int OutputINChI1( CANON_GLOBALS *pCG, if (io.bOutType == OUT_TN && io.bTautomeric && io.bNonTautomeric && /* Check whether the Fixed-H layer is empty */ - ( *pSortPrintINChIFlags & ( ( INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : - FLAG_SORT_PRINT_NO_NFIX_H_REC ) ) && - ( *pSortPrintINChIFlags & ( ( INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : - FLAG_SORT_PRINT_NO_IFIX_H_REC ) ) - ) + (*pSortPrintINChIFlags & ((INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : FLAG_SORT_PRINT_NO_NFIX_H_REC)) && + (*pSortPrintINChIFlags & ((INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : FLAG_SORT_PRINT_NO_IFIX_H_REC))) { io.bNonTautomeric = 0; /* bNonTautIdentifierNotEmpty == 0 => no fixed H info 02-10-2995 */ } @@ -1946,13 +1915,11 @@ int OutputINChI1( CANON_GLOBALS *pCG, io.bSecondNonTautPass = 1; io.num_components = io.num_comp[io.iCurTautMode]; io.bFhTag = AL_FIXH; - inchi_strbuf_reset( strbuf ); /*pStr[io.tot_len=0] = '\0';*/ + inchi_strbuf_reset(strbuf); /*pStr[io.tot_len=0] = '\0';*/ /* if InChI Fixed-H isotopic is empty then do not output corresponding AuxInfo */ - if (!( *pSortPrintINChIFlags & - ( ( INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : - FLAG_SORT_PRINT_NO_NFIX_H_REC ) ) - ) + if (!(*pSortPrintINChIFlags & + ((INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : FLAG_SORT_PRINT_NO_NFIX_H_REC))) { npass++; goto repeat_INChI_Aux_output; @@ -1979,22 +1946,21 @@ int OutputINChI1( CANON_GLOBALS *pCG, } /* Charges, radicals, unusual valences */ - intermediate_result = OutputAUXINFO_ChargesRadicalsAndUnusualValences( pCG, out_file, strbuf, &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_ChargesRadicalsAndUnusualValences(pCG, out_file, strbuf, &io, pLF, pTAB); if (intermediate_result != 0) { goto exit_function; } - /* Output the original input structure -- quick fix */ - intermediate_result = OutputAUXINFO_ReversibilityInfo( pCG, out_file, strbuf, pOrigStruct, &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_ReversibilityInfo(pCG, out_file, strbuf, pOrigStruct, &io, pLF, pTAB); if (intermediate_result != 0) { goto exit_function; } /* Output polymeric Aux Info */ - intermediate_result = OutputAUXINFO_PolymerInfo( pCG, out_file, strbuf, pOrigStruct, &io, pLF, pTAB ); + intermediate_result = OutputAUXINFO_PolymerInfo(pCG, out_file, strbuf, pOrigStruct, &io, pLF, pTAB); if (intermediate_result != 0) { goto exit_function; @@ -2005,31 +1971,31 @@ int OutputINChI1( CANON_GLOBALS *pCG, */ bEmbeddedOutputCalled = 0; - if (bDisconnectedCoord && INCHI_basic_or_INCHI_reconnected == INCHI_BAS && ( bINChIOutputOptions & INCHI_OUT_EMBED_REC ) && - num_components2[INCHI_REC] && !( bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO )) + if (bDisconnectedCoord && INCHI_basic_or_INCHI_reconnected == INCHI_BAS && (bINChIOutputOptions & INCHI_OUT_EMBED_REC) && + num_components2[INCHI_REC] && !(bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO)) { int nRet; bEmbeddedOutputCalled = 1; - inchi_ios_print( out_file, "%s", pLF ); - - nRet = OutputINChI1( pCG, - strbuf, - pINChISortTautAndNonTaut2, - INCHI_REC, - NULL, - NULL, - ip, - 0 /*bDisconnectedCoord*/, - bOutputType, - INCHI_OUT_ONLY_AUX_INFO | bINChIOutputOptions, - num_components2, - num_non_taut2, - num_taut2, - out_file, - log_file, - num_input_struct, - pSortPrintINChIFlags, - save_opt_bits ); + inchi_ios_print(out_file, "%s", pLF); + + nRet = OutputINChI1(pCG, + strbuf, + pINChISortTautAndNonTaut2, + INCHI_REC, + NULL, + NULL, + ip, + 0 /*bDisconnectedCoord*/, + bOutputType, + INCHI_OUT_ONLY_AUX_INFO | bINChIOutputOptions, + num_components2, + num_non_taut2, + num_taut2, + out_file, + log_file, + num_input_struct, + pSortPrintINChIFlags, + save_opt_bits); if (!nRet) { @@ -2040,56 +2006,53 @@ int OutputINChI1( CANON_GLOBALS *pCG, /* Close INChI_Aux */ if (!bEmbeddedOutputCalled && !bPlainTextCommnts) { - inchi_ios_print( out_file, "%s\n", ( !num_components2[0] && !num_components2[1] ) ? "//" : "" ); + inchi_ios_print(out_file, "%s\n", (!num_components2[0] && !num_components2[1]) ? "//" : ""); /* plain text comment earlier ended with LF */ } /* in wINChI window, separate AuxInfo: from InChIKey: with blank line */ - inchi_ios_print( out_file, "%s", - ( bINChIOutputOptions & INCHI_OUT_WINCHI_WINDOW ) ? "\n" : "" ); + inchi_ios_print(out_file, "%s", + (bINChIOutputOptions & INCHI_OUT_WINCHI_WINDOW) ? "\n" : ""); } /* end of output AuxInfo */ ret = 1; - exit_function: - #ifdef TARGET_LIB_FOR_WINCHI /* @@@ If for any error we get here silent, display previously hidden output */ if (silent) { - /* - if ( !inchi_ios_flush_not_displayed( out_file ) != -1 ) - silent = 0; - */ + /* + if ( !inchi_ios_flush_not_displayed( out_file ) != -1 ) + silent = 0; + */ silent = 0; } #endif if (io.bOverflow) { - inchi_ios_print( out_file, "\nFATAL ERROR: Output buffer overflow\n" ); + inchi_ios_print(out_file, "\nFATAL ERROR: Output buffer overflow\n"); } if (intermediate_result) { ret = 0; - inchi_ios_eprint( log_file, "InChI serialization error for structure #%d.%s%s%s%s\n", - num_input_struct, SDF_LBL_VAL( ip->pSdfLabel, ip->pSdfValue ) ); + inchi_ios_eprint(log_file, "InChI serialization error for structure #%d.%s%s%s%s\n", + num_input_struct, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); } return ret; } /* OutputINChI1 */ - /****************************************************************************/ -char *szGetTag( const INCHI_TAG *Tag, - int nTag, - int bTag, - char *szTag, - int *bAlways, - short tag_flag) +char *szGetTag(const INCHI_TAG *Tag, + int nTag, + int bTag, + char *szTag, + int *bAlways, + short tag_flag) { int i, j, bit, num, len; const int MAX_TAG_NUM = tag_flag ? (int)IL_MAX_ORD : (int)AL_MAX_ORD; /* djb-rwth: fixing GHI #160 */ @@ -2110,9 +2073,11 @@ char *szGetTag( const INCHI_TAG *Tag, stl1 = strlen(Tag[j].szXmlLabel) + 1; stl2 = strlen(Tag[j].szPlainLabel) + 1; dstsz = max_3(stl1, stl2, 5); - strcpy_s( szTag, dstsz, nTag == 1 ? Tag[j].szXmlLabel : nTag == 2 ? Tag[j].szPlainLabel : "???" ); /* djb-rwth: function replaced with its safe C11 variant */ + strcpy_s(szTag, dstsz, nTag == 1 ? Tag[j].szXmlLabel : nTag == 2 ? Tag[j].szPlainLabel + : "???"); /* djb-rwth: function replaced with its safe C11 variant */ #else - strcpy(szTag, nTag == 1 ? Tag[j].szXmlLabel : nTag == 2 ? Tag[j].szPlainLabel : "???"); + strcpy(szTag, nTag == 1 ? Tag[j].szXmlLabel : nTag == 2 ? Tag[j].szPlainLabel + : "???"); #endif if (nTag != 2) { @@ -2121,55 +2086,52 @@ char *szGetTag( const INCHI_TAG *Tag, return szTag; } } - else - if (nTag == 3) + else if (nTag == 3) + { + /* plain text with comments */ + szTag[0] = '{'; + szTag[1] = '\0'; + for (i = 0, j = -1, bit = 1, num = 0; i < MAX_TAG_NUM; i++, bit <<= 1) { - /* plain text with comments */ - szTag[0] = '{'; - szTag[1] = '\0'; - for (i = 0, j = -1, bit = 1, num = 0; i < MAX_TAG_NUM; i++, bit <<= 1) + if (bTag & bit) { - if (bTag & bit) + j = i; + if (num++) { - j = i; - if (num++) - { - strcat(szTag, ":"); - } - strcat(szTag, Tag[i].szPlainComment); + strcat(szTag, ":"); } + strcat(szTag, Tag[i].szPlainComment); } - if (num) + } + if (num) + { + strcat(szTag, "}"); + num = (int)strlen(Tag[j].szPlainLabel); + len = (int)strlen(szTag); + if (len) { - strcat(szTag, "}"); - num = (int) strlen( Tag[j].szPlainLabel ); - len = (int) strlen( szTag ); - if (len) - { - memmove(szTag + num, szTag, (long long)len + 1); /* djb-rwth: cast operator added */ - memcpy(szTag, Tag[j].szPlainLabel, num); - } - else - { - strcpy(szTag, Tag[j].szPlainLabel); - } - *bAlways = Tag[j].bAlwaysOutput; + memmove(szTag + num, szTag, (long long)len + 1); /* djb-rwth: cast operator added */ + memcpy(szTag, Tag[j].szPlainLabel, num); } else { - strcpy(szTag, "???"); + strcpy(szTag, Tag[j].szPlainLabel); } - return szTag; + *bAlways = Tag[j].bAlwaysOutput; + } + else + { + strcpy(szTag, "???"); } + return szTag; + } strcpy(szTag, "???"); return szTag; } - /* djb-rwth: removing redundant code */ - /**************************************************************************** str_LineEnd( ... ) @@ -2180,11 +2142,11 @@ char *szGetTag( const INCHI_TAG *Tag, *obsolete* if ind >=0 XML output ****************************************************************************/ -int str_LineEnd( const char *tag, - int *bOverflow, - INCHI_IOS_STRING *buf, - int ind, - int bPlainTextTags ) +int str_LineEnd(const char *tag, + int *bOverflow, + INCHI_IOS_STRING *buf, + int ind, + int bPlainTextTags) { /* djb-rwth: removing redundant variables */ int tag_len; @@ -2204,18 +2166,18 @@ int str_LineEnd( const char *tag, */ if (buf->pStr[0] || ind < -1) { - tag_len = bPlainTextTags ? (int) strlen( tag ) : 0; + tag_len = bPlainTextTags ? (int)strlen(tag) : 0; if (tag_len > 0) { int n_added = tag_len + 2 + 2; - inchi_strbuf_update( buf, n_added ); + inchi_strbuf_update(buf, n_added); memmove(buf->pStr + tag_len, buf->pStr, (long long)buf->nUsedLength + 1); /* djb-rwth: cast operator added */ /* NB: trailing 0 is also memmoved */ memcpy(buf->pStr, tag, tag_len); /* to be sure... */ - buf->nUsedLength = strlen( buf->pStr ); + buf->nUsedLength = strlen(buf->pStr); } } } @@ -2223,11 +2185,10 @@ int str_LineEnd( const char *tag, return 0; } - /****************************************************************************/ -int CleanOrigCoord( MOL_COORD szCoord, int delim ) +int CleanOrigCoord(MOL_COORD szCoord, int delim) { -#define MIN_BOND_LENGTH (1.0e-6) +#define MIN_BOND_LENGTH (1.0e-6) char szVal[LEN_COORD + 1]; MOL_COORD szBuf; char *q; @@ -2235,13 +2196,13 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) int k, i; double coord; - for (k = 0; k < NUM_COORD*LEN_COORD; k += LEN_COORD) + for (k = 0; k < NUM_COORD * LEN_COORD; k += LEN_COORD) { memcpy(szVal, szCoord + k, LEN_COORD); szVal[LEN_COORD] = '\0'; - lrtrim( szVal, &len ); - coord = strtod( szVal, &q ); - if (MIN_BOND_LENGTH > fabs( coord )) + lrtrim(szVal, &len); + coord = strtod(szVal, &q); + if (MIN_BOND_LENGTH > fabs(coord)) { strcpy(szVal, "0"); len = 1; @@ -2249,15 +2210,15 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) } else { - len = (int) ( q - szVal ); + len = (int)(q - szVal); /* last = (last mantissa digit position + 1) */ - if (( q = strchr( szVal, 'e' ) ) || ( q = strchr( szVal, 'E' ) ) || - ( q = strchr( szVal, 'd' ) ) || ( q = strchr( szVal, 'D' ) )) + if ((q = strchr(szVal, 'e')) || (q = strchr(szVal, 'E')) || + (q = strchr(szVal, 'd')) || (q = strchr(szVal, 'D'))) { /* floating point */ last = q - szVal; /* remove (+) and leading zeroes from the exponent */ - e = (int) strtol( szVal + last + 1, &q, 10 ); /* exponent */ + e = (int)strtol(szVal + last + 1, &q, 10); /* exponent */ if (e) { /* new exp; update the length */ @@ -2274,11 +2235,11 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) last = len; } /* fst = (first mantissa digit); fst=1 if the sign is present, otherwise 0 */ - fst = ( szVal[0] != '.' && !isdigit( UCINT szVal[0] ) ); + fst = (szVal[0] != '.' && !isdigit(UCINT szVal[0])); /* dec_pnt = (decimal point position) or last */ - if ((q = strchr( szVal, '.' ))) /* djb-rwth: addressing LLVM warning */ + if ((q = strchr(szVal, '.'))) /* djb-rwth: addressing LLVM warning */ { - dec_pnt = (int) ( q - szVal ); + dec_pnt = (int)(q - szVal); } else { @@ -2310,10 +2271,10 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) } if (len_buf && (len_buf < (int)sizeof(MOL_COORD))) { -#pragma warning (push) -#pragma warning (disable: 6386) +#pragma warning(push) +#pragma warning(disable : 6386) szBuf[len_buf++] = delim; -#pragma warning (pop) +#pragma warning(pop) } if (len_buf >= (int)sizeof(MOL_COORD)) /* djb-rwth: fixing coverity CID #499520 */ { @@ -2324,9 +2285,9 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) len_buf += len; } /* zero termination */ - if (len_buf < ( int )sizeof( MOL_COORD )) + if (len_buf < (int)sizeof(MOL_COORD)) { - memset( szBuf + len_buf, 0, sizeof( MOL_COORD ) - len_buf ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(szBuf + len_buf, 0, sizeof(MOL_COORD) - len_buf); /* djb-rwth: memset_s C11/Annex K variant? */ } memcpy(szCoord, szBuf, sizeof(MOL_COORD)); @@ -2335,36 +2296,35 @@ int CleanOrigCoord( MOL_COORD szCoord, int delim ) #undef MIN_BOND_LENGTH } - /****************************************************************************/ -int WriteOrigCoord( int num_inp_atoms, - MOL_COORD *szMolCoord, - int *i, - char *szBuf, - int buf_len ) +int WriteOrigCoord(int num_inp_atoms, + MOL_COORD *szMolCoord, + int *i, + char *szBuf, + int buf_len) { int j, num_zer, len, cur_len; char *p; MOL_COORD szCurCoord; cur_len = 0; - for (j = *i; j < num_inp_atoms; ) + for (j = *i; j < num_inp_atoms;) { memcpy(szCurCoord, szMolCoord[j], sizeof(szCurCoord)); - num_zer = CleanOrigCoord( szCurCoord, ',' ); + num_zer = CleanOrigCoord(szCurCoord, ','); if (NUM_COORD == num_zer) { len = 0; } else { - if ((p = (char *) memchr( szCurCoord, '\0', sizeof( szCurCoord ) ))) /* djb-rwth: addressing LLVM warning */ + if ((p = (char *)memchr(szCurCoord, '\0', sizeof(szCurCoord)))) /* djb-rwth: addressing LLVM warning */ { - len = (int) ( p - szCurCoord ); + len = (int)(p - szCurCoord); } else { - len = sizeof( szCurCoord ); + len = sizeof(szCurCoord); } } if (len + cur_len + 1 < buf_len) @@ -2388,7 +2348,6 @@ int WriteOrigCoord( int num_inp_atoms, return cur_len; } - /**************************************************************************** WriteOrigAtoms @@ -2407,13 +2366,13 @@ int WriteOrigCoord( int num_inp_atoms, Note: . occurs only once and only if radical or 1-character element ****************************************************************************/ -int WriteOrigAtoms( CANON_GLOBALS *pCG, - int num_inp_atoms, - inp_ATOM *at, - int *i, - char *szBuf, - int buf_len, - STRUCT_DATA *sd ) +int WriteOrigAtoms(CANON_GLOBALS *pCG, + int num_inp_atoms, + inp_ATOM *at, + int *i, + char *szBuf, + int buf_len, + STRUCT_DATA *sd) { int j, k, n, len, len0, cur_len, val, bonds_val, mw, parity, num_trans, is_ok, b_self; static const char szIsoH[] = "hdt"; @@ -2424,10 +2383,10 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, if (0 == *i) { cur_len = sprintf(szBuf, "%d%s", num_inp_atoms, - (sd->bChiralFlag & FLAG_INP_AT_CHIRAL) ? "c" : - (sd->bChiralFlag & FLAG_INP_AT_NONCHIRAL) ? "n" : ""); + (sd->bChiralFlag & FLAG_INP_AT_CHIRAL) ? "c" : (sd->bChiralFlag & FLAG_INP_AT_NONCHIRAL) ? "n" + : ""); } - for (j = *i; j < num_inp_atoms; ) + for (j = *i; j < num_inp_atoms;) { /* tetrahedral parity treatment */ parity = 0; @@ -2440,15 +2399,15 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, for (n = 0, k = 0; n < MAX_NUM_STEREO_ATOM_NEIGH; n++) { neigh = at[j].p_orig_at_num[n] - 1; - if (is_in_the_list( at[j].neighbor, neigh, at[j].valence ) && - at[neigh].orig_at_number == at[j].p_orig_at_num[n]) + if (is_in_the_list(at[j].neighbor, neigh, at[j].valence) && + at[neigh].orig_at_number == at[j].p_orig_at_num[n]) { /* real neighbor */ nNeighOrder[k++] = at[j].p_orig_at_num[n]; } else { - if ((int) neigh == j && at[neigh].orig_at_number == at[j].p_orig_at_num[n]) + if ((int)neigh == j && at[neigh].orig_at_number == at[j].p_orig_at_num[n]) { /* central atom is a neighbor */ num_trans = n; /* move this neighbor to 0 position permutation parity */ @@ -2463,14 +2422,14 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, } if (is_ok && b_self <= 1 && b_self + k == MAX_NUM_STEREO_ATOM_NEIGH) { - num_trans += insertions_sort( pCG, nNeighOrder, k, sizeof( nNeighOrder[0] ), comp_AT_RANK ); - if (ATOM_PARITY_WELL_DEF( at[j].p_parity )) + num_trans += insertions_sort(pCG, nNeighOrder, k, sizeof(nNeighOrder[0]), comp_AT_RANK); + if (ATOM_PARITY_WELL_DEF(at[j].p_parity)) { - parity = 2 - ( num_trans + at[j].p_parity ) % 2; + parity = 2 - (num_trans + at[j].p_parity) % 2; } else { - if (ATOM_PARITY_ILL_DEF( at[j].p_parity )) + if (ATOM_PARITY_ILL_DEF(at[j].p_parity)) { parity = at[j].p_parity; } @@ -2482,18 +2441,18 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, } else { - ;/* add error message here */ + ; /* add error message here */ } } - len = len0 = (int) strlen( at[j].elname ); + len = len0 = (int)strlen(at[j].elname); memcpy(szCurAtom, at[j].elname, len); - bonds_val = nBondsValenceInpAt( at + j, NULL, NULL ); + bonds_val = nBondsValenceInpAt(at + j, NULL, NULL); - if (( val = needed_unusual_el_valence( at[j].el_number, at[j].charge, at[j].radical, - at[j].chem_bonds_valence, bonds_val, at[j].num_H, at[j].valence ) ) || - at[j].charge || at[j].radical || at[j].iso_atw_diff || NUM_ISO_H( at, j ) || parity) + if ((val = needed_unusual_el_valence(at[j].el_number, at[j].charge, at[j].radical, + at[j].chem_bonds_valence, bonds_val, at[j].num_H, at[j].valence)) || + at[j].charge || at[j].radical || at[j].iso_atw_diff || NUM_ISO_H(at, j) || parity) { /* valence */ if (val) @@ -2504,7 +2463,7 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, if ((val = at[j].charge)) /* djb-rwth: addressing LLVM warning */ { szCurAtom[len++] = val > 0 ? '+' : '-'; - if (( val = abs( val ) ) > 1) + if ((val = abs(val)) > 1) { len += sprintf(szCurAtom + len, "%d", val); } @@ -2517,14 +2476,13 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, /* isotopic shift */ if ((val = at[j].iso_atw_diff)) /* djb-rwth: addressing LLVM warning */ { - mw = get_atomic_mass_from_elnum( at[j].el_number ); + mw = get_atomic_mass_from_elnum(at[j].el_number); if (val == 1) val = mw; + else if (val > 0) + val = mw + val - 1; else - if (val > 0) - val = mw + val - 1; - else - val = mw + val; + val = mw + val; len += sprintf(szCurAtom + len, "%si%d", len == len0 ? "." : "", val); } @@ -2532,13 +2490,13 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, if (parity) { len += sprintf(szCurAtom + len, "%s%s", len == len0 ? "." : "", - parity == AB_PARITY_ODD ? "o" : - parity == AB_PARITY_EVEN ? "e" : - parity == AB_PARITY_UNKN ? "u" : - parity == AB_PARITY_UNDF ? "?" : ""); + parity == AB_PARITY_ODD ? "o" : parity == AB_PARITY_EVEN ? "e" + : parity == AB_PARITY_UNKN ? "u" + : parity == AB_PARITY_UNDF ? "?" + : ""); } /* implicit isotopic H */ - if (NUM_ISO_H( at, j )) + if (NUM_ISO_H(at, j)) { for (k = 0; k < NUM_H_ISOTOPES; k++) { @@ -2571,7 +2529,6 @@ int WriteOrigAtoms( CANON_GLOBALS *pCG, return cur_len; } - /**************************************************************************** WriteOrigBonds( ... ) @@ -2607,23 +2564,23 @@ A = neighbor orig. atom number neighbor orig. atom number < number of the current atom Number of the current atom: 2 until first ";", 3 until 2nd ";", etc. ****************************************************************************/ -int WriteOrigBonds( CANON_GLOBALS *pCG, - int num_inp_atoms, - inp_ATOM *at, - int *i, - char *szBuf, - int buf_len, - STRUCT_DATA *sd ) +int WriteOrigBonds(CANON_GLOBALS *pCG, + int num_inp_atoms, + inp_ATOM *at, + int *i, + char *szBuf, + int buf_len, + STRUCT_DATA *sd) { int j, k, k2, kk, len, cur_len, j2 = 0, bond_stereo, bond_char, bond_parity, bond_parityNM, num_trans; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - char szCurBonds[7 * MAXVAL + 2]; /* num_neigh*(1 byte bond type + 2 bytes for bond parity up to 4 digits per neighbor number) + at the end one ';' */ + char szCurBonds[7 * MAXVAL + 2]; /* num_neigh*(1 byte bond type + 2 bytes for bond parity up to 4 digits per neighbor number) + at the end one ';' */ AT_RANK nNeighOrder[MAXVAL]; - int chain_len, pnxt_atom, pinxt2cur, pinxt_sb_parity_ord; - int chain_len2, pnxt_atom2, pinxt2cur2, pinxt_sb_parity_ord2, m1, m2; - int pcur_atom, picur2nxt, picur_sb_parity_ord; + int chain_len, pnxt_atom, pinxt2cur, pinxt_sb_parity_ord; + int chain_len2, pnxt_atom2, pinxt2cur2, pinxt_sb_parity_ord2, m1, m2; + int pcur_atom, picur2nxt, picur_sb_parity_ord; cur_len = 0; - for (j = *i; j < num_inp_atoms; ) + for (j = *i; j < num_inp_atoms;) { len = 0; if (at[j].valence >= 1) /* djb-rwth: changing condition to avoid garbage values */ @@ -2633,14 +2590,14 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, nNeighOrder[k] = k; } pCG->m_pn_RankForSort = at[j].neighbor; - num_trans = insertions_sort( pCG, nNeighOrder, at[j].valence, sizeof( nNeighOrder[0] ), CompRank ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + num_trans = insertions_sort(pCG, nNeighOrder, at[j].valence, sizeof(nNeighOrder[0]), CompRank); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ } else { num_trans = 0; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ nNeighOrder[0] = 0; } - for (kk = 0; kk < at[j].valence; kk++) + for (kk = 0; kk < at[j].valence; kk++) { k = nNeighOrder[kk]; j2 = at[j].neighbor[k]; @@ -2651,63 +2608,63 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, bond_stereo = at[j].bond_stereo[k]; switch (at[j].bond_type[k]) { - case BOND_TYPE_SINGLE: - switch (bond_stereo) - { - case STEREO_SNGL_UP: - bond_char = 'p'; - break; - case -STEREO_SNGL_UP: - bond_char = 'P'; - break; - case STEREO_SNGL_DOWN: - bond_char = 'n'; - break; - case -STEREO_SNGL_DOWN: - bond_char = 'N'; - break; -#if ( FIX_EITHER_STEREO_IN_AUX_INFO == 1 ) - case STEREO_SNGL_EITHER: - bond_char = 'v'; - break; - case -STEREO_SNGL_EITHER: - bond_char = 'V'; - break; -#else - case STEREO_SNGL_EITHER: - case -STEREO_SNGL_EITHER: - bond_char = 'v'; - break; -#endif - default: - bond_char = 's'; - break; - } + case BOND_TYPE_SINGLE: + switch (bond_stereo) + { + case STEREO_SNGL_UP: + bond_char = 'p'; break; - case BOND_TYPE_DOUBLE: - switch (bond_stereo) - { - case STEREO_DBLE_EITHER: - case -STEREO_DBLE_EITHER: - bond_char = 'w'; - break; - default: - bond_char = 'd'; - break; - } + case -STEREO_SNGL_UP: + bond_char = 'P'; + break; + case STEREO_SNGL_DOWN: + bond_char = 'n'; + break; + case -STEREO_SNGL_DOWN: + bond_char = 'N'; break; - case BOND_TYPE_TRIPLE: - bond_char = 't'; +#if (FIX_EITHER_STEREO_IN_AUX_INFO == 1) + case STEREO_SNGL_EITHER: + bond_char = 'v'; break; - case BOND_TYPE_ALTERN: - bond_char = 'a'; + case -STEREO_SNGL_EITHER: + bond_char = 'V'; break; +#else + case STEREO_SNGL_EITHER: + case -STEREO_SNGL_EITHER: + bond_char = 'v'; + break; +#endif default: bond_char = 's'; break; + } + break; + case BOND_TYPE_DOUBLE: + switch (bond_stereo) + { + case STEREO_DBLE_EITHER: + case -STEREO_DBLE_EITHER: + bond_char = 'w'; + break; + default: + bond_char = 'd'; + break; + } + break; + case BOND_TYPE_TRIPLE: + bond_char = 't'; + break; + case BOND_TYPE_ALTERN: + bond_char = 'a'; + break; + default: + bond_char = 's'; + break; } /* check for allene/cumulene */ - k2 = (int) ( is_in_the_list( at[j2].neighbor, (AT_NUMB) j, at[j2].valence ) - at[j2].neighbor ); + k2 = (int)(is_in_the_list(at[j2].neighbor, (AT_NUMB)j, at[j2].valence) - at[j2].neighbor); chain_len = chain_len2 = 0; if (at[j].sb_parity[0]) { @@ -2715,8 +2672,8 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, { if (k == at[j].sb_ord[m1]) { - chain_len = get_opposite_sb_atom( at, j, k, - &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord ); + chain_len = get_opposite_sb_atom(at, j, k, + &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord); break; } } @@ -2727,18 +2684,18 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, { if (k2 == at[j2].sb_ord[m2]) { - chain_len2 = get_opposite_sb_atom( at, j2, k2, - &pnxt_atom2, &pinxt2cur2, &pinxt_sb_parity_ord2 ); + chain_len2 = get_opposite_sb_atom(at, j2, k2, + &pnxt_atom2, &pinxt2cur2, &pinxt_sb_parity_ord2); break; } } } - if ((chain_len == 1 && chain_len2 == 1) || /* regular stereobond */ - (chain_len > 1 && j > pnxt_atom)) /* djb-rwth: addressing LLVM warnings */ + if ((chain_len == 1 && chain_len2 == 1) || /* regular stereobond */ + (chain_len > 1 && j > pnxt_atom)) /* djb-rwth: addressing LLVM warnings */ { /* j is a cumulene endpoint */ int m; - pcur_atom = j; /* pcur_atom > pnxt_atom */ + pcur_atom = j; /* pcur_atom > pnxt_atom */ picur2nxt = k; picur_sb_parity_ord = -1; for (m = 0; m < MAX_NUM_STEREO_BONDS && at[pcur_atom].sb_parity[m]; m++) @@ -2781,20 +2738,20 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, /* both atoms belong to a stereo bond */ int kc; int p1 = 0, p2, p1NM = 0, p2NM, neigh, neigh1, neigh2, bHasMetal, bWellDef; /* djb-rwth: initialising p1 and p1NM */ - int bNeighSwitched1, bNeighSwitched2; + int bNeighSwitched1, bNeighSwitched2; /* djb-rwth: avoiding buffer overrun as picur_sb_parity_ord == -1 is possible */ if (picur_sb_parity_ord >= 0) { - p1 = SB_PARITY_1( at[pcur_atom].sb_parity[picur_sb_parity_ord] ); - p1NM = SB_PARITY_2( at[pcur_atom].sb_parity[picur_sb_parity_ord] ); + p1 = SB_PARITY_1(at[pcur_atom].sb_parity[picur_sb_parity_ord]); + p1NM = SB_PARITY_2(at[pcur_atom].sb_parity[picur_sb_parity_ord]); } - p2 = SB_PARITY_1( at[pnxt_atom].sb_parity[pinxt_sb_parity_ord] ); - p2NM = SB_PARITY_2( at[pnxt_atom].sb_parity[pinxt_sb_parity_ord] ); + p2 = SB_PARITY_1(at[pnxt_atom].sb_parity[pinxt_sb_parity_ord]); + p2NM = SB_PARITY_2(at[pnxt_atom].sb_parity[pinxt_sb_parity_ord]); - bWellDef = ATOM_PARITY_WELL_DEF( p1 ) && ATOM_PARITY_WELL_DEF( p2 ); - bHasMetal = ATOM_PARITY_WELL_DEF( p1NM ) && ATOM_PARITY_WELL_DEF( p2NM ); + bWellDef = ATOM_PARITY_WELL_DEF(p1) && ATOM_PARITY_WELL_DEF(p2); + bHasMetal = ATOM_PARITY_WELL_DEF(p1NM) && ATOM_PARITY_WELL_DEF(p2NM); bNeighSwitched1 = bNeighSwitched2 = 0; @@ -2807,18 +2764,18 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, if (kc == picur2nxt) continue; neigh = at[pcur_atom].neighbor[kc]; - if (bHasMetal && is_el_a_metal( at[neigh].el_number )) + if (bHasMetal && is_el_a_metal(at[neigh].el_number)) continue; if (neigh < neigh1) neigh1 = neigh; } if (neigh1 < num_inp_atoms) { - bNeighSwitched1 = ( neigh1 != at[pcur_atom].neighbor[(int) at[pcur_atom].sn_ord[picur_sb_parity_ord]] ); + bNeighSwitched1 = (neigh1 != at[pcur_atom].neighbor[(int)at[pcur_atom].sn_ord[picur_sb_parity_ord]]); } else { - AddErrorMessage( sd->pStrErrStruct, "Cannot find 0D stereobond neighbor" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot find 0D stereobond neighbor"); /* sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; @@ -2831,18 +2788,18 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, if (kc == pinxt2cur) continue; neigh = at[pnxt_atom].neighbor[kc]; - if (bHasMetal && is_el_a_metal( at[neigh].el_number )) + if (bHasMetal && is_el_a_metal(at[neigh].el_number)) continue; if (neigh < neigh2) neigh2 = neigh; } if (neigh2 < num_inp_atoms) { - bNeighSwitched2 = ( neigh2 != at[pnxt_atom].neighbor[(int) at[pnxt_atom].sn_ord[pinxt_sb_parity_ord]] ); + bNeighSwitched2 = (neigh2 != at[pnxt_atom].neighbor[(int)at[pnxt_atom].sn_ord[pinxt_sb_parity_ord]]); } else { - AddErrorMessage( sd->pStrErrStruct, "Cannot find 0D stereobond neighbor" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot find 0D stereobond neighbor"); /* sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; @@ -2851,24 +2808,24 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, if (neigh1 < num_inp_atoms && neigh2 < num_inp_atoms) { - if (ATOM_PARITY_WELL_DEF( p1 ) && ATOM_PARITY_WELL_DEF( p2 )) + if (ATOM_PARITY_WELL_DEF(p1) && ATOM_PARITY_WELL_DEF(p2)) { - bond_parity = 2 - ( p1 + p2 + bNeighSwitched1 + bNeighSwitched2 ) % 2; + bond_parity = 2 - (p1 + p2 + bNeighSwitched1 + bNeighSwitched2) % 2; } else { - bond_parity = inchi_min( p1, p2 ); + bond_parity = inchi_min(p1, p2); } if (bHasMetal) { - bond_parityNM = 2 - ( p1NM + p2NM + bNeighSwitched1 + bNeighSwitched2 ) % 2; + bond_parityNM = 2 - (p1NM + p2NM + bNeighSwitched1 + bNeighSwitched2) % 2; } else { if (p1NM && p2NM) { - bond_parityNM = inchi_min( p1NM, p2NM ); + bond_parityNM = inchi_min(p1NM, p2NM); } } } @@ -2877,11 +2834,11 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, { if (p1 && p2) { - bond_parity = inchi_min( p1, p2 ); + bond_parity = inchi_min(p1, p2); } if (p1NM && p2NM) { - bond_parityNM = inchi_min( p1NM, p2NM ); + bond_parityNM = inchi_min(p1NM, p2NM); } if (bond_parityNM && !bond_parity) { @@ -2891,19 +2848,19 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, } len += sprintf(szCurBonds + len, "%c%s%s%d", - bond_char, + bond_char, - (bond_parity == AB_PARITY_ODD) ? "-" : - (bond_parity == AB_PARITY_EVEN) ? "+" : - (bond_parity == AB_PARITY_UNKN) ? "u" : - (bond_parity == AB_PARITY_UNDF) ? "?" : "", + (bond_parity == AB_PARITY_ODD) ? "-" : (bond_parity == AB_PARITY_EVEN) ? "+" + : (bond_parity == AB_PARITY_UNKN) ? "u" + : (bond_parity == AB_PARITY_UNDF) ? "?" + : "", - (bond_parityNM == AB_PARITY_ODD) ? "-" : - (bond_parityNM == AB_PARITY_EVEN) ? "+" : - (bond_parityNM == AB_PARITY_UNKN) ? "u" : - (bond_parityNM == AB_PARITY_UNDF) ? "?" : "", + (bond_parityNM == AB_PARITY_ODD) ? "-" : (bond_parityNM == AB_PARITY_EVEN) ? "+" + : (bond_parityNM == AB_PARITY_UNKN) ? "u" + : (bond_parityNM == AB_PARITY_UNDF) ? "?" + : "", - j2 + 1); + j2 + 1); } } if (len + cur_len + 2 < buf_len) @@ -2924,19 +2881,18 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, return cur_len; } - -#define ORIG_STR_BUFLEN (7*MAXVAL+2) /* > 7*MAXVAL+2 = 142 */ +#define ORIG_STR_BUFLEN (7 * MAXVAL + 2) /* > 7*MAXVAL+2 = 142 */ /**************************************************************************** Fill out original input structure ****************************************************************************/ -int OrigStruct_FillOut( CANON_GLOBALS *pCG, +int OrigStruct_FillOut(CANON_GLOBALS *pCG, ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - STRUCT_DATA *sd ) + ORIG_STRUCT *pOrigStruct, + STRUCT_DATA *sd) { char szBuf[ORIG_STR_BUFLEN]; - int i, len, len_coord, len_atoms, len_bonds; + int i, len, len_coord, len_atoms, len_bonds; pOrigStruct->polymer = NULL; pOrigStruct->v3000 = NULL; @@ -2948,22 +2904,22 @@ int OrigStruct_FillOut( CANON_GLOBALS *pCG, if (orig_inp_data->szCoord) { - while ((len = WriteOrigCoord( orig_inp_data->num_inp_atoms, - orig_inp_data->szCoord, &i, szBuf, sizeof( szBuf ) ))) /* djb-rwth: addressing LLVM warning */ + while ((len = WriteOrigCoord(orig_inp_data->num_inp_atoms, + orig_inp_data->szCoord, &i, szBuf, sizeof(szBuf)))) /* djb-rwth: addressing LLVM warning */ { len_coord += len; } - pOrigStruct->szCoord = (char*) inchi_malloc( ( (long long)len_coord + 1 ) * sizeof( pOrigStruct->szCoord[0] ) ); /* djb-rwth: cast operator added */ + pOrigStruct->szCoord = (char *)inchi_malloc(((long long)len_coord + 1) * sizeof(pOrigStruct->szCoord[0])); /* djb-rwth: cast operator added */ i = 0; if (pOrigStruct->szCoord && - len_coord == WriteOrigCoord( orig_inp_data->num_inp_atoms, - orig_inp_data->szCoord, &i, pOrigStruct->szCoord, len_coord + 1 ) && - i == orig_inp_data->num_inp_atoms) + len_coord == WriteOrigCoord(orig_inp_data->num_inp_atoms, + orig_inp_data->szCoord, &i, pOrigStruct->szCoord, len_coord + 1) && + i == orig_inp_data->num_inp_atoms) { /* success */ if (orig_inp_data->szCoord) { - inchi_free( orig_inp_data->szCoord ); + inchi_free(orig_inp_data->szCoord); orig_inp_data->szCoord = NULL; } } @@ -2975,19 +2931,19 @@ int OrigStruct_FillOut( CANON_GLOBALS *pCG, /* Atoms */ len_atoms = i = 0; - while ((len = WriteOrigAtoms( pCG, orig_inp_data->num_inp_atoms, - orig_inp_data->at, &i, szBuf, sizeof( szBuf ), sd ))) /* djb-rwth: addressing LLVM warning */ + while ((len = WriteOrigAtoms(pCG, orig_inp_data->num_inp_atoms, + orig_inp_data->at, &i, szBuf, sizeof(szBuf), sd))) /* djb-rwth: addressing LLVM warning */ { len_atoms += len; if (!orig_inp_data->num_inp_atoms) break; } - pOrigStruct->szAtoms = (char*) inchi_malloc( ( (long long)len_atoms + 1 ) * sizeof( pOrigStruct->szAtoms[0] ) ); /* djb-rwth: cast operator added */ + pOrigStruct->szAtoms = (char *)inchi_malloc(((long long)len_atoms + 1) * sizeof(pOrigStruct->szAtoms[0])); /* djb-rwth: cast operator added */ i = 0; if (pOrigStruct->szAtoms && - len_atoms == WriteOrigAtoms( pCG, orig_inp_data->num_inp_atoms, - orig_inp_data->at, &i, pOrigStruct->szAtoms, len_atoms + 1, sd ) && - i == orig_inp_data->num_inp_atoms) + len_atoms == WriteOrigAtoms(pCG, orig_inp_data->num_inp_atoms, + orig_inp_data->at, &i, pOrigStruct->szAtoms, len_atoms + 1, sd) && + i == orig_inp_data->num_inp_atoms) { ; /* success */ } @@ -2999,11 +2955,11 @@ int OrigStruct_FillOut( CANON_GLOBALS *pCG, /* Bonds */ len_bonds = 0; i = 1; - while ((len = WriteOrigBonds( pCG, orig_inp_data->num_inp_atoms, -#if ( FIX_CURE53_ISSUE_OOB_ALREADY_HAVE_THIS_MESSAGE==1 ) - orig_inp_data->at, &i, szBuf, sizeof(szBuf), sd))) /* djb-rwth: addressing LLVM warning */ + while ((len = WriteOrigBonds(pCG, orig_inp_data->num_inp_atoms, +#if (FIX_CURE53_ISSUE_OOB_ALREADY_HAVE_THIS_MESSAGE == 1) + orig_inp_data->at, &i, szBuf, sizeof(szBuf), sd))) /* djb-rwth: addressing LLVM warning */ #else - orig_inp_data->at, &i, szBuf, sizeof(szBuf), NULL))) + orig_inp_data->at, &i, szBuf, sizeof(szBuf), NULL))) #endif { len_bonds += len; @@ -3013,13 +2969,13 @@ int OrigStruct_FillOut( CANON_GLOBALS *pCG, } } - pOrigStruct->szBonds = (char*) inchi_malloc( ( (long long)len_bonds + 2 ) * sizeof( pOrigStruct->szBonds[0] ) ); /* djb-rwth: cast operator added */ + pOrigStruct->szBonds = (char *)inchi_malloc(((long long)len_bonds + 2) * sizeof(pOrigStruct->szBonds[0])); /* djb-rwth: cast operator added */ i = 1; if (pOrigStruct->szBonds && - len_bonds == WriteOrigBonds( pCG, orig_inp_data->num_inp_atoms, - orig_inp_data->at, &i, pOrigStruct->szBonds, len_bonds + 2, sd ) && - i == orig_inp_data->num_inp_atoms) + len_bonds == WriteOrigBonds(pCG, orig_inp_data->num_inp_atoms, + orig_inp_data->at, &i, pOrigStruct->szBonds, len_bonds + 2, sd) && + i == orig_inp_data->num_inp_atoms) { ; /* success */ } @@ -3030,39 +2986,36 @@ int OrigStruct_FillOut( CANON_GLOBALS *pCG, pOrigStruct->num_atoms = orig_inp_data->num_inp_atoms; /* Extensions of v. 1.05 */ - if (orig_inp_data->polymer != NULL - && orig_inp_data->polymer->n > 0 - && orig_inp_data->valid_polymer) + if (orig_inp_data->polymer != NULL && orig_inp_data->polymer->n > 0 && orig_inp_data->valid_polymer) { pOrigStruct->polymer = orig_inp_data->polymer; - /* pointer copy, do not free after use! */ + /* pointer copy, do not free after use! */ } if (orig_inp_data->v3000 != NULL) { pOrigStruct->v3000 = orig_inp_data->v3000; - /* pointer copy, do not free after use! */ + /* pointer copy, do not free after use! */ } return 0; } - /****************************************************************************/ -void OrigStruct_Free( ORIG_STRUCT *pOrigStruct ) +void OrigStruct_Free(ORIG_STRUCT *pOrigStruct) { if (pOrigStruct) { if (pOrigStruct->szAtoms) { - inchi_free( pOrigStruct->szAtoms ); + inchi_free(pOrigStruct->szAtoms); } if (pOrigStruct->szBonds) { - inchi_free( pOrigStruct->szBonds ); + inchi_free(pOrigStruct->szBonds); } if (pOrigStruct->szCoord) { - inchi_free( pOrigStruct->szCoord ); + inchi_free(pOrigStruct->szCoord); } /* For @@ -3079,7 +3032,6 @@ void OrigStruct_Free( ORIG_STRUCT *pOrigStruct ) } } - /**************************************************************************** GetSaveOptLetters @@ -3097,29 +3049,28 @@ void OrigStruct_Free( ORIG_STRUCT *pOrigStruct ) Also, there is a reservation for future needs: the 2nd memo char may accommodate two more ON/OFF ****************************************************************************/ -void GetSaveOptLetters( unsigned char save_opt_bits, char* let1, char* let2 ) +void GetSaveOptLetters(unsigned char save_opt_bits, char *let1, char *let2) { const char a2p[] = "ABCDEFGHIJKLMNOP"; /* SaveOptBits layout: {unused|unused|Ket|15T|RecMet|FixedH|SUU|SLUUD} */ - *let1 = a2p[(size_t) ( save_opt_bits & 0x0f )]; - *let2 = a2p[(size_t) ( ( save_opt_bits & 0x30 ) >> 4 )]; + *let1 = a2p[(size_t)(save_opt_bits & 0x0f)]; + *let2 = a2p[(size_t)((save_opt_bits & 0x30) >> 4)]; } - /**************************************************************************** Set line separators dependent on requested output mode ****************************************************************************/ -void set_line_separators( int bINChIOutputOptions, char **pLF, char **pTAB ) +void set_line_separators(int bINChIOutputOptions, char **pLF, char **pTAB) { - int bPlainTextCommnts = 0 != ( bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT_COMMENTS ); + int bPlainTextCommnts = 0 != (bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT_COMMENTS); *pLF = (char *)(bPlainTextCommnts ? "\n" : "\0"); -#if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) ) +#if (!defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI)) { - int bPlainText = 0 != ( bINChIOutputOptions & ( INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS ) ); - int bPlainTabbedOutput = 0 != ( bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT ) && - bPlainText && !bPlainTextCommnts; + int bPlainText = 0 != (bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS)); + int bPlainTabbedOutput = 0 != (bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT) && + bPlainText && !bPlainTextCommnts; *pTAB = bPlainTabbedOutput ? "\t" : "\n"; } @@ -3130,63 +3081,61 @@ void set_line_separators( int bINChIOutputOptions, char **pLF, char **pTAB ) return; } - /**************************************************************************** Output InChI: InChI version and kind ****************************************************************************/ -int OutputINCHI_VersionAndKind( INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int bINChIOutputOptions, - int is_beta, - char *pLF, - char *pTAB ) +int OutputINCHI_VersionAndKind(INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int bINChIOutputOptions, + int is_beta, + char *pLF, + char *pTAB) { - inchi_ios_print_nodisplay( out_file, "%s%s=%s", pLF, INCHI_NAME, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s=%s", pLF, INCHI_NAME, pLF); - inchi_strbuf_reset( strbuf ); - inchi_strbuf_printf( strbuf, "%s", x_curr_ver ); + inchi_strbuf_reset(strbuf); + inchi_strbuf_printf(strbuf, "%s", x_curr_ver); /* - add 'Beta' flag if applicable */ if (is_beta) { - inchi_strbuf_printf( strbuf, "B" ); + inchi_strbuf_printf(strbuf, "B"); } /* - add 'Standard' flag if applicable */ else if (bINChIOutputOptions & INCHI_OUT_STDINCHI) { - inchi_strbuf_printf( strbuf, "S" ); + inchi_strbuf_printf(strbuf, "S"); } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); return 0; } - /**************************************************************************** Output InChI: main layer - formula, connections and hydrogens (incl. tautomeric info == mobile H) ***************************************************************************/ -int OutputINCHI_MainLayerFormula( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_MainLayerFormula(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* constitution ( dot-disconnected Hill formulas: ) */ if (num_components2[0] || num_components2[1]) { - szGetTag( IdentLbl, io->nTag, io->bTag1 = *INCHI_basic_or_INCHI_reconnected == INCHI_REC ? IL_REC_ : IL_FML_, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); - io->tot_len = str_HillFormula( io->pINChISort, strbuf, &io->bOverflow, io->bOutType, - io->num_components, io->bUseMulipliers ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = *INCHI_basic_or_INCHI_reconnected == INCHI_REC ? IL_REC_ : IL_FML_, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); + io->tot_len = str_HillFormula(io->pINChISort, strbuf, &io->bOverflow, io->bOutType, + io->num_components, io->bUseMulipliers); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, 1 )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, 1)) { return 1; } @@ -3198,7 +3147,7 @@ int OutputINCHI_MainLayerFormula( CANON_GLOBALS *pCG, return -1; } } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } LOG_NO_ARGS("\n#################### (L3318:ichiprt1.c) ##########################\n"); @@ -3208,35 +3157,34 @@ int OutputINCHI_MainLayerFormula( CANON_GLOBALS *pCG, return 0; } - /****************************************************************************/ -int OutputINCHI_MainLayerConnections( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_MainLayerConnections(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* connections ( semicolon/dot-disconnected connection tables ) */ - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_CONN, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_CONN, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - io->tot_len2 = str_Connections( pCG, io->pINChISort, strbuf, &io->bOverflow, io->bOutType, - io->ATOM_MODE, io->num_components, io->bUseMulipliers ); + io->tot_len2 = str_Connections(pCG, io->pINChISort, strbuf, &io->bOverflow, io->bOutType, + io->ATOM_MODE, io->num_components, io->bUseMulipliers); /* current version does not output empty (";;;;") connectivity */ if (io->tot_len != io->tot_len2) { /* 2004-06-30: never output empty connection table */ io->tot_len = io->tot_len2; - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -2, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -2, io->bPlainTextTags)) { return 1; /* pStr overfow */ } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } LOG_NO_ARGS("\n##################### (L3357:ichiprt1.c) #########################\n"); @@ -3246,36 +3194,35 @@ int OutputINCHI_MainLayerConnections( CANON_GLOBALS *pCG, return 0; } - /****************************************************************************/ -int OutputINCHI_MainLayerHydrogens( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_MainLayerHydrogens(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* hydrogen atoms (do not output empty) */ - if (INCHI_SEGM_FILL == INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS] )) + if (INCHI_SEGM_FILL == INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS])) { - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_ALLH, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_ALLH, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - io->tot_len2 = str_H_atoms( io->pINChISort, strbuf, &io->bOverflow, io->bOutType, - io->ATOM_MODE, io->TAUT_MODE, - io->num_components, io->bUseMulipliers ); + io->tot_len2 = str_H_atoms(io->pINChISort, strbuf, &io->bOverflow, io->bOutType, + io->ATOM_MODE, io->TAUT_MODE, + io->num_components, io->bUseMulipliers); if (io->tot_len != io->tot_len2) { /* 2004-06-21: never output empty */ io->tot_len = io->tot_len2; - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -2, 1 )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -2, 1)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } } @@ -3286,38 +3233,37 @@ int OutputINCHI_MainLayerHydrogens( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output InChI: charge and removed protons layers ****************************************************************************/ -int OutputINCHI_ChargeAndRemovedAddedProtonsLayers( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_ChargeAndRemovedAddedProtonsLayers(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* charge */ - io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_q_CHARGE] ); + io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_q_CHARGE]); if (io->nSegmAction) { - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_CHRG | io->bFhTag, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_CHRG | io->bFhTag, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_Charge2( io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_Charge2(io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } /* removed protons */ @@ -3325,209 +3271,212 @@ int OutputINCHI_ChargeAndRemovedAddedProtonsLayers( CANON_GLOBALS *pCG, if (io->iCurTautMode == TAUT_YES && !io->bSecondNonTautPass) { - io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_p_PROTONS] ); + io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_p_PROTONS]); if (io->nSegmAction) { - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_PROT | io->bFhTag, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_PROT | io->bFhTag, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - inchi_strbuf_printf( strbuf, "%+d", io->nNumRemovedProtons ); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + inchi_strbuf_printf(strbuf, "%+d", io->nNumRemovedProtons); + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { - if (io->bPlainTextTags == 1) inchi_ios_print_nodisplay( out_file, "/" ); + if (io->bPlainTextTags == 1) + inchi_ios_print_nodisplay(out_file, "/"); } } return 0; } - /**************************************************************************** Output InChI: stereo layer with sublayers ****************************************************************************/ -int OutputINCHI_StereoLayer( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_StereoLayer(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { { int i; - i = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS] ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + i = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS]); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ /* djb-rwth: removing redundant code */ } - if (INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE] )) + if (INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE])) { /* stereo */ - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_STER | io->bFhTag, io->szTag1, &io->bAlways, 1 ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_STER | io->bFhTag, io->szTag1, &io->bAlways, 1); /* sp2 */ /*if ( bStereoSp2[io->iCurTautMode] )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_DBND, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_DBND, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_Sp2( io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_Sp2(io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); /* sp2 */ + inchi_ios_print_nodisplay(out_file, "/"); /* sp2 */ } } /* sp3 */ /*if ( bStereoSp3[io->iCurTautMode] )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS]))) /* djb-rwth: addressing LLVM warning */ { io->bRelRac = io->bRelativeStereo[io->iCurTautMode] || io->bRacemicStereo[io->iCurTautMode]; - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_SP3S, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_SP3S, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_Sp3( io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, io->bRelRac, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_Sp3(io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, io->bRelRac, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 2; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { - if (io->bPlainTextTags == 1) inchi_ios_print_nodisplay( out_file, "/" ); /* sp3 */ + if (io->bPlainTextTags == 1) + inchi_ios_print_nodisplay(out_file, "/"); /* sp3 */ } /* bStereoAbsInverted[io->iCurTautMode] */ /* if ( bStereoAbs[io->iCurTautMode] ) */ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_INVS, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_INVS, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_StereoAbsInv( io->pINChISort, strbuf, - &io->bOverflow, io->bOutType, io->num_components ); + io->tot_len = str_StereoAbsInv(io->pINChISort, strbuf, + &io->bOverflow, io->bOutType, io->num_components); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 3; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); /* stereo-abs-inv */ + inchi_ios_print_nodisplay(out_file, "/"); /* stereo-abs-inv */ } } /* stereo type */ /*if ( io->bRacemicStereo[io->iCurTautMode] || io->bRelativeStereo[io->iCurTautMode] || bStereoAbs[io->iCurTautMode] )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE]))) /* djb-rwth: addressing LLVM warning */ { - const char *p_stereo = io->bRelativeStereo[io->iCurTautMode] ? x_rel : - io->bRacemicStereo[io->iCurTautMode] ? x_rac : x_abs; - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_TYPS, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; + const char *p_stereo = io->bRelativeStereo[io->iCurTautMode] ? x_rel : io->bRacemicStereo[io->iCurTautMode] ? x_rac + : x_abs; + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_TYPS, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - ( io->tot_len ) += MakeDelim( p_stereo, strbuf, &io->bOverflow ); + (io->tot_len) += MakeDelim(p_stereo, strbuf, &io->bOverflow); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); /* no abs, inv or racemic stereo */ + inchi_ios_print_nodisplay(out_file, "/"); /* no abs, inv or racemic stereo */ } } else { - if (io->bPlainTextTags == 1) inchi_ios_print_nodisplay( out_file, "////" ); /* sp3, sp2, abs-inv, stereo.type */ + if (io->bPlainTextTags == 1) + inchi_ios_print_nodisplay(out_file, "////"); /* sp3, sp2, abs-inv, stereo.type */ } return 0; } - /**************************************************************************** Output InChI: isotopic layer and sublayers ****************************************************************************/ -int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputINCHI_IsotopicLayer(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { - if (INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_i_IATOMS] )) + if (INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_i_IATOMS])) { /* isotopic #1: composition -- atoms -- do not output in xml if empty */ - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_ISOT | io->bFhTag, io->szTag1, &io->bAlways, 1 ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_ISOT | io->bFhTag, io->szTag1, &io->bAlways, 1); /* isotopic atoms without mobile H. * Fixed 2004-06-15: always output if not bXml. Note: * Previous condition if( bHasIsotopicAtoms[io->iCurTautMode] || bIsotopic && !bXml) * did not optput /i in case of only mobile isotopic H */ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_i_IATOMS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_i_IATOMS]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_ATMS, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_ATMS, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; /*if ( bHasIsotopicAtoms[io->iCurTautMode] )*/ if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len2 = str_IsoAtoms( io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, io->bAbcNumbers, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len2 = str_IsoAtoms(io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, io->bAbcNumbers, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; } else @@ -3536,27 +3485,27 @@ int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, } io->tot_len = io->tot_len2; - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } /* isotopic #1a: composition -- exchangeable isotopic H (mobile H only) */ /*if ( !io->bSecondNonTautPass && bHasIsoH )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_XCGA, io->szTag2, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_XCGA, io->szTag2, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - ( io->tot_len ) += MakeIsoHString( io->num_iso_H, strbuf, io->TAUT_MODE, &io->bOverflow ); + (io->tot_len) += MakeIsoHString(io->num_iso_H, strbuf, io->TAUT_MODE, &io->bOverflow); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 2; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } /*************************************************** @@ -3566,121 +3515,122 @@ int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, ***************************************************/ /*if ( bIsotopicStereo[io->iCurTautMode] )*/ - if (INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV] ) || - INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE] )) + if (INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV]) || + INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE])) { /* stereo */ - szGetTag( IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_STER, io->szTag2, &io->bAlways, 1 ); + szGetTag(IdentLbl, io->nTag, io->bTag2 = io->bTag1 | IL_STER, io->szTag2, &io->bAlways, 1); /************************ isotopic #2: sp2 ************************/ /*if ( bIsotopicStereoSp2[io->iCurTautMode] )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_b_SBONDS]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_DBND, io->szTag3, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_DBND, io->szTag3, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_IsoSp2( io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_IsoSp2(io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 3; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { - if (io->bPlainTextTags == 1) inchi_ios_print_nodisplay( out_file, "/" ); /* iso sp2 */ + if (io->bPlainTextTags == 1) + inchi_ios_print_nodisplay(out_file, "/"); /* iso sp2 */ } /************************ isotopic #3: sp3 ************************/ /*if ( bIsotopicStereoSp3[io->iCurTautMode] )*/ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_t_SATOMS]))) /* djb-rwth: addressing LLVM warning */ { io->bRelRac = io->bIsotopicRelativeStereo[io->iCurTautMode] || io->bIsotopicRacemicStereo[io->iCurTautMode]; - szGetTag( IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_SP3S, io->szTag3, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_SP3S, io->szTag3, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_IsoSp3( io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, io->bRelRac, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_IsoSp3(io->pINChISort, io->pINChISort2, strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, io->bRelRac, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 5; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); /* iso-sp3 */ + inchi_ios_print_nodisplay(out_file, "/"); /* iso-sp3 */ } } /* isotopic #4: abs inverted */ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_m_SP3INV]))) /* djb-rwth: addressing LLVM warning */ { - szGetTag( IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_INVS, io->szTag3, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_INVS, io->szTag3, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len = str_IsoStereoAbsInv( io->pINChISort, strbuf, - &io->bOverflow, io->bOutType, io->num_components ); + io->tot_len = str_IsoStereoAbsInv(io->pINChISort, strbuf, + &io->bOverflow, io->bOutType, io->num_components); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 5; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); + inchi_ios_print_nodisplay(out_file, "/"); } } /* isotopic #5: stereo type. Do not output if it has already been output in non-iso */ - if ((io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE] ))) /* djb-rwth: addressing LLVM warning */ + if ((io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_s_STYPE]))) /* djb-rwth: addressing LLVM warning */ { - const char *p_stereo = io->bIsotopicRelativeStereo[io->iCurTautMode] ? x_rel : - io->bIsotopicRacemicStereo[io->iCurTautMode] ? x_rac : x_abs; - szGetTag( IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_TYPS, io->szTag3, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + const char *p_stereo = io->bIsotopicRelativeStereo[io->iCurTautMode] ? x_rel : io->bIsotopicRacemicStereo[io->iCurTautMode] ? x_rac + : x_abs; + szGetTag(IdentLbl, io->nTag, io->bTag3 = io->bTag2 | IL_TYPS, io->szTag3, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len += MakeDelim( p_stereo, strbuf, &io->bOverflow ); + io->tot_len += MakeDelim(p_stereo, strbuf, &io->bOverflow); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; } - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 6; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); } if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); /* no abs, inv or racemic stereo */ + inchi_ios_print_nodisplay(out_file, "/"); /* no abs, inv or racemic stereo */ } } else @@ -3688,7 +3638,7 @@ int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, /* no isotopic stereo */ if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "////" ); /* sp3, sp2, abs-inv, stereo.type */ + inchi_ios_print_nodisplay(out_file, "////"); /* sp3, sp2, abs-inv, stereo.type */ } } } @@ -3696,45 +3646,45 @@ int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "///" ); /* isotopic composition, sp2, sp3 */ + inchi_ios_print_nodisplay(out_file, "///"); /* isotopic composition, sp2, sp3 */ } if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "//" ); /* inv or racemic stereo */ + inchi_ios_print_nodisplay(out_file, "//"); /* inv or racemic stereo */ } } -#if ( CANON_FIXH_TRANS == 1 ) +#if (CANON_FIXH_TRANS == 1) if (io->bOutType == OUT_NONTAUT && io->bOutputType == OUT_TN && io->bSecondNonTautPass && - INCHI_SEGM_FILL == INChI_SegmentAction( io->sDifSegs[DIFL_F][DIFS_o_TRANSP] )) + INCHI_SEGM_FILL == INChI_SegmentAction(io->sDifSegs[DIFL_F][DIFS_o_TRANSP])) { /* find and print non-tautomeric components transposition, if non-trivial */ AT_NUMB *nTrans_n, *nTrans_s; - if (0 < bin_AuxTautTrans( io->pINChISort, io->pINChISort2, &nTrans_n, &nTrans_s, io->bOutType, io->num_components )) + if (0 < bin_AuxTautTrans(io->pINChISort, io->pINChISort2, &nTrans_n, &nTrans_s, io->bOutType, io->num_components)) { /* a non-trivial transposition does exist; output start tag */ - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_TRNS | io->bFhTag, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_TRNS | io->bFhTag, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); io->tot_len = 0; /* print the transposition, cycle after cycle */ - io->tot_len = str_AuxTautTrans( pCG, nTrans_n, nTrans_s, strbuf, - &io->bOverflow, io->TAUT_MODE, io->num_components ); + io->tot_len = str_AuxTautTrans(pCG, nTrans_n, nTrans_s, strbuf, + &io->bOverflow, io->TAUT_MODE, io->num_components); io->bNonTautIsoIdentifierNotEmpty += io->bSecondNonTautPass; - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 7; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); - /* detected transposition */ - ( *io->pSortPrintINChIFlags ) |= - ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_TRANSPOS_BAS : FLAG_SORT_PRINT_TRANSPOS_REC; + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); + /* detected transposition */ + (*io->pSortPrintINChIFlags) |= + (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_TRANSPOS_BAS : FLAG_SORT_PRINT_TRANSPOS_REC; } else { if (io->bPlainTextTags == 1) { - inchi_ios_print_nodisplay( out_file, "/" ); + inchi_ios_print_nodisplay(out_file, "/"); } } } @@ -3743,68 +3693,66 @@ int OutputINCHI_IsotopicLayer( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output InChI: FixedH layer and related sublayers ****************************************************************************/ -int OutputINCHI_FixedHLayerWithSublayers( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB, - int *then_goto_repeat ) +int OutputINCHI_FixedHLayerWithSublayers(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB, + int *then_goto_repeat) { *then_goto_repeat = 0; if (io->bOutType == OUT_TN && - !( io->bSecondNonTautPass ) && - io->bNonTautIsIdenticalToTaut && - io->bTautomeric && - io->bNonTautomeric) + !(io->bSecondNonTautPass) && + io->bNonTautIsIdenticalToTaut && + io->bTautomeric && + io->bNonTautomeric) { - /* Fixed-H layer is empty in the Identifier */ - ( *io->pSortPrintINChIFlags ) |= - ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : - FLAG_SORT_PRINT_NO_NFIX_H_REC; - ( *io->pSortPrintINChIFlags ) |= - ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : - FLAG_SORT_PRINT_NO_IFIX_H_REC; + /* Fixed-H layer is empty in the Identifier */ + (*io->pSortPrintINChIFlags) |= + (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : FLAG_SORT_PRINT_NO_NFIX_H_REC; + (*io->pSortPrintINChIFlags) |= + (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : FLAG_SORT_PRINT_NO_IFIX_H_REC; } if (io->bOutType == OUT_TN && - !io->bNonTautIsIdenticalToTaut && /* added 2004-10-04 Fix16 */ + !io->bNonTautIsIdenticalToTaut && /* added 2004-10-04 Fix16 */ #ifdef OLD_ITEM_DISCOVERY - io->bTautomeric && - io->bNonTautomeric && + io->bTautomeric && + io->bNonTautomeric && #endif - INChI_SegmentAction( io->sDifSegs[DIFL_F][DIFS_f_FORMULA] ) - /* special case: removed isolated H(+): */ - /* || io->iCurTautMode == TAUT_YES && num_comp[TAUT_YES] < num_comp[TAUT_NON] && - 0 < num_comp[TAUT_NON]*/ - ) + INChI_SegmentAction(io->sDifSegs[DIFL_F][DIFS_f_FORMULA]) + /* special case: removed isolated H(+): */ + /* || io->iCurTautMode == TAUT_YES && num_comp[TAUT_YES] < num_comp[TAUT_NON] && + 0 < num_comp[TAUT_NON]*/ + ) { /* add the second (non-tautomeric) output */ - io->bOutType = OUT_NONTAUT; /* pick up only non-tautomeric representation of tautomeric */ + io->bOutType = OUT_NONTAUT; /* pick up only non-tautomeric representation of tautomeric */ io->iCurTautMode = TAUT_NON; io->pINChISort = io->pINChISortTautAndNonTaut[TAUT_NON]; io->bSecondNonTautPass = 1; io->nCurINChISegment = DIFL_F; io->num_components = io->num_comp[io->iCurTautMode]; /* number of components could change due to removal of isolated H(+) from tautomeric */ io->bFhTag = IL_FIXH; - szGetTag( IdentLbl, io->nTag, io->bTag1 = io->bFhTag, io->szTag1, &io->bAlways, 1 ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = io->bFhTag, io->szTag1, &io->bAlways, 1); /***** constitution non-taut: dot-disconnected Hill formulas: -- only if different */ - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_FMLF | io->bFhTag, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_f_FORMULA] ); + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_FMLF | io->bFhTag, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_f_FORMULA]); if (INCHI_SEGM_FILL == io->nSegmAction) { - io->tot_len2 = str_HillFormula2( io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, - io->num_components, io->bUseMulipliers ); + io->tot_len2 = str_HillFormula2(io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, + io->num_components, io->bUseMulipliers); if (io->n_pzz > 0 && io->n_zy > 0) { MergeZzInHillFormula(strbuf); @@ -3816,28 +3764,29 @@ int OutputINCHI_FixedHLayerWithSublayers( CANON_GLOBALS *pCG, io->tot_len2 = io->tot_len; } io->tot_len = io->tot_len2; - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 1; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); - io->nSegmAction = INChI_SegmentAction( io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS] ); + io->nSegmAction = INChI_SegmentAction(io->sDifSegs[io->nCurINChISegment][DIFS_h_H_ATOMS]); if (INCHI_SEGM_FILL == io->nSegmAction) { - szGetTag( IdentLbl, io->nTag, io->bTag1 = IL_HFIX | io->bFhTag, io->szTag1, &io->bAlways, 1 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; /* open H-fixed */ + szGetTag(IdentLbl, io->nTag, io->bTag1 = IL_HFIX | io->bFhTag, io->szTag1, &io->bAlways, 1); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; /* open H-fixed */ /* output the second non-tautomeric item: fixed H -- do not output in xml if empty */ - io->tot_len2 = str_FixedH_atoms( io->pINChISort, strbuf, - &io->bOverflow, io->bOutType, io->ATOM_MODE, - io->num_components, io->bUseMulipliers ); + io->tot_len2 = str_FixedH_atoms(io->pINChISort, strbuf, + &io->bOverflow, io->bOutType, io->ATOM_MODE, + io->num_components, io->bUseMulipliers); io->tot_len = io->tot_len2; - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -io->nSegmAction, io->bPlainTextTags)) { return 2; } - inchi_ios_print_nodisplay( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print_nodisplay(out_file, "%s%s", strbuf->pStr, pLF); io->bNonTautNonIsoIdentifierNotEmpty += io->bSecondNonTautPass; } *then_goto_repeat = 1; @@ -3857,14 +3806,12 @@ int OutputINCHI_FixedHLayerWithSublayers( CANON_GLOBALS *pCG, if (!io->bNonTautNonIsoIdentifierNotEmpty) { /* Fixed-H layer is empty in the Identifier */ - ( *io->pSortPrintINChIFlags ) |= ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : - FLAG_SORT_PRINT_NO_NFIX_H_REC; + (*io->pSortPrintINChIFlags) |= (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_NFIX_H_BAS : FLAG_SORT_PRINT_NO_NFIX_H_REC; } if (!io->bNonTautIsoIdentifierNotEmpty) { /* Fixed-H layer is empty in the Identifier */ - ( *io->pSortPrintINChIFlags ) |= ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : - FLAG_SORT_PRINT_NO_IFIX_H_REC; + (*io->pSortPrintINChIFlags) |= (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : FLAG_SORT_PRINT_NO_IFIX_H_REC; } io->bFhTag = 0; } @@ -3873,19 +3820,18 @@ int OutputINCHI_FixedHLayerWithSublayers( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output InChI: polymer layer ****************************************************************************/ -static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +static int OutputINCHI_PolymerLayer(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + ORIG_ATOM_DATA *orig_inp_data, + ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { int i, err = 0; int nunits2 = 0; @@ -3895,8 +3841,8 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, OAD_PolymerUnit **units2 = NULL; OAD_Polymer *p = NULL; OAD_AtProps *aprops = NULL; - int nat,num_inp_bonds; - inp_ATOM *at = NULL; + int nat, num_inp_bonds; + inp_ATOM *at = NULL; int is_inchi2inchi = 0; if (!orig_inp_data) @@ -3908,7 +3854,6 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, nat = orig_inp_data->num_inp_atoms; num_inp_bonds = orig_inp_data->num_inp_bonds; - if (pOrigStruct && !pOrigStruct->polymer) { return 0; @@ -3928,33 +3873,32 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, /*OAD_Polymer_DebugTrace( p );*/ /* Get canonical numbers and numbers-of-components for each original atom */ - cano_nums = (int*)inchi_calloc((long long)pOrigStruct->num_atoms + 1, sizeof(int)); /* djb-rwth: cast operator added */ + cano_nums = (int *)inchi_calloc((long long)pOrigStruct->num_atoms + 1, sizeof(int)); /* djb-rwth: cast operator added */ if (!cano_nums) { err = 1; goto exit_function; } - compnt_nums = (int*)inchi_calloc((long long)pOrigStruct->num_atoms + 1, sizeof(int)); /* djb-rwth: cast operator added */ + compnt_nums = (int *)inchi_calloc((long long)pOrigStruct->num_atoms + 1, sizeof(int)); /* djb-rwth: cast operator added */ if (!compnt_nums) { err = 2; goto exit_function; } err = InternallyGetCanoNumsAndComponentNums(pCG, - strbuf, - io, - pOrigStruct->num_atoms, - cano_nums, - compnt_nums); + strbuf, + io, + pOrigStruct->num_atoms, + cano_nums, + compnt_nums); if (err != 0) { err = 3; goto exit_function; } - /* Set atom properties for sorting */ - aprops = (OAD_AtProps*)inchi_calloc((long long)nat + 1, sizeof(OAD_AtProps)); /* djb-rwth: cast operator added */ + aprops = (OAD_AtProps *)inchi_calloc((long long)nat + 1, sizeof(OAD_AtProps)); /* djb-rwth: cast operator added */ /* nat + 1: add extra element for possibe 1-based indexing */ if (!aprops) { @@ -3979,12 +3923,11 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, /* Supply non-NULL cano_nums to adjust the domains (base will be adjusted at place) */ OAD_Polymer_SetAtProps(p, at, nat, &num_inp_bonds, aprops, cano_nums); - /* Make a working copy of polymer units data: units2 is a copy */ /* of original polymer units (p->units) with atomic numbers changed */ /* to curr canonical ones; atoms in alists sorted; atoms in blists */ /* and blists themselves sorted */ - units2 = (OAD_PolymerUnit**)inchi_calloc(p->n, sizeof(OAD_PolymerUnit*)); + units2 = (OAD_PolymerUnit **)inchi_calloc(p->n, sizeof(OAD_PolymerUnit *)); if (NULL == units2) { @@ -3993,7 +3936,7 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, } memset(units2, 0, sizeof(*units2)); /* djb-rwth: memset_s C11/Annex K variant? */ - old_stars = (int*)inchi_calloc(pOrigStruct->polymer->n_pzz, sizeof(int)); + old_stars = (int *)inchi_calloc(pOrigStruct->polymer->n_pzz, sizeof(int)); if (NULL == old_stars) { err = 3; @@ -4004,7 +3947,6 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, old_stars[i] = pOrigStruct->polymer->pzz[i]; } - for (i = 0; i < p->n; i++) { units2[i] = OAD_PolymerUnit_CreateCopy(p->units[i]); @@ -4018,14 +3960,13 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, /* unum contains numbers of units (0..p->n) as they go */ /* when sorted by alist's in lexicographic order */ - unum = (int*)inchi_calloc(p->n, sizeof(int)); + unum = (int *)inchi_calloc(p->n, sizeof(int)); if (NULL == unum) { err = 4; goto exit_function; } - err = OAD_Polymer_PrepareWorkingSet(p, cano_nums, compnt_nums, units2, unum); if (err != 0) @@ -4047,12 +3988,12 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, u = units2[unum[i]]; err = OutputINCHI_PolymerLayer_SingleUnit(u, - io->bPolymers, - pOrigStruct->polymer->n_pzz, - &n_used_stars, aprops, - cano_nums, - orig_inp_data, - pOrigStruct, strbuf); + io->bPolymers, + pOrigStruct->polymer->n_pzz, + &n_used_stars, aprops, + cano_nums, + orig_inp_data, + pOrigStruct, strbuf); if (err) { goto exit_function; @@ -4099,35 +4040,33 @@ static int OutputINCHI_PolymerLayer( CANON_GLOBALS *pCG, pOrigStruct->polymer->pzz[i] = old_stars[i]; inchi_free(old_stars); } - } return err; } - /**************************************************************************** Output InChI: polymer layer, single CRU data ****************************************************************************/ -static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, - int bPolymers, - int total_star_atoms, - int *n_used_stars, - OAD_AtProps *aprops, - int *cano_nums, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct, - INCHI_IOS_STRING *strbuf ) +static int OutputINCHI_PolymerLayer_SingleUnit(OAD_PolymerUnit *u, + int bPolymers, + int total_star_atoms, + int *n_used_stars, + OAD_AtProps *aprops, + int *cano_nums, + ORIG_ATOM_DATA *orig_inp_data, + ORIG_STRUCT *pOrigStruct, + INCHI_IOS_STRING *strbuf) { int j, k, tmp, a1 = 0, a2 = 0, a3 = 0, a4 = 0, b, curr_star_num; int err = 0; OAD_Polymer *p = orig_inp_data->polymer; - inp_ATOM *at = orig_inp_data->at; + inp_ATOM *at = orig_inp_data->at; /* print unit type and subtype */ - inchi_strbuf_printf( strbuf, "%-d%-d%-d-", u->type, u->subtype, u->conn ); + inchi_strbuf_printf(strbuf, "%-d%-d%-d-", u->type, u->subtype, u->conn); /* print unit atoms */ - print_sequence_of_nums_compressing_ranges( u->na, u->alist, strbuf ); + print_sequence_of_nums_compressing_ranges(u->na, u->alist, strbuf); /* Print the crossing bonds or frame-shiftable pattern */ if (u->nb > 2) @@ -4138,21 +4077,21 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, } /* Print crossing bonds "(cap1-partner1,cap2-partner2)" */ - if (u->nb == 2 && ( !u->cyclizable || !u->cyclized )) + if (u->nb == 2 && (!u->cyclizable || !u->cyclized)) { int swap = 0; a1 = u->blist[0]; a2 = u->blist[1]; a3 = u->blist[2]; a4 = u->blist[3]; - - if (is_in_the_ilist( u->alist, a1, u->na )) + + if (is_in_the_ilist(u->alist, a1, u->na)) { tmp = a2; a2 = a1; a1 = tmp; } - if (is_in_the_ilist( u->alist, a3, u->na )) + if (is_in_the_ilist(u->alist, a3, u->na)) { tmp = a4; a4 = a3; @@ -4160,7 +4099,7 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, } /* Always print first the crossing bond pointing to more senior CRU end ("head") */ - if (bPolymers==POLYMERS_LEGACY) + if (bPolymers == POLYMERS_LEGACY) { /* old, v. 1.05 */ /* The first printed is the crossing bond with higher canonical number of the cap */ @@ -4172,18 +4111,18 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, /* The first printed is the crossing bond pointing to more senior CRU end ("head") */ swap = (OAD_Polymer_IsFirstAtomRankLower(a2, a4, aprops) == 1); } - + if (swap) { - inchi_strbuf_printf( strbuf, "(%-d-%-d,%-d-%-d)", a3, a4, a1, a2 ); + inchi_strbuf_printf(strbuf, "(%-d-%-d,%-d-%-d)", a3, a4, a1, a2); } else { - inchi_strbuf_printf( strbuf, "(%-d-%-d,%-d-%-d)", a1, a2, a3, a4 ); + inchi_strbuf_printf(strbuf, "(%-d-%-d,%-d-%-d)", a1, a2, a3, a4); } } - else if (u->nb <= 2 && ( u->cyclizable || u->nbkbonds > 0 )) + else if (u->nb <= 2 && (u->cyclizable || u->nbkbonds > 0)) { /* Print frame-shiftable pattern "cap1,cap2-(b1a1,b1a2, b2a1,b2a2, ... )" */ /* where b1, b2, ... are CRU bonds potentially invilved in frame shift */ @@ -4198,7 +4137,7 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, { if (sza[pos] == 'H') { - if (isupper( UCINT sza[pos + 1] ) || !sza[pos + 1]) /* if ( next_c is Uppercase or NUL ) */ + if (isupper(UCINT sza[pos + 1]) || !sza[pos + 1]) /* if ( next_c is Uppercase or NUL ) */ { n_expl_H++; } @@ -4215,7 +4154,8 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, curr_star_num = pOrigStruct->num_atoms - n_expl_H - total_star_atoms + *n_used_stars + 1; if (curr_star_num > pOrigStruct->num_atoms) { - err = 11; goto exit_function; + err = 11; + goto exit_function; } a1 = curr_star_num; (*n_used_stars)++; @@ -4225,7 +4165,8 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, curr_star_num = pOrigStruct->num_atoms - n_expl_H - total_star_atoms + *n_used_stars + 1; if (curr_star_num > pOrigStruct->num_atoms) { - err = 11; goto exit_function; + err = 11; + goto exit_function; } a2 = curr_star_num; (*n_used_stars)++; @@ -4233,19 +4174,19 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, } /* a1 and a2 are number of star atoms associated (but actually */ /* disconnected at this moment ) with SRU head and tail atoms */ - inchi_strbuf_printf( strbuf, "(%-d,%-d-", a1, a2 ); + inchi_strbuf_printf(strbuf, "(%-d,%-d-", a1, a2); if (u->cyclizable == CLOSING_SRU_DIRADICAL) { - inchi_strbuf_printf( strbuf, "%-d)", u->end_atom1 ); + inchi_strbuf_printf(strbuf, "%-d)", u->end_atom1); } else if (u->cyclizable == CLOSING_SRU_HIGHER_ORDER_BOND) { a3 = u->end_atom1; a4 = u->end_atom2; - inchi_sort_int_pair_ascending( &a3, &a4 ); + inchi_sort_int_pair_ascending(&a3, &a4); /* if ( a3 > a4 ) { tmp = a4; a4 = a3; a3 = tmp; }*/ - inchi_strbuf_printf( strbuf, "%-d.%-d)", a3, a4 ); + inchi_strbuf_printf(strbuf, "%-d.%-d)", a3, a4); } else if (u->cyclizable == CLOSING_SRU_RING) { @@ -4254,9 +4195,9 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, /* last resort */ a3 = u->end_atom1; a4 = u->end_atom2; - inchi_sort_int_pair_ascending( &a3, &a4 ); + inchi_sort_int_pair_ascending(&a3, &a4); /* if ( a3 > a4 ) { tmp = a4; a4 = a3; a3 = tmp; } */ - inchi_strbuf_printf( strbuf, "%-d,%-d)", a3, a4 ); + inchi_strbuf_printf(strbuf, "%-d,%-d)", a3, a4); } else { @@ -4265,7 +4206,7 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, { int *tmp_psbond = u->bkbonds[b]; j = b - 1; - while (j >= 0 && IsBondAtomNumsLesser( u->bkbonds[j], tmp_psbond ) > 0) + while (j >= 0 && IsBondAtomNumsLesser(u->bkbonds[j], tmp_psbond) > 0) { u->bkbonds[j + 1] = u->bkbonds[j]; j--; @@ -4273,7 +4214,7 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, u->bkbonds[j + 1] = tmp_psbond; } - if (p->treat==POLYMERS_MODERN || p->treat==POLYMERS_LEGACY_PLUS) + if (p->treat == POLYMERS_MODERN || p->treat == POLYMERS_LEGACY_PLUS) { /* was #if DO_POLYMER_FRAME_SHIFT_AT_STRUCT_TO_INCHI_CONVERSION==1 */ /* was: OAD_PolymerUnit_ReorderPolymerFrameShiftLinks( u, orig_inp_data, aprops, cano_nums ); @@ -4288,8 +4229,8 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, here at1, at2 is the most senior bond, and at1 is more senior than at2 all other pairs at3,at4, at5,at6, ... are sorted just in increasing - order of first number in pair, then second one, e.g.: at3frame_shift_scheme != FSS_NONE && u->nbkbonds >= 1 && u->cap1 >= 1 && u->cap2 >= 1) @@ -4319,9 +4260,10 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, for (k = 0; k < u->nbkbonds; k++) { - a3 = u->bkbonds[k][0]; a4 = u->bkbonds[k][1]; + a3 = u->bkbonds[k][0]; + a4 = u->bkbonds[k][1]; /*if ( a3 > a4 ) { tmp = a4; a4 = a3; a3 = tmp; }*/ - inchi_strbuf_printf( strbuf, "%-d,%-d%-c", a3, a4, k == u->nbkbonds - 1 ? ')' : ',' ); + inchi_strbuf_printf(strbuf, "%-d,%-d%-c", a3, a4, k == u->nbkbonds - 1 ? ')' : ','); } } } @@ -4332,93 +4274,93 @@ static int OutputINCHI_PolymerLayer_SingleUnit( OAD_PolymerUnit *u, return err; } - /**************************************************************************** Output AuxInfo: header and normalization type ****************************************************************************/ -int OutputAUXINFO_HeaderAndNormalization_type( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int bINChIOutputOptions, - int *INCHI_basic_or_INCHI_reconnected, - int num_components2[], - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_HeaderAndNormalization_type(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int bINChIOutputOptions, + int *INCHI_basic_or_INCHI_reconnected, + int num_components2[], + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* AuxInfo header */ if (*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) { - inchi_strbuf_printf( strbuf, "AuxInfo=" ); /* in wINChI window, separate INChI: from AuxInfo: with blank line */ - inchi_ios_print( out_file, "%s%s%s", - /* blank line before AuxInfo in winchi window unless it is an annotation */ - ( bINChIOutputOptions & INCHI_OUT_WINCHI_WINDOW ) ? "\n" : "", - strbuf->pStr, pLF ); - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_VERS, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - inchi_strbuf_printf( strbuf, "%s", x_curr_ver ); + inchi_strbuf_printf(strbuf, "AuxInfo="); /* in wINChI window, separate INChI: from AuxInfo: with blank line */ + inchi_ios_print(out_file, "%s%s%s", + /* blank line before AuxInfo in winchi window unless it is an annotation */ + (bINChIOutputOptions & INCHI_OUT_WINCHI_WINDOW) ? "\n" : "", + strbuf->pStr, pLF); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_VERS, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + inchi_strbuf_printf(strbuf, "%s", x_curr_ver); /* avoid leading slash in plain output */ - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { if (*INCHI_basic_or_INCHI_reconnected == INCHI_REC) { - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_REC_, io->szTag1, &io->bAlways, 0 ); - inchi_ios_print( out_file, "%s%s", io->szTag1, pLF ); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_REC_, io->szTag1, &io->bAlways, 0); + inchi_ios_print(out_file, "%s%s", io->szTag1, pLF); } } /* AuxInfo normalization type */ if (num_components2[0] || num_components2[1]) { - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_NORM, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - inchi_strbuf_printf( strbuf, "%d", ( io->bTautomeric && io->bTautomericOutputAllowed ) ? io->bTautomeric : 0 ); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_NORM, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + inchi_strbuf_printf(strbuf, "%d", (io->bTautomeric && io->bTautomericOutputAllowed) ? io->bTautomeric : 0); + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } return 0; } - /**************************************************************************** Output AuxInfo: original atom numbers and symmetry numbers (constit. equivalence /E: ) ****************************************************************************/ -int OutputAUXINFO_OriginalNumbersAndEquivalenceClasses( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int num_components2[], - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_OriginalNumbersAndEquivalenceClasses(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int num_components2[], + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /* Original atom numbers in order of canonical numbers */ if (num_components2[0] || num_components2[1]) { - szGetTag( AuxLbl, io->nTag, - io->bTag1 = ( io->bSecondNonTautPass ? AL_FIXN : AL_ANBR ) | io->bFhTag, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); + szGetTag(AuxLbl, io->nTag, + io->bTag1 = (io->bSecondNonTautPass ? AL_FIXN : AL_ANBR) | io->bFhTag, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); io->tot_len = 0; /* Original numbering output */ - io->tot_len = str_AuxNumb( pCG, io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions ); + io->tot_len = str_AuxNumb(pCG, io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } /* @@ -4429,55 +4371,55 @@ int OutputAUXINFO_OriginalNumbersAndEquivalenceClasses( CANON_GLOBALS *pCG, /* aux equ atoms */ /* 1. Compare to tautomeric equivalence (in case of second, non-taut, pass only) */ /* 2. Compare to the previous component if (1) failed to find equivalence */ - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_AEQU | io->bFhTag, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_AEQU | io->bFhTag, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - io->tot_len = str_AuxEqu( io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, io->TAUT_MODE, - io->num_components, io->bSecondNonTautPass, - io->bOmitRepetitions, io->bUseMulipliers ); + io->tot_len = str_AuxEqu(io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, io->TAUT_MODE, + io->num_components, io->bSecondNonTautPass, + io->bOmitRepetitions, io->bUseMulipliers); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "/" ); + inchi_ios_print(out_file, "/"); } } return 0; } - /**************************************************************************** Output AuxInfo: tautomeric groups equivalence ****************************************************************************/ -int OutputAUXINFO_TautomericGroupsEquivalence( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io ) +int OutputAUXINFO_TautomericGroupsEquivalence(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io) { if (io->bTautomericOutputAllowed && io->bTautomeric && io->bTautEqu[io->iCurTautMode] && !io->bSecondNonTautPass) { /*-- Tautomeric groups constitutional equivalence */ /*-- aux tgroup equ */ - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_GEQU | io->bFhTag, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxTgroupEqu( io->pINChISort, - strbuf, &io->bOverflow, io->bOutType, io->TAUT_MODE, - io->num_components, io->bUseMulipliers ); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_GEQU | io->bFhTag, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxTgroupEqu(io->pINChISort, + strbuf, &io->bOverflow, io->bOutType, io->TAUT_MODE, + io->num_components, io->bUseMulipliers); + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s", strbuf->pStr ); + inchi_ios_print(out_file, "%s", strbuf->pStr); } else { @@ -4485,7 +4427,7 @@ int OutputAUXINFO_TautomericGroupsEquivalence( CANON_GLOBALS *pCG, { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "/" ); + inchi_ios_print(out_file, "/"); } } } @@ -4493,59 +4435,61 @@ int OutputAUXINFO_TautomericGroupsEquivalence( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output AuxInfo: stereo info ****************************************************************************/ -int OutputAUXINFO_Stereo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_Stereo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { /*-- Inverted stereo -- sp3 only + canonical numbering - */ + */ if (io->bInvStereo[io->iCurTautMode]) { - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_STER | io->bFhTag, io->szTag1, &io->bAlways, 0 ); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_STER | io->bFhTag, io->szTag1, &io->bAlways, 0); /*-- inverted sp3 start tag */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_SP3I, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxInvSp3( io->pINChISort, io->pINChISort2, strbuf, - &io->bOverflow, io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_SP3I, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxInvSp3(io->pINChISort, io->pINChISort2, strbuf, + &io->bOverflow, io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) return 1; - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); /*-- inverted sp3 canonical numbering */ if (io->bInvStereoOrigNumb[io->iCurTautMode]) { - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_SP3N, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_SP3N, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; - io->tot_len = str_AuxInvSp3Numb( pCG, io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, - io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions ); + io->tot_len = str_AuxInvSp3Numb(pCG, io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, + io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions); - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { - if (io->bPlainTextTags == 1) inchi_ios_print( out_file, "/" ); + if (io->bPlainTextTags == 1) + inchi_ios_print(out_file, "/"); } } else { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "//" ); + inchi_ios_print(out_file, "//"); } /* Inverted stereo -- sp3 only + canonical numbering */ } @@ -4553,79 +4497,77 @@ int OutputAUXINFO_Stereo( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output AuxInfo: isotopic info ****************************************************************************/ -int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - int *INCHI_basic_or_INCHI_reconnected, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_IsotopicInfo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + int *INCHI_basic_or_INCHI_reconnected, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { int i; /* if InChI Fixed-H isotopic is empty, then do not output corresponding AuxInfo */ i = io->bSecondNonTautPass && - ( *io->pSortPrintINChIFlags & ( ( *INCHI_basic_or_INCHI_reconnected == INCHI_BAS ) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : - FLAG_SORT_PRINT_NO_IFIX_H_REC ) ); + (*io->pSortPrintINChIFlags & ((*INCHI_basic_or_INCHI_reconnected == INCHI_BAS) ? FLAG_SORT_PRINT_NO_IFIX_H_BAS : FLAG_SORT_PRINT_NO_IFIX_H_REC)); if (io->bIsotopic && !i && - ( io->bIsotopicOrigNumb[io->iCurTautMode] || - io->bIsotopicAtomEqu[io->iCurTautMode] || - (io->bTautomericOutputAllowed && io->bTautomeric && io->bIsotopicTautEqu[io->iCurTautMode]) || - (io->bInvIsotopicStereo[io->iCurTautMode] - && ( io->bIgn_UU_Sp3_Iso[io->iCurTautMode])) || io->bIgn_UU_Sp2_Iso[io->iCurTautMode] ) ) /* djb-rwth: addressing LLVM warnings */ + (io->bIsotopicOrigNumb[io->iCurTautMode] || + io->bIsotopicAtomEqu[io->iCurTautMode] || + (io->bTautomericOutputAllowed && io->bTautomeric && io->bIsotopicTautEqu[io->iCurTautMode]) || + (io->bInvIsotopicStereo[io->iCurTautMode] && (io->bIgn_UU_Sp3_Iso[io->iCurTautMode])) || io->bIgn_UU_Sp2_Iso[io->iCurTautMode])) /* djb-rwth: addressing LLVM warnings */ { /*-- isotopic aux info header */ - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_ISOT | io->bFhTag, io->szTag1, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); /* pStr[io->tot_len = 0] = '\0'; */ + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_ISOT | io->bFhTag, io->szTag1, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); /* pStr[io->tot_len = 0] = '\0'; */ /*-- Original atom numbers in order of isotopic canonical numbers */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_ISON, io->szTag2, &io->bAlways, 0 ); + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_ISON, io->szTag2, &io->bAlways, 0); if (io->bIsotopicOrigNumb[io->iCurTautMode]) { - inchi_strbuf_reset( strbuf ); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - io->tot_len = str_AuxIsoNumb( pCG, io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, - io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions ); - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + io->tot_len = str_AuxIsoNumb(pCG, io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, + io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions); + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { /*if ( io->bPlainTextTags == 1 ) inchi_ios_print( out_file, "/" );*/ - inchi_ios_print( out_file, "%s%s", io->szTag2, pLF ); /* mark isotopic output */ + inchi_ios_print(out_file, "%s%s", io->szTag2, pLF); /* mark isotopic output */ } /*-- Isotopic symmetry */ if (io->bIsotopicAtomEqu[io->iCurTautMode]) { /*-- atoms */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_AEQU, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxIsoEqu( io->pINChISort, io->pINChISort2, - strbuf, - &io->bOverflow, io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -2/*was -1: Fix15*/, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_AEQU, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxIsoEqu(io->pINChISort, io->pINChISort2, + strbuf, + &io->bOverflow, io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -2 /*was -1: Fix15*/, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "/" ); + inchi_ios_print(out_file, "/"); } } @@ -4633,17 +4575,18 @@ int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, if (io->bTautomericOutputAllowed && io->bTautomeric && io->bIsotopicTautEqu[io->iCurTautMode]) { /*-- Isotopic tautomeric groups equivalence */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_GEQU, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxIsoTgroupEqu( io->pINChISort, - strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, - io->bOmitRepetitions, io->bUseMulipliers ); - if (str_LineEnd( io->szTag2, &io->bOverflow, strbuf, -2/*was -1: Fix15*/, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_GEQU, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxIsoTgroupEqu(io->pINChISort, + strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, + io->bOmitRepetitions, io->bUseMulipliers); + if (str_LineEnd(io->szTag2, &io->bOverflow, strbuf, -2 /*was -1: Fix15*/, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { @@ -4651,49 +4594,51 @@ int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "/" ); + inchi_ios_print(out_file, "/"); } } } /*-- Isotopic inverted stereo */ if (io->bInvIsotopicStereo[io->iCurTautMode]) { - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_STER, io->szTag2, &io->bAlways, 0 ); + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_STER, io->szTag2, &io->bAlways, 0); /*-- inverted isotopic sp3 start tag */ - szGetTag( AuxLbl, io->nTag, io->bTag3 = io->bTag2 | AL_SP3I, io->szTag3, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxInvIsoSp3( io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers ); - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag3 = io->bTag2 | AL_SP3I, io->szTag3, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxInvIsoSp3(io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions, io->bUseMulipliers); + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s", strbuf->pStr ); + inchi_ios_print(out_file, "%s", strbuf->pStr); /*-- inverted isotopic sp3 canonical numbering */ if (io->bInvIsotopicStereoOrigNumb[io->iCurTautMode]) { - szGetTag( AuxLbl, io->nTag, io->bTag3 = io->bTag2 | AL_SP3N, io->szTag3, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); io->tot_len = 0; - io->tot_len = str_AuxInvIsoSp3Numb( pCG, io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, - io->bOutType, io->TAUT_MODE, - io->num_components, - io->bSecondNonTautPass, - io->bOmitRepetitions ); - - if (str_LineEnd( io->szTag3, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + szGetTag(AuxLbl, io->nTag, io->bTag3 = io->bTag2 | AL_SP3N, io->szTag3, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + io->tot_len = 0; + io->tot_len = str_AuxInvIsoSp3Numb(pCG, io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, + io->bOutType, io->TAUT_MODE, + io->num_components, + io->bSecondNonTautPass, + io->bOmitRepetitions); + + if (str_LineEnd(io->szTag3, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } else { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "/" ); + inchi_ios_print(out_file, "/"); } } } @@ -4701,7 +4646,7 @@ int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, { if (io->bPlainTextTags == 1) { - inchi_ios_print( out_file, "//" ); + inchi_ios_print(out_file, "//"); } } /*-- totally omitted undefined/unknown isotopic stereo */ @@ -4710,72 +4655,68 @@ int OutputAUXINFO_IsotopicInfo( CANON_GLOBALS *pCG, return 0; } - /**************************************************************************** Output AuxInfo: charges, radicals, unusual valences ****************************************************************************/ -int OutputAUXINFO_ChargesRadicalsAndUnusualValences( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_ChargesRadicalsAndUnusualValences(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { if (!io->bSecondNonTautPass && io->bChargesRadVal[io->iCurTautMode]) { /* aux equ atoms */ /* 1. Compare to tautomeric equivalence (in case of second, non-taut, pass only) */ /* 2. Compare to the previous component if (1) failed to find equivalence */ - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_CRV_ | io->bFhTag, io->szTag1, &io->bAlways, 0 ); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_CRV_ | io->bFhTag, io->szTag1, &io->bAlways, 0); - inchi_strbuf_reset( strbuf ); + inchi_strbuf_reset(strbuf); io->tot_len = 0; - io->tot_len = str_AuxChargeRadVal( io->pINChISort, strbuf, - &io->bOverflow, io->bOutType, io->TAUT_MODE, - io->num_components, io->bUseMulipliers ); + io->tot_len = str_AuxChargeRadVal(io->pINChISort, strbuf, + &io->bOverflow, io->bOutType, io->TAUT_MODE, + io->num_components, io->bUseMulipliers); - if (str_LineEnd( io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags )) + if (str_LineEnd(io->szTag1, &io->bOverflow, strbuf, -1, io->bPlainTextTags)) { return 1; } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); } return 0; } - /**************************************************************************** Output AuxInfo: reversibility info (to restore orig. structure) ****************************************************************************/ -int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - ORIG_STRUCT *pOrigStruct, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_ReversibilityInfo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { if (!io->bSecondNonTautPass && - pOrigStruct && pOrigStruct->num_atoms && - pOrigStruct->szAtoms - && pOrigStruct->szBonds - && pOrigStruct->szCoord) + pOrigStruct && pOrigStruct->num_atoms && + pOrigStruct->szAtoms && pOrigStruct->szBonds && pOrigStruct->szCoord) { int length, cur_pos, line_len, last_pos, nMaxLineLen; char *p; - nMaxLineLen = inchi_min( 80, strbuf->nAllocatedLength ); /* restrict line length to 80 characters */ + nMaxLineLen = inchi_min(80, strbuf->nAllocatedLength); /* restrict line length to 80 characters */ - szGetTag( AuxLbl, io->nTag, io->bTag1 = AL_REVR | io->bFhTag, io->szTag1, &io->bAlways, 0 ); + szGetTag(AuxLbl, io->nTag, io->bTag1 = AL_REVR | io->bFhTag, io->szTag1, &io->bAlways, 0); /* Atoms /A: */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_ATMR, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); - inchi_ios_print( out_file, "%s%s", io->szTag2, strbuf->pStr ); + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_ATMR, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + inchi_ios_print(out_file, "%s%s", io->szTag2, strbuf->pStr); p = pOrigStruct->szAtoms; - length = (int) strlen( p ); + length = (int)strlen(p); io->tot_len = strbuf->nUsedLength; line_len = nMaxLineLen - io->tot_len; for (cur_pos = 0; cur_pos < length; cur_pos = last_pos) @@ -4784,7 +4725,7 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, { last_pos = cur_pos + line_len; /* search backward for the nearest first atom letter (always uppercase) */ - while (cur_pos < last_pos && !isupper( UCINT p[last_pos] )) + while (cur_pos < last_pos && !isupper(UCINT p[last_pos])) { last_pos--; } @@ -4801,15 +4742,15 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, if (1) /* always show "Zy" as "Zz" */ { - char *pzy, *pstart=strbuf->pStr + strbuf->nUsedLength; - while ((pzy = strstr( pstart, "Zy" ))) /* djb-rwth: addressing LLVM warning */ + char *pzy, *pstart = strbuf->pStr + strbuf->nUsedLength; + while ((pzy = strstr(pstart, "Zy"))) /* djb-rwth: addressing LLVM warning */ { *(++pzy) = 'z'; pstart = pzy; } } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n" ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n"); } else { @@ -4818,18 +4759,18 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, } if (pLF[0]) { - inchi_ios_print( out_file, "%s", pLF ); + inchi_ios_print(out_file, "%s", pLF); } - inchi_strbuf_reset( strbuf ); + inchi_strbuf_reset(strbuf); /* Bonds /B: */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_BNDR, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); - inchi_ios_print( out_file, "%s%s", io->szTag2, strbuf->pStr ); + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_BNDR, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + inchi_ios_print(out_file, "%s%s", io->szTag2, strbuf->pStr); p = pOrigStruct->szBonds; - length = (int) strlen( p ); + length = (int)strlen(p); line_len = nMaxLineLen - io->tot_len; for (cur_pos = 0; cur_pos < length; cur_pos = last_pos) { @@ -4855,8 +4796,8 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, memcpy(strbuf->pStr, p + cur_pos, (long long)last_pos - (long long)cur_pos); /* djb-rwth: cast operators added */ strbuf->pStr[last_pos - cur_pos] = '\0'; strbuf->nUsedLength = last_pos - cur_pos; - inchi_ios_print( out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n" ); - inchi_strbuf_reset( strbuf ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n"); + inchi_strbuf_reset(strbuf); } else { @@ -4865,16 +4806,16 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, } if (pLF[0]) { - inchi_ios_print( out_file, "%s", pLF ); + inchi_ios_print(out_file, "%s", pLF); } /* Coordinates /C: */ - szGetTag( AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_XYZR, io->szTag2, &io->bAlways, 0 ); - inchi_strbuf_reset( strbuf ); - inchi_ios_print( out_file, "%s%s", io->szTag2, strbuf->pStr ); + szGetTag(AuxLbl, io->nTag, io->bTag2 = io->bTag1 | AL_XYZR, io->szTag2, &io->bAlways, 0); + inchi_strbuf_reset(strbuf); + inchi_ios_print(out_file, "%s%s", io->szTag2, strbuf->pStr); p = pOrigStruct->szCoord; - length = (int) strlen( p ); + length = (int)strlen(p); line_len = nMaxLineLen - io->tot_len; for (cur_pos = 0; cur_pos < length; cur_pos = last_pos) { @@ -4900,8 +4841,8 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, memcpy(strbuf->pStr, p + cur_pos, (long long)last_pos - (long long)cur_pos); /* djb-rwth: cast operator added */ strbuf->pStr[last_pos - cur_pos] = '\0'; strbuf->nUsedLength = last_pos - cur_pos; - inchi_ios_print( out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n" ); - inchi_strbuf_reset( strbuf ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, io->bPlainTextTags ? "" : "\n"); + inchi_strbuf_reset(strbuf); } else { @@ -4911,28 +4852,26 @@ int OutputAUXINFO_ReversibilityInfo( CANON_GLOBALS *pCG, if (pLF[0]) { - inchi_ios_print( out_file, "%s", pLF ); + inchi_ios_print(out_file, "%s", pLF); } } return 0; } - /****************************************************************************/ -int OutputAUXINFO_PolymerInfo( CANON_GLOBALS *pCG, - INCHI_IOSTREAM *out_file, - INCHI_IOS_STRING *strbuf, - ORIG_STRUCT *pOrigStruct, - INCHI_OUT_CTL *io, - char *pLF, - char *pTAB ) +int OutputAUXINFO_PolymerInfo(CANON_GLOBALS *pCG, + INCHI_IOSTREAM *out_file, + INCHI_IOS_STRING *strbuf, + ORIG_STRUCT *pOrigStruct, + INCHI_OUT_CTL *io, + char *pLF, + char *pTAB) { int k, i, q; OAD_Polymer *p; OAD_PolymerUnit *u; - if (!pOrigStruct) { return 0; @@ -4943,10 +4882,9 @@ int OutputAUXINFO_PolymerInfo( CANON_GLOBALS *pCG, return 0; } - inchi_strbuf_reset( strbuf ); - - inchi_ios_print( out_file, "/Z:" ); + inchi_strbuf_reset(strbuf); + inchi_ios_print(out_file, "/Z:"); /* Print polymer units data */ for (i = 0; i < p->n; i++) @@ -4955,61 +4893,60 @@ int OutputAUXINFO_PolymerInfo( CANON_GLOBALS *pCG, u = p->units[i]; /* print kinds of unit */ - inchi_strbuf_printf( strbuf, "%-d%-d%-d-", u->type, u->subtype, u->conn ); - inchi_strbuf_printf( strbuf, "%-s-", u->smt[0] ? u->smt : "n" ); + inchi_strbuf_printf(strbuf, "%-d%-d%-d-", u->type, u->subtype, u->conn); + inchi_strbuf_printf(strbuf, "%-s-", u->smt[0] ? u->smt : "n"); /* Print unit atoms */ - print_sequence_of_nums_compressing_ranges( u->na, u->alist, strbuf ); + print_sequence_of_nums_compressing_ranges(u->na, u->alist, strbuf); /* Print bonds from unit to otside */ if (u->nb > 0) { - inchi_strbuf_printf( strbuf, "(" ); + inchi_strbuf_printf(strbuf, "("); for (k = 0; k < 2 * u->nb - 1; k++) { - inchi_strbuf_printf( strbuf, "%-d,", u->blist[k] ); + inchi_strbuf_printf(strbuf, "%-d,", u->blist[k]); } - inchi_strbuf_printf( strbuf, "%-d)", u->blist[2 * u->nb - 1] ); + inchi_strbuf_printf(strbuf, "%-d)", u->blist[2 * u->nb - 1]); } - if (fabs( -fabs( u->xbr1[0] ) + 777777.777 ) > 1.e-7) + if (fabs(-fabs(u->xbr1[0]) + 777777.777) > 1.e-7) { - inchi_strbuf_printf( strbuf, "[" ); + inchi_strbuf_printf(strbuf, "["); for (q = 0; q < 3; q++) { - inchi_strbuf_printf( strbuf, "%-f,", u->xbr1[q] ); + inchi_strbuf_printf(strbuf, "%-f,", u->xbr1[q]); } - inchi_strbuf_printf( strbuf, "%-f]", u->xbr1[3] ); + inchi_strbuf_printf(strbuf, "%-f]", u->xbr1[3]); } - if (fabs( -fabs( u->xbr2[0] ) + 777777.777 ) > 1.e-7) + if (fabs(-fabs(u->xbr2[0]) + 777777.777) > 1.e-7) { - inchi_strbuf_printf( strbuf, "[" ); + inchi_strbuf_printf(strbuf, "["); for (q = 0; q < 3; q++) { - inchi_strbuf_printf( strbuf, "%-f,", u->xbr2[q] ); + inchi_strbuf_printf(strbuf, "%-f,", u->xbr2[q]); } - inchi_strbuf_printf( strbuf, "%-f]", u->xbr2[3] ); + inchi_strbuf_printf(strbuf, "%-f]", u->xbr2[3]); } if (i < p->n - 1) { - inchi_strbuf_printf( strbuf, ";" ); + inchi_strbuf_printf(strbuf, ";"); } } - inchi_ios_print( out_file, "%s%s", strbuf->pStr, pLF ); + inchi_ios_print(out_file, "%s%s", strbuf->pStr, pLF); return 0; } - /****************************************************************************/ -int IsBondAtomNumsLesser( int *bond1, int* bond2 ) +int IsBondAtomNumsLesser(int *bond1, int *bond2) { - int min1 = inchi_min( bond1[0], bond1[1] ); - int min2 = inchi_min( bond2[0], bond2[1] ); - int max1 = inchi_max( bond1[0], bond1[1] ); - int max2 = inchi_max( bond2[0], bond2[1] ); + int min1 = inchi_min(bond1[0], bond1[1]); + int min2 = inchi_min(bond2[0], bond2[1]); + int max1 = inchi_max(bond1[0], bond1[1]); + int max2 = inchi_max(bond2[0], bond2[1]); if (min1 < min2) { @@ -5034,7 +4971,6 @@ int IsBondAtomNumsLesser( int *bond1, int* bond2 ) return 0; } - /****************************************************************************/ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) { @@ -5046,7 +4982,7 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) eol_was_consumed = 0, pre_eol = 0, nonprt_sym = 0, nonprt_prev = 0; - if (n_zy > 0) + if (n_zy > 0) { /* We have some placeholder pseudo atoms which should not be removed below (if anyway they are allowed) */ if (n_pzz == 0) @@ -5088,7 +5024,7 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) nzz1 = n_pzz; /* OK, we must hide n_pzz Zz's*/ - buf = (char *) inchi_calloc( (long long)out->s.nUsedLength + 1, sizeof( char ) ); /* djb-rwth: cast operator added */ + buf = (char *)inchi_calloc((long long)out->s.nUsedLength + 1, sizeof(char)); /* djb-rwth: cast operator added */ if (!buf) { return; @@ -5128,10 +5064,10 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) /* Software version 1.07 : skip pattern "(cap,cap-bkbonds)" but not "(cap-end, cap-end)" */ const char *q; const char *p = out->s.pStr + i + 1; - AT_NUMB ia = (AT_NUMB) inchi_strtol(p, &q, 10); /* make compiler happy: */ /* djb-rwth: removing redundant code; ignoring LLVM warning: variable used to store function return value */ + AT_NUMB ia = (AT_NUMB)inchi_strtol(p, &q, 10); /* make compiler happy: */ /* djb-rwth: removing redundant code; ignoring LLVM warning: variable used to store function return value */ if (*q != '-') { - skip = 1; + skip = 1; } } } @@ -5143,7 +5079,7 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) } } - if (s[i] == '/' || pre_eol || nonprt_sym ) + if (s[i] == '/' || pre_eol || nonprt_sym) { if (is_in_z_layer) { @@ -5156,9 +5092,8 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) } if (nslash == 2 || - ( nslash == 1 && pre_eol ) || - ( prev_layer_symbol == 'f' ) - ) + (nslash == 1 && pre_eol) || + (prev_layer_symbol == 'f')) { if (nzz) { @@ -5196,10 +5131,9 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) if (nzz) { if (prev_layer_symbol != 'p' && - prev_layer_symbol != 's' && - prev_layer_symbol != 'f' && - prev_layer_symbol != 'z' - ) + prev_layer_symbol != 's' && + prev_layer_symbol != 'f' && + prev_layer_symbol != 'z') { /* eat nzz last ; if any */ int n_eaten = 0; @@ -5215,7 +5149,7 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) } for (j = ii - 1; j >= 0; j--) { - if (s[j] == eatable && n_eaten < nzz) + if (s[j] == eatable && n_eaten < nzz) { ncopied--; n_eaten++; @@ -5268,22 +5202,21 @@ void EditINCHI_HidePolymerZz(INCHI_IOSTREAM *out, int n_pzz, int n_zy) } out->s.nUsedLength = 0; - inchi_ios_print_nodisplay( out, "%s%s", buf, eol_was_consumed ? "\n" : "" ); - inchi_free( buf ); + inchi_ios_print_nodisplay(out, "%s%s", buf, eol_was_consumed ? "\n" : ""); + inchi_free(buf); return; } - /****************************************************************************/ -int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: ignoring LLVM warning: function used */ +int CountPseudoElementInFormula(const char *pseudo, char *s) /* djb-rwth: ignoring LLVM warning: function used */ { - int npseudo=0, mult=1, index=1, new_component=1; + int npseudo = 0, mult = 1, index = 1, new_component = 1; const char *p, *q; char prev = '/'; /* - format is + format is [sequence of] [.[int_mult[Zz[int_index]]]] */ @@ -5291,12 +5224,12 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno { return 0; } - - p = s; + + p = s; while (*p) /*for (p = s ; *p; p++)*/ { - if (*p =='/') + if (*p == '/') { /* end of formula layer */ break; @@ -5317,7 +5250,7 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno { mult = (int)inchi_strtol(p, &q, 10); p = q; - prev = *q--; + prev = *q--; continue; } else @@ -5326,13 +5259,13 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno } if (!mult) { - break; + break; } } - else if (*p== pseudo[1] && prev== pseudo[0]) + else if (*p == pseudo[1] && prev == pseudo[0]) { q = p++; - if ( *q && isdigit(*q)) + if (*q && isdigit(*q)) { index = (int)inchi_strtol(q, &p, 10); } @@ -5341,7 +5274,7 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno index = 1; p = q; } - npseudo+= mult*index; + npseudo += mult * index; } prev = *p; p++; @@ -5350,7 +5283,6 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno return npseudo; } - /**************************************************************************** Get canonical numbers and component numbers for each original atom NB: cano_nums[orig_num] - in orig_nums order, @@ -5359,12 +5291,12 @@ int CountPseudoElementInFormula( const char *pseudo, char *s ) /* djb-rwth: igno cano_nums are 0-based compnt_nums are 1-based ****************************************************************************/ -int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, - INCHI_IOS_STRING *strbuf, - INCHI_OUT_CTL *io, - int nat, - int *cano_nums, - int *compnt_nums ) +int InternallyGetCanoNumsAndComponentNums(CANON_GLOBALS *pCG, + INCHI_IOS_STRING *strbuf, + INCHI_OUT_CTL *io, + int nat, + int *cano_nums, + int *compnt_nums) { int orig_num, cano_num, icompnt, i, k, ndigit, err; char c, cnum[8]; @@ -5374,11 +5306,11 @@ int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, return 1; } - inchi_strbuf_reset( strbuf ); - io->tot_len = str_AuxNumb( pCG, io->pINChISort, io->pINChISort2, - strbuf, &io->bOverflow, io->bOutType, - io->TAUT_MODE, io->num_components, - io->bSecondNonTautPass, io->bOmitRepetitions ); + inchi_strbuf_reset(strbuf); + io->tot_len = str_AuxNumb(pCG, io->pINChISort, io->pINChISort2, + strbuf, &io->bOverflow, io->bOutType, + io->TAUT_MODE, io->num_components, + io->bSecondNonTautPass, io->bOmitRepetitions); for (i = 0; i < nat; i++) { compnt_nums[i] = -1; @@ -5396,7 +5328,7 @@ int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, if (c == ',' || c == ';' || c == '\0') { cnum[ndigit] = '\0'; - orig_num = atoi( cnum ); + orig_num = atoi(cnum); cano_nums[orig_num] = cano_num; compnt_nums[cano_num] = icompnt; cnum[0] = '\0'; @@ -5412,7 +5344,7 @@ int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, } continue; } - else if (isdigit( c )) + else if (isdigit(c)) { cnum[ndigit] = c; ndigit++; @@ -5425,40 +5357,39 @@ int InternallyGetCanoNumsAndComponentNums( CANON_GLOBALS *pCG, } exit_function: - inchi_strbuf_reset( strbuf ); + inchi_strbuf_reset(strbuf); return err; } - /***************************************************************************/ int MergeZzInHillFormula(INCHI_IOS_STRING *strbuf) { - char *p, *scopy = NULL, *stmp=NULL, *pend=NULL, *p0 = NULL; /* djb-rwth: removing redundant variables */ - size_t sublen; /* djb-rwth: removing redundant variables */ + char *p, *scopy = NULL, *stmp = NULL, *pend = NULL, *p0 = NULL; /* djb-rwth: removing redundant variables */ + size_t sublen; /* djb-rwth: removing redundant variables */ if (!strbuf->pStr || strbuf->nUsedLength < 1) { return 0; } - scopy = (char *)inchi_calloc((long long)strbuf->nAllocatedLength+1, sizeof(char)); /* djb-rwth: cast operator added */ + scopy = (char *)inchi_calloc((long long)strbuf->nAllocatedLength + 1, sizeof(char)); /* djb-rwth: cast operator added */ if (!scopy) { inchi_free(scopy); /* djb-rwth: avoiding memory leak */ - return -1; /* failed */ - } + return -1; /* failed */ + } memcpy(scopy, strbuf->pStr, strbuf->nAllocatedLength); stmp = (char *)inchi_calloc((long long)strbuf->nAllocatedLength + 1, sizeof(char)); /* djb-rwth: cast operator added */ if (!stmp) { inchi_free(scopy); /* djb-rwth: avoiding memory leak */ - return -1; /* failed */ + return -1; /* failed */ } inchi_strbuf_reset(strbuf); p0 = scopy; p = p0; - do + do { /* djb-rwth: removing redundant code */ pend = strchr(p, '.'); @@ -5475,8 +5406,7 @@ int MergeZzInHillFormula(INCHI_IOS_STRING *strbuf) inchi_strbuf_printf(strbuf, "%-s%-c", stmp, *pend); } /* djb-rwth: removing redundant code */ - } while ( *pend && (p=pend+1)); - + } while (*pend && (p = pend + 1)); if (scopy) { @@ -5490,7 +5420,6 @@ int MergeZzInHillFormula(INCHI_IOS_STRING *strbuf) return 0; } - /***************************************************************************/ void MergeZzInStrHillFormulaComponent(char *s) { @@ -5520,7 +5449,6 @@ void MergeZzInStrHillFormulaComponent(char *s) return; } - /****************************************************************************/ static void inchi_sort_int_pair_ascending(int *a, int *b) { @@ -5534,5 +5462,3 @@ static void inchi_sort_int_pair_ascending(int *a, int *b) return; } - - diff --git a/INCHI-1-SRC/INCHI_BASE/src/inchi_api.h b/INCHI-1-SRC/INCHI_BASE/src/inchi_api.h index c54cb777..bc826348 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/inchi_api.h +++ b/INCHI-1-SRC/INCHI_BASE/src/inchi_api.h @@ -72,7 +72,7 @@ typedef enum tagINCHIBondType { INCHI_BOND_TYPE_ALTERN = 4 /* avoid by all means */ } inchi_BondType; typedef enum tagINCHIBondStereo2D { - /* stereocenter-related; positive: the sharp end points to this atom */ + /* stereocenter-related; positive: the sharp end points to this atom */ INCHI_BOND_STEREO_NONE = 0, INCHI_BOND_STEREO_SINGLE_1UP = 1, INCHI_BOND_STEREO_SINGLE_1EITHER = 4, @@ -101,8 +101,8 @@ typedef enum tagINCHIBondStereo2D { * whether the stereochemistry is unknown. * *************************************************************************/ -/* sizes definitions */ -#define MAXVAL 20 /* max number of bonds per atom */ + /* sizes definitions */ +#define MAXVAL 50 /* max number of bonds per atom */ /* @nnuk : Changed from 20 -> 50 for testing purposes, to account for some structures with one atom having more than 20 bonds */ #define ATOM_EL_LEN 6 /* length of ASCIIZ element symbol field */ #define NUM_H_ISOTOPES 3 /* number of hydrogen isotopes: protium, D, T */ #define ISOTOPIC_SHIFT_FLAG 10000 /* add to isotopic mass if isotopic_mass = */ @@ -138,25 +138,25 @@ typedef struct tagInchiAtom { double z; /* connectivity */ AT_NUM neighbor[MAXVAL]; /* adjacency list: ordering numbers of */ - /* the adjacent atoms, >= 0 */ + /* the adjacent atoms, >= 0 */ S_CHAR bond_type[MAXVAL]; /* inchi_BondType */ /* 2D stereo */ S_CHAR bond_stereo[MAXVAL]; /* inchi_BondStereo2D; negative if the */ - /* sharp end points to opposite atom */ - /* other atom properties */ + /* sharp end points to opposite atom */ +/* other atom properties */ char elname[ATOM_EL_LEN]; /* zero-terminated chemical element name:*/ - /* "H", "Si", etc. */ + /* "H", "Si", etc. */ AT_NUM num_bonds; /* number of neighbors, bond types and bond*/ - /* stereo in the adjacency list */ + /* stereo in the adjacency list */ S_CHAR num_iso_H[NUM_H_ISOTOPES + 1]; /* implicit hydrogen atoms */ - /* [0]: number of implicit non-isotopic H - (exception: num_iso_H[0]=-1 means INCHI - adds implicit H automatically), - [1]: number of implicit isotopic 1H (protium), - [2]: number of implicit 2H (deuterium), - [3]: number of implicit 3H (tritium) */ + /* [0]: number of implicit non-isotopic H + (exception: num_iso_H[0]=-1 means INCHI + adds implicit H automatically), + [1]: number of implicit isotopic 1H (protium), + [2]: number of implicit 2H (deuterium), + [3]: number of implicit 3H (tritium) */ AT_NUM isotopic_mass; /* 0 => non-isotopic; isotopic mass or */ - /* ISOTOPIC_SHIFT_FLAG + mass - (average atomic mass) */ + /* ISOTOPIC_SHIFT_FLAG + mass - (average atomic mass) */ S_CHAR radical; /* inchi_Radical */ S_CHAR charge; /* positive or negative; 0 => no charge */ }inchi_Atom; @@ -185,225 +185,225 @@ typedef struct tagInchiAtom { * languages such as Visual Basic. *******************************************************************/ -/******************************************************************* - 0D Stereo Parity and Type definitions - ******************************************************************* - Note: - ===== - o Below #A is the ordering number of atom A, starting from 0 - o See parity values corresponding to 'o', 'e', and 'u' in - inchi_StereoParity0D definition below) - - ============================================= - stereogenic bond >A=B< or cumulene >A=C=C=B< - ============================================= - - neighbor[4] : {#X,#A,#B,#Y} in this order - X central_atom : NO_ATOM - \ X Y type : INCHI_StereoType_DoubleBond - A==B \ / - \ A==B - Y - - parity= 'e' parity= 'o' unknown parity = 'u' - - Limitations: - ============ - o Atoms A and B in cumulenes MUST be connected by a chain of double bonds; - atoms A and B in a stereogenic 'double bond' may be connected by a double, - single, or alternating bond. - o One atom may belong to up to 3 stereogenic bonds (i.g. in a fused - aromatic structure). - o Multiple stereogenic bonds incident to any given atom should - either all except possibly one have (possibly different) defined - parities ('o' or 'e') or should all have an unknown parity 'u'. - - Note on parities of alternating stereobonds - =========================================== - D--E - In large rings (see Fig. 1, all // \\ - atoms are C) all alternating bonds B--C F--G - are treated as stereogenic. // \\ - To avoid "undefined" bond parities A H - for bonds BC, DE, FG, HI, JK, LM, AN \ / - it is recommended to mark them with N==M J==I - parities. \ / - L==K Fig. 1 - Such a marking will make - the stereochemical layer unambiguous - and it will be different from the B--C F--G - stereochemical layer of the second // \\ // \\ - structure (Fig. 2). A D--E H - \ / - N==M J==I - By default, double and alternating \ / - bonds in 8-member and greater rings L==K Fig. 2 - are treated by InChI as stereogenic. - - - ============================================= - tetrahedral atom - ============================================= - - 4 neighbors - - X neighbor[4] : {#W, #X, #Y, #Z} - | central_atom: #A - W--A--Y type : INCHI_StereoType_Tetrahedral - | - Z - parity: if (X,Y,Z) are clockwize when seen from W then parity is 'e' otherwise 'o' - Example (see AXYZW above): if W is above the plane XYZ then parity = 'e' - - 3 neighbors - - Y Y neighbor[4] : {#A, #X, #Y, #Z} - / / central_atom: #A - X--A (e.g. O=S ) type : INCHI_StereoType_Tetrahedral - \ \ - Z Z - - parity: if (X,Y,Z) are clockwize when seen from A then parity is 'e', - otherwise 'o' - unknown parity = 'u' - Example (see AXYZ above): if A is above the plane XYZ then parity = 'e' - This approach may be used also in case of an implicit H attached to A. - - ============================================= - allene - ============================================= - - X Y neighbor[4] : {#X,#A,#B,#Y} - \ / central_atom : #C - A=C=B type : INCHI_StereoType_Allene - - Y X - | | - when seen from A along A=C=B: X-A Y-A - - parity: 'e' 'o' - - parity: if A, B, Y are clockwise when seen from X then parity is 'e', - otherwise 'o' - unknown parity = 'u' - Example (see XACBY above): if X on the diagram is above the plane ABY - then parity is 'o' - - Limitations - =========== - o Atoms A and B in allenes MUST be connected by a chain of double bonds; - - - How InChI uses 0D parities - ========================== - - 1. 0D parities are used if all atom coordinates are zeroes. - - In addition to that: - - 2. 0D parities are used for Stereobonds, Allenes, or Cumulenes if: - - 2a. A bond to the end-atom is shorter than MIN_BOND_LEN=0.000001 - 2b. A ratio of two bond lengths to the end-atom is smaller than MIN_SINE=0.03 - 2c. In case of a linear fragment X-A=B end-atom A is treated as satisfying 2a-b - - 0D parities are used if 2a or 2b or 2c applies to one or both end-atoms. - - 3. 0D parities are used for Tetrahedral Atoms if at least one of 3a-c is true: - - 3a. One of bonds to the central atom is shorter than MIN_BOND_LEN=0.000001 - 3b. A ratio of two bond lengths to the central atom is smaller than MIN_SINE=0.03 - 3c. The four neighbors are almost in one plane or the central atom and - its only 3 explicit neighbors are almost in one plane - - Notes on 0D parities and 'undefined' stereogenic elements - ========================================================= - - If 0D parity is to be used according to 1-3 but CH3 CH3 - has not been provided then the corresponding \ / - stereogenic element is considered 'undefined'. C=CH - / - For example, if in the structure (Fig. 3) H - the explicit H has been moved so that it Fig. 3 - has same coordinates as atom >C= (that is, - the length of the bond H-C became zero) - then the double bond is assigned 'undefined' CH3 CH3 - parity which by default is omitted from the \ / - Identifier. CH=CH - - However, the structure on Fig. 4 will have double Fig. 4 - bond parity 'o' and its parity in the Identifier is (-). - - Notes on 0D parities in structures containing metals - ==================================================== - Since InChI disconnects bonds to metals the 0D parities upon the - disconnection may change in several different ways: + /******************************************************************* + 0D Stereo Parity and Type definitions + ******************************************************************* + Note: + ===== + o Below #A is the ordering number of atom A, starting from 0 + o See parity values corresponding to 'o', 'e', and 'u' in + inchi_StereoParity0D definition below) + + ============================================= + stereogenic bond >A=B< or cumulene >A=C=C=B< + ============================================= + + neighbor[4] : {#X,#A,#B,#Y} in this order + X central_atom : NO_ATOM + \ X Y type : INCHI_StereoType_DoubleBond + A==B \ / + \ A==B + Y + + parity= 'e' parity= 'o' unknown parity = 'u' + + Limitations: + ============ + o Atoms A and B in cumulenes MUST be connected by a chain of double bonds; + atoms A and B in a stereogenic 'double bond' may be connected by a double, + single, or alternating bond. + o One atom may belong to up to 3 stereogenic bonds (i.g. in a fused + aromatic structure). + o Multiple stereogenic bonds incident to any given atom should + either all except possibly one have (possibly different) defined + parities ('o' or 'e') or should all have an unknown parity 'u'. + + Note on parities of alternating stereobonds + =========================================== + D--E + In large rings (see Fig. 1, all // \\ + atoms are C) all alternating bonds B--C F--G + are treated as stereogenic. // \\ + To avoid "undefined" bond parities A H + for bonds BC, DE, FG, HI, JK, LM, AN \ / + it is recommended to mark them with N==M J==I + parities. \ / + L==K Fig. 1 + Such a marking will make + the stereochemical layer unambiguous + and it will be different from the B--C F--G + stereochemical layer of the second // \\ // \\ + structure (Fig. 2). A D--E H + \ / + N==M J==I + By default, double and alternating \ / + bonds in 8-member and greater rings L==K Fig. 2 + are treated by InChI as stereogenic. + + + ============================================= + tetrahedral atom + ============================================= + + 4 neighbors + + X neighbor[4] : {#W, #X, #Y, #Z} + | central_atom: #A + W--A--Y type : INCHI_StereoType_Tetrahedral + | + Z + parity: if (X,Y,Z) are clockwize when seen from W then parity is 'e' otherwise 'o' + Example (see AXYZW above): if W is above the plane XYZ then parity = 'e' + + 3 neighbors + + Y Y neighbor[4] : {#A, #X, #Y, #Z} + / / central_atom: #A + X--A (e.g. O=S ) type : INCHI_StereoType_Tetrahedral + \ \ + Z Z + + parity: if (X,Y,Z) are clockwize when seen from A then parity is 'e', + otherwise 'o' + unknown parity = 'u' + Example (see AXYZ above): if A is above the plane XYZ then parity = 'e' + This approach may be used also in case of an implicit H attached to A. + + ============================================= + allene + ============================================= + + X Y neighbor[4] : {#X,#A,#B,#Y} + \ / central_atom : #C + A=C=B type : INCHI_StereoType_Allene + + Y X + | | + when seen from A along A=C=B: X-A Y-A + + parity: 'e' 'o' + + parity: if A, B, Y are clockwise when seen from X then parity is 'e', + otherwise 'o' + unknown parity = 'u' + Example (see XACBY above): if X on the diagram is above the plane ABY + then parity is 'o' + + Limitations + =========== + o Atoms A and B in allenes MUST be connected by a chain of double bonds; + + + How InChI uses 0D parities + ========================== + + 1. 0D parities are used if all atom coordinates are zeroes. + + In addition to that: + + 2. 0D parities are used for Stereobonds, Allenes, or Cumulenes if: + + 2a. A bond to the end-atom is shorter than MIN_BOND_LEN=0.000001 + 2b. A ratio of two bond lengths to the end-atom is smaller than MIN_SINE=0.03 + 2c. In case of a linear fragment X-A=B end-atom A is treated as satisfying 2a-b + + 0D parities are used if 2a or 2b or 2c applies to one or both end-atoms. + + 3. 0D parities are used for Tetrahedral Atoms if at least one of 3a-c is true: + + 3a. One of bonds to the central atom is shorter than MIN_BOND_LEN=0.000001 + 3b. A ratio of two bond lengths to the central atom is smaller than MIN_SINE=0.03 + 3c. The four neighbors are almost in one plane or the central atom and + its only 3 explicit neighbors are almost in one plane + + Notes on 0D parities and 'undefined' stereogenic elements + ========================================================= + + If 0D parity is to be used according to 1-3 but CH3 CH3 + has not been provided then the corresponding \ / + stereogenic element is considered 'undefined'. C=CH + / + For example, if in the structure (Fig. 3) H + the explicit H has been moved so that it Fig. 3 + has same coordinates as atom >C= (that is, + the length of the bond H-C became zero) + then the double bond is assigned 'undefined' CH3 CH3 + parity which by default is omitted from the \ / + Identifier. CH=CH + + However, the structure on Fig. 4 will have double Fig. 4 + bond parity 'o' and its parity in the Identifier is (-). + + Notes on 0D parities in structures containing metals + ==================================================== + Since InChI disconnects bonds to metals the 0D parities upon the + disconnection may change in several different ways: - 1) previously non-stereogenic bond may become stereogenic: + 1) previously non-stereogenic bond may become stereogenic: - \ / \ / - CH==CH disconnection CH==CH - \ / ======> - M M - - before the disconnection: after the disconnection: - atoms C have valence=5 and the double bond may become - the double bond is not stereogenic - recognized as stereogenic + \ / \ / + CH==CH disconnection CH==CH + \ / ======> + M M + + before the disconnection: after the disconnection: + atoms C have valence=5 and the double bond may become + the double bond is not stereogenic + recognized as stereogenic - 2) previously stereogenic bond may become non-stereogenic: + 2) previously stereogenic bond may become non-stereogenic: - M M(+) - \ / / - N==C disconnection (-)N==C - \ ======> \ - - 3) Oddball structures, usually resulting from projecting 3D - structures on the plane, may contain fragment like that - depicted on Fig. 5: + M M(+) + \ / / + N==C disconnection (-)N==C + \ ======> \ + + 3) Oddball structures, usually resulting from projecting 3D + structures on the plane, may contain fragment like that + depicted on Fig. 5: - M A M A - |\ / B / B - | X / disconnection / / - |/ \ / ======> / / - C===C C===C - Fig. 5 - (X stands for bond intersection) + M A M A + |\ / B / B + | X / disconnection / / + |/ \ / ======> / / + C===C C===C + Fig. 5 + (X stands for bond intersection) - A-C=C-B parity is A-C=C-B parity is - trans (e) cis (o) or undefined - because the bond because C valence = 3, - orientation is same not 4. - as on Fig, 6 below: + A-C=C-B parity is A-C=C-B parity is + trans (e) cis (o) or undefined + because the bond because C valence = 3, + orientation is same not 4. + as on Fig, 6 below: - A M - \ / Removal of M from the structure - C===C on Fig. 5 changes the geometry from trans - / \ to cis. - M' B Removal of M and M' from the structure - Fig. 6 on Fig. 6 does not change the A-C=C-B - geometry: it is trans. + A M + \ / Removal of M from the structure + C===C on Fig. 5 changes the geometry from trans + / \ to cis. + M' B Removal of M and M' from the structure + Fig. 6 on Fig. 6 does not change the A-C=C-B + geometry: it is trans. - To resolve the problem InChI API accepts the second parity - corresponding to the metal-disconnected structure. - To store both bond parities use left shift by 3 bits: + To resolve the problem InChI API accepts the second parity + corresponding to the metal-disconnected structure. + To store both bond parities use left shift by 3 bits: - inchi_Stereo0D::parity = ParityOfConnected | (ParityOfDisconnected<<3) + inchi_Stereo0D::parity = ParityOfConnected | (ParityOfDisconnected<<3) - In case when only disconnected structure parity exists set - ParityOfConnected = INCHI_PARITY_UNDEFINED. - This is the only case when INCHI_PARITY_UNDEFINED parity - may be fed to the InChI. + In case when only disconnected structure parity exists set + ParityOfConnected = INCHI_PARITY_UNDEFINED. + This is the only case when INCHI_PARITY_UNDEFINED parity + may be fed to the InChI. - In cases when the bond parity in a disconnected structure exists and - differs from the parity in the connected structure the atoms A and B - should be non-metals. + In cases when the bond parity in a disconnected structure exists and + differs from the parity in the connected structure the atoms A and B + should be non-metals. -****************************************************************************/ + ****************************************************************************/ #define NO_ATOM (-1) /* non-existent (central) atom */ -/* 0D parity types */ + /* 0D parity types */ typedef enum tagINCHIStereoType0D { INCHI_StereoType_None = 0, INCHI_StereoType_DoubleBond = 1, @@ -434,10 +434,10 @@ typedef enum tagINCHIStereoParity0D { typedef struct tagINCHIStereo0D { AT_NUM neighbor[4]; /* 4 atoms always */ AT_NUM central_atom; /* central tetrahedral atom or a central */ - /* atom of allene; otherwise NO_ATOM */ + /* atom of allene; otherwise NO_ATOM */ S_CHAR type; /* inchi_StereoType0D */ S_CHAR parity; /* inchi_StereoParity0D: may be a combination of two parities: */ - /* ParityOfConnected | (ParityOfDisconnected << 3), see Note above */ + /* ParityOfConnected | (ParityOfDisconnected << 3), see Note above */ }inchi_Stereo0D; @@ -452,23 +452,23 @@ typedef struct tagINCHIStereo0D { *************************************************/ -/* - Structure -> InChI + /* + Structure -> InChI - GetINCHI() - GetStdINCHI() - GetINCHIEx() + GetINCHI() + GetStdINCHI() + GetINCHIEx() -*/ + */ typedef struct tagINCHI_Input { /* the caller is responsible for the data allocation and deallocation */ - inchi_Atom *atom; /* array of num_atoms elements */ - inchi_Stereo0D *stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ - char *szOptions; /* InChI options: space-delimited; each is preceded by*/ - /* '/' or '-' depending on OS and compiler */ + inchi_Atom* atom; /* array of num_atoms elements */ + inchi_Stereo0D* stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ + char* szOptions; /* InChI options: space-delimited; each is preceded by*/ + /* '/' or '-' depending on OS and compiler */ AT_NUM num_atoms; /* number of atoms in the structure < MAX_ATOMS */ AT_NUM num_stereo0D; /* number of 0D stereo elements */ }inchi_Input; @@ -493,27 +493,27 @@ typedef struct tagINCHI_Input typedef struct inchi_Input_PolymerUnit { int id; /* Unit id; it is what is called 'Sgroup number' */ - /* in CTFile (not used, kept for compatibility) */ + /* in CTFile (not used, kept for compatibility) */ int type; /* Unit type as per CTFile format (STY) */ int subtype; /* Unit subtype as per CTFile format (SST) */ int conn; /* Unit connection scheme as per CTFile format (SCN) */ int label; /* One more unit id; what is called 'unique Sgroup */ - /* identifier' in CTFile (not used, for compatibility) */ + /* identifier' in CTFile (not used, for compatibility) */ int na; /* Number of atoms in the unit */ int nb; /* Number of bonds in the unit */ double xbr1[4]; /* Bracket ends coordinates (SDI) */ double xbr2[4]; /* Bracket ends coordinates (SDI) */ char smt[80]; /* Sgroup Subscript (SMT) ('n' or so ) */ - int *alist; /* List of atoms in the unit (SAL), atomic numbers */ - int *blist; /* List of crossing bonds of unit: */ - /* [bond1end1, bond1end2, bond2end1, bond2end2] */ + int* alist; /* List of atoms in the unit (SAL), atomic numbers */ + int* blist; /* List of crossing bonds of unit: */ + /* [bond1end1, bond1end2, bond2end1, bond2end2] */ } inchi_Input_PolymerUnit; typedef struct inchi_Input_Polymer { /* List of pointers to polymer units */ - inchi_Input_PolymerUnit **units; + inchi_Input_PolymerUnit** units; int n; /* Number of polymer units */ } inchi_Input_Polymer; @@ -528,30 +528,30 @@ typedef struct inchi_Input_V3000 { int n_non_star_atoms; int n_star_atoms; - int *atom_index_orig; /* Index as supplied for atoms */ - int *atom_index_fin; /* = index or -1 for star atom */ + int* atom_index_orig; /* Index as supplied for atoms */ + int* atom_index_fin; /* = index or -1 for star atom */ int n_sgroups; /* Not used yet. */ int n_3d_constraints; /* Not used yet. */ int n_collections; int n_non_haptic_bonds; int n_haptic_bonds; - int **lists_haptic_bonds; /* Haptic_bonds[i] is pointer to int */ - /* array which contains: */ - /* bond_type, non-star atom number, */ - /* nendpts, then endpts themselves */ - /* Enhanced stereo collections */ + int** lists_haptic_bonds; /* Haptic_bonds[i] is pointer to int */ + /* array which contains: */ + /* bond_type, non-star atom number, */ + /* nendpts, then endpts themselves */ +/* Enhanced stereo collections */ int n_steabs; - int **lists_steabs; /* steabs[k][0] - not used */ - /* steabs[k][1] - number of members in collection */ - /* steabs[k][2..] - member atom numbers */ + int** lists_steabs; /* steabs[k][0] - not used */ + /* steabs[k][1] - number of members in collection */ + /* steabs[k][2..] - member atom numbers */ int n_sterel; - int **lists_sterel; /* sterel[k][0] - n from "STERELn" tag */ - /* sterel[k][1] - number of members in collection */ - /* sterel[k][2..] - member atom numbers */ + int** lists_sterel; /* sterel[k][0] - n from "STERELn" tag */ + /* sterel[k][1] - number of members in collection */ + /* sterel[k][2..] - member atom numbers */ int n_sterac; - int **lists_sterac; /* sterac[k][0] - n from "STERACn" tag */ - /* sterac[k][1] - number of members in collection */ - /* sterac[k][0] - number from "STERACn" tag */ + int** lists_sterac; /* sterac[k][0] - n from "STERACn" tag */ + /* sterac[k][1] - number of members in collection */ + /* sterac[k][0] - number from "STERACn" tag */ } inchi_Input_V3000; @@ -563,20 +563,20 @@ typedef struct inchi_InputEx /* the caller is responsible for the data allocation and deallocation */ /* same as in older inchi_Input */ - inchi_Atom *atom; /* array of num_atoms elements */ - /* same as in older inchi_Input */ - inchi_Stereo0D *stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ + inchi_Atom* atom; /* array of num_atoms elements */ /* same as in older inchi_Input */ - char *szOptions; /* InChI options: space-delimited; each is preceded by */ - /* '/' or '-' depending on OS and compiler */ + inchi_Stereo0D* stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ /* same as in older inchi_Input */ + char* szOptions; /* InChI options: space-delimited; each is preceded by */ + /* '/' or '-' depending on OS and compiler */ +/* same as in older inchi_Input */ AT_NUM num_atoms; /* number of atoms in the structure */ /* same as in older inchi_Input */ AT_NUM num_stereo0D; /* number of 0D stereo elements */ - inchi_Input_Polymer *polymer; /* v. 1.05+ extended data, polymers */ - /* NULL if not a polymer */ - inchi_Input_V3000 *v3000; /* v. 1.05+ extended data, V3000 Molfile features */ - /* NULL if no V3000 extensions present */ + inchi_Input_Polymer* polymer; /* v. 1.05+ extended data, polymers */ + /* NULL if not a polymer */ + inchi_Input_V3000* v3000; /* v. 1.05+ extended data, V3000 Molfile features */ + /* NULL if no V3000 extensions present */ } inchi_InputEx; @@ -590,9 +590,9 @@ typedef struct inchi_InputEx typedef struct tagINCHI_InputINCHI { /* the caller is responsible for the data allocation and deallocation */ - char *szInChI; /* InChI ASCIIZ string to be converted to a strucure */ - char *szOptions; /* InChI options: space-delimited; each is preceded by */ - /* '/' or '-' depending on OS and compiler */ + char* szInChI; /* InChI ASCIIZ string to be converted to a strucure */ + char* szOptions; /* InChI options: space-delimited; each is preceded by */ + /* '/' or '-' depending on OS and compiler */ } inchi_InputINCHI; @@ -613,20 +613,20 @@ typedef inchi_Input_V3000 inchi_Output_V3000; -/* - Structure -> InChI -*/ + /* + Structure -> InChI + */ typedef struct tagINCHI_Output { /* zero-terminated C-strings allocated by GetStdINCHI() */ /* to deallocate all of them call FreeStdINCHI() (see below) */ - char *szInChI; /* InChI ASCIIZ string */ - char *szAuxInfo; /* Aux info ASCIIZ string */ - char *szMessage; /* Error/warning ASCIIZ message */ - char *szLog; /* log-file ASCIIZ string, contains a human-readable list */ - /* of recognized options and possibly an Error/warning message */ + char* szInChI; /* InChI ASCIIZ string */ + char* szAuxInfo; /* Aux info ASCIIZ string */ + char* szMessage; /* Error/warning ASCIIZ message */ + char* szLog; /* log-file ASCIIZ string, contains a human-readable list */ + /* of recognized options and possibly an Error/warning message */ } inchi_Output; @@ -636,20 +636,20 @@ typedef struct tagINCHI_OutputStruct { /* Pointers are allocated by GetStructFromINCHI()/GetStructFromStdINCHI() */ /* to deallocate all of them call FreeStructFromStdINCHI()/FreeStructFromStdINCHI() */ - inchi_Atom *atom; /* array of num_atoms elements */ - inchi_Stereo0D *stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ + inchi_Atom* atom; /* array of num_atoms elements */ + inchi_Stereo0D* stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ AT_NUM num_atoms; /* number of atoms in the structure */ AT_NUM num_stereo0D; /* number of 0D stereo elements */ - char *szMessage; /* Error/warning ASCIIZ message */ - char *szLog; /* log-file ASCIIZ string, contains a human-readable list */ - /* of recognized options and possibly an Error/warn message */ + char* szMessage; /* Error/warning ASCIIZ message */ + char* szLog; /* log-file ASCIIZ string, contains a human-readable list */ + /* of recognized options and possibly an Error/warn message */ unsigned long WarningFlags[2][2]; /* warnings, see INCHIDIFF in inchicmp.h */ - /* [x][y]: */ - /* x=0 => Reconnected if present in InChI */ - /* otherwise Disconnected/Normal */ - /* x=1 => Disconnected layer if Reconn. layer is present */ - /* y=1 => Main layer or Mobile-H */ - /* y=0 => Fixed-H layer */ + /* [x][y]: */ + /* x=0 => Reconnected if present in InChI */ + /* otherwise Disconnected/Normal */ + /* x=1 => Disconnected layer if Reconn. layer is present */ + /* y=1 => Main layer or Mobile-H */ + /* y=0 => Fixed-H layer */ }inchi_OutputStruct; @@ -658,24 +658,24 @@ typedef struct tagINCHI_OutputStructEx { /* Pointers are allocated by GetStructFromINCHIEx() */ /* to deallocate all of them call FreeStructFromNCHIEx() */ - inchi_Atom *atom; /* array of num_atoms elements */ - inchi_Stereo0D *stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ + inchi_Atom* atom; /* array of num_atoms elements */ + inchi_Stereo0D* stereo0D; /* array of num_stereo0D 0D stereo elements or NULL */ AT_NUM num_atoms; /* number of atoms in the structure */ AT_NUM num_stereo0D; /* number of 0D stereo elements */ - char *szMessage; /* Error/warning ASCIIZ message */ - char *szLog; /* log-file ASCIIZ string, contains a human-readable list */ - /* of recognized options and possibly an Error/Warn message */ + char* szMessage; /* Error/warning ASCIIZ message */ + char* szLog; /* log-file ASCIIZ string, contains a human-readable list */ + /* of recognized options and possibly an Error/Warn message */ unsigned long WarningFlags[2][2];/* warnings, see INCHIDIFF in inchicmp.h */ - /* [x][y]: x=0 => Reconnected if present in InChI */ - /* otherwise Disconnected/Normal */ - /* x=1 => Disconnected layer if Reconne layer is present */ - /* y=1 => Main layer or Mobile-H */ - /* y=0 => Fixed-H layer */ - inchi_Output_Polymer *polymer; /* v. 1.05+ extended data, polymers */ - inchi_Output_V3000 *v3000; /* v. 1.05+ extended data, V3000 Molfile features */ + /* [x][y]: x=0 => Reconnected if present in InChI */ + /* otherwise Disconnected/Normal */ + /* x=1 => Disconnected layer if Reconne layer is present */ + /* y=1 => Main layer or Mobile-H */ + /* y=0 => Fixed-H layer */ + inchi_Output_Polymer* polymer; /* v. 1.05+ extended data, polymers */ + inchi_Output_V3000* v3000; /* v. 1.05+ extended data, V3000 Molfile features */ } inchi_OutputStructEx; -void FreeInChIExtInput( inchi_Input_Polymer *polymer, inchi_Input_V3000 *v3000 ); +void FreeInChIExtInput(inchi_Input_Polymer* polymer, inchi_Input_V3000* v3000); @@ -689,7 +689,7 @@ void FreeInChIExtInput( inchi_Input_Polymer *polymer, inchi_Input_V3000 *v300 #if (defined( _WIN32 ) && defined( _MSC_VER ) && defined(BUILD_LINK_AS_DLL) ) - /* Win32 & MS VC ++, compile and link as a DLL */ + /* Win32 & MS VC ++, compile and link as a DLL */ #ifdef _USRDLL /* InChI library dll */ #define INCHI_API __declspec(dllexport) @@ -702,7 +702,7 @@ void FreeInChIExtInput( inchi_Input_Polymer *polymer, inchi_Input_V3000 *v300 #define INCHI_DECL #endif #else - /* create a statically linked InChI library or link to an executable */ + /* create a statically linked InChI library or link to an executable */ #define INCHI_API #define EXPIMP_TEMPLATE #define INCHI_DECL @@ -769,7 +769,7 @@ extern "C" { #endif -/* InChI PREFIX */ + /* InChI PREFIX */ #define INCHI_STRING_PREFIX "InChI=" #define LEN_INCHI_STRING_PREFIX 6 @@ -786,58 +786,58 @@ extern "C" { -/* EXPORTED FUNCTIONS */ + /* EXPORTED FUNCTIONS */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -GetINCHI / GetStdINCHI + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + GetINCHI / GetStdINCHI - inchi_Input is created by the user; strings in inchi_Output are allocated and deallocated by InChI - inchi_Output does not need to be initilized out to zeroes; see FreeNCHI()/FreeSTDINCHI() on how to deallocate it + inchi_Input is created by the user; strings in inchi_Output are allocated and deallocated by InChI + inchi_Output does not need to be initilized out to zeroes; see FreeNCHI()/FreeSTDINCHI() on how to deallocate it - Valid options for GetINCHI: - (use - instead of / for O.S. other than MS Windows) + Valid options for GetINCHI: + (use - instead of / for O.S. other than MS Windows) - Structure perception (compatible with stdInChI) - /NEWPSOFF /DoNotAddH /SNon - Stereo interpretation (lead to generation of non-standard InChI) - /SRel /SRac /SUCF /ChiralFlagON /ChiralFlagOFF - InChI creation options (lead to generation of non-standard InChI) - /SUU /SLUUD /FixedH /RecMet /KET /15T + Structure perception (compatible with stdInChI) + /NEWPSOFF /DoNotAddH /SNon + Stereo interpretation (lead to generation of non-standard InChI) + /SRel /SRac /SUCF /ChiralFlagON /ChiralFlagOFF + InChI creation options (lead to generation of non-standard InChI) + /SUU /SLUUD /FixedH /RecMet /KET /15T - GetINCHI produces standard InChI if no InChI creation/stereo modification options - are specified. Inveresely, if any of SUU/SLUUD/RecMet/FixedH/Ket/15T/SRel/SRac/SUCF - options are specified, generated InChI will be non-standard one. + GetINCHI produces standard InChI if no InChI creation/stereo modification options + are specified. Inveresely, if any of SUU/SLUUD/RecMet/FixedH/Ket/15T/SRel/SRac/SUCF + options are specified, generated InChI will be non-standard one. - GetStdINCHI produces standard InChI only. - The valid structure perception options are: - /NEWPSOFF /DoNotAddH /SNon + GetStdINCHI produces standard InChI only. + The valid structure perception options are: + /NEWPSOFF /DoNotAddH /SNon - Other options are: - /AuxNone Omit auxiliary information (default: Include) - /Wnumber Set time-out per structure in seconds; W0 means unlimited - In InChI library the default value is unlimited - /WMnumber Set time-out per structure in milliseconds; WM0 means unlimited - In InChI library the default value is unlimited - /OutputSDF Output SDfile instead of InChI - /WarnOnEmptyStructure - Warn and produce empty InChI for empty structure - /SaveOpt Save custom InChI creation options (non-standard InChI) + Other options are: + /AuxNone Omit auxiliary information (default: Include) + /Wnumber Set time-out per structure in seconds; W0 means unlimited + In InChI library the default value is unlimited + /WMnumber Set time-out per structure in milliseconds; WM0 means unlimited + In InChI library the default value is unlimited + /OutputSDF Output SDfile instead of InChI + /WarnOnEmptyStructure + Warn and produce empty InChI for empty structure + /SaveOpt Save custom InChI creation options (non-standard InChI) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHI( inchi_Input *inp, inchi_Output *out ); - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStdINCHI( inchi_Input *inp, inchi_Output *out ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHI(inchi_Input* inp, inchi_Output* out); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStdINCHI(inchi_Input* inp, inchi_Output* out); /* Extended version of GetINCHI supporting v. 1.05+ extensions: V3000; polymers */ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIEx( inchi_InputEx *inp, inchi_Output *out ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIEx(inchi_InputEx* inp, inchi_Output* out); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -847,8 +847,8 @@ GetINCHI / GetStdINCHI obtained from each GetINCHI /GetStdINCHI call ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeINCHI( inchi_Output *out ); - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStdINCHI( inchi_Output *out ); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeINCHI(inchi_Output* out); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStdINCHI(inchi_Output* out); @@ -858,7 +858,7 @@ GetINCHI / GetStdINCHI helper: get string length ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStringLength( char *p ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStringLength(char* p); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -869,9 +869,9 @@ GetINCHI / GetStdINCHI Option /Inchi2Struct is not needed for GetStructFromINCHI()/GetStructFromStdINCHI() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromINCHI( inchi_InputINCHI *inpInChI, inchi_OutputStruct *outStruct ); - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromStdINCHI( inchi_InputINCHI *inpInChI, inchi_OutputStruct *outStruct ); - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromINCHIEx( inchi_InputINCHI *inpInChI, inchi_OutputStructEx *outStruct ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromINCHI(inchi_InputINCHI* inpInChI, inchi_OutputStruct* outStruct); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromStdINCHI(inchi_InputINCHI* inpInChI, inchi_OutputStruct* outStruct); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStructFromINCHIEx(inchi_InputINCHI* inpInChI, inchi_OutputStructEx* outStruct); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -881,9 +881,9 @@ GetINCHI / GetStdINCHI GetStructFromStdINCHI / GetStructFromINCHI / GetStructFromINCHIEx ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromINCHI( inchi_OutputStruct *out ); - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromStdINCHI( inchi_OutputStruct *out ); - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromINCHIEx( inchi_OutputStructEx *out ); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromINCHI(inchi_OutputStruct* out); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromStdINCHI(inchi_OutputStruct* out); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL FreeStructFromINCHIEx(inchi_OutputStructEx* out); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -899,7 +899,7 @@ GetINCHI / GetStdINCHI Note: there is no explicit tool to conversion from/to standard InChI ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIfromINCHI( inchi_InputINCHI *inpInChI, inchi_Output *out ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIfromINCHI(inchi_InputINCHI* inpInChI, inchi_Output* out); #ifndef COMPILE_ALL_CPP #ifdef __cplusplus @@ -921,7 +921,7 @@ GetINCHI / GetStdINCHI #endif typedef struct tagInchiInpData { - inchi_Input *pInp; /* a pointer to pInp that has all items 0 or NULL */ + inchi_Input* pInp; /* a pointer to pInp that has all items 0 or NULL */ int bChiral; /* 1 => the structure was marked as chiral, 2=> not chiral, 0=> not marked */ char szErrMsg[STR_ERR_LEN]; } InchiInpData; @@ -935,32 +935,32 @@ extern "C" { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Get_inchi_Input_FromAuxInfo / Get_std_inchi_Input_FromAuxInfo - -Input: - szInchiAuxInfo: contains ASCIIZ string of InChI output for a single - structure or only the AuxInfo line - bDoNotAddH: if 0 then InChI will be allowed to add implicit H - bDiffUnkUndfStereo - if not 0, use different labels for unknown and undefined stereo - pInchiInp: should have a valid pointer pInchiInp->pInp to an empty - (all members = 0) inchi_Input structure - -Output: - pInchiInp: The following members of pInp may be filled during the call: - atom, num_atoms, stereo0D, num_stereo0D - Return value: see RetValGetINCHI + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Get_inchi_Input_FromAuxInfo / Get_std_inchi_Input_FromAuxInfo -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + Input: + szInchiAuxInfo: contains ASCIIZ string of InChI output for a single + structure or only the AuxInfo line + bDoNotAddH: if 0 then InChI will be allowed to add implicit H + bDiffUnkUndfStereo + if not 0, use different labels for unknown and undefined stereo + pInchiInp: should have a valid pointer pInchiInp->pInp to an empty + (all members = 0) inchi_Input structure + + Output: + pInchiInp: The following members of pInp may be filled during the call: + atom, num_atoms, stereo0D, num_stereo0D + Return value: see RetValGetINCHI + + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ EXPIMP_TEMPLATE INCHI_API int INCHI_DECL Get_inchi_Input_FromAuxInfo( - char *szInchiAuxInfo, - int bDoNotAddH, - int bDiffUnkUndfStereo, - InchiInpData *pInchiInp ); - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL Get_std_inchi_Input_FromAuxInfo( char *szInchiAuxInfo, - int bDoNotAddH, - InchiInpData *pInchiInp ); + char* szInchiAuxInfo, + int bDoNotAddH, + int bDiffUnkUndfStereo, + InchiInpData* pInchiInp); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL Get_std_inchi_Input_FromAuxInfo(char* szInchiAuxInfo, + int bDoNotAddH, + InchiInpData* pInchiInp); @@ -971,8 +971,8 @@ Get_inchi_Input_FromAuxInfo / Get_std_inchi_Input_FromAuxInfo Free_inchi_Input( inchi_Input *pInp ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL Free_inchi_Input( inchi_Input *pInp ); - EXPIMP_TEMPLATE INCHI_API void INCHI_DECL Free_std_inchi_Input( inchi_Input *pInp ); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL Free_inchi_Input(inchi_Input* pInp); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL Free_std_inchi_Input(inchi_Input* pInp); @@ -991,7 +991,7 @@ Get_inchi_Input_FromAuxInfo / Get_std_inchi_Input_FromAuxInfo success/errors codes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL CheckINCHI( const char *szINCHI, const int strict ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL CheckINCHI(const char* szINCHI, const int strict); #ifndef COMPILE_ALL_CPP @@ -1082,40 +1082,40 @@ extern "C" { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -GetINCHIKeyFromINCHI - -Calculate InChIKey by InChI string. - -Input: - szINCHISource - source InChI string - xtra1 - =1 calculate hash extension (up to 256 bits; 1st block) - xtra2 - =1 calculate hash extension (up to 256 bits; 2nd block) - -Output: - szINCHIKey - InChIKey string - The user-supplied buffer szINCHIKey should be at least 28 bytes long. - szXtra1 - hash extension (up to 256 bits; 1st block) string - Caller should allocate space for 64 characters + trailing NULL - szXtra2 - hash extension (up to 256 bits; 2nd block) string - Caller should allocate space for 64 characters + trailing NULL - -Returns: - success/errors codes + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + GetINCHIKeyFromINCHI -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIKeyFromINCHI( const char* szINCHISource, - const int xtra1, - const int xtra2, - char* szINCHIKey, - char* szXtra1, - char* szXtra2 ); + Calculate InChIKey by InChI string. + + Input: + szINCHISource + source InChI string + xtra1 + =1 calculate hash extension (up to 256 bits; 1st block) + xtra2 + =1 calculate hash extension (up to 256 bits; 2nd block) + + Output: + szINCHIKey + InChIKey string + The user-supplied buffer szINCHIKey should be at least 28 bytes long. + szXtra1 + hash extension (up to 256 bits; 1st block) string + Caller should allocate space for 64 characters + trailing NULL + szXtra2 + hash extension (up to 256 bits; 2nd block) string + Caller should allocate space for 64 characters + trailing NULL + + Returns: + success/errors codes + + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetINCHIKeyFromINCHI(const char* szINCHISource, + const int xtra1, + const int xtra2, + char* szINCHIKey, + char* szXtra1, + char* szXtra2); @@ -1128,8 +1128,8 @@ Calculate InChIKey by InChI string. To calculate extra hash(es), use GetINCHIKeyFromINCHI with stdInChI as input. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStdINCHIKeyFromStdINCHI( const char* szINCHISource, - char* szINCHIKey ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL GetStdINCHIKeyFromStdINCHI(const char* szINCHISource, + char* szINCHIKey); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1143,7 +1143,7 @@ Calculate InChIKey by InChI string. success/errors codes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - EXPIMP_TEMPLATE INCHI_API int INCHI_DECL CheckINCHIKey( const char *szINCHIKey ); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL CheckINCHIKey(const char* szINCHIKey); #ifndef COMPILE_ALL_CPP #ifdef __cplusplus @@ -1194,15 +1194,15 @@ typedef struct tagNormAtom S_CHAR bond_stereo[MAXVAL]; /* 1=Up,4=Either,6=Down (this atom is at the pointing wedge) negative => on the opposite side of the wedge; 3=Either double bond */ U_CHAR bond_type[MAXVAL]; /* 1=single, 2=double, 3=triple, 4=1/2 (bond order is 1 or 2) */ - /* 5=1/2/3, 6=1/3, 7=2/3, 8=tautomeric, 9=1/2 non-stereogenic */ + /* 5=1/2/3, 6=1/3, 7=2/3, 8=tautomeric, 9=1/2 non-stereogenic */ S_CHAR valence; /* number of bonds = number of neighbors not greater than MAXVAL */ S_CHAR chem_bonds_valence; /* sum of bond types (1,2,3); type 4 needs special treatment */ S_CHAR num_H; /* number of adjacent implicit hydrogen atoms including D and T */ S_CHAR num_iso_H[NUM_H_ISOTOPES];/* number of adjacent implicit 1H(protium), 2H(D), 3H(T) < 16 */ S_CHAR iso_atw_diff; /* =0 => natural isotopic abundances */ - /* >0 => (isotopic mass) - (rounded average atomic mass) + 1 */ - /* <0 => (isotopic mass) - (rounded average atomic mass) */ + /* >0 => (isotopic mass) - (rounded average atomic mass) + 1 */ + /* <0 => (isotopic mass) - (rounded average atomic mass) */ S_CHAR charge; /* charge */ S_CHAR radical; /* RADICAL_SINGLET, RADICAL_DOUBLET, or RADICAL_TRIPLET */ S_CHAR bAmbiguousStereo; /* flag of detected stereo ambiguity */ @@ -1223,7 +1223,7 @@ typedef struct tagNormAtom S_CHAR sb_ord[MAX_NUM_STEREO_BONDS]; /* neighbor[] index of another end of this SB, starts from 0 */ S_CHAR sn_ord[MAX_NUM_STEREO_BONDS]; /* neighbor[] index of a bond that is not this SB; starts from 0; -1 means the neighbor is a removed explicit H */ - /* atoms on both ends of a stereobond have same parity => trans/T/E/2, diff. parities => cis/C/Z/1 */ + /* atoms on both ends of a stereobond have same parity => trans/T/E/2, diff. parities => cis/C/Z/1 */ S_CHAR sb_parity[MAX_NUM_STEREO_BONDS]; /* parities of stereobonds (sp2) incident to this atom */ AT_NUMBR sn_orig_at_num[MAX_NUM_STEREO_BONDS]; /* orig_at_number of sn_ord[] neighbor > 0 */ @@ -1244,8 +1244,8 @@ typedef struct tagNormAtom typedef struct tagNormAtomData { - NORM_ATOM *at; /* atom list */ - NORM_ATOM *at_fixed_bonds; /* atom list with added or removed protons only */ + NORM_ATOM* at; /* atom list */ + NORM_ATOM* at_fixed_bonds; /* atom list with added or removed protons only */ int num_at; /* number of atoms except removed terminal H */ int num_removed_H; /* number of removed H; at[] has (num_at+num_removed_H) elements */ int num_bonds; @@ -1257,10 +1257,10 @@ typedef struct tagNormAtomData int bTautPreprocessed; /* for internal use */ int nNumRemovedProtons; NUM_HS nNumRemovedProtonsIsotopic[NUM_H_ISOTOPES]; - /* isotopic composition of removed protons, not included in num_iso_H[] */ + /* isotopic composition of removed protons, not included in num_iso_H[] */ NUM_HS num_iso_H[NUM_H_ISOTOPES]; - /* isotopic H on tautomeric atoms and those - in nIsotopicEndpointAtomNumber */ + /* isotopic H on tautomeric atoms and those + in nIsotopicEndpointAtomNumber */ INCHI_MODES bTautFlags; /* for internal use */ INCHI_MODES bTautFlagsDone; /* for internal use */ INCHI_MODES bNormalizationFlags;/* for internal use */ @@ -1272,12 +1272,12 @@ typedef struct tagINCHIGEN_DATA char pStrErrStruct[STR_ERR_LEN]; /* intermediate log (warning/error report) */ int num_components[INCHI_NUM]; /* number of allocated INChI, INChI_Aux data structures */ - /* index=0 => disconnected, 1 => reconnected structure */ + /* index=0 => disconnected, 1 => reconnected structure */ - /* The results of normalization stage */ - /* for each member of pair disconnected/reconnected structures: */ - NORM_ATOMS *NormAtomsNontaut[INCHI_NUM]; - NORM_ATOMS *NormAtomsTaut[INCHI_NUM]; +/* The results of normalization stage */ +/* for each member of pair disconnected/reconnected structures: */ + NORM_ATOMS* NormAtomsNontaut[INCHI_NUM]; + NORM_ATOMS* NormAtomsTaut[INCHI_NUM]; } INCHIGEN_DATA; @@ -1301,107 +1301,107 @@ extern "C" { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_Create / STDINCHIGEN_Create + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_Create / STDINCHIGEN_Create -InChI Generator: create generator -Returns handle of generator object or NULL on failure + InChI Generator: create generator + Returns handle of generator object or NULL on failure -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API INCHIGEN_HANDLE INCHI_DECL INCHIGEN_Create( void ); -EXPIMP_TEMPLATE INCHI_API INCHIGEN_HANDLE INCHI_DECL STDINCHIGEN_Create( void ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API INCHIGEN_HANDLE INCHI_DECL INCHIGEN_Create(void); + EXPIMP_TEMPLATE INCHI_API INCHIGEN_HANDLE INCHI_DECL STDINCHIGEN_Create(void); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_Setup / STDINCHIGEN_Setup + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_Setup / STDINCHIGEN_Setup -InChI Generator: setup + InChI Generator: setup -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_Setup( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Input * pInp ); -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_Setup( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Input * pInp ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_Setup(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Input* pInp); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_Setup(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Input* pInp); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_DoNormalization / STDINCHIGEN_DoNormalization + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_DoNormalization / STDINCHIGEN_DoNormalization -InChI Generator: structure normalization stage + InChI Generator: structure normalization stage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoNormalization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData ); -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoNormalization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoNormalization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoNormalization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_DoCanonicalization / STDINCHIGEN_DoCanonicalization + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_DoCanonicalization / STDINCHIGEN_DoCanonicalization -InChI Generator: structure canonicalization stage + InChI Generator: structure canonicalization stage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoCanonicalization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData ); -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoCanonicalization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoCanonicalization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoCanonicalization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_DoSerialization / STDINCHIGEN_DoSerialization + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_DoSerialization / STDINCHIGEN_DoSerialization -InChI Generator: InChI serialization stage + InChI Generator: InChI serialization stage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoSerialization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Output * pResults ); -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoSerialization( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Output * pResults ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL INCHIGEN_DoSerialization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Output* pResults); + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL STDINCHIGEN_DoSerialization(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Output* pResults); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_Reset / STDINCHIGEN_Reset + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_Reset / STDINCHIGEN_Reset - InChI Generator: reset stage (use before get next structure) + InChI Generator: reset stage (use before get next structure) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API void INCHI_DECL INCHIGEN_Reset( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Output * pResults ); -EXPIMP_TEMPLATE INCHI_API void INCHI_DECL STDINCHIGEN_Reset( INCHIGEN_HANDLE HGen, - INCHIGEN_DATA * pGenData, - inchi_Output * pResults ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL INCHIGEN_Reset(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Output* pResults); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL STDINCHIGEN_Reset(INCHIGEN_HANDLE HGen, + INCHIGEN_DATA* pGenData, + inchi_Output* pResults); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -INCHIGEN_Destroy / STDINCHIGEN_Destroy + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + INCHIGEN_Destroy / STDINCHIGEN_Destroy - InChI Generator: destroy generator + InChI Generator: destroy generator -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API void INCHI_DECL INCHIGEN_Destroy( INCHIGEN_HANDLE HGen ); -EXPIMP_TEMPLATE INCHI_API void INCHI_DECL STDINCHIGEN_Destroy( INCHIGEN_HANDLE HGen ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL INCHIGEN_Destroy(INCHIGEN_HANDLE HGen); + EXPIMP_TEMPLATE INCHI_API void INCHI_DECL STDINCHIGEN_Destroy(INCHIGEN_HANDLE HGen); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -MakeINCHIFromMolfileText + /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + MakeINCHIFromMolfileText - Direct generation of InChI from Molfile supplied as text + Direct generation of InChI from Molfile supplied as text -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ -EXPIMP_TEMPLATE INCHI_API int INCHI_DECL MakeINCHIFromMolfileText( const char *moltext, - char *options, - inchi_Output *result ); + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + EXPIMP_TEMPLATE INCHI_API int INCHI_DECL MakeINCHIFromMolfileText(const char* moltext, + char* options, + inchi_Output* result); #ifndef COMPILE_ALL_CPP diff --git a/INCHI-1-SRC/INCHI_BASE/src/incomdef.h b/INCHI-1-SRC/INCHI_BASE/src/incomdef.h index ba76493a..d388e213 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/incomdef.h +++ b/INCHI-1-SRC/INCHI_BASE/src/incomdef.h @@ -55,7 +55,7 @@ /* size resrictions */ #define ATOM_EL_LEN 6 /* length of atom name string including zero termination */ #define ATOM_INFO_LEN 36 /* inf_ATOM output string ^123Al^+2H12..(+)/999/999/999/999: 32 chars */ -#define MAXVAL 20 /* max number of bonds per atom */ +#define MAXVAL 50 /* max number of bonds per atom */ /* @nnuk : Changed from 20 -> 50 for testing purposes, to account for some structures with one atom having more than 20 bonds */ #define MAX_STEREO_BONDS 3 /* max number of stereogenic bonds per atom */ #define NUM_H_ISOTOPES 3 /* number of hydrogen isotopes: protium, deuterium, tritium */ #define ATW_H 1 /* hydrogen atomic weight */ @@ -141,27 +141,27 @@ extern "C" { #endif -/* allocator */ + /* allocator */ #ifndef inchi_malloc - void *inchi_malloc( size_t c ); + void* inchi_malloc(size_t c); #endif #ifndef inchi_calloc - void *inchi_calloc( size_t c, size_t n ); + void* inchi_calloc(size_t c, size_t n); #endif #ifndef inchi_free - void inchi_free( void *p ); + void inchi_free(void* p); #endif -/* sorting etc */ + /* sorting etc */ - void inchi_swap( char *a, char *b, size_t width ); + void inchi_swap(char* a, char* b, size_t width); - int insertions_sort( void *pCG, - void *base, size_t num, size_t width, int( *compare )( const void *e1, const void *e2, void * ) ); - int insertions_sort_AT_NUMBERS( void *pCG, - AT_NUMB *base, int num, int( *compare )( const void *e1, const void *e2, void * ) ); + int insertions_sort(void* pCG, + void* base, size_t num, size_t width, int(*compare)(const void* e1, const void* e2, void*)); + int insertions_sort_AT_NUMBERS(void* pCG, + AT_NUMB* base, int num, int(*compare)(const void* e1, const void* e2, void*)); /* int insertions_sort( void *base, size_t num, size_t width, int ( *compare )(const void *e1, const void *e2 ) ); int insertions_sort_AT_NUMBERS( AT_NUMB *base, int num, int ( *compare )(const void *e1, const void *e2 ) ); diff --git a/INCHI-1-SRC/INCHI_BASE/src/mode.h b/INCHI-1-SRC/INCHI_BASE/src/mode.h index a83bbbc6..737a4a4a 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/mode.h +++ b/INCHI-1-SRC/INCHI_BASE/src/mode.h @@ -296,6 +296,8 @@ extern "C" { #define DISPLAY_ZZ_AS_STAR 1 +#define COORDINATIVE_BOND 9 /* (@nnuk) introduction of bond_type = 9 (Coordinative Bond) */ + /* BUG FIXES */ diff --git a/INCHI-1-SRC/INCHI_BASE/src/mol2atom.c b/INCHI-1-SRC/INCHI_BASE/src/mol2atom.c index ca519c0a..063849fb 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/mol2atom.c +++ b/INCHI-1-SRC/INCHI_BASE/src/mol2atom.c @@ -732,7 +732,8 @@ inp_ATOM *MakeInpAtomsFromMolfileData(MOL_FMT_DATA *mfdata, continue; } - if (bond_type < MIN_INPUT_BOND_TYPE || bond_type > MAX_INPUT_BOND_TYPE) + /* (@nnuk) : Bond type 9 (coordinative bond) recognized by InChI now */ + if (bond_type < MIN_INPUT_BOND_TYPE || (bond_type > MAX_INPUT_BOND_TYPE && bond_type != COORDINATIVE_BOND)) { char szBondType[16]; sprintf(szBondType, "%d", bond_type); @@ -795,6 +796,61 @@ inp_ATOM *MakeInpAtomsFromMolfileData(MOL_FMT_DATA *mfdata, *num_bonds = bonds; + /* (@nnuk) : Handling haptic bonds */ + if (mfdata->ctab.v3000 && mfdata->ctab.v3000->n_haptic_bonds > 0 && + mfdata->ctab.v3000->haptic_bonds && mfdata->ctab.v3000->haptic_bonds->lists) + { + for (i = 0; i < mfdata->ctab.v3000->n_haptic_bonds; i++) + { + int* list = mfdata->ctab.v3000->haptic_bonds->lists[i]; + if (!list) + { + TREAT_ERR(*err, 0, "Null haptic bond list"); + continue; + } + + int bond_type = list[0]; + int central_atom = list[1]; + int endpoint_count = list[2]; + int central_idx = central_atom - 1; + + int endpoints_added = 0; + + for (int j = 0; j < endpoint_count; j++) + { + int n_endpoint = list[3 + j]; + int endpoint_idx = n_endpoint - 1; + + int central_at_num = at[central_idx].valence; + int endpoint_at_num = at[endpoint_idx].valence; + + p1 = is_in_the_list(at[central_idx].neighbor, (AT_NUMB)endpoint_idx, central_at_num); + p2 = is_in_the_list(at[endpoint_idx].neighbor, (AT_NUMB)central_idx, endpoint_at_num); + + if (central_at_num >= MAXVAL || endpoint_at_num >= MAXVAL) + { + fprintf(stderr, "Atom number exceeded when trying to add haptic bond between atoms %d and %d\n", central_idx, endpoint_idx); + continue; + } + + at[central_idx].neighbor[central_at_num] = endpoint_idx; + at[central_idx].bond_type[central_at_num] = COORDINATIVE_BOND; + at[central_idx].bond_stereo[central_at_num] = 0; + at[central_idx].valence++; + + at[endpoint_idx].neighbor[endpoint_at_num] = central_idx; + at[endpoint_idx].bond_type[endpoint_at_num] = COORDINATIVE_BOND; + at[endpoint_idx].bond_stereo[endpoint_at_num] = 0; + at[endpoint_idx].valence++; + + bonds++; + endpoints_added++; + } + } + + *num_bonds = bonds; + } + /* special valences */ calculate_valences(mfdata, at, num_atoms, bDoNotAddH, err, pStrErr); @@ -814,6 +870,35 @@ void calculate_valences(MOL_FMT_DATA *mfdata, int bNonMetal; int a1, a2, n1, n2, valence; AT_NUMB *p1; + int* coord_bonds_count = NULL; /* (@nnuk) :: Array to track coordination bonds for non - metals */ + + /* (@nnuk) :: Allocate memory for coordination bonds count */ + coord_bonds_count = (int*)inchi_calloc(*num_atoms, sizeof(int)); + if (!coord_bonds_count) + { + *err = -1; + TREAT_ERR(*err, 0, "Memory allocation failed for coord_bonds_count"); + return; + } + + /* (@nnuk : Nauman Ullah Khan) + * Count coordination bonds (type 9) for each non-metal atom + * Iterates through all atoms and their bonds to identify coordination bonds + * and tracks count per non-metal atom in coord_bonds_count array + */ + for (a1 = 0; a1 < *num_atoms; a1++) + { + if (!is_el_a_metal(at[a1].el_number)) + { + for (n1 = 0; n1 < at[a1].valence; n1++) + { + if (at[a1].bond_type[n1] == COORDINATIVE_BOND) + { + coord_bonds_count[a1]++; + } + } + } + } /* special valences */ @@ -848,7 +933,7 @@ void calculate_valences(MOL_FMT_DATA *mfdata, if (bond_type < 0 || bond_type > MAX_INPUT_BOND_TYPE - MIN_INPUT_BOND_TYPE) { bond_type = 0; - TREAT_ERR(*err, 0, "Unknown bond type in MOLfile assigned as a single bond"); + TREAT_ERR(*err, 0, "Unknown bond type or a COORDINATIVE BOND (9) in MOLfile assigned as a single bond"); /* @nnuk : Coordinative bond is accepted now and is assigned as a single bond */ } num_bond_type[bond_type]++; /* -- too a radical solution -- removed from next to ver 1.12B --- */ @@ -955,19 +1040,40 @@ void calculate_valences(MOL_FMT_DATA *mfdata, /* Set number of hydrogen atoms */ if (mfdata) { + int additional_H = coord_bonds_count[a1]; + + int newValence = -1; + + if (!is_el_a_metal(at[a1].el_number) && additional_H) + { + /*If the atom is a non - metal and has coordination bonds, adjust valence* / + /* (@fbaensch) : Get new valence based on element number, charge, and valence defined in input file */ + newValence = get_el_valence(at[a1].el_number, at[a1].charge, mfdata->ctab.atoms[a1].valence); + newValence += additional_H; + } + else + { + /* If the atom is a metal or has no coordination bonds, use the valence defined in input file */ + newValence = mfdata->ctab.atoms[a1].valence; + } + at[a1].num_H = get_num_H(at[a1].elname, at[a1].num_H, at[a1].num_iso_H, at[a1].charge, at[a1].radical, at[a1].chem_bonds_valence, - mfdata->ctab.atoms[a1].valence, /* instead of valence */ - mfdata->ctab.atoms[a1].atom_aliased_flag, + /*mfdata->ctab.atoms[a1].valence,*/ + newValence, /* instead of valence */ /* (@Felix Bänsch)(@Gerd Blanke)(@nnuk) : The valence stated in the mol file is considerd here. A value of 0 means use default value for this element. */ + mfdata->ctab.atoms[a1].atom_aliased_flag, bDoNotAddH, bHasMetalNeighbor); } } } /* for ( bNonMetal = ... */ + /* (@nnuk) : Free allocated memory */ + free(coord_bonds_count); + return; } diff --git a/INCHI-1-SRC/INCHI_BASE/src/mol_fmt3.c b/INCHI-1-SRC/INCHI_BASE/src/mol_fmt3.c index 2369663a..888a78ee 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/mol_fmt3.c +++ b/INCHI-1-SRC/INCHI_BASE/src/mol_fmt3.c @@ -1225,7 +1225,7 @@ int MolfileV3000ReadAtomsBlock(MOL_FMT_CTAB *ctab, if (ctab->v3000->n_star_atoms) { - AddErrorMessage(pStrErr, "V3000 star atoms ignored"); + AddErrorMessage(pStrErr, "V3000 star atoms ignored if MolecularInorganics or NPZz parameter not used"); /* @nnuk : when using /MolecularInorganics or /NPZz, star atoms will not be ignored */ ctab->n_atoms = ctab->v3000->n_non_star_atoms; } @@ -1467,7 +1467,7 @@ int MolfileV3000ReadBondsBlock(MOL_FMT_CTAB *ctab, existent_atom = atnum2; } if (existent_atom < 0) /* should not be here */ - { + { failed = 1; } else @@ -1475,7 +1475,7 @@ int MolfileV3000ReadBondsBlock(MOL_FMT_CTAB *ctab, int k, nnum; nnum = num_list[2]; num_list[1] = existent_atom; - for (k = 3; k < nnum; k++) + for (k = 3; k < nnum + 3; k++) /* @nnuk : wrong mapping of endpoints (+3 added for full endpoints mapping for all haptic bonds) */ { num_list[k] = get_actual_atom_number(num_list[k], n_orig_at, @@ -1548,7 +1548,7 @@ int MolfileV3000ReadBondsBlock(MOL_FMT_CTAB *ctab, if (ctab->v3000->n_haptic_bonds) { - AddErrorMessage(pStrErr, "V3000 haptic bonds read/stored but ignored"); + AddErrorMessage(pStrErr, "V3000 haptic bonds read/stored and ignored if MolecularInorganics or NPZz parameter is not used"); /* @nnuk : when using /MolecularInorganics or /NPZz, haptic bonds will not be ignored */ ctab->n_bonds = ctab->v3000->n_non_haptic_bonds; } diff --git a/INCHI-1-SRC/INCHI_BASE/src/runichi.c b/INCHI-1-SRC/INCHI_BASE/src/runichi.c index a5dc9e1c..2aa3bb5e 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/runichi.c +++ b/INCHI-1-SRC/INCHI_BASE/src/runichi.c @@ -75,127 +75,127 @@ #include "bcf_s.h" -extern int DisplayTheWholeStructure( struct tagCANON_GLOBALS *pCG, - struct tagINCHI_CLOCK *ic, - struct tagStructData *sd, - INPUT_PARMS *ip, - char *szTitle, - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - ORIG_ATOM_DATA *orig_inp_data, - long num_inp, - int iINChI, - int bShowStruct, - int bINCHI_LIB_Flag ); - -extern int DisplayStructure( struct tagCANON_GLOBALS *pCG, - inp_ATOM *at, - int num_at, - OAD_Polymer *polymer, - int num_removed_H, - int bAdd_DT_to_num_H, - int nNumRemovedProtons, - NUM_H *nNumRemovedProtonsIsotopic, - int bIsotopic, - int j /*bTautomeric*/, - INChI **cur_INChI, - INChI_Aux **cur_INChI_Aux, - int bAbcNumbers, - DRAW_PARMS *dp, - INCHI_MODE nMode, - char *szTitle ); - -extern int ReadInChICoord( INCHI_IOSTREAM *pInp, - SEGM_LINE *pLine, - int *pState, - INChI *pInpInChI[INCHI_NUM][TAUT_NUM], - int nNumComponents[INCHI_NUM][TAUT_NUM] ); +extern int DisplayTheWholeStructure(struct tagCANON_GLOBALS* pCG, + struct tagINCHI_CLOCK* ic, + struct tagStructData* sd, + INPUT_PARMS* ip, + char* szTitle, + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + ORIG_ATOM_DATA* orig_inp_data, + long num_inp, + int iINChI, + int bShowStruct, + int bINCHI_LIB_Flag); + +extern int DisplayStructure(struct tagCANON_GLOBALS* pCG, + inp_ATOM* at, + int num_at, + OAD_Polymer* polymer, + int num_removed_H, + int bAdd_DT_to_num_H, + int nNumRemovedProtons, + NUM_H* nNumRemovedProtonsIsotopic, + int bIsotopic, + int j /*bTautomeric*/, + INChI** cur_INChI, + INChI_Aux** cur_INChI_Aux, + int bAbcNumbers, + DRAW_PARMS* dp, + INCHI_MODE nMode, + char* szTitle); + +extern int ReadInChICoord(INCHI_IOSTREAM* pInp, + SEGM_LINE* pLine, + int* pState, + INChI* pInpInChI[INCHI_NUM][TAUT_NUM], + int nNumComponents[INCHI_NUM][TAUT_NUM]); /* Local functions */ -static int DoOneStructureEarlyPreprocessing( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - long num_inp, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data ); +static int DoOneStructureEarlyPreprocessing(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + long num_inp, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data); /* Actual worker sitting under ProcessOneStructureEx */ -int ProcessOneStructureExCore( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits ); +int ProcessOneStructureExCore(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits); static ORIG_STRUCT* -OrigAtData_StoreNativeInput( CANON_GLOBALS *pCG, - int *nRet, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct ); -static void PrepareSaveOptBits( unsigned char *save_opt_bits, - INPUT_PARMS *ip ); - -static void DisplayOrigAndResultStructuresAndComponents( int nRet, - INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux[INCHI_NUM], - INCHI_IOSTREAM *inp_file, INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - int maxINChI, - COMP_ATOM_DATA composite_norm_data[INCHI_NUM][TAUT_NUM + 1] ); -static void SaveOkProcessedMolfile( int nRet, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - INCHI_IOSTREAM *prb_file, - INCHI_IOSTREAM *inp_file ); - -static int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, - OAD_StructureEdits *ed, - int *at_renum); -static int set_renumbered_or_delete( int *number, - int *buf, - int nelems, - int *renum, - int base ); - -static void swap_atoms_xyz( ORIG_ATOM_DATA *orig_at_data, int ia1, int ia2 ); +OrigAtData_StoreNativeInput(CANON_GLOBALS* pCG, + int* nRet, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_STRUCT* pOrigStruct); +static void PrepareSaveOptBits(unsigned char* save_opt_bits, + INPUT_PARMS* ip); + +static void DisplayOrigAndResultStructuresAndComponents(int nRet, + INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI[INCHI_NUM], + PINChI_Aux2* pINChI_Aux[INCHI_NUM], + INCHI_IOSTREAM* inp_file, INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + int maxINChI, + COMP_ATOM_DATA composite_norm_data[INCHI_NUM][TAUT_NUM + 1]); +static void SaveOkProcessedMolfile(int nRet, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + INCHI_IOSTREAM* prb_file, + INCHI_IOSTREAM* inp_file); + +static int mark_atoms_to_delete_or_renumber(ORIG_ATOM_DATA* orig_at_data, + OAD_StructureEdits* ed, + int* at_renum); +static int set_renumbered_or_delete(int* number, + int* buf, + int nelems, + int* renum, + int base); + +static void swap_atoms_xyz(ORIG_ATOM_DATA* orig_at_data, int ia1, int ia2); /* Callbacks */ /* Console user issued CTRL+C etc. */ -int( *ConsoleQuit )( void ) = NULL; -int( *UserAction ) ( void ) = NULL; +int(*ConsoleQuit)(void) = NULL; +int(*UserAction) (void) = NULL; #if (BUILD_WITH_ENG_OPTIONS==1) #if ALLOW_SUBSTRUCTURE_FILTERING==1 -static int OrigAtData_CheckForSubstructure(ORIG_ATOM_DATA *orig_inp_data); +static int OrigAtData_CheckForSubstructure(ORIG_ATOM_DATA* orig_inp_data); #endif #endif @@ -215,22 +215,22 @@ const char gsEqual[] = "="; Process a portion of input data (molecule, InChI string, ...) in a relevant way (generate InChI, restore molecule by InChI ) ****************************************************************************/ -int ProcessOneStructure( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits ) +int ProcessOneStructure(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI[INCHI_NUM], + PINChI_Aux2* pINChI_Aux[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits) { int nRet = 0, nRet1, i, k, @@ -241,9 +241,9 @@ int ProcessOneStructure( INCHI_CLOCK *ic, [1]:taut, [2]:intermediate taut struct */ NORM_CANON_FLAGS ncFlags; - NORM_CANON_FLAGS *pncFlags = &ncFlags; + NORM_CANON_FLAGS* pncFlags = &ncFlags; ORIG_STRUCT OrigStruct; - ORIG_STRUCT *pOrigStruct = NULL; + ORIG_STRUCT* pOrigStruct = NULL; int err, ret1 = 0; /* djb-rwth: removing redundant code */ @@ -256,116 +256,184 @@ int ProcessOneStructure( INCHI_CLOCK *ic, /* 1. Preliminary work */ int is_polymer = orig_inp_data - && orig_inp_data->valid_polymer - && orig_inp_data->polymer - && orig_inp_data->polymer->n ; + && orig_inp_data->valid_polymer + && orig_inp_data->polymer + && orig_inp_data->polymer->n; - int is_polymer2inchi = is_polymer && ( ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE ); + int is_polymer2inchi = is_polymer && (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE); sd->bUserQuitComponent = 0; sd->bUserQuitComponentDisplay = 0; - memset( composite_norm_data, 0, sizeof( composite_norm_data ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( pncFlags, 0, sizeof( *pncFlags ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(composite_norm_data, 0, sizeof(composite_norm_data)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pncFlags, 0, sizeof(*pncFlags)); /* djb-rwth: memset_s C11/Annex K variant? */ + - /* For experimental purposes only */ /*ret1 = DoOneStructureEarlyPreprocessing( num_inp, sd, ip, inp_file, log_file, out_file, prb_file, orig_inp_data, prep_inp_data ); */ - ret1 = DoOneStructureEarlyPreprocessing( ic, pCG, num_inp, sd, ip, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data ); - switch (ret1) + ret1 = DoOneStructureEarlyPreprocessing(ic, pCG, num_inp, sd, ip, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data); + switch ( ret1 ) { - case _IS_SKIP: - case _IS_ERROR: - case _IS_FATAL: - nRet = ret1; + case _IS_SKIP: + case _IS_ERROR: + case _IS_FATAL: + nRet = ret1; } - if (ret1) + if ( ret1 ) { goto exit_function; } + /*(@nnuk : Nauman Ullah Khan) + *invoking Molecular Inorganics preprocessing (if flag is active) + */ + if ( ip->bMolecularInorganics && nRet != _IS_FATAL && nRet != _IS_ERROR ) + { + /* Call the MolecularInorganicsPreprocessing function to handle specific inorganics-related tasks */ + ret1 = MolecularInorganicsPreprocessing(orig_inp_data, ip); + + /* Check for errors during preprocessing */ + if ( ret1 < 0 ) + { + /* Log and handle fatal error in molecular inorganics preprocessing */ + fprintf(stderr, "Error during Molecular Inorganics preprocessing\n"); + AddErrorMessage(sd->pStrErrStruct, "Molecular Inorganics preprocessing failed"); + nRet = _IS_FATAL; + goto exit_function; + } + + /*// Debugging: Print atom structure after disconnections + for (int i = 0; i < orig_inp_data->num_inp_atoms; i++) + { + printf("Atom %d: Element %s, Valence: %d, Charge: %d, Num of Implicit H: %d, Neighbors: ", + i + 1, orig_inp_data->at[i].elname, orig_inp_data->at[i].valence, orig_inp_data->at[i].charge, orig_inp_data->at[i].num_H); + for (int j = 0; j < orig_inp_data->at[i].valence; j++) + { + printf("%d ", orig_inp_data->at[i].neighbor[j] + 1); + } + printf("\n"); + }*/ + + /*printf("Molecular inorganics preprocessing completed successfully.\n");*/ + nRet1 = CreateOneStructureINChI(pCG, ic, sd, ip, szTitle, + pINChI, pINChI_Aux, INCHI_BAS, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + composite_norm_data, + num_inp, strbuf, pncFlags); + nRet = inchi_max(nRet, nRet1); + + /* If preprocessing indicates we need a reconnected InChI, create it here */ + if ( ip->bMolecularInorganicsReconnectedInChI && nRet != _IS_FATAL && + nRet != _IS_ERROR && + (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE) && + (ip->bTautFlags & TG_FLAG_RECONNECT_COORD) ) + { + /*printf("Generating reconnected InChI due to retained bonds.\n");*/ + + nRet1 = CreateOneStructureINChI(pCG, ic, sd, ip, szTitle, + pINChI, pINChI_Aux, INCHI_REC, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + composite_norm_data, + num_inp, strbuf, pncFlags); + nRet = inchi_max(nRet, nRet1); + + if ( nRet1 == _IS_FATAL || nRet1 == _IS_ERROR ) + { + fprintf(stderr, "Error during reconnected InChI generation.\n"); + goto exit_function; + } + + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) + { + maxINChI = 2; /* Update to indicate reconnected InChI has been generated */ + } + } + } + - if (is_polymer) + if ( is_polymer ) { /* Polymer house-keeping related to possible CRU frame shift(s) */ orig_inp_data->polymer->frame_shift_scheme = ip->bFrameShiftScheme; orig_inp_data->polymer->treat = ip->bPolymers; - if (!is_polymer2inchi) + if ( !is_polymer2inchi ) { /* Polymer structure is being restored from InChI string */ /* If CRUs were pre-cyclized, re-open them in preferred forms here */ - if (orig_inp_data->polymer->frame_shift_scheme == FSS_STARS_CYCLED) + if ( orig_inp_data->polymer->frame_shift_scheme == FSS_STARS_CYCLED ) { - OAD_Polymer_SmartReopenCyclizedUnits( orig_inp_data->polymer, - orig_inp_data->at, - orig_inp_data->num_inp_atoms, - &orig_inp_data->num_inp_bonds ); + OAD_Polymer_SmartReopenCyclizedUnits(orig_inp_data->polymer, + orig_inp_data->at, + orig_inp_data->num_inp_atoms, + &orig_inp_data->num_inp_bonds); } } } - ret1 = OrigAtData_SaveMolfile( orig_inp_data, sd, ip, num_inp, out_file ); - if (ret1) + ret1 = OrigAtData_SaveMolfile(orig_inp_data, sd, ip, num_inp, out_file); + if ( ret1 ) { goto exit_function; } pOrigStruct = &OrigStruct; - memset( pOrigStruct, 0, sizeof( *pOrigStruct ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pOrigStruct, 0, sizeof(*pOrigStruct)); /* djb-rwth: memset_s C11/Annex K variant? */ - OrigAtData_StoreNativeInput( pCG, &nRet, sd, ip, orig_inp_data, pOrigStruct ); + OrigAtData_StoreNativeInput(pCG, &nRet, sd, ip, orig_inp_data, pOrigStruct); /* 2. Create INChI for the whole disconnected or original structure */ - if (nRet != _IS_FATAL && nRet != _IS_ERROR) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) { - nRet1 = CreateOneStructureINChI( pCG, ic, sd, ip, szTitle, - pINChI, pINChI_Aux, INCHI_BAS, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - composite_norm_data, - num_inp, strbuf, pncFlags ); - nRet = inchi_max( nRet, nRet1 ); + nRet1 = CreateOneStructureINChI(pCG, ic, sd, ip, szTitle, + pINChI, pINChI_Aux, INCHI_BAS, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + composite_norm_data, + num_inp, strbuf, pncFlags); + nRet = inchi_max(nRet, nRet1); /* If we create InChI from polymer-containing structure */ - if (is_polymer2inchi) + if ( is_polymer2inchi ) { - int polymer_repr_type = OAD_Polymer_GetRepresentation( orig_inp_data->polymer ); + int polymer_repr_type = OAD_Polymer_GetRepresentation(orig_inp_data->polymer); #ifdef ALLOW_MIXED_SRU_AND_MON - if (polymer_repr_type == POLYMER_REPRESENTATION_STRUCTURE_BASED || - polymer_repr_type == POLYMER_REPRESENTATION_MIXED) + if ( polymer_repr_type == POLYMER_REPRESENTATION_STRUCTURE_BASED || + polymer_repr_type == POLYMER_REPRESENTATION_MIXED ) #else - if (polymer_repr_type == POLYMER_REPRESENTATION_STRUCTURE_BASED) + if ( polymer_repr_type == POLYMER_REPRESENTATION_STRUCTURE_BASED ) #endif { /* Temporarily copy ptr to polymer data to prep_inp_data */ - OAD_Polymer *prep_polymer = prep_inp_data->polymer; /* may be NULL */ + OAD_Polymer* prep_polymer = prep_inp_data->polymer; /* may be NULL */ prep_inp_data->polymer = orig_inp_data->polymer; - OAD_Polymer_FindBackbones( prep_inp_data, /* NB: not orig_inp_data! */ - &( composite_norm_data[INCHI_BAS][TAUT_YES] ), - &err, sd->pStrErrStruct ); - if (err) + OAD_Polymer_FindBackbones(prep_inp_data, /* NB: not orig_inp_data! */ + &(composite_norm_data[INCHI_BAS][TAUT_YES]), + &err, sd->pStrErrStruct); + if ( err ) { ret1 = _IS_ERROR; } - nRet = inchi_max( nRet, ret1 ); + nRet = inchi_max(nRet, ret1); prep_inp_data->polymer = prep_polymer; /* restore temp copied*/ } } } - if (nRet != _IS_FATAL && nRet != _IS_ERROR) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) { maxINChI = 1; } @@ -373,104 +441,104 @@ int ProcessOneStructure( INCHI_CLOCK *ic, /* 3. Create INChI for the whole metal-reconnected structure */ - if (nRet != _IS_FATAL && - nRet != _IS_ERROR && - ( sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE ) && - ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD )) + if ( nRet != _IS_FATAL && + nRet != _IS_ERROR && + (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE) && + (ip->bTautFlags & TG_FLAG_RECONNECT_COORD) ) { - nRet1 = CreateOneStructureINChI( pCG, ic, sd, ip, szTitle, - pINChI, pINChI_Aux, INCHI_REC, inp_file, - log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - composite_norm_data, - num_inp, strbuf, pncFlags ); - nRet = inchi_max( nRet, nRet1 ); + nRet1 = CreateOneStructureINChI(pCG, ic, sd, ip, szTitle, + pINChI, pINChI_Aux, INCHI_REC, inp_file, + log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + composite_norm_data, + num_inp, strbuf, pncFlags); + nRet = inchi_max(nRet, nRet1); - if (is_polymer2inchi) + if ( is_polymer2inchi ) { ret1 = 0; /* temporarily copy ptr to polymer data to prep_inp_data */ prep_inp_data->polymer = orig_inp_data->polymer; - OAD_Polymer_FindBackbones( prep_inp_data, /* NB: not orig_inp_data! */ - &( composite_norm_data[INCHI_REC][TAUT_YES] ), - &err, sd->pStrErrStruct ); - if (err) + OAD_Polymer_FindBackbones(prep_inp_data, /* NB: not orig_inp_data! */ + &(composite_norm_data[INCHI_REC][TAUT_YES]), + &err, sd->pStrErrStruct); + if ( err ) { ret1 = _IS_ERROR; } - nRet = inchi_max( nRet, ret1 ); + nRet = inchi_max(nRet, ret1); prep_inp_data->polymer = NULL; /* remove temp copied */ } - if (nRet != _IS_FATAL && nRet != _IS_ERROR) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) { maxINChI = 2; } } - if (nRet != _IS_FATAL && nRet != _IS_ERROR) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) { - if (( sd->bChiralFlag & FLAG_INP_AT_CHIRAL ) && - ( ip->nMode & REQ_MODE_STEREO ) && - !( ip->nMode & ( REQ_MODE_RELATIVE_STEREO | REQ_MODE_RACEMIC_STEREO ) ) && - !bIsStructChiral( pINChI, sd->num_components )) + if ( (sd->bChiralFlag & FLAG_INP_AT_CHIRAL) && + (ip->nMode & REQ_MODE_STEREO) && + !(ip->nMode & (REQ_MODE_RELATIVE_STEREO | REQ_MODE_RACEMIC_STEREO)) && + !bIsStructChiral(pINChI, sd->num_components) ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Not chiral" ); + WarningMessage(sd->pStrErrStruct, "Not chiral"); } } - if (!sd->bUserQuitComponent && !sd->bUserQuit) + if ( !sd->bUserQuitComponent && !sd->bUserQuit ) { - nRet1 = TreatCreateINChIWarning( sd, ip, prep_inp_data, num_inp, - inp_file, log_file, out_file, prb_file ); - nRet = inchi_max( nRet, nRet1 ); + nRet1 = TreatCreateINChIWarning(sd, ip, prep_inp_data, num_inp, + inp_file, log_file, out_file, prb_file); + nRet = inchi_max(nRet, nRet1); } } /* 4. Sort and print INChI for the whole structure */ - PrepareSaveOptBits( &save_opt_bits, ip ); - if (nRet != _IS_FATAL && nRet != _IS_ERROR) + PrepareSaveOptBits(&save_opt_bits, ip); + if ( nRet != _IS_FATAL && nRet != _IS_ERROR ) { - nRet1 = SortAndPrintINChI( pCG, out_file, strbuf, log_file, ip, - orig_inp_data, prep_inp_data, - composite_norm_data, - pOrigStruct, sd->num_components, - sd->num_non_taut, sd->num_taut, - sd->bTautFlags, sd->bTautFlagsDone, - pncFlags, num_inp, - pINChI, pINChI_Aux, - &bSortPrintINChIFlags, save_opt_bits ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + nRet1 = SortAndPrintINChI(pCG, out_file, strbuf, log_file, ip, + orig_inp_data, prep_inp_data, + composite_norm_data, + pOrigStruct, sd->num_components, + sd->num_non_taut, sd->num_taut, + sd->bTautFlags, sd->bTautFlagsDone, + pncFlags, num_inp, + pINChI, pINChI_Aux, + &bSortPrintINChIFlags, save_opt_bits); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ } /* 5. Post-process */ - DisplayOrigAndResultStructuresAndComponents( nRet, ic, pCG, sd, ip, szTitle, - pINChI, pINChI_Aux, - inp_file, log_file, out_file, - orig_inp_data, prep_inp_data, - num_inp, maxINChI, - composite_norm_data ); + DisplayOrigAndResultStructuresAndComponents(nRet, ic, pCG, sd, ip, szTitle, + pINChI, pINChI_Aux, + inp_file, log_file, out_file, + orig_inp_data, prep_inp_data, + num_inp, maxINChI, + composite_norm_data); - SaveOkProcessedMolfile( nRet, sd, ip, prb_file, inp_file ); + SaveOkProcessedMolfile(nRet, sd, ip, prb_file, inp_file); /* Cleanup */ - for (i = 0; i < INCHI_NUM; i++) + for ( i = 0; i < INCHI_NUM; i++ ) { - for (k = 0; k < TAUT_NUM + 1; k++) + for ( k = 0; k < TAUT_NUM + 1; k++ ) { - FreeCompAtomData( &composite_norm_data[i][k] ); + FreeCompAtomData(&composite_norm_data[i][k]); } } - OrigStruct_Free( pOrigStruct ); + OrigStruct_Free(pOrigStruct); exit_function: @@ -485,17 +553,17 @@ int ProcessOneStructure( INCHI_CLOCK *ic, ****************************************************************************/ -int DoOneStructureEarlyPreprocessing( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - long num_inp, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data ) +int DoOneStructureEarlyPreprocessing(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + long num_inp, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data) { #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 ) @@ -503,49 +571,49 @@ int DoOneStructureEarlyPreprocessing( INCHI_CLOCK *ic, #endif #if ( REMOVE_ION_PAIRS_ORIG_STRU == 1 ) - fix_odd_things( orig_inp_data->num_inp_atoms, orig_inp_data->at, 0, ip->bFixNonUniformDraw ); + fix_odd_things(orig_inp_data->num_inp_atoms, orig_inp_data->at, 0, ip->bFixNonUniformDraw); #endif #if ( UNDERIVATIZE == 1 ) - if (ip->bUnderivatize) + if ( ip->bUnderivatize ) { - if (0 > ( ret2 = OAD_Edit_Underivatize( ic, pCG, orig_inp_data, ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY ), ip->bUnderivatize & 2, ip->pSdfValue ) )) + if ( 0 > (ret2 = OAD_Edit_Underivatize(ic, pCG, orig_inp_data, (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY), ip->bUnderivatize & 2, ip->pSdfValue)) ) { long num_inp2 = num_inp; - AddErrorMessage( sd->pStrErrStruct, "Underivatization error" ); + AddErrorMessage(sd->pStrErrStruct, "Underivatization error"); sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; - TreatErrorsInReadTheStructure( sd, ip, LOG_MASK_ALL, inp_file, log_file, out_file, prb_file, - prep_inp_data, &num_inp2 ); + TreatErrorsInReadTheStructure(sd, ip, LOG_MASK_ALL, inp_file, log_file, out_file, prb_file, + prep_inp_data, &num_inp2); return _IS_ERROR; /* output only if derivatives found */ } - else if (0 < ret2) + else if ( 0 < ret2 ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Input structure underivatized" ); + WarningMessage(sd->pStrErrStruct, "Input structure underivatized"); } } } #endif /* UNDERIVATIZE == 1 */ #if ( RING2CHAIN == 1 ) - if (ip->bRing2Chain && 0 > ( ret1 = Ring2Chain( ic, pCG, orig_inp_data ) )) + if ( ip->bRing2Chain && 0 > (ret1 = Ring2Chain(ic, pCG, orig_inp_data)) ) { long num_inp2 = num_inp; - AddErrorMessage( sd->pStrErrStruct, "Ring to chain error" ); + AddErrorMessage(sd->pStrErrStruct, "Ring to chain error"); sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; /* djb-rwth: removing redundant code */ - TreatErrorsInReadTheStructure( sd, ip, LOG_MASK_ALL, - inp_file, log_file, - out_file, prb_file, - prep_inp_data, &num_inp2 ); + TreatErrorsInReadTheStructure(sd, ip, LOG_MASK_ALL, + inp_file, log_file, + out_file, prb_file, + prep_inp_data, &num_inp2); return _IS_ERROR; /* output only if derivatives found */ } #endif /* RING2CHAIN == 1 */ #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 ) /***** post v.1 feature *****/ - if (ip->bIgnoreUnchanged && !ret1 && !ret2) + if ( ip->bIgnoreUnchanged && !ret1 && !ret2 ) { return _IS_SKIP; /* output only if derivatives or ring/chain found */ } @@ -556,15 +624,15 @@ int DoOneStructureEarlyPreprocessing( INCHI_CLOCK *ic, /* If requested, save input data to a Molfile instead of creating INChI */ /* Also used for output in case of combination of options 'InChI2Struct' and 'OutputSDF' */ -int OrigAtData_SaveMolfile( ORIG_ATOM_DATA *orig_inp_data, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - long num_inp, - INCHI_IOSTREAM *out_file ) +int OrigAtData_SaveMolfile(ORIG_ATOM_DATA* orig_inp_data, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + long num_inp, + INCHI_IOSTREAM* out_file) { int ret = 0; - if (!( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY )) + if ( !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) ) { return _IS_OKAY; } @@ -572,10 +640,10 @@ int OrigAtData_SaveMolfile( ORIG_ATOM_DATA *orig_inp_data, { char szNumber[256]; sprintf(szNumber, "Structure #%ld. %s%s%s%s", num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); - ret = OrigAtData_WriteToSDfile( orig_inp_data, out_file, szNumber, NULL, - ( sd->bChiralFlag&FLAG_INP_AT_CHIRAL ) ? 1 : 0, - ( ip->bINChIOutputOptions&INCHI_OUT_SDFILE_ATOMS_DT ) ? 1 : 0, - ip->pSdfLabel, ip->pSdfValue ); + ret = OrigAtData_WriteToSDfile(orig_inp_data, out_file, szNumber, NULL, + (sd->bChiralFlag & FLAG_INP_AT_CHIRAL) ? 1 : 0, + (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ATOMS_DT) ? 1 : 0, + ip->pSdfLabel, ip->pSdfValue); } return ret; @@ -585,12 +653,12 @@ int OrigAtData_SaveMolfile( ORIG_ATOM_DATA *orig_inp_data, /**************************************************************************** Optionally save native input data as 'OrigStruct' data package ****************************************************************************/ -ORIG_STRUCT * OrigAtData_StoreNativeInput( CANON_GLOBALS *pCG, - int *nRet, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_STRUCT *pOrigStruct ) +ORIG_STRUCT* OrigAtData_StoreNativeInput(CANON_GLOBALS* pCG, + int* nRet, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_STRUCT* pOrigStruct) { /* v. 1.05 always create and fill OrigStruc as it may be used to store e.g. polymer info */ @@ -598,9 +666,9 @@ ORIG_STRUCT * OrigAtData_StoreNativeInput( CANON_GLOBALS *pCG, if ( ip->bINChIOutputOptions & (INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO)) return NULL; */ - if (OrigStruct_FillOut( pCG, orig_inp_data, pOrigStruct, sd )) + if ( OrigStruct_FillOut(pCG, orig_inp_data, pOrigStruct, sd) ) { - AddErrorMessage( sd->pStrErrStruct, "Cannot interpret reversibility information" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot interpret reversibility information"); sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; *nRet = _IS_ERROR; @@ -613,54 +681,54 @@ ORIG_STRUCT * OrigAtData_StoreNativeInput( CANON_GLOBALS *pCG, /**************************************************************************** Prepare SaveOpt bits ****************************************************************************/ -void PrepareSaveOptBits( unsigned char *save_opt_bits, INPUT_PARMS *ip ) +void PrepareSaveOptBits(unsigned char* save_opt_bits, INPUT_PARMS* ip) { - if (ip->nInputType != INPUT_INCHI) + if ( ip->nInputType != INPUT_INCHI ) { *save_opt_bits = 0; - if (ip->bINChIOutputOptions & INCHI_OUT_SAVEOPT) + if ( ip->bINChIOutputOptions & INCHI_OUT_SAVEOPT ) { - if (0 != ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD )) + if ( 0 != (ip->bTautFlags & TG_FLAG_RECONNECT_COORD) ) { - ( *save_opt_bits ) |= SAVE_OPT_RECMET; + (*save_opt_bits) |= SAVE_OPT_RECMET; } - if (0 != ( ip->nMode & REQ_MODE_BASIC )) + if ( 0 != (ip->nMode & REQ_MODE_BASIC) ) { - ( *save_opt_bits ) |= SAVE_OPT_FIXEDH; + (*save_opt_bits) |= SAVE_OPT_FIXEDH; } - if (0 != ( ip->nMode & REQ_MODE_DIFF_UU_STEREO )) + if ( 0 != (ip->nMode & REQ_MODE_DIFF_UU_STEREO) ) { - ( *save_opt_bits ) |= SAVE_OPT_SLUUD; + (*save_opt_bits) |= SAVE_OPT_SLUUD; } - if (0 == ( ip->nMode & ( REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU ) )) + if ( 0 == (ip->nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) ) { - ( *save_opt_bits ) |= SAVE_OPT_SUU; + (*save_opt_bits) |= SAVE_OPT_SUU; } - if (0 != ( ip->bTautFlags & TG_FLAG_KETO_ENOL_TAUT )) + if ( 0 != (ip->bTautFlags & TG_FLAG_KETO_ENOL_TAUT) ) { - ( *save_opt_bits ) |= SAVE_OPT_KET; + (*save_opt_bits) |= SAVE_OPT_KET; } - if (0 != ( ip->bTautFlags & TG_FLAG_1_5_TAUT )) + if ( 0 != (ip->bTautFlags & TG_FLAG_1_5_TAUT) ) { - ( *save_opt_bits ) |= SAVE_OPT_15T; + (*save_opt_bits) |= SAVE_OPT_15T; } - if (0 != (ip->bTautFlags & TG_FLAG_PT_22_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_22_00) ) (*save_opt_bits) |= SAVE_OPT_PT_22_00; - if (0 != (ip->bTautFlags & TG_FLAG_PT_16_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_16_00) ) (*save_opt_bits) |= SAVE_OPT_PT_16_00; - if (0 != (ip->bTautFlags & TG_FLAG_PT_06_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_06_00) ) (*save_opt_bits) |= SAVE_OPT_PT_06_00; - if (0 != (ip->bTautFlags & TG_FLAG_PT_39_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_39_00) ) (*save_opt_bits) |= SAVE_OPT_PT_39_00; - if (0 != (ip->bTautFlags & TG_FLAG_PT_13_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_13_00) ) (*save_opt_bits) |= SAVE_OPT_PT_13_00; - if (0 != (ip->bTautFlags & TG_FLAG_PT_18_00)) + if ( 0 != (ip->bTautFlags & TG_FLAG_PT_18_00) ) (*save_opt_bits) |= SAVE_OPT_PT_18_00; /* Check if /SNon requested and turn OFF stereo bits if so */ - if (!( ip->nMode & REQ_MODE_STEREO )) + if ( !(ip->nMode & REQ_MODE_STEREO) ) { - ( *save_opt_bits ) &= ~SAVE_OPT_SUU; - ( *save_opt_bits ) &= ~SAVE_OPT_SLUUD; + (*save_opt_bits) &= ~SAVE_OPT_SUU; + (*save_opt_bits) &= ~SAVE_OPT_SLUUD; } } } @@ -670,75 +738,75 @@ void PrepareSaveOptBits( unsigned char *save_opt_bits, INPUT_PARMS *ip ) /**************************************************************************** Display structures/components on screen ****************************************************************************/ -void DisplayOrigAndResultStructuresAndComponents( int nRet, - INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - int maxINChI, - COMP_ATOM_DATA composite_norm_data[INCHI_NUM][TAUT_NUM + 1] ) +void DisplayOrigAndResultStructuresAndComponents(int nRet, + INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI[INCHI_NUM], + PINChI_Aux2* pINChI_Aux[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + int maxINChI, + COMP_ATOM_DATA composite_norm_data[INCHI_NUM][TAUT_NUM + 1]) { - if (ip->bDisplay) ip->bDisplayCompositeResults = 1; /* v. 1.05 */ + if ( ip->bDisplay ) ip->bDisplayCompositeResults = 1; /* v. 1.05 */ #ifndef COMPILE_ANSI_ONLY /* { */ /* Display equivalent components on original or preprocessed structure(s) */ #ifndef TARGET_LIB_FOR_WINCHI - if (nRet != _IS_FATAL && nRet != _IS_ERROR && /*ip->bDisplay &&*/ - ( ip->bCompareComponents & CMP_COMPONENTS ) && !sd->bUserQuit && !sd->bUserQuitComponent) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR && /*ip->bDisplay &&*/ + (ip->bCompareComponents & CMP_COMPONENTS) && !sd->bUserQuit && !sd->bUserQuitComponent ) { int j, ret, ord; int bDisplaySaved = ip->bDisplay; - ORIG_ATOM_DATA *inp_data; + ORIG_ATOM_DATA* inp_data; AT_NUMB nEquSet; - for (ord = -1; ord < INCHI_NUM; ord++) + for ( ord = -1; ord < INCHI_NUM; ord++ ) { - switch (ord) + switch ( ord ) { - case -1: - j = INCHI_BAS; /* preprocessed non-tautomeric */ - break; - case 0: - j = INCHI_REC; /* preprocessed tautomeric */ - break; - case 1: - j = -1; /* original input */ - break; - default: - continue; + case -1: + j = INCHI_BAS; /* preprocessed non-tautomeric */ + break; + case 0: + j = INCHI_REC; /* preprocessed tautomeric */ + break; + case 1: + j = -1; /* original input */ + break; + default: + continue; } inp_data = j < 0 ? orig_inp_data : prep_inp_data + j; - if (inp_data && inp_data->num_inp_atoms && inp_data->at && - inp_data->nEquLabels && - inp_data->nNumEquSets) + if ( inp_data && inp_data->num_inp_atoms && inp_data->at && + inp_data->nEquLabels && + inp_data->nNumEquSets ) { - for (nEquSet = 1; nEquSet <= inp_data->nNumEquSets; nEquSet++) + for ( nEquSet = 1; nEquSet <= inp_data->nNumEquSets; nEquSet++ ) { ip->dp.nEquLabels = inp_data->nEquLabels; ip->dp.nCurEquLabel = nEquSet; ip->dp.nNumEquSets = inp_data->nNumEquSets; ip->bDisplay = 1; /* force display if it was not requested */ - ret = DisplayTheWholeStructure( pCG, ic, sd, ip, szTitle, - inp_file, log_file, inp_data, - num_inp, j, 1 /*bShowStructure*/, 0 ); + ret = DisplayTheWholeStructure(pCG, ic, sd, ip, szTitle, + inp_file, log_file, inp_data, + num_inp, j, 1 /*bShowStructure*/, 0); ip->dp.nEquLabels = NULL; ip->dp.nCurEquLabel = 0; ip->dp.nNumEquSets = 0; ip->bDisplay = bDisplaySaved; /* restore display option */ - if (ret) + if ( ret ) { - /* user pressed Esc */ + /* user pressed Esc */ goto exit_loop; } } @@ -749,17 +817,17 @@ void DisplayOrigAndResultStructuresAndComponents( int nRet, #endif /* Display composite results and equivalent components on composite results */ - if (nRet != _IS_FATAL && nRet != _IS_ERROR && /*ip->bDisplay &&*/ ip->bDisplayCompositeResults) + if ( nRet != _IS_FATAL && nRet != _IS_ERROR && /*ip->bDisplay &&*/ ip->bDisplayCompositeResults ) { int iINChI; - for (iINChI = 0; iINChI < maxINChI && !sd->bUserQuitComponentDisplay; iINChI++) + for ( iINChI = 0; iINChI < maxINChI && !sd->bUserQuitComponentDisplay; iINChI++ ) { - DisplayTheWholeCompositeStructure( pCG, ic, ip, sd, num_inp, - iINChI, pINChI[iINChI], pINChI_Aux[iINChI], - orig_inp_data, prep_inp_data, composite_norm_data[iINChI] ); + DisplayTheWholeCompositeStructure(pCG, ic, ip, sd, num_inp, + iINChI, pINChI[iINChI], pINChI_Aux[iINChI], + orig_inp_data, prep_inp_data, composite_norm_data[iINChI]); } #ifndef TARGET_LIB_FOR_WINCHI - if (!ip->bDisplay && sd->bUserQuitComponentDisplay) + if ( !ip->bDisplay && sd->bUserQuitComponentDisplay ) { sd->bUserQuit = 1; } @@ -776,21 +844,21 @@ void DisplayOrigAndResultStructuresAndComponents( int nRet, Special mode (option /PGO) : extract all good MOLfiles into the problem file; do not extract any MOLfile that could not be processed. ****************************************************************************/ -void SaveOkProcessedMolfile( int nRet, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - INCHI_IOSTREAM *prb_file, - INCHI_IOSTREAM *inp_file ) +void SaveOkProcessedMolfile(int nRet, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + INCHI_IOSTREAM* prb_file, + INCHI_IOSTREAM* inp_file) { - if (ip->bSaveAllGoodStructsAsProblem && - nRet != _IS_FATAL && - nRet != _IS_ERROR && - prb_file && - prb_file->f && - 0L <= sd->fPtrStart && - sd->fPtrStart < sd->fPtrEnd) + if ( ip->bSaveAllGoodStructsAsProblem && + nRet != _IS_FATAL && + nRet != _IS_ERROR && + prb_file && + prb_file->f && + 0L <= sd->fPtrStart && + sd->fPtrStart < sd->fPtrEnd ) { - MolfileSaveCopy( inp_file, sd->fPtrStart, sd->fPtrEnd, prb_file->f, 0 ); + MolfileSaveCopy(inp_file, sd->fPtrStart, sd->fPtrEnd, prb_file->f, 0); } return; @@ -800,24 +868,24 @@ void SaveOkProcessedMolfile( int nRet, /**************************************************************************** Generate InChI for the whole (multi-component) structure ****************************************************************************/ -int CreateOneStructureINChI( CANON_GLOBALS *pCG, - INCHI_CLOCK *ic, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - int iINChI, - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - COMP_ATOM_DATA composite_norm_data2[][TAUT_NUM + 1], - long num_inp, - INCHI_IOS_STRING *strbuf, - NORM_CANON_FLAGS *pncFlags ) +int CreateOneStructureINChI(CANON_GLOBALS* pCG, + INCHI_CLOCK* ic, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + int iINChI, + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + COMP_ATOM_DATA composite_norm_data2[][TAUT_NUM + 1], + long num_inp, + INCHI_IOS_STRING* strbuf, + NORM_CANON_FLAGS* pncFlags) { int i, j, k, nRet = 0, n = 0l; #if defined (TARGET_EXE_STANDALONE) && defined(_WIN32) @@ -834,11 +902,11 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, PINChI_Aux2 *pINChI_Aux = NULL; INP_ATOM_DATA InpCurAtData; - INP_ATOM_DATA *inp_cur_data; + INP_ATOM_DATA* inp_cur_data; INP_ATOM_DATA InpNormAtData, InpNormTautData; - INP_ATOM_DATA *inp_norm_data[TAUT_NUM]; /* = { &InpNormAtData, &InpNormTautData }; */ - ORIG_ATOM_DATA *cur_prep_inp_data = prep_inp_data + iINChI; + INP_ATOM_DATA* inp_norm_data[TAUT_NUM]; /* = { &InpNormAtData, &InpNormTautData }; */ + ORIG_ATOM_DATA* cur_prep_inp_data = prep_inp_data + iINChI; inchiTime ulTStart; /* Always create info data structures (but do not display them always ) @@ -848,8 +916,8 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, int bStructurePreprocessed = 0; /* All changes except disconnection */ int bStructureDisconnected = 0; int bAlsoOutputReconnected = 0, bINCHI_LIB_Flag = 0; - COMP_ATOM_DATA *composite_norm_data = composite_norm_data2[iINChI]; - INP_ATOM_DATA2 *all_inp_norm_data = NULL; + COMP_ATOM_DATA* composite_norm_data = composite_norm_data2[iINChI]; + INP_ATOM_DATA2* all_inp_norm_data = NULL; /*#endif*/ /* Order of actions: @@ -890,34 +958,34 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, inp_norm_data[TAUT_NON] = &InpNormAtData; inp_norm_data[TAUT_YES] = &InpNormTautData; - memset( inp_cur_data, 0, sizeof( *inp_cur_data ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( inp_norm_data[TAUT_NON], 0, sizeof( *inp_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( inp_norm_data[TAUT_YES], 0, sizeof( *inp_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(inp_cur_data, 0, sizeof(*inp_cur_data)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(inp_norm_data[TAUT_NON], 0, sizeof(*inp_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(inp_norm_data[TAUT_YES], 0, sizeof(*inp_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ { /*#ifndef COMPILE_ANSI_ONLY*/ - memset( composite_norm_data + TAUT_NON, 0, sizeof( composite_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( composite_norm_data + TAUT_YES, 0, sizeof( composite_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( composite_norm_data + TAUT_INI, 0, sizeof( composite_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(composite_norm_data + TAUT_NON, 0, sizeof(composite_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(composite_norm_data + TAUT_YES, 0, sizeof(composite_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(composite_norm_data + TAUT_INI, 0, sizeof(composite_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ } /*#endif*/ - if (ip->bAllowEmptyStructure && !orig_inp_data->at && !orig_inp_data->num_inp_atoms) + if ( ip->bAllowEmptyStructure && !orig_inp_data->at && !orig_inp_data->num_inp_atoms ) { ; } - else if (!orig_inp_data->at || !orig_inp_data->num_inp_atoms) + else if ( !orig_inp_data->at || !orig_inp_data->num_inp_atoms ) { return 0; /* nothing to do */ } - if (iINChI == 1 && orig_inp_data->bDisconnectCoord <= 0) + if ( iINChI == 1 && orig_inp_data->bDisconnectCoord <= 0 ) { return 0; } /* m = iINChI; */ /* orig_inp_data index */ - if (iINChI != INCHI_BAS && iINChI != INCHI_REC) + if ( iINChI != INCHI_BAS && iINChI != INCHI_REC ) { - AddErrorMessage( sd->pStrErrStruct, "Fatal undetermined program error" ); + AddErrorMessage(sd->pStrErrStruct, "Fatal undetermined program error"); sd->nStructReadError = 97; nRet = sd->nErrorType = _IS_FATAL; inchi_free(all_inp_norm_data); /* djb-rwth: avoiding memory leak */ @@ -934,20 +1002,20 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, * * *******************************************************************/ - if (( !prep_inp_data->at || !prep_inp_data->num_inp_atoms ) && - orig_inp_data->num_inp_atoms > 0) + if ( (!prep_inp_data->at || !prep_inp_data->num_inp_atoms) && + orig_inp_data->num_inp_atoms > 0 ) { /* The structure has not been preprocessed */ - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { - InchiTimeGet( &ulTStart ); + InchiTimeGet(&ulTStart); } - PreprocessOneStructure( ic, sd, ip, orig_inp_data, prep_inp_data ); + PreprocessOneStructure(ic, sd, ip, orig_inp_data, prep_inp_data); pncFlags->bTautFlags[iINChI][TAUT_YES] = - pncFlags->bTautFlags[iINChI][TAUT_NON] = - sd->bTautFlags[INCHI_BAS] | ip->bTautFlags; + pncFlags->bTautFlags[iINChI][TAUT_NON] = + sd->bTautFlags[INCHI_BAS] | ip->bTautFlags; pncFlags->bTautFlagsDone[iINChI][TAUT_YES] = pncFlags->bTautFlagsDone[iINChI][TAUT_NON] = @@ -956,23 +1024,23 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, { /*#ifndef COMPILE_ANSI_ONLY*/ /* in this location the call happens once for each input structure, before preprocessing */ - bStructurePreprocessed = ( 0 != ( sd->bTautFlagsDone[INCHI_BAS] & ( + bStructurePreprocessed = (0 != (sd->bTautFlagsDone[INCHI_BAS] & ( TG_FLAG_MOVE_HPLUS2NEUTR_DONE | TG_FLAG_DISCONNECT_SALTS_DONE | TG_FLAG_MOVE_POS_CHARGES_DONE | - TG_FLAG_FIX_ODD_THINGS_DONE ) ) ); + TG_FLAG_FIX_ODD_THINGS_DONE))); - bStructureDisconnected = ( 0 != ( sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE ) ); + bStructureDisconnected = (0 != (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE)); - bShowStructure = ( bStructurePreprocessed || - bStructureDisconnected || - prep_inp_data[0].num_components > 1 ); + bShowStructure = (bStructurePreprocessed || + bStructureDisconnected || + prep_inp_data[0].num_components > 1); /* sd->bTautFlags[] contains output flags ip->bTautFlags contains input flags */ - bAlsoOutputReconnected = ( sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE ) && - ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD ); + bAlsoOutputReconnected = (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE) && + (ip->bTautFlags & TG_FLAG_RECONNECT_COORD); bINCHI_LIB_Flag = 0; /*************** output structures to TARGET_LIB_FOR_WINCHI conditions ********************* @@ -1006,47 +1074,47 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, * ******************************************************************************/ - /* Original -> Main, component #0, Original */ - if (prep_inp_data[INCHI_BAS].num_components > 1) + /* Original -> Main, component #0, Original */ + if ( prep_inp_data[INCHI_BAS].num_components > 1 ) { bINCHI_LIB_Flag |= COMP_ORIG_0_MAIN; } else { /* Original -> Main, component #1, Original */ - if (prep_inp_data[INCHI_BAS].num_components == 1 && bStructurePreprocessed) + if ( prep_inp_data[INCHI_BAS].num_components == 1 && bStructurePreprocessed ) { bINCHI_LIB_Flag |= COMP_ORIG_1_MAIN; /* preprocessed will be added when output canonicalization results */ } } - if (bAlsoOutputReconnected) + if ( bAlsoOutputReconnected ) { /* Original -> Reconnected, component #0, Original */ - if (prep_inp_data[INCHI_REC].num_components > 1) + if ( prep_inp_data[INCHI_REC].num_components > 1 ) { bINCHI_LIB_Flag |= COMP_ORIG_0_RECN; } - else if (prep_inp_data[INCHI_BAS].num_components == 1 && bStructurePreprocessed) + else if ( prep_inp_data[INCHI_BAS].num_components == 1 && bStructurePreprocessed ) { /* Original -> Reconnected, component #1, Original */ bINCHI_LIB_Flag |= COMP_ORIG_1_RECN; /* preprocessed will be added when output canonicalization results */ } } - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { - ip->msec_LeftTime -= InchiTimeElapsed( ic, &ulTStart ); + ip->msec_LeftTime -= InchiTimeElapsed(ic, &ulTStart); } /* display the ORIGINAL, UN-PREPROCESSED structure */ - if (ip->bDisplay) + if ( ip->bDisplay ) { - if (DisplayTheWholeStructure( pCG, ic, sd, ip, szTitle, + if ( DisplayTheWholeStructure(pCG, ic, sd, ip, szTitle, inp_file, log_file, orig_inp_data, num_inp, - -1, bShowStructure, bINCHI_LIB_Flag )) + -1, bShowStructure, bINCHI_LIB_Flag) ) { inchi_free(all_inp_norm_data); /* djb-rwth: avoiding memory leak */ goto exit_function; @@ -1054,16 +1122,16 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } } /*#endif */ - switch (sd->nErrorType) + switch ( sd->nErrorType ) { - case _IS_ERROR: - case _IS_FATAL: - /* error message */ - nRet = TreatErrorsInReadTheStructure( sd, ip, - LOG_MASK_ALL, - inp_file, log_file, out_file, prb_file, - prep_inp_data, &num_inp ); - goto exit_cycle; + case _IS_ERROR: + case _IS_FATAL: + /* error message */ + nRet = TreatErrorsInReadTheStructure(sd, ip, + LOG_MASK_ALL, + inp_file, log_file, out_file, prb_file, + prep_inp_data, &num_inp); + goto exit_cycle; } } /* tranfer flags from INChI_Aux to sd */ @@ -1077,75 +1145,75 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* Only under WIN32 */ /******************************************/ if ( /* ip->bDisplayCompositeResults && !sd->bUserQuitComponentDisplay && */ - prep_inp_data[iINChI].num_components > 1 - ) + prep_inp_data[iINChI].num_components > 1 + ) { - all_inp_norm_data = (INP_ATOM_DATA2 *) inchi_calloc( prep_inp_data[iINChI].num_components, sizeof( all_inp_norm_data[0] ) ); + all_inp_norm_data = (INP_ATOM_DATA2*)inchi_calloc(prep_inp_data[iINChI].num_components, sizeof(all_inp_norm_data[0])); } /* Display the input structure AFTER PREPROCESSING */ - switch (iINChI) + switch ( iINChI ) { - case INCHI_BAS: - /*------------ Possibly disconnected structure -------------------*/ - bStructurePreprocessed = 0 != ( sd->bTautFlagsDone[iINChI] & ( - TG_FLAG_MOVE_HPLUS2NEUTR_DONE | - TG_FLAG_DISCONNECT_SALTS_DONE | - TG_FLAG_MOVE_POS_CHARGES_DONE | - TG_FLAG_MOVE_CHARGE_COORD_DONE | - TG_FLAG_DISCONNECT_COORD_DONE | - TG_FLAG_FIX_ODD_THINGS_DONE ) ); - bINCHI_LIB_Flag = 0; - /* Preprocessed/Main -> Main, component #0, Preprocessed */ - if (prep_inp_data[iINChI].num_components > 1 && - bStructurePreprocessed) - { - bINCHI_LIB_Flag |= COMP_PREP_0_MAIN; - } - bShowStructure = ( bStructurePreprocessed && - prep_inp_data[iINChI].num_components > 1 ); - break; - - case INCHI_REC: - /*------------ Reconnected structure ------------------------------*/ - bAlsoOutputReconnected = - ( sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE ) && - ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD ); + case INCHI_BAS: + /*------------ Possibly disconnected structure -------------------*/ + bStructurePreprocessed = 0 != (sd->bTautFlagsDone[iINChI] & ( + TG_FLAG_MOVE_HPLUS2NEUTR_DONE | + TG_FLAG_DISCONNECT_SALTS_DONE | + TG_FLAG_MOVE_POS_CHARGES_DONE | + TG_FLAG_MOVE_CHARGE_COORD_DONE | + TG_FLAG_DISCONNECT_COORD_DONE | + TG_FLAG_FIX_ODD_THINGS_DONE)); + bINCHI_LIB_Flag = 0; + /* Preprocessed/Main -> Main, component #0, Preprocessed */ + if ( prep_inp_data[iINChI].num_components > 1 && + bStructurePreprocessed ) + { + bINCHI_LIB_Flag |= COMP_PREP_0_MAIN; + } + bShowStructure = (bStructurePreprocessed && + prep_inp_data[iINChI].num_components > 1); + break; - if (!bAlsoOutputReconnected) - { - break; - } + case INCHI_REC: + /*------------ Reconnected structure ------------------------------*/ + bAlsoOutputReconnected = + (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE) && + (ip->bTautFlags & TG_FLAG_RECONNECT_COORD); - bStructurePreprocessed = 0 != ( sd->bTautFlagsDone[iINChI] & ( - TG_FLAG_MOVE_HPLUS2NEUTR_DONE | - TG_FLAG_DISCONNECT_SALTS_DONE | - TG_FLAG_MOVE_POS_CHARGES_DONE | - TG_FLAG_FIX_ODD_THINGS_DONE ) ); - bINCHI_LIB_Flag = 0; - /* Preprocessed/Reconnected -> Reconnected, component #0, Preprocessed */ - if (prep_inp_data[iINChI].num_components > 1 && bStructurePreprocessed) - { - bINCHI_LIB_Flag |= COMP_PREP_0_RECN; - } - bShowStructure = ( bStructurePreprocessed && - prep_inp_data[iINChI].num_components > 1 ); + if ( !bAlsoOutputReconnected ) + { break; + } - default: - bShowStructure = 0; + bStructurePreprocessed = 0 != (sd->bTautFlagsDone[iINChI] & ( + TG_FLAG_MOVE_HPLUS2NEUTR_DONE | + TG_FLAG_DISCONNECT_SALTS_DONE | + TG_FLAG_MOVE_POS_CHARGES_DONE | + TG_FLAG_FIX_ODD_THINGS_DONE)); + bINCHI_LIB_Flag = 0; + /* Preprocessed/Reconnected -> Reconnected, component #0, Preprocessed */ + if ( prep_inp_data[iINChI].num_components > 1 && bStructurePreprocessed ) + { + bINCHI_LIB_Flag |= COMP_PREP_0_RECN; + } + bShowStructure = (bStructurePreprocessed && + prep_inp_data[iINChI].num_components > 1); + break; + + default: + bShowStructure = 0; } - if (ip->bDisplay && prep_inp_data[iINChI].num_inp_atoms > 0) + if ( ip->bDisplay && prep_inp_data[iINChI].num_inp_atoms > 0 ) { - if (DisplayTheWholeStructure( pCG, ic, sd, ip, szTitle, + if ( DisplayTheWholeStructure(pCG, ic, sd, ip, szTitle, inp_file, log_file, prep_inp_data + iINChI, num_inp, iINChI, bShowStructure, - bINCHI_LIB_Flag )) + bINCHI_LIB_Flag) ) { inchi_free(all_inp_norm_data); /* djb-rwth: avoiding memory leak */ goto exit_function; @@ -1156,20 +1224,20 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* allocate pINChI[iINChI] and pINChI_Aux2[iINChI] -- arrays of pointers to INChI and INChI_Aux */ /* assign values to sd->num_components[] */ - + /* djb-rwth: MYREALLOC2 has been replaced and the whole block rewritten to address memory leaks and reading from freed memory locations */ do { - if( (sd->num_components[iINChI]) <= ((long long)cur_prep_inp_data->num_components) ) { - PINChI2* newPTR1 = (PINChI2*)inchi_calloc( ((long long)cur_prep_inp_data->num_components)+1, sizeof(PINChI2) ); - PINChI_Aux2* newPTR2 = (PINChI_Aux2*)inchi_calloc( ((long long)cur_prep_inp_data->num_components)+1, sizeof(PINChI_Aux2) ); + if ( (sd->num_components[iINChI]) <= ((long long)cur_prep_inp_data->num_components) ) { + PINChI2* newPTR1 = (PINChI2*)inchi_calloc(((long long)cur_prep_inp_data->num_components) + 1, sizeof(PINChI2)); + PINChI_Aux2* newPTR2 = (PINChI_Aux2*)inchi_calloc(((long long)cur_prep_inp_data->num_components) + 1, sizeof(PINChI_Aux2)); if ( newPTR1 && newPTR2 ) { if ( (pINChI2[iINChI]) && (sd->num_components[iINChI]) > 0 ) memcpy(newPTR1, pINChI2[iINChI], (sd->num_components[iINChI]) * sizeof(PINChI2)); - if ((pINChI_Aux2[iINChI]) && (sd->num_components[iINChI]) > 0) + if ( (pINChI_Aux2[iINChI]) && (sd->num_components[iINChI]) > 0 ) memcpy(newPTR2, pINChI_Aux2[iINChI], (sd->num_components[iINChI]) * sizeof(PINChI_Aux2)); - if (pINChI2[iINChI]) + if ( pINChI2[iINChI] ) inchi_free(pINChI2[iINChI]); - if (pINChI_Aux2[iINChI]) + if ( pINChI_Aux2[iINChI] ) inchi_free(pINChI_Aux2[iINChI]); pINChI2[iINChI] = newPTR1; pINChI_Aux2[iINChI] = newPTR2; @@ -1183,11 +1251,11 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } } else { k = 0; } - } while (0); + } while ( 0 ); - if (k) + if ( k ) { - AddErrorMessage( sd->pStrErrStruct, "Cannot allocate output data. Terminating" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot allocate output data. Terminating"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; inchi_free(all_inp_norm_data); /* djb-rwth: avoiding memory leak */ @@ -1208,66 +1276,66 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* */ /**************************************************************************/ - for (i = 0, nRet = 0; - !sd->bUserQuitComponent && i < cur_prep_inp_data->num_components; - i++) + for ( i = 0, nRet = 0; + !sd->bUserQuitComponent && i < cur_prep_inp_data->num_components; + i++ ) { - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { - InchiTimeGet( &ulTStart ); + InchiTimeGet(&ulTStart); } #ifndef TARGET_LIB_FOR_WINCHI /* { */ #if ( bREUSE_INCHI == 1 ) - if ((iINChI == INCHI_REC && - /*( !ip->bDisplay && - !ip->bDisplayCompositeResults && */ - !( ip->bCompareComponents & CMP_COMPONENTS )) || - sd->bUserQuitComponentDisplay) /* djb-rwth: addressing LLVM warning */ + if ( (iINChI == INCHI_REC && + /*( !ip->bDisplay && + !ip->bDisplayCompositeResults && */ + !(ip->bCompareComponents & CMP_COMPONENTS)) || + sd->bUserQuitComponentDisplay ) /* djb-rwth: addressing LLVM warning */ { /* Reconnected structure (06-20-2005: added "&& !ip->bDisplayCompositeResults" to display composite structure) */ int m = iINChI - 1; /* Find whether we have already calculated this INChI in basic (disconnected) layer */ - for (j = n = 0; j < prep_inp_data[m].num_components; j++) + for ( j = n = 0; j < prep_inp_data[m].num_components; j++ ) { - if (i + 1 == prep_inp_data[m].nOldCompNumber[j] && - ( pINChI2[m][j][TAUT_NON] || pINChI2[m][j][TAUT_YES] )) + if ( i + 1 == prep_inp_data[m].nOldCompNumber[j] && + (pINChI2[m][j][TAUT_NON] || pINChI2[m][j][TAUT_YES]) ) { /* Yes, we have already done this */ - if (!n++) + if ( !n++ ) { memcpy(pINChI + i, pINChI2[m] + j, sizeof(pINChI[0])); memcpy(pINChI_Aux + i, pINChI_Aux2[m] + j, sizeof(pINChI_Aux[0])); - for (k = 0; k < TAUT_NUM; k++) + for ( k = 0; k < TAUT_NUM; k++ ) { - if (pINChI[i][k]) + if ( pINChI[i][k] ) { pINChI[i][k]->nRefCount++; - if (pINChI[i][k]->nNumberOfAtoms > 0) + if ( pINChI[i][k]->nNumberOfAtoms > 0 ) { - switch (k) + switch ( k ) { - case TAUT_NON: - sd->num_non_taut[iINChI] ++; - break; - case TAUT_YES: - if (pINChI[i][k]->lenTautomer > 0) + case TAUT_NON: + sd->num_non_taut[iINChI]++; + break; + case TAUT_YES: + if ( pINChI[i][k]->lenTautomer > 0 ) + { + sd->num_taut[iINChI]++; + } + else + if ( !pINChI[i][TAUT_NON] || + !pINChI[i][TAUT_NON]->nNumberOfAtoms ) { - sd->num_taut[iINChI] ++; + sd->num_non_taut[iINChI]++; } - else - if (!pINChI[i][TAUT_NON] || - !pINChI[i][TAUT_NON]->nNumberOfAtoms) - { - sd->num_non_taut[iINChI] ++; - } - break; + break; } } } - if (pINChI_Aux[i][k]) + if ( pINChI_Aux[i][k] ) { pINChI_Aux[i][k]->nRefCount++; } @@ -1276,14 +1344,14 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } } - if (n == 1) + if ( n == 1 ) { continue; } - if (n > 1) + if ( n > 1 ) { /* ith component is equivalent to more than one another component */ - AddErrorMessage( sd->pStrErrStruct, "Cannot distinguish components" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot distinguish components"); sd->nStructReadError = 99; sd->nErrorType = _IS_ERROR; inchi_free(all_inp_norm_data); /* djb-rwth: avoiding memory leak */ @@ -1298,28 +1366,28 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* a) Allocate memory and extract current component */ /*****************************************************/ - nRet = GetOneComponent( ic, sd, ip, - log_file, out_file, - inp_cur_data, cur_prep_inp_data, - i, num_inp ); + nRet = GetOneComponent(ic, sd, ip, + log_file, out_file, + inp_cur_data, cur_prep_inp_data, + i, num_inp); - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { - ip->msec_LeftTime -= InchiTimeElapsed( ic, &ulTStart ); + ip->msec_LeftTime -= InchiTimeElapsed(ic, &ulTStart); } - switch (nRet) + switch ( nRet ) { - case _IS_ERROR: - case _IS_FATAL: - goto exit_cycle; + case _IS_ERROR: + case _IS_FATAL: + goto exit_cycle; } #if !defined(TARGET_API_LIB) && !defined(COMPILE_ANSI_ONLY) /* console request: Display the component? */ - if (ip->bDisplay && inp_file->f != stdin) + if ( ip->bDisplay && inp_file->f != stdin ) { - if (user_quit( ic, "Enter=Display Component, Esc=Stop ?", ip->ulDisplTime )) + if ( user_quit(ic, "Enter=Display Component, Esc=Stop ?", ip->ulDisplTime) ) { sd->bUserQuitComponent = 1; break; @@ -1327,13 +1395,13 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } #endif - /*#ifndef COMPILE_ANSI_ONLY + /*#ifndef COMPILE_ANSI_ONLY { */ /* b) Display the extracted original component structure */ - if (ip->bDisplay && inp_cur_data->at && !sd->bUserQuitComponentDisplay) + if ( ip->bDisplay && inp_cur_data->at && !sd->bUserQuitComponentDisplay ) { - if (cur_prep_inp_data->num_components == 1) + if ( cur_prep_inp_data->num_components == 1 ) { sprintf(szTitle, "%sInput Structure #%ld.%s%s%s%s%s", bStructurePreprocessed ? "Preprocessed " : "", @@ -1347,52 +1415,52 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } #if defined (TARGET_EXE_STANDALONE) && defined(_WIN32) - err_display = DisplayStructure( pCG, - inp_cur_data->at, - inp_cur_data->num_at, - NULL, /* OAD_Polymer *polymer, */ - 0, - 1, - 0, - NULL, - 1 /*isotopic*/, - 0 /*taut*/, - NULL, - NULL, - ip->bAbcNumbers, - &ip->dp, - ip->nMode, - szTitle ); - - sd->bUserQuitComponentDisplay = (err_display == ESC_KEY ); - - if (!err_display) + err_display = DisplayStructure(pCG, + inp_cur_data->at, + inp_cur_data->num_at, + NULL, /* OAD_Polymer *polymer, */ + 0, + 1, + 0, + NULL, + 1 /*isotopic*/, + 0 /*taut*/, + NULL, + NULL, + ip->bAbcNumbers, + &ip->dp, + ip->nMode, + szTitle); + + sd->bUserQuitComponentDisplay = (err_display == ESC_KEY); + + if ( !err_display ) { - inchi_fprintf( stderr, "Cannot display the structure\n" ); + inchi_fprintf(stderr, "Cannot display the structure\n"); } #endif #ifdef TARGET_LIB_FOR_WINCHI - if (DRAWDATA && DRAWDATA_EXISTS) + if ( DRAWDATA && DRAWDATA_EXISTS ) { struct DrawData vDrawData; int nType = COMPONENT_ORIGINAL; - vDrawData.pWindowData = CreateWinData_( pCG, - inp_cur_data->at, - inp_cur_data->num_at, - 0, - 1 /* bAdd_DT_to_num_H */, - 0, - NULL, - 1 /* display isotopic if present */, - 0, - NULL, - NULL, - ip->bAbcNumbers, - &ip->dp, - ip->nMode ); - if (vDrawData.pWindowData != NULL) + vDrawData.pWindowData = CreateWinData_(pCG, + inp_cur_data->at, + inp_cur_data->num_at, + 0, + 1 /* bAdd_DT_to_num_H */, + 0, + NULL, + 1 /* display isotopic if present */, + 0, + NULL, + NULL, + ip->bAbcNumbers, + &ip->dp, + ip->nMode); + if ( vDrawData.pWindowData != NULL ) { - if (DRAWDATA_EXISTS( i + 1, nType, iINChI )) + if ( DRAWDATA_EXISTS(i + 1, nType, iINChI) ) { /* i = component number */ nType = COMPONENT_ORIGINAL_PREPROCESSED; @@ -1400,9 +1468,9 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, vDrawData.nComponent = i + 1; vDrawData.nType = nType; vDrawData.bReconnected = iINChI; /* 0=>main; 1=>reconnected */ - vDrawData.szTitle = inchi__strdup( szTitle ); - vDrawData.pWindowData->szTitle = inchi__strdup( szTitle ); - DRAWDATA( &vDrawData ); + vDrawData.szTitle = inchi__strdup(szTitle); + vDrawData.pWindowData->szTitle = inchi__strdup(szTitle); + DRAWDATA(&vDrawData); } } #endif @@ -1420,19 +1488,19 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* c) Create the component's INChI ( copies ip->bTautFlags into sd->bTautFlags)*/ /*******************************************************************************/ - nRet = CreateOneComponentINChI( pCG, ic, sd, ip, - inp_cur_data, orig_inp_data, - pINChI/*2[iINChI]*/, - pINChI_Aux/*2[iINChI]*/, - iINChI, i, num_inp, - inp_norm_data, pncFlags, log_file ); + nRet = CreateOneComponentINChI(pCG, ic, sd, ip, + inp_cur_data, orig_inp_data, + pINChI/*2[iINChI]*/, + pINChI_Aux/*2[iINChI]*/, + iINChI, i, num_inp, + inp_norm_data, pncFlags, log_file); /* d) Display one component structure and/or INChI results only if there was no error */ /* #ifndef COMPILE_ANSI_ONLY */ /* { */ - if (!nRet) + if ( !nRet ) { /* output one component INChI to the stdout if requested */ /* @@ -1461,30 +1529,30 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, int bIsotopic, bTautomeric, bDisplayTaut, bHasIsotopicLayer, bFixedBondsTaut, m_max, m, nNumDisplayedFixedBondTaut = 0; /* djb-rwth: ignoring LLVM warning: variable used */ for ( j = 0; - ip->bDisplay && !sd->bUserQuitComponentDisplay && j < TAUT_NUM; - j++) + ip->bDisplay && !sd->bUserQuitComponentDisplay && j < TAUT_NUM; + j++ ) { - if (inp_norm_data[j]->bExists && !inp_norm_data[j]->bDeleted) + if ( inp_norm_data[j]->bExists && !inp_norm_data[j]->bDeleted ) { - bTautomeric = ( pINChI[i][j]->lenTautomer > 0 ); - /* same as (inp_norm_data[j]->bTautomeric > 0) */ + bTautomeric = (pINChI[i][j]->lenTautomer > 0); + /* same as (inp_norm_data[j]->bTautomeric > 0) */ - /* If requested tautomeric and no tautmerism found then do not say mobile or fixed H. 2004-10-27 */ - bDisplayTaut = ( !( ip->nMode & REQ_MODE_BASIC ) && !bTautomeric ) ? -1 : bTautomeric; - bHasIsotopicLayer = ( inp_norm_data[j]->bHasIsotopicLayer > 0 ); + /* If requested tautomeric and no tautmerism found then do not say mobile or fixed H. 2004-10-27 */ + bDisplayTaut = (!(ip->nMode & REQ_MODE_BASIC) && !bTautomeric) ? -1 : bTautomeric; + bHasIsotopicLayer = (inp_norm_data[j]->bHasIsotopicLayer > 0); - for (k = 0; k <= bHasIsotopicLayer; k++) + for ( k = 0; k <= bHasIsotopicLayer; k++ ) { - bIsotopic = ( k > 0 ); + bIsotopic = (k > 0); m_max = inp_norm_data[j]->at_fixed_bonds && inp_norm_data[j]->bTautPreprocessed ? 1 : 0; - for (m = m_max; 0 <= m; m--) + for ( m = m_max; 0 <= m; m-- ) { - bFixedBondsTaut = ( m > 0 ); + bFixedBondsTaut = (m > 0); nNumDisplayedFixedBondTaut += bFixedBondsTaut; - /* display only one time */ + /* display only one time */ - /* Added number of components, added another format for a single component case - DCh */ - if (cur_prep_inp_data->num_components > 1) + /* Added number of components, added another format for a single component case - DCh */ + if ( cur_prep_inp_data->num_components > 1 ) { sprintf(szTitle, "%s Component #%d of %d, Structure #%ld%s%s.%s%s%s%s%s", bFixedBondsTaut ? "Preprocessed" : "Result for", @@ -1504,50 +1572,50 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, } #if defined (TARGET_EXE_STANDALONE) && defined(_WIN32) - if (bFixedBondsTaut && nNumDisplayedFixedBondTaut != 1) + if ( bFixedBondsTaut && nNumDisplayedFixedBondTaut != 1 ) { continue; } - if (ip->bDisplay) + if ( ip->bDisplay ) { - if (bFixedBondsTaut) + if ( bFixedBondsTaut ) { - err_display = DisplayStructure( pCG, - inp_norm_data[j]->at_fixed_bonds, - inp_norm_data[j]->num_at, - NULL, /* OAD_Polymer *polymer, */ - inp_norm_data[j]->num_removed_H, - 0 /*bAdd_DT_to_num_H*/, - inp_norm_data[j]->nNumRemovedProtons, - inp_norm_data[j]->nNumRemovedProtonsIsotopic, - bHasIsotopicLayer, - j, - NULL, - NULL, - ip->bAbcNumbers, - &ip->dp, - ip->nMode, - szTitle ); + err_display = DisplayStructure(pCG, + inp_norm_data[j]->at_fixed_bonds, + inp_norm_data[j]->num_at, + NULL, /* OAD_Polymer *polymer, */ + inp_norm_data[j]->num_removed_H, + 0 /*bAdd_DT_to_num_H*/, + inp_norm_data[j]->nNumRemovedProtons, + inp_norm_data[j]->nNumRemovedProtonsIsotopic, + bHasIsotopicLayer, + j, + NULL, + NULL, + ip->bAbcNumbers, + &ip->dp, + ip->nMode, + szTitle); } else { - err_display = DisplayStructure( pCG, - inp_norm_data[j]->at, - inp_norm_data[j]->num_at, - NULL, /* OAD_Polymer *polymer, */ - 0, - 0 /*bAdd_DT_to_num_H*/, - 0, - NULL, - k, - j, - pINChI[i], - pINChI_Aux[i], - ip->bAbcNumbers, - &ip->dp, - ip->nMode, szTitle ); + err_display = DisplayStructure(pCG, + inp_norm_data[j]->at, + inp_norm_data[j]->num_at, + NULL, /* OAD_Polymer *polymer, */ + 0, + 0 /*bAdd_DT_to_num_H*/, + 0, + NULL, + k, + j, + pINChI[i], + pINChI_Aux[i], + ip->bAbcNumbers, + &ip->dp, + ip->nMode, szTitle); } - if ((sd->bUserQuitComponentDisplay = (err_display == ESC_KEY ))) /* djb-rwth: addressing LLVM warning */ + if ( (sd->bUserQuitComponentDisplay = (err_display == ESC_KEY)) ) /* djb-rwth: addressing LLVM warning */ { break; } @@ -1555,79 +1623,79 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, #endif #ifdef TARGET_LIB_FOR_WINCHI - if (DRAWDATA && !bFixedBondsTaut) + if ( DRAWDATA && !bFixedBondsTaut ) { struct DrawData vDrawData; vDrawData.pWindowData = - CreateWinData_( pCG, - inp_norm_data[j]->at, - inp_norm_data[j]->num_at, - 0, - 0 /* bAdd_DT_to_num_H */, - 0, - NULL, - k, - j, - pINChI[i], - pINChI_Aux[i], - ip->bAbcNumbers, - &ip->dp, - ip->nMode ); - - if (vDrawData.pWindowData != NULL) + CreateWinData_(pCG, + inp_norm_data[j]->at, + inp_norm_data[j]->num_at, + 0, + 0 /* bAdd_DT_to_num_H */, + 0, + NULL, + k, + j, + pINChI[i], + pINChI_Aux[i], + ip->bAbcNumbers, + &ip->dp, + ip->nMode); + + if ( vDrawData.pWindowData != NULL ) { int nType; vDrawData.nComponent = i + 1; - if (bTautomeric == 0) - nType = ( bIsotopic == 0 ) ? COMPONENT_BN + if ( bTautomeric == 0 ) + nType = (bIsotopic == 0) ? COMPONENT_BN : COMPONENT_BI; else - nType = ( bIsotopic == 0 ) ? COMPONENT_TN + nType = (bIsotopic == 0) ? COMPONENT_TN : COMPONENT_TI; vDrawData.nType = nType; vDrawData.bReconnected = iINChI; /* 0=>main; 1=>reconnected */ - vDrawData.szTitle = inchi__strdup( szTitle ); - vDrawData.pWindowData->szTitle = inchi__strdup( szTitle ); - DRAWDATA( &vDrawData ); + vDrawData.szTitle = inchi__strdup(szTitle); + vDrawData.pWindowData->szTitle = inchi__strdup(szTitle); + DRAWDATA(&vDrawData); } } - else if (DRAWDATA && bFixedBondsTaut) + else if ( DRAWDATA && bFixedBondsTaut ) { struct DrawData vDrawData; - if (( ip->bCompareComponents & CMP_COMPONENTS ) && - !( ip->bCompareComponents & CMP_COMPONENTS_NONTAUT ) && - !bIsotopic == !inp_norm_data[j]->bHasIsotopicLayer) + if ( (ip->bCompareComponents & CMP_COMPONENTS) && + !(ip->bCompareComponents & CMP_COMPONENTS_NONTAUT) && + !bIsotopic == !inp_norm_data[j]->bHasIsotopicLayer ) { vDrawData.pWindowData = - CreateWinData_( pCG, - inp_norm_data[j]->at_fixed_bonds, - inp_norm_data[j]->num_at, - inp_norm_data[j]->num_removed_H, - 0 /* bAdd_DT_to_num_H */, - inp_norm_data[j]->nNumRemovedProtons, - inp_norm_data[j]->nNumRemovedProtonsIsotopic, - k, - j, - NULL, - NULL, - ip->bAbcNumbers, - &ip->dp, - ip->nMode ); + CreateWinData_(pCG, + inp_norm_data[j]->at_fixed_bonds, + inp_norm_data[j]->num_at, + inp_norm_data[j]->num_removed_H, + 0 /* bAdd_DT_to_num_H */, + inp_norm_data[j]->nNumRemovedProtons, + inp_norm_data[j]->nNumRemovedProtonsIsotopic, + k, + j, + NULL, + NULL, + ip->bAbcNumbers, + &ip->dp, + ip->nMode); } else { continue; } - if (vDrawData.pWindowData != NULL) + if ( vDrawData.pWindowData != NULL ) { vDrawData.nComponent = i + 1; vDrawData.nType = COMPONENT_ORIGINAL_PREPROCESSED; vDrawData.bReconnected = iINChI; /* 0=>main; 1=>reconnected */ - vDrawData.szTitle = inchi__strdup( szTitle ); - vDrawData.pWindowData->szTitle = inchi__strdup( szTitle ); - DRAWDATA( &vDrawData ); + vDrawData.szTitle = inchi__strdup(szTitle); + vDrawData.pWindowData->szTitle = inchi__strdup(szTitle); + DRAWDATA(&vDrawData); } } #endif @@ -1638,15 +1706,15 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* Save normalized components for composite display */ if ( /*ip->bDisplayCompositeResults && */ - all_inp_norm_data + all_inp_norm_data ) { - for (j = 0; j < TAUT_NUM; j++) + for ( j = 0; j < TAUT_NUM; j++ ) { - if (inp_norm_data[j]->bExists) + if ( inp_norm_data[j]->bExists ) { all_inp_norm_data[i][j] = *inp_norm_data[j]; - memset( inp_norm_data[j], 0, sizeof( *inp_norm_data[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(inp_norm_data[j], 0, sizeof(*inp_norm_data[0])); /* djb-rwth: memset_s C11/Annex K variant? */ } } } @@ -1655,12 +1723,12 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /* #endif */ /* } COMPILE_ANSI_ONLY */ - if (nRet) + if ( nRet ) { - nRet = TreatErrorsInCreateOneComponentINChI( sd, ip, - cur_prep_inp_data, - i, num_inp, inp_file, - log_file, out_file, prb_file ); + nRet = TreatErrorsInCreateOneComponentINChI(sd, ip, + cur_prep_inp_data, + i, num_inp, inp_file, + log_file, out_file, prb_file); break; } } @@ -1675,56 +1743,56 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, /**************************************************************************/ exit_cycle: - switch (nRet) + switch ( nRet ) { - case _IS_FATAL: - case _IS_ERROR: - break; - default: + case _IS_FATAL: + case _IS_ERROR: + break; + default: /* #ifndef COMPILE_ANSI_ONLY *//* { */ /* composite results picture(s) */ - if (all_inp_norm_data) - { - CreateCompositeNormAtom( composite_norm_data, - all_inp_norm_data, - prep_inp_data[iINChI].num_components ); - /* - for ( i = 0; i < prep_inp_data[iINChI].num_components; i ++ ) { - for ( k = 0; k < TAUT_NUM; k ++ ) { - FreeInpAtomData( &all_inp_norm_data[i][k] ); - } + if ( all_inp_norm_data ) + { + CreateCompositeNormAtom(composite_norm_data, + all_inp_norm_data, + prep_inp_data[iINChI].num_components); + /* + for ( i = 0; i < prep_inp_data[iINChI].num_components; i ++ ) { + for ( k = 0; k < TAUT_NUM; k ++ ) { + FreeInpAtomData( &all_inp_norm_data[i][k] ); } - inchi_free( all_inp_norm_data ); - all_inp_norm_data = NULL; - */ } - /* #endif */ /* } COMPILE_ANSI_ONLY */ + inchi_free( all_inp_norm_data ); + all_inp_norm_data = NULL; + */ + } + /* #endif */ /* } COMPILE_ANSI_ONLY */ - break; + break; } /*#ifndef COMPILE_ANSI_ONLY*/ /* { */ /* avoid memory leaks in case of error */ - if (all_inp_norm_data) + if ( all_inp_norm_data ) { - for (i = 0; i < prep_inp_data[iINChI].num_components; i++) + for ( i = 0; i < prep_inp_data[iINChI].num_components; i++ ) { - for (k = 0; k < TAUT_NUM; k++) + for ( k = 0; k < TAUT_NUM; k++ ) { - FreeInpAtomData( &all_inp_norm_data[i][k] ); + FreeInpAtomData(&all_inp_norm_data[i][k]); } } - inchi_free( all_inp_norm_data ); + inchi_free(all_inp_norm_data); all_inp_norm_data = NULL; } -/*#endif */ /* } COMPILE_ANSI_ONLY */ + /*#endif */ /* } COMPILE_ANSI_ONLY */ - FreeInpAtomData( inp_cur_data ); - for (i = 0; i < TAUT_NUM; i++) + FreeInpAtomData(inp_cur_data); + for ( i = 0; i < TAUT_NUM; i++ ) { - FreeInpAtomData( inp_norm_data[i] ); + FreeInpAtomData(inp_norm_data[i]); } @@ -1738,28 +1806,28 @@ int CreateOneStructureINChI( CANON_GLOBALS *pCG, Generate InChI for one connected component (of possibly multi-component structure) ****************************************************************************/ -int CreateOneComponentINChI( CANON_GLOBALS *pCG, - INCHI_CLOCK *ic, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - INP_ATOM_DATA *inp_cur_data, - ORIG_ATOM_DATA *orig_inp_data, - PINChI2 *pINChI, - PINChI_Aux2 *pINChI_Aux, - int iINChI, - int i, - long num_inp, - INP_ATOM_DATA **inp_norm_data, - NORM_CANON_FLAGS *pncFlags, - INCHI_IOSTREAM *log_file ) +int CreateOneComponentINChI(CANON_GLOBALS* pCG, + INCHI_CLOCK* ic, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + INP_ATOM_DATA* inp_cur_data, + ORIG_ATOM_DATA* orig_inp_data, + PINChI2* pINChI, + PINChI_Aux2* pINChI_Aux, + int iINChI, + int i, + long num_inp, + INP_ATOM_DATA** inp_norm_data, + NORM_CANON_FLAGS* pncFlags, + INCHI_IOSTREAM* log_file) { - inchiTime ulTStart, ulTEnd, *pulTEnd = NULL; + inchiTime ulTStart, ulTEnd, * pulTEnd = NULL; int k, num_at, ret = 0; int bOrigCoord; INCHI_MODE bTautFlags = ip->bTautFlags; - INCHI_MODE bTautFlagsDone = ( ip->bTautFlagsDone | sd->bTautFlagsDone[INCHI_BAS] ); - INChI *cur_INChI[TAUT_NUM]; - INChI_Aux *cur_INChI_Aux[TAUT_NUM]; + INCHI_MODE bTautFlagsDone = (ip->bTautFlagsDone | sd->bTautFlagsDone[INCHI_BAS]); + INChI* cur_INChI[TAUT_NUM]; + INChI_Aux* cur_INChI_Aux[TAUT_NUM]; long lElapsedTime; int nAllocMode = 0; /* moved from below 2024-09-01 DT */ @@ -1771,106 +1839,107 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, #endif InchiTimeGet( &ulTStart ); + bOrigCoord = - !( ip->bINChIOutputOptions & ( INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO ) ); + !(ip->bINChIOutputOptions & (INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO)); - for (k = 0; k < TAUT_NUM; k++) + for ( k = 0; k < TAUT_NUM; k++ ) { cur_INChI[k] = NULL; cur_INChI_Aux[k] = NULL; } /* Allocate memory for non-tautomeric (k=0) and tautomeric (k=1) results */ - for (k = 0; k < TAUT_NUM; k++) + for ( k = 0; k < TAUT_NUM; k++ ) { /* djb-rwth: introducing variables for correct nAllocMode expression */ int nAM1 = 0, nAM2 = 0; - if (k == TAUT_YES) + if ( k == TAUT_YES ) nAM1 = REQ_MODE_TAUT; - if (bTautFlagsDone & (TG_FLAG_FOUND_ISOTOPIC_H_DONE | TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE)) + if ( bTautFlagsDone & (TG_FLAG_FOUND_ISOTOPIC_H_DONE | TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE) ) nAM2 = ip->nMode & REQ_MODE_ISO; nAllocMode = nAM1 | nAM2; /* djb-rwth: original sequence of bit-wise operations had to be rewritten */ - if ((k == TAUT_NON && ( ip->nMode & REQ_MODE_BASIC )) || - (k == TAUT_YES && ( ip->nMode & REQ_MODE_TAUT ))) /* djb-rwth: addressing LLVM warning */ + if ( (k == TAUT_NON && (ip->nMode & REQ_MODE_BASIC)) || + (k == TAUT_YES && (ip->nMode & REQ_MODE_TAUT)) ) /* djb-rwth: addressing LLVM warning */ { /* alloc INChI and INChI_Aux */ - cur_INChI[k] = Alloc_INChI( inp_cur_data->at, - inp_cur_data->num_at, - &inp_cur_data->num_bonds, - &inp_cur_data->num_isotopic, - nAllocMode ); - - cur_INChI_Aux[k] = Alloc_INChI_Aux( inp_cur_data->num_at, - inp_cur_data->num_isotopic, - nAllocMode, - bOrigCoord ); - if (cur_INChI_Aux[k]) + cur_INChI[k] = Alloc_INChI(inp_cur_data->at, + inp_cur_data->num_at, + &inp_cur_data->num_bonds, + &inp_cur_data->num_isotopic, + nAllocMode); + + cur_INChI_Aux[k] = Alloc_INChI_Aux(inp_cur_data->num_at, + inp_cur_data->num_isotopic, + nAllocMode, + bOrigCoord); + if ( cur_INChI_Aux[k] ) { cur_INChI_Aux[k]->bIsIsotopic = inp_cur_data->num_isotopic; } /* alloc memory for the output structure: non-tautomeric and tautomeric (for displaying) */ - CreateInpAtomData( inp_norm_data[k], inp_cur_data->num_at, k ); + CreateInpAtomData(inp_norm_data[k], inp_cur_data->num_at, k); } else { - FreeInpAtomData( inp_norm_data[k] ); + FreeInpAtomData(inp_norm_data[k]); } } - lElapsedTime = InchiTimeElapsed( ic, &ulTStart ); - if (ip->msec_MaxTime) + lElapsedTime = InchiTimeElapsed(ic, &ulTStart); + if ( ip->msec_MaxTime ) { ip->msec_LeftTime -= lElapsedTime; } sd->ulStructTime += lElapsedTime; /*^^^#if ( !defined( TARGET_LIB_FOR_WINCHI ) && !defined( TARGET_API_LIB ) ) */ - #if ( !defined( TARGET_LIB_FOR_WINCHI ) && !defined( TARGET_API_LIB ) && !defined(TARGET_EXE_STANDALONE) ) - #endif +#if ( !defined( TARGET_LIB_FOR_WINCHI ) && !defined( TARGET_API_LIB ) && !defined(TARGET_EXE_STANDALONE) ) +#endif - /****************************************************** - * - * Get one component canonical numberings, etc. - * - ******************************************************/ +/****************************************************** + * + * Get one component canonical numberings, etc. + * + ******************************************************/ - /* Create_INChI() return value: - * num_at <= 0: error code - * num_at > 0: number of atoms (excluding terminal hydrogen atoms) - * inp_norm_data[0] => non-tautomeric, inp_norm_data[1] => tautomeric */ + /* Create_INChI() return value: + * num_at <= 0: error code + * num_at > 0: number of atoms (excluding terminal hydrogen atoms) + * inp_norm_data[0] => non-tautomeric, inp_norm_data[1] => tautomeric */ - InchiTimeGet( &ulTStart ); + InchiTimeGet(&ulTStart); - if (ip->msec_MaxTime) + if ( ip->msec_MaxTime ) { ulTEnd = ulTStart; pulTEnd = &ulTEnd; - if (ip->msec_LeftTime > 0) + if ( ip->msec_LeftTime > 0 ) { - InchiTimeAddMsec( ic, pulTEnd, ip->msec_LeftTime ); + InchiTimeAddMsec(ic, pulTEnd, ip->msec_LeftTime); } } - num_at = Create_INChI( pCG, ic, ip, - cur_INChI, cur_INChI_Aux, - orig_inp_data/* not used */, - inp_cur_data->at, inp_norm_data, inp_cur_data->num_at, - ip->nMode, - &bTautFlags, &bTautFlagsDone, - pulTEnd, NULL, sd->pStrErrStruct ); + num_at = Create_INChI(pCG, ic, ip, + cur_INChI, cur_INChI_Aux, + orig_inp_data/* not used */, + inp_cur_data->at, inp_norm_data, inp_cur_data->num_at, + ip->nMode, + &bTautFlags, &bTautFlagsDone, + pulTEnd, NULL, sd->pStrErrStruct); - SetConnectedComponentNumber( inp_cur_data->at, inp_cur_data->num_at, i + 1 ); - /* NB: normalization alters structure component number */ + SetConnectedComponentNumber(inp_cur_data->at, inp_cur_data->num_at, i + 1); + /* NB: normalization alters structure component number */ - for (k = 0; k < TAUT_NUM; k++) + for ( k = 0; k < TAUT_NUM; k++ ) { - if (cur_INChI_Aux[k] && cur_INChI_Aux[k]->nNumberOfAtoms > 0) + if ( cur_INChI_Aux[k] && cur_INChI_Aux[k]->nNumberOfAtoms > 0 ) { pncFlags->bNormalizationFlags[iINChI][k] |= cur_INChI_Aux[k]->bNormalizationFlags; @@ -1884,39 +1953,39 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, } /* Detect errors */ - if (num_at < 0) + if ( num_at < 0 ) { sd->nErrorCode = num_at; } - else if (num_at == 0) + else if ( num_at == 0 ) { sd->nErrorCode = -1; } - else if (cur_INChI[TAUT_NON] && cur_INChI[TAUT_NON]->nErrorCode) + else if ( cur_INChI[TAUT_NON] && cur_INChI[TAUT_NON]->nErrorCode ) { /* non-tautomeric error */ sd->nErrorCode = cur_INChI[TAUT_NON]->nErrorCode; } - else if (cur_INChI[TAUT_YES] && cur_INChI[TAUT_YES]->nErrorCode) + else if ( cur_INChI[TAUT_YES] && cur_INChI[TAUT_YES]->nErrorCode ) { /* tautomeric error */ sd->nErrorCode = cur_INChI[TAUT_YES]->nErrorCode; } #if ( bRELEASE_VERSION == 0 ) - if (cur_INChI[TAUT_NON]) sd->bExtract |= cur_INChI[TAUT_NON]->bExtract; - if (cur_INChI[TAUT_YES]) sd->bExtract |= cur_INChI[TAUT_YES]->bExtract; - if (( TG_FLAG_TEST_TAUT3_SALTS_DONE & bTautFlagsDone )) + if ( cur_INChI[TAUT_NON] ) sd->bExtract |= cur_INChI[TAUT_NON]->bExtract; + if ( cur_INChI[TAUT_YES] ) sd->bExtract |= cur_INChI[TAUT_YES]->bExtract; + if ( (TG_FLAG_TEST_TAUT3_SALTS_DONE & bTautFlagsDone) ) { sd->bExtract |= EXTR_TEST_TAUT3_SALTS_DONE; } #endif /* Detect and store stereo warnings */ - if (!sd->nErrorCode) - GetProcessingWarningsOneComponentInChI( cur_INChI, inp_norm_data, sd, ip->bNoWarnings ); + if ( !sd->nErrorCode ) + GetProcessingWarningsOneComponentInChI(cur_INChI, inp_norm_data, sd, ip->bNoWarnings); - lElapsedTime = InchiTimeElapsed( ic, &ulTStart ); - if (ip->msec_MaxTime) + lElapsedTime = InchiTimeElapsed(ic, &ulTStart); + if ( ip->msec_MaxTime ) { ip->msec_LeftTime -= lElapsedTime; } @@ -1924,17 +1993,17 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, #if !defined(TARGET_API_LIB) && !defined(COMPILE_ANSI_ONLY) /* Display the results */ - if (ip->bDisplay) + if ( ip->bDisplay ) { - eat_keyboard_input( ); + eat_keyboard_input(); } #endif /* a) No matter what happened save the allocated INChI pointers */ /* save the INChI of the current component */ - InchiTimeGet( &ulTStart ); - for (k = 0; k < TAUT_NUM; k++) + InchiTimeGet(&ulTStart); + for ( k = 0; k < TAUT_NUM; k++ ) { pINChI[i][k] = cur_INChI[k]; pINChI_Aux[i][k] = cur_INChI_Aux[k]; @@ -1947,13 +2016,13 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, Set inp_norm_data[j]->num_removed_H = number of removed explicit H */ - if (!sd->nErrorCode) + if ( !sd->nErrorCode ) { /* find where the current processed structure is located */ - int cur_is_in_non_taut = ( pINChI[i][TAUT_NON] && - pINChI[i][TAUT_NON]->nNumberOfAtoms > 0 ); - int cur_is_in_taut = ( pINChI[i][TAUT_YES] && - pINChI[i][TAUT_YES]->nNumberOfAtoms > 0 ); + int cur_is_in_non_taut = (pINChI[i][TAUT_NON] && + pINChI[i][TAUT_NON]->nNumberOfAtoms > 0); + int cur_is_in_taut = (pINChI[i][TAUT_YES] && + pINChI[i][TAUT_YES]->nNumberOfAtoms > 0); int cur_is_non_taut = (cur_is_in_non_taut && 0 == pINChI[i][TAUT_NON]->lenTautomer) || (cur_is_in_taut && 0 == pINChI[i][TAUT_YES]->lenTautomer); /* djb-rwth: addressing LLVM warnings */ @@ -1964,7 +2033,7 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, sd->bTautFlagsDone[iINChI] |= bTautFlagsDone; */ - if (cur_is_non_taut + cur_is_taut) + if ( cur_is_non_taut + cur_is_taut ) { /* count tautomeric and non-tautomeric components of the structures */ int j1 = cur_is_in_non_taut ? TAUT_NON : TAUT_YES; @@ -1972,16 +2041,16 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, int j; sd->num_non_taut[iINChI] += cur_is_non_taut; sd->num_taut[iINChI] += cur_is_taut; - for (j = j1; j <= j2; j++) + for ( j = j1; j <= j2; j++ ) { - int bIsotopic = ( pINChI[i][j]->nNumberOfIsotopicAtoms || - pINChI[i][j]->nNumberOfIsotopicTGroups || - (pINChI[i][j]->nPossibleLocationsOfIsotopicH && pINChI[i][j]->nPossibleLocationsOfIsotopicH[0] > 1) ); /* djb-rwth: addressing LLVM warning */ - if (pINChI_Aux[i][j] && (j == TAUT_YES)) /* djb-rwth: fixing a NULL pointer dereference */ + int bIsotopic = (pINChI[i][j]->nNumberOfIsotopicAtoms || + pINChI[i][j]->nNumberOfIsotopicTGroups || + (pINChI[i][j]->nPossibleLocationsOfIsotopicH && pINChI[i][j]->nPossibleLocationsOfIsotopicH[0] > 1)); /* djb-rwth: addressing LLVM warning */ + if ( pINChI_Aux[i][j] && (j == TAUT_YES) ) /* djb-rwth: fixing a NULL pointer dereference */ { - bIsotopic |= ( 0 < pINChI_Aux[i][j]->nNumRemovedIsotopicH[0] + - pINChI_Aux[i][j]->nNumRemovedIsotopicH[1] + - pINChI_Aux[i][j]->nNumRemovedIsotopicH[2] ); + bIsotopic |= (0 < pINChI_Aux[i][j]->nNumRemovedIsotopicH[0] + + pINChI_Aux[i][j]->nNumRemovedIsotopicH[1] + + pINChI_Aux[i][j]->nNumRemovedIsotopicH[2]); } inp_norm_data[j]->bExists = 1; /* j=0: non-taut exists, j=1: taut exists */ @@ -1994,17 +2063,17 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, /* return (sd->nErrorCode==CT_OUT_OF_RAM || sd->nErrorCode==CT_USER_QUIT_ERR)? _IS_FATAL : sd->nErrorCode? _IS_ERROR : 0; */ - if (sd->nErrorCode == CT_OUT_OF_RAM || sd->nErrorCode == CT_USER_QUIT_ERR) + if ( sd->nErrorCode == CT_OUT_OF_RAM || sd->nErrorCode == CT_USER_QUIT_ERR ) { ret = _IS_FATAL; } - else if (sd->nErrorCode) + else if ( sd->nErrorCode ) { ret = _IS_ERROR; } - lElapsedTime = InchiTimeElapsed( ic, &ulTStart ); - if (ip->msec_MaxTime) + lElapsedTime = InchiTimeElapsed(ic, &ulTStart); + if ( ip->msec_MaxTime ) { ip->msec_LeftTime -= lElapsedTime; } @@ -2020,44 +2089,44 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, able to handle both polymer related and unrelated pseudoelement atoms and to perform advanced polymer treatment (v. 1.06+) ****************************************************************************/ -int ProcessOneStructureEx( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits ) +int ProcessOneStructureEx(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits) { int ret = _IS_OKAY; - char *sinchi_noedits=NULL, *saux_noedits=NULL; - + char* sinchi_noedits = NULL, * saux_noedits = NULL; + /* PREPROCESS */ #if (BUILD_WITH_ENG_OPTIONS==1) #if ALLOW_SUBSTRUCTURE_FILTERING==1 - if (ip->bFilterSS) + if ( ip->bFilterSS ) { int present, ok = 0; - + present = OrigAtData_CheckForSubstructure(orig_inp_data); - if (ip->bFilterSS == 1 && present) ok = 1; - else if (ip->bFilterSS == -1 && !present) ok = 1; + if ( ip->bFilterSS == 1 && present ) ok = 1; + else if ( ip->bFilterSS == -1 && !present ) ok = 1; - if (!ok) + if ( !ok ) { inchi_ios_eprint(log_file, "Warning (Skip record which does not pass substructure presence/absence filter) structure #%ld.%s%s%s%s\n", - num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); + num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); return _IS_SKIP; } } @@ -2065,29 +2134,29 @@ int ProcessOneStructureEx( struct tagINCHI_CLOCK *ic, #endif /* Preprocess Polymer CRUs (collect frame shift info and edit the original input accordingly) */ - ret = PreprocessPolymerCRUData( ic, CG, sd, ip, szTitle, - pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - num_inp, strbuf, save_opt_bits, - &sinchi_noedits, &saux_noedits); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret = PreprocessPolymerCRUData(ic, CG, sd, ip, szTitle, + pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + num_inp, strbuf, save_opt_bits, + &sinchi_noedits, &saux_noedits); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ /* CALCULATE INCHI */ - - /* Perform calculation as usual either for untouched (modes POLYMERS_LEGACY and POLYMERS_LEGACY_PLUS) + + /* Perform calculation as usual either for untouched (modes POLYMERS_LEGACY and POLYMERS_LEGACY_PLUS) or just edited, probably (mode POLYMERS_MODERN) structure as passed in orig_inp_data */ - ret = ProcessOneStructureExCore( ic, CG, sd, ip, szTitle, - pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - num_inp, strbuf, save_opt_bits ); + ret = ProcessOneStructureExCore(ic, CG, sd, ip, szTitle, + pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + num_inp, strbuf, save_opt_bits); - if (ip->bINChIOutputOptions2 & INCHI_OUT_INCHI_GEN_ERROR) + if ( ip->bINChIOutputOptions2 & INCHI_OUT_INCHI_GEN_ERROR ) { - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { - if (ip->bINChIOutputOptions & INCHI_OUT_STDINCHI) + if ( ip->bINChIOutputOptions & INCHI_OUT_STDINCHI ) { inchi_ios_eprint(out_file, "InChI=1S//\n"); } @@ -2099,18 +2168,18 @@ int ProcessOneStructureEx( struct tagINCHI_CLOCK *ic, } /* Post-process: add AuxInfo for a very unedited original structure */ - if (ret != _IS_FATAL && ret != _IS_ERROR) + if ( ret != _IS_FATAL && ret != _IS_ERROR ) { - if (!(ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) && - out_file->s.pStr && strstr(out_file->s.pStr, "AuxInfo=" ) && + if ( !(ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO) && + out_file->s.pStr && strstr(out_file->s.pStr, "AuxInfo=") && saux_noedits && strstr(saux_noedits, "AuxInfo=") ) { - char *pp = out_file->s.pStr; - if (saux_noedits[8]) + char* pp = out_file->s.pStr; + if ( saux_noedits[8] ) { remove_one_lf(pp); out_file->s.nUsedLength = strlen(out_file->s.pStr); - inchi_ios_eprint(out_file, "/U/%-s\n", saux_noedits +8); + inchi_ios_eprint(out_file, "/U/%-s\n", saux_noedits + 8); } } } @@ -2118,12 +2187,12 @@ int ProcessOneStructureEx( struct tagINCHI_CLOCK *ic, inchi_free(sinchi_noedits); inchi_free(saux_noedits); - + #ifdef TARGET_LIB_FOR_WINCHI push_to_winchi_text_window(out_file); - if (sd->pStrErrStruct && FWPUSH) + if ( sd->pStrErrStruct && FWPUSH ) { FWPUSH(sd->pStrErrStruct); } @@ -2135,47 +2204,47 @@ int ProcessOneStructureEx( struct tagINCHI_CLOCK *ic, /**************************************************************************** - Special treatment for polymers: perform CRU frame shift analysis + Special treatment for polymers: perform CRU frame shift analysis and make related edits in orig_inp_data whenever applicable ****************************************************************************/ -int PreprocessPolymerCRUData( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits, - char **sinchi_noedits, - char **saux_noedits) +int PreprocessPolymerCRUData(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits, + char** sinchi_noedits, + char** saux_noedits) { int ret = _IS_OKAY; - char *sinchi_105p = NULL, *saux_105p = NULL; - OAD_StructureEdits edits_unit_frame_shift, *ed_fs = &edits_unit_frame_shift; - OAD_StructureEdits edits_unit_folding, *ed_fold = &edits_unit_folding; - + char* sinchi_105p = NULL, * saux_105p = NULL; + OAD_StructureEdits edits_unit_frame_shift, * ed_fs = &edits_unit_frame_shift; + OAD_StructureEdits edits_unit_folding, * ed_fold = &edits_unit_folding; + OAD_StructureEdits_Init(ed_fold); OAD_StructureEdits_Init(ed_fs); - if (orig_inp_data) + if ( orig_inp_data ) { orig_inp_data->valid_polymer = 0; - if (orig_inp_data->polymer) + if ( orig_inp_data->polymer ) { orig_inp_data->polymer->treat = ip->bPolymers; - if (orig_inp_data->polymer->treat != POLYMERS_NO) + if ( orig_inp_data->polymer->treat != POLYMERS_NO ) { orig_inp_data->valid_polymer = 1; - if (orig_inp_data->polymer->treat == POLYMERS_MODERN) + if ( orig_inp_data->polymer->treat == POLYMERS_MODERN ) { int n_done, n_todo = 0, n_poly_zz = 0; /* djb-rwth: ignoring LLVM warning: variable used */ @@ -2184,31 +2253,31 @@ int PreprocessPolymerCRUData( struct tagINCHI_CLOCK *ic, we then append it to the final result AuxInfo, in order to preserve total reversibility (restoring the original structure ) */ ret = OAD_ProcessOneStructureNoEdits(ic, CG, sd, ip, szTitle, - pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - num_inp, strbuf, save_opt_bits, - &n_poly_zz, - sinchi_noedits, saux_noedits); - if (ret == _IS_FATAL || ret == _IS_ERROR) + pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + num_inp, strbuf, save_opt_bits, + &n_poly_zz, + sinchi_noedits, saux_noedits); + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { - ret = _IS_WARNING; - if (!ip->bNoWarnings) + ret = _IS_WARNING; + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "CRU folding and frame shift analysis failed"); } goto exit_function; } - if (n_poly_zz < 2) + if ( n_poly_zz < 2 ) { /* For now, CRU folding and frame shift analysis are only applicable to */ /* CRU having both caps of indefinite nature, Zz */ goto exit_function; } - + /* Prepare and perform CRU folding related edits */ - if (ip->bFoldPolymerSRU != 0) + if ( ip->bFoldPolymerSRU != 0 ) { /* Get interim 105+ flavour of InChI and AuxInfo and prepare */ int old_bFrameShiftScheme = ip->bFrameShiftScheme; @@ -2220,31 +2289,31 @@ int PreprocessPolymerCRUData( struct tagINCHI_CLOCK *ic, num_inp, strbuf, save_opt_bits, &sinchi_105p, &saux_105p); ip->bFrameShiftScheme = old_bFrameShiftScheme; - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { ret = _IS_WARNING; - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { /* AddErrorMessage(sd->pStrErrStruct, "CRU fold analysis failed");*/ ; } - goto frame_shift; + goto frame_shift; } - ret = OAD_Polymer_PrepareFoldCRUEdits( orig_inp_data, *sinchi_noedits, *saux_noedits, sinchi_105p, saux_105p, ed_fold); - if (ret == _IS_FATAL || ret == _IS_ERROR) + ret = OAD_Polymer_PrepareFoldCRUEdits(orig_inp_data, *sinchi_noedits, *saux_noedits, sinchi_105p, saux_105p, ed_fold); + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { /*AddErrorMessage(sd->pStrErrStruct, "CRU fold analysis failed");*/ ; } goto frame_shift; } - if (ret == _IS_WARNING) + if ( ret == _IS_WARNING ) { - /* inchi_ios_eprint(log_file, "Warning (CRU fold analysis failed) structure #%ld.%s%s%s%s\n", - num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue));*/ + /* inchi_ios_eprint(log_file, "Warning (CRU fold analysis failed) structure #%ld.%s%s%s%s\n", + num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue));*/ ; } /* else */ @@ -2254,25 +2323,25 @@ int PreprocessPolymerCRUData( struct tagINCHI_CLOCK *ic, n_todo = ed_fold->del_atom->used + ed_fold->del_bond->used + ed_fold->new_bond->used + ed_fold->mod_bond->used; ed_fold->del_side_chains = 1; OAD_StructureEdits_DebugPrint(ed_fold); - if (n_todo) + if ( n_todo ) { /* Edit the original input data */ ed_fold->del_side_chains = 1; n_done = OAD_StructureEdits_Apply(sd, ip, orig_inp_data, ed_fold, &ret); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { ret = _IS_WARNING; /*inchi_ios_eprint(log_file, "Warning (CRU fold failed) structure #%ld.%s%s%s%s\n", num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); */ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "CRU folding failed"); } } else { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { WarningMessage(sd->pStrErrStruct, "Atom(s) removed due to CRU folding"); } @@ -2281,46 +2350,46 @@ int PreprocessPolymerCRUData( struct tagINCHI_CLOCK *ic, } } -frame_shift: ; + frame_shift:; /* Prepare and perform frame shift related edits */ - if (ip->bFrameShiftScheme != FSS_NONE) + if ( ip->bFrameShiftScheme != FSS_NONE ) { /* Clear buffers */ - if (sinchi_105p) + if ( sinchi_105p ) { inchi_free(sinchi_105p); } - if (saux_105p) + if ( saux_105p ) { inchi_free(saux_105p); } /* Get interim 105+ flavour of InChI and AuxInfo (possibly 2nd time) */ ret = OAD_ProcessOneStructure105Plus(ic, CG, sd, ip, szTitle, - pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - num_inp, strbuf, save_opt_bits, - &sinchi_105p, &saux_105p); - if (ret == _IS_FATAL || ret == _IS_ERROR) + pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + num_inp, strbuf, save_opt_bits, + &sinchi_105p, &saux_105p); + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { ret = _IS_WARNING; /*inchi_ios_eprint(log_file, "Warning (Frame shift analysis failed) structure #%ld.%s%s%s%s\n", num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue));*/ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "Frame shift analysis failed"); } goto exit_function; } - ret = OAD_Polymer_PrepareFrameShiftEdits( orig_inp_data, sinchi_105p, saux_105p, ed_fs); - - if (ret == _IS_FATAL || ret == _IS_ERROR) /* djb-rwth: logical operator corrected */ + ret = OAD_Polymer_PrepareFrameShiftEdits(orig_inp_data, sinchi_105p, saux_105p, ed_fs); + + if ( ret == _IS_FATAL || ret == _IS_ERROR ) /* djb-rwth: logical operator corrected */ { ret = _IS_WARNING; /*inchi_ios_eprint(log_file, "Warning (Frame shift analysis failed) structure #%ld.%s%s%s%s\n", num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue));*/ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "Frame shift analysis failed"); } @@ -2331,26 +2400,26 @@ frame_shift: ; /* OK, proceed with frame shift */ n_done = 0; /* djb-rwth: ignoring LLVM warning: variable used */ n_todo = ed_fs->del_atom->used + - ed_fs->del_bond->used + ed_fs->new_bond->used + ed_fs->mod_bond->used + - ed_fs->mod_coord->used; + ed_fs->del_bond->used + ed_fs->new_bond->used + ed_fs->mod_bond->used + + ed_fs->mod_coord->used; OAD_StructureEdits_DebugPrint(ed_fs); - if (n_todo) + if ( n_todo ) { /* Edit the original input data according to frame shift info */ n_done = OAD_StructureEdits_Apply(sd, ip, orig_inp_data, ed_fs, &ret); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { ret = _IS_WARNING; /*inchi_ios_eprint(log_file, "Warning (Frame shift failed) structure #%ld.%s%s%s%s\n", num_inp, SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue));*/ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "Frame shift failed"); } } else { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { WarningMessage(sd->pStrErrStruct, "Bond(s) rearranged due to CRU frame shift"); } @@ -2366,7 +2435,7 @@ frame_shift: ; else /* orig_inp_data->polymer->treat == POLYMERS_NO) */ { /*inchi_ios_eprint(log_file, "Ignore polymer data");*/ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { AddErrorMessage(sd->pStrErrStruct, "Ignore polymer data"); } @@ -2375,37 +2444,37 @@ frame_shift: ; } exit_function: - if (sinchi_105p) + if ( sinchi_105p ) { inchi_free(sinchi_105p); } - if (saux_105p) + if ( saux_105p ) { inchi_free(saux_105p); } OAD_StructureEdits_Clear(ed_fold); /* Clear edits collection */ OAD_StructureEdits_Clear(ed_fs); /* Clear edits collection */ - + return ret; } /****************************************************************************/ -void swap_atoms_xyz( ORIG_ATOM_DATA *orig_at_data, int ia1, int ia2 ) +void swap_atoms_xyz(ORIG_ATOM_DATA* orig_at_data, int ia1, int ia2) { double x, y, z; - - if (ia1 != ia2) + + if ( ia1 != ia2 ) { - x = orig_at_data->at[ia1].x; - y = orig_at_data->at[ia1].y; + x = orig_at_data->at[ia1].x; + y = orig_at_data->at[ia1].y; z = orig_at_data->at[ia1].z; orig_at_data->at[ia1].x = orig_at_data->at[ia2].x; orig_at_data->at[ia1].y = orig_at_data->at[ia2].y; orig_at_data->at[ia1].z = orig_at_data->at[ia2].z; - + orig_at_data->at[ia2].x = x; orig_at_data->at[ia2].y = y; orig_at_data->at[ia2].z = z; @@ -2418,31 +2487,31 @@ void swap_atoms_xyz( ORIG_ATOM_DATA *orig_at_data, int ia1, int ia2 ) /**************************************************************************** OAD_StructureEdits_Edit ****************************************************************************/ -int OAD_StructureEdits_Apply( STRUCT_DATA *sd, - INPUT_PARMS *ip, - ORIG_ATOM_DATA *orig_at_data, - OAD_StructureEdits *ed, - int *ret) +int OAD_StructureEdits_Apply(STRUCT_DATA* sd, + INPUT_PARMS* ip, + ORIG_ATOM_DATA* orig_at_data, + OAD_StructureEdits* ed, + int* ret) { int ok = 0, fail; int i, j, old_a1, old_a2, new_a1, new_a2, n_edits = 0; int n_del_atom, n_del_bond, n_new_bond, n_mod_bond, n_mod_coord; int a1, a2; int bond_type = INCHI_BOND_TYPE_NONE, bond_stereo = INCHI_BOND_STEREO_NONE; - inp_ATOM *at = orig_at_data->at; - OAD_Polymer *p = orig_at_data->polymer; - int *at_renum = NULL; - int *ibuf = NULL; - int n_max_stored=-1; + inp_ATOM* at = orig_at_data->at; + OAD_Polymer* p = orig_at_data->polymer; + int* at_renum = NULL; + int* ibuf = NULL; + int n_max_stored = -1; *ret = _IS_OKAY; n_del_atom = ed->del_atom->used; - n_del_bond = ed->del_bond->used/2; - n_new_bond = ed->new_bond->used/3; - n_mod_bond = ed->mod_bond->used/4; - n_mod_coord = ed->mod_coord->used/2; - if (n_del_atom + n_del_bond + n_new_bond + n_mod_bond + n_mod_coord < 1) + n_del_bond = ed->del_bond->used / 2; + n_new_bond = ed->new_bond->used / 3; + n_mod_bond = ed->mod_bond->used / 4; + n_mod_coord = ed->mod_coord->used / 2; + if ( n_del_atom + n_del_bond + n_new_bond + n_mod_bond + n_mod_coord < 1 ) { return 0; } @@ -2454,14 +2523,14 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, OAD_Polymer_DebugTrace(orig_at_data->polymer); /* Delete bonds */ - if (n_del_bond) + if ( n_del_bond ) { - for (i = 0; i < 2 * n_del_bond; i += 2) + for ( i = 0; i < 2 * n_del_bond; i += 2 ) { a1 = ed->del_bond->item[i] - 1; a2 = ed->del_bond->item[i + 1] - 1; ok = OrigAtData_RemoveBond(a1, a2, at, &bond_type, &bond_stereo, &orig_at_data->num_inp_bonds); - if (!ok) + if ( !ok ) { *ret = _IS_ERROR; goto exit_function; @@ -2469,18 +2538,18 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, n_edits++; } } - + /* Add bonds */ - if (n_new_bond) + if ( n_new_bond ) { - for (i = 0; i < 2 * n_new_bond; i += 2) + for ( i = 0; i < 2 * n_new_bond; i += 2 ) { a1 = ed->new_bond->item[i] - 1; a2 = ed->new_bond->item[i + 1] - 1; /* TODO: consider real bond_type, bond_stereo */ /* OrigAtData_AddSingleStereolessBond( a1, a2, at, &dummy ); */ ok = OrigAtData_AddBond(a1, a2, at, bond_type, bond_stereo, &orig_at_data->num_inp_bonds); - if (!ok) + if ( !ok ) { *ret = _IS_ERROR; goto exit_function; @@ -2488,37 +2557,37 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, n_edits++; } } - + /* Modify bonds */ - if (n_mod_bond) + if ( n_mod_bond ) { - for (j = 0; j < 4 * n_mod_bond; j += 4) + for ( j = 0; j < 4 * n_mod_bond; j += 4 ) { old_a1 = ed->mod_bond->item[j]; old_a2 = ed->mod_bond->item[j + 1]; new_a1 = ed->mod_bond->item[j + 2]; new_a2 = ed->mod_bond->item[j + 3]; - if ((old_a1 == new_a1&&old_a2 == new_a2) || (old_a2 == new_a1&&old_a1 == new_a2)) + if ( (old_a1 == new_a1 && old_a2 == new_a2) || (old_a2 == new_a1 && old_a1 == new_a2) ) { continue; } ok = OrigAtData_RemoveBond(old_a1 - 1, old_a2 - 1, at, &bond_type, &bond_stereo, &orig_at_data->num_inp_bonds); - if (!ok) + if ( !ok ) { *ret = _IS_ERROR; goto exit_function; } ok = OrigAtData_AddBond(new_a1 - 1, new_a2 - 1, at, bond_type, bond_stereo, &orig_at_data->num_inp_bonds); - if (!ok) + if ( !ok ) { *ret = _IS_ERROR; goto exit_function; } /* Correct CRU blist lists */ - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { - OAD_PolymerUnit *u = p->units[i]; - if (!u->blist) + OAD_PolymerUnit* u = p->units[i]; + if ( !u->blist ) { /* No crossing bonds in the unit */ continue; @@ -2540,9 +2609,9 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, } /* Modify coordinates */ - if (n_mod_coord) + if ( n_mod_coord ) { - for (j = 0; j < 2 * n_mod_coord; j += 2) + for ( j = 0; j < 2 * n_mod_coord; j += 2 ) { old_a1 = ed->mod_coord->item[j]; new_a1 = ed->mod_bond->item[j + 1]; @@ -2551,29 +2620,29 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, } } - + /* Delete atoms */ - if (n_del_atom) + if ( n_del_atom ) { int nat0, nat, nacc; - inp_ATOM *new_at = NULL, *new_at0=NULL; + inp_ATOM* new_at = NULL, * new_at0 = NULL; - at_renum = (int *)inchi_calloc(n_max_stored, sizeof(int)); - if (!at_renum) + at_renum = (int*)inchi_calloc(n_max_stored, sizeof(int)); + if ( !at_renum ) { *ret = _IS_ERROR; goto exit_function; } /* all-purpose buffer */ - ibuf = (int *)inchi_calloc(n_max_stored, sizeof(int)); - if (!ibuf) + ibuf = (int*)inchi_calloc(n_max_stored, sizeof(int)); + if ( !ibuf ) { *ret = _IS_ERROR; goto exit_function; } - fail = mark_atoms_to_delete_or_renumber(orig_at_data, ed, at_renum); - if (fail) + fail = mark_atoms_to_delete_or_renumber(orig_at_data, ed, at_renum); + if ( fail ) { *ret = _IS_ERROR; goto exit_function; @@ -2582,53 +2651,53 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, nat0 = orig_at_data->num_inp_atoms; nat = nat0 - ed->del_atom->used; - new_at = (inp_ATOM *)inchi_calloc(nat, sizeof(new_at[0])); - if (!new_at) + new_at = (inp_ATOM*)inchi_calloc(nat, sizeof(new_at[0])); + if ( !new_at ) { *ret = _IS_ERROR; goto exit_function; } - for (i = 0, nacc = 0; i < nat0; i++) + for ( i = 0, nacc = 0; i < nat0; i++ ) { AT_NUMB nbr0[MAXVAL]; U_CHAR btype0[MAXVAL]; int m, macc, valen; - int new_num = at_renum[i]; - if (new_num == -1) + int new_num = at_renum[i]; + if ( new_num == -1 ) { /* Skip removed atom */ continue; } - /* Atom to keep; copy it */ + /* Atom to keep; copy it */ new_at0 = new_at + nacc; ++nacc; memcpy(new_at0, orig_at_data->at + i, sizeof(new_at[0])); /* Correct its own number(s) */ new_at0->orig_at_number = new_num + 1; - + /* Correct its nbr number(s) */ valen = new_at0->valence; memcpy(nbr0, new_at0->neighbor, valen * sizeof(AT_NUMB)); memcpy(btype0, new_at0->bond_type, valen); memset(new_at0->neighbor, 0, valen); /* djb-rwth: memset_s C11/Annex K variant? */ - for (m = 0, macc=0; m < valen; m++) + for ( m = 0, macc = 0; m < valen; m++ ) { int num2 = nbr0[m]; int renum2 = at_renum[num2]; - if (renum2 == num2) + if ( renum2 == num2 ) { /* keep old */ - new_at0->neighbor[macc++] = num2; + new_at0->neighbor[macc++] = num2; } - else if (renum2 == -1) + else if ( renum2 == -1 ) { /* skip and decrement valences */ new_at0->chem_bonds_valence -= btype0[m]; new_at0->valence--; } - else + else { /* set renumbered */ new_at0->neighbor[macc++] = renum2; @@ -2636,7 +2705,7 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, } } - if (new_at) + if ( new_at ) { inchi_free(orig_at_data->at); orig_at_data->at = new_at; @@ -2644,7 +2713,7 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, orig_at_data->num_inp_atoms = nacc; orig_at_data->num_inp_bonds = 0; - for (i = 0; i < nacc; i++) + for ( i = 0; i < nacc; i++ ) { orig_at_data->num_inp_bonds += new_at[i].valence; } @@ -2653,34 +2722,34 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, /* Correct other data */ /* Correct polymer data */ - if (p) + if ( p ) { int iu; - for (iu = 0; iu < p->n; iu++) + for ( iu = 0; iu < p->n; iu++ ) { OAD_PolymerUnit* u = p->units[iu]; int new_na, new_nb, new_bb; memset(ibuf, 0, n_max_stored * sizeof(ibuf[0])); /* djb-rwth: memset_s C11/Annex K variant? */ - if (u) + if ( u ) { - if (u->alist) + if ( u->alist ) { memcpy(ibuf, u->alist, u->na * sizeof(ibuf[0])); new_na = set_renumbered_or_delete(u->alist, ibuf, u->na, at_renum, 1); - if (new_na == -1) + if ( new_na == -1 ) { *ret = _IS_ERROR; goto exit_function; } u->na = new_na; } - if (u->blist) + if ( u->blist ) { memcpy(ibuf, u->blist, 2 * (long long)u->nb * sizeof(int)); /* djb-rwth: cast operator added */ - new_nb = set_renumbered_or_delete(u->blist, ibuf, 2*u->nb, at_renum, 1); + new_nb = set_renumbered_or_delete(u->blist, ibuf, 2 * u->nb, at_renum, 1); new_nb /= 2; - if (new_nb == -1) + if ( new_nb == -1 ) { *ret = _IS_ERROR; goto exit_function; @@ -2689,10 +2758,10 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, } - if (u->bkbonds) + if ( u->bkbonds ) { int b, new_nbkbonds; - for (b = 0, new_nbkbonds = 0; b < u->nbkbonds; b++) + for ( b = 0, new_nbkbonds = 0; b < u->nbkbonds; b++ ) { int bnd[2]; bnd[0] = u->bkbonds[b][0]; @@ -2700,12 +2769,12 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, memcpy(ibuf, bnd, 2 * sizeof(ibuf[0])); memset(u->bkbonds[b], 0, 2 * sizeof(u->bkbonds[0][0])); /* djb-rwth: memset_s C11/Annex K variant? */ new_bb = set_renumbered_or_delete(bnd, ibuf, 2, at_renum, 1); - if (new_bb == -1) + if ( new_bb == -1 ) { *ret = _IS_ERROR; goto exit_function; } - else if (new_bb == 2) + else if ( new_bb == 2 ) { u->bkbonds[new_nbkbonds][0] = bnd[0]; u->bkbonds[new_nbkbonds][1] = bnd[1]; @@ -2720,14 +2789,14 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, u->nbkbonds = new_nbkbonds; } - if (u->blist) /* djb-rwth: fixing a NULL pointer dereference */ + if ( u->blist ) /* djb-rwth: fixing a NULL pointer dereference */ { u->cap1 = u->blist[0]; u->end_atom1 = u->blist[1]; u->cap2 = u->blist[2]; u->end_atom2 = u->blist[3]; } - if (u->cap1 < 1 || u->cap2 < 1 || u->end_atom1 < 1 || u->end_atom2 < 1) + if ( u->cap1 < 1 || u->cap2 < 1 || u->end_atom1 < 1 || u->end_atom2 < 1 ) { *ret = _IS_ERROR; goto exit_function; @@ -2739,46 +2808,46 @@ int OAD_StructureEdits_Apply( STRUCT_DATA *sd, } /* if (p) */ /* Correct V300 data */ - if (orig_at_data->v3000) + if ( orig_at_data->v3000 ) { ; } } /* if (n_del_atom) */ - + exit_function: - if (ibuf) + if ( ibuf ) { inchi_free(ibuf); } - if (at_renum) + if ( at_renum ) { inchi_free(at_renum); } return n_edits; } - + /**************************************************************************** Set each element of number to renum[element] or delete it if renum==(base -1) base is either 0 (0-started numbers) or 1 (1-started) Returns new number of elements or -1 at error ****************************************************************************/ -int set_renumbered_or_delete( int *number, /* numbers to correct */ - int *buf, /* must be enough size to hold nelems elements */ - int nelems, /* initial size of numbers */ - int *renum, /* new numbers in order of old numbers; always 0-based */ - int base) +int set_renumbered_or_delete(int* number, /* numbers to correct */ + int* buf, /* must be enough size to hold nelems elements */ + int nelems, /* initial size of numbers */ + int* renum, /* new numbers in order of old numbers; always 0-based */ + int base) { int i, new_nelems; memcpy(buf, number, nelems * sizeof(int)); memset(number, 0, nelems * sizeof(int)); /* djb-rwth: memset_s C11/Annex K variant? */ - for (i = 0, new_nelems = 0; i < nelems; i++) + for ( i = 0, new_nelems = 0; i < nelems; i++ ) { - int new_num = renum[ buf[i]-base ] + base; - if (new_num == (base-1)) + int new_num = renum[buf[i] - base] + base; + if ( new_num == (base - 1) ) { continue; } @@ -2794,55 +2863,55 @@ int set_renumbered_or_delete( int *number, /* numbers to correct */ /**************************************************************************** Worker placed under ProcessOneStructure wrapper (not the last nested doll) ****************************************************************************/ -int ProcessOneStructureExCore( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits ) +int ProcessOneStructureExCore(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits) { int res = _IS_OKAY; int mind_polymers; #ifdef TARGET_LIB_FOR_WINCHI - inchi_ios_free_str( out_file ); + inchi_ios_free_str(out_file); inchi_ios_print(out_file, "Structure: %d\n", num_inp); #endif /* Polymer and pseudoelement specific */ - res = ValidateAndPreparePolymerAndPseudoatoms( ic, CG, sd, ip, szTitle, pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, num_inp, strbuf, - save_opt_bits, &mind_polymers); - if (res== _IS_ERROR || res == _IS_FATAL ) + res = ValidateAndPreparePolymerAndPseudoatoms(ic, CG, sd, ip, szTitle, pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, num_inp, strbuf, + save_opt_bits, &mind_polymers); + if ( res == _IS_ERROR || res == _IS_FATAL ) { return res; } /* Call the very actual worker placed under this (ProcessOneStructureCore) wrapper */ - res = ProcessOneStructure( ic, CG, sd, ip, szTitle, pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, num_inp, strbuf, - save_opt_bits); + res = ProcessOneStructure(ic, CG, sd, ip, szTitle, pINChI2, pINChI_Aux2, + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, num_inp, strbuf, + save_opt_bits); - if ( (res == _IS_OKAY || res == _IS_WARNING ) && mind_polymers ) + if ( (res == _IS_OKAY || res == _IS_WARNING) && mind_polymers ) { /* Post-edit the polymer layer at older polymer treatment modes (1.05, 1.05+) */ - if (ip->bPolymers == POLYMERS_LEGACY || ip->bPolymers == POLYMERS_LEGACY_PLUS) + if ( ip->bPolymers == POLYMERS_LEGACY || ip->bPolymers == POLYMERS_LEGACY_PLUS ) { /* Cut and hide "Zz" and related things in InChI (AuxInfo has a specifics). */ int n_pzz = 0, n_zy = orig_inp_data->n_zy; - if (orig_inp_data->polymer) + if ( orig_inp_data->polymer ) { n_pzz = orig_inp_data->polymer->n_pzz; } @@ -2853,11 +2922,11 @@ int ProcessOneStructureExCore( struct tagINCHI_CLOCK *ic, } #ifdef TARGET_LIB_FOR_WINCHI -/* if ( res == _IS_ERROR || res == _IS_FATAL ) - { - inchi_ios_print(out_file, "Error %d (%s)\n", sd->nErrorCode, sd->pStrErrStruct); - } -*/ + /* if ( res == _IS_ERROR || res == _IS_FATAL ) + { + inchi_ios_print(out_file, "Error %d (%s)\n", sd->nErrorCode, sd->pStrErrStruct); + } + */ /*push_to_winchi_text_window(out_file); */ /*inchi_ios_free_str(out_file);*/ /*inchi_ios_flush(out_file);*/ @@ -2868,30 +2937,30 @@ int ProcessOneStructureExCore( struct tagINCHI_CLOCK *ic, /**************************************************************************** - Treat pseudoelement and polymers: parse, validate and set details + Treat pseudoelement and polymers: parse, validate and set details ****************************************************************************/ -int ValidateAndPreparePolymerAndPseudoatoms( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits, - int *mind_polymers ) +int ValidateAndPreparePolymerAndPseudoatoms(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits, + int* mind_polymers) { int res = _IS_OKAY; int mind_pseudoelements = 0; - + *mind_polymers = orig_inp_data && orig_inp_data->polymer && orig_inp_data->polymer->n > 0; *mind_polymers = *mind_polymers && orig_inp_data->valid_polymer && (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE); @@ -2904,33 +2973,33 @@ int ValidateAndPreparePolymerAndPseudoatoms( struct tagINCHI_CLOCK *ic, ip->bNPZz, sd->pStrErrStruct, ip->bNoWarnings); - if (res) + if ( res ) { sd->nErrorCode = res; - inchi_ios_eprint( log_file, "Error %d (%s) structure #%ld.%s%s%s%s\n", - sd->nErrorCode, sd->pStrErrStruct, num_inp, - SDF_LBL_VAL( ip->pSdfLabel, ip->pSdfValue ) ); + inchi_ios_eprint(log_file, "Error %d (%s) structure #%ld.%s%s%s%s\n", + sd->nErrorCode, sd->pStrErrStruct, num_inp, + SDF_LBL_VAL(ip->pSdfLabel, ip->pSdfValue)); res = _IS_ERROR; - if (orig_inp_data) /* djb-rwth: fixing a NULL pointer dereference */ + if ( orig_inp_data ) /* djb-rwth: fixing a NULL pointer dereference */ orig_inp_data->num_inp_atoms = -1; goto exit_function; } - if (*mind_polymers || mind_pseudoelements) + if ( *mind_polymers || mind_pseudoelements ) { /*OrigAtData_DebugTrace(orig_inp_data);*/ - if (*mind_polymers && + if ( *mind_polymers && ip->bPolymers != POLYMERS_MODERN && - (ip->bFrameShiftScheme == FSS_STARS_CYCLED || ip->bFrameShiftScheme == FSS_STARS_CYCLED_SORTED)) + (ip->bFrameShiftScheme == FSS_STARS_CYCLED || ip->bFrameShiftScheme == FSS_STARS_CYCLED_SORTED) ) { - /* Analyze and cyclize frame-shift eligible CRUs using InChI canonical numbers - (do this only at older polymer treatment modes 1.05, 1.05+) + /* Analyze and cyclize frame-shift eligible CRUs using InChI canonical numbers + (do this only at older polymer treatment modes 1.05, 1.05+) */ - res = OAD_Polymer_CyclizeCloseableUnits( orig_inp_data, - ip->bPolymers, - sd->pStrErrStruct, - ip->bNoWarnings ); - if (res) + res = OAD_Polymer_CyclizeCloseableUnits(orig_inp_data, + ip->bPolymers, + sd->pStrErrStruct, + ip->bNoWarnings); + if ( res ) { sd->nErrorCode = res; AddErrorMessage(sd->pStrErrStruct, "Error while processing polymer-related input"); @@ -2951,31 +3020,31 @@ int ValidateAndPreparePolymerAndPseudoatoms( struct tagINCHI_CLOCK *ic, /**************************************************************************** Get InChI and AuxInfo of totally unedited original structure. The intent is to preserve AuxInfo for the very original structure - in order to keep a final ability to restore that structure. + in order to keep a final ability to restore that structure. ****************************************************************************/ -int OAD_ProcessOneStructureNoEdits( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits, - int *n_pzz, - char **sinchi, - char **saux) +int OAD_ProcessOneStructureNoEdits(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits, + int* n_pzz, + char** sinchi, + char** saux) { size_t slen; int ret = _IS_OKAY, dup_fail = 0; - POSEContext dup_context, *dup = &dup_context; + POSEContext dup_context, * dup = &dup_context; *n_pzz = 0; *sinchi = NULL; @@ -2986,7 +3055,7 @@ int OAD_ProcessOneStructureNoEdits( struct tagINCHI_CLOCK *ic, inp_file, log_file, out_file, prb_file, orig_inp_data, prep_inp_data, num_inp, strbuf, save_opt_bits); - if (dup_fail) + if ( dup_fail ) { ret = _IS_ERROR; goto exit_function; @@ -3002,38 +3071,38 @@ int OAD_ProcessOneStructureNoEdits( struct tagINCHI_CLOCK *ic, /*dup->ip.bTautFlags |= TG_FLAG_RECONNECT_COORD;*/ /* Calculate */ - ret = ProcessOneStructureExCore( ic, CG, &dup->sd, &dup->ip, dup->szTitle, - dup->pINChI2, dup->pINChI_Aux2, - dup->inp_file, dup->log_file, - dup->out_file, dup->prb_file, - dup->orig_inp_data, dup->prep_inp_data, - dup->num_inp, dup->strbuf, dup->save_opt_bits ); + ret = ProcessOneStructureExCore(ic, CG, &dup->sd, &dup->ip, dup->szTitle, + dup->pINChI2, dup->pINChI_Aux2, + dup->inp_file, dup->log_file, + dup->out_file, dup->prb_file, + dup->orig_inp_data, dup->prep_inp_data, + dup->num_inp, dup->strbuf, dup->save_opt_bits); - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } - + *n_pzz = dup->orig_inp_data->polymer->n_pzz; /* Extract InChI */ slen = dup->out_file->s.nUsedLength; extract_inchi_substring(sinchi, dup->out_file->s.pStr, slen); - if (!*sinchi) + if ( !*sinchi ) { ret = _IS_ERROR; } - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } /* Extract AuxInfo */ slen = dup->out_file->s.nUsedLength; extract_auxinfo_substring(saux, dup->out_file->s.pStr, slen); - if (!*saux) + if ( !*saux ) { ret = _IS_ERROR; } - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } @@ -3048,38 +3117,38 @@ int OAD_ProcessOneStructureNoEdits( struct tagINCHI_CLOCK *ic, /**************************************************************************** Get InChI and AuxInfo of original structure using 1.05+ InChI version. ****************************************************************************/ -int OAD_ProcessOneStructure105Plus( struct tagINCHI_CLOCK *ic, - struct tagCANON_GLOBALS *CG, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - char *szTitle, - PINChI2 *pINChI2[INCHI_NUM], - PINChI_Aux2 *pINChI_Aux2[INCHI_NUM], - INCHI_IOSTREAM *inp_file, - INCHI_IOSTREAM *log_file, - INCHI_IOSTREAM *out_file, - INCHI_IOSTREAM *prb_file, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data, - long num_inp, - INCHI_IOS_STRING *strbuf, - unsigned char save_opt_bits, - char **sinchi, - char **saux) +int OAD_ProcessOneStructure105Plus(struct tagINCHI_CLOCK* ic, + struct tagCANON_GLOBALS* CG, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + char* szTitle, + PINChI2* pINChI2[INCHI_NUM], + PINChI_Aux2* pINChI_Aux2[INCHI_NUM], + INCHI_IOSTREAM* inp_file, + INCHI_IOSTREAM* log_file, + INCHI_IOSTREAM* out_file, + INCHI_IOSTREAM* prb_file, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data, + long num_inp, + INCHI_IOS_STRING* strbuf, + unsigned char save_opt_bits, + char** sinchi, + char** saux) { size_t slen; int ret = _IS_OKAY, dup_fail = 0; - POSEContext dup_context, *dup = &dup_context; + POSEContext dup_context, * dup = &dup_context; *sinchi = NULL; *saux = NULL; /* Make a working copy of all the native input */ dup_fail = POSEContext_Init(dup, sd, ip, szTitle, pINChI2, pINChI_Aux2, - inp_file, log_file, out_file, prb_file, - orig_inp_data, prep_inp_data, - num_inp, strbuf, save_opt_bits); - if (dup_fail) + inp_file, log_file, out_file, prb_file, + orig_inp_data, prep_inp_data, + num_inp, strbuf, save_opt_bits); + if ( dup_fail ) { ret = _IS_ERROR; goto exit_function; @@ -3095,13 +3164,13 @@ int OAD_ProcessOneStructure105Plus( struct tagINCHI_CLOCK *ic, /* Calculate */ ret = ProcessOneStructureExCore(ic, CG, &dup->sd, &dup->ip, dup->szTitle, - dup->pINChI2, dup->pINChI_Aux2, - dup->inp_file, dup->log_file, - dup->out_file, dup->prb_file, - dup->orig_inp_data, dup->prep_inp_data, - dup->num_inp, dup->strbuf, dup->save_opt_bits); + dup->pINChI2, dup->pINChI_Aux2, + dup->inp_file, dup->log_file, + dup->out_file, dup->prb_file, + dup->orig_inp_data, dup->prep_inp_data, + dup->num_inp, dup->strbuf, dup->save_opt_bits); - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } @@ -3109,22 +3178,22 @@ int OAD_ProcessOneStructure105Plus( struct tagINCHI_CLOCK *ic, /* Extract InChI */ slen = dup->out_file->s.nUsedLength; extract_inchi_substring(sinchi, dup->out_file->s.pStr, slen); - if (!*sinchi) + if ( !*sinchi ) { ret = _IS_ERROR; } - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } /* Extract AuxInfo */ slen = dup->out_file->s.nUsedLength; extract_auxinfo_substring(saux, dup->out_file->s.pStr, slen); - if (!*saux) + if ( !*saux ) { ret = _IS_ERROR; } - if (ret == _IS_FATAL || ret == _IS_ERROR) + if ( ret == _IS_FATAL || ret == _IS_ERROR ) { goto exit_function; } @@ -3141,56 +3210,56 @@ int OAD_ProcessOneStructure105Plus( struct tagINCHI_CLOCK *ic, Mark atoms to be renumbered or removed at_renum[initial number] := new_number or -1 (mark of deletion) ****************************************************************************/ -int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, - OAD_StructureEdits *ed, - int *at_renum) +int mark_atoms_to_delete_or_renumber(ORIG_ATOM_DATA* orig_at_data, + OAD_StructureEdits* ed, + int* at_renum) { int i, j; - int fail=0, ret = 0; - size_t *atnums = NULL; /* djb-rwth: needs to be size_t type */ + int fail = 0, ret = 0; + size_t* atnums = NULL; /* djb-rwth: needs to be size_t type */ size_t max_atoms = orig_at_data->num_inp_atoms; - /* NB: new/old ORIG_ATOM_DATA atom numbers are 0-based (==orig_number-1) + /* NB: new/old ORIG_ATOM_DATA atom numbers are 0-based (==orig_number-1) while those in ed->... are just 1-based orig_numbers */ - - for (i = 0; (size_t)i < max_atoms; i++) + + for ( i = 0; (size_t)i < max_atoms; i++ ) { at_renum[i] = i; } - if (ed->del_side_chains) + if ( ed->del_side_chains ) { /* Extend list of atoms to be deleted with those connected to original ones (i.e., delete a whole connected component(s) comprising original atoms) */ int natnums = 0; - atnums = (size_t *)inchi_calloc(max_atoms, sizeof(size_t)); /* djb-rwth: size_t type used for max_atoms to fit the definition of inchi_calloc */ - if (!atnums) + atnums = (size_t*)inchi_calloc(max_atoms, sizeof(size_t)); /* djb-rwth: size_t type used for max_atoms to fit the definition of inchi_calloc */ + if ( !atnums ) { return _IS_ERROR; } - for (i = 0; (size_t)i < max_atoms; i++) + for ( i = 0; (size_t)i < max_atoms; i++ ) { int iatom = ed->del_atom->item[i] - 1; - subgraf *sg = NULL; - subgraf_pathfinder *spf = NULL; - if (i >= ed->del_atom->used) /* NB: ed->del_atom->used may be increased within this loop */ + subgraf* sg = NULL; + subgraf_pathfinder* spf = NULL; + if ( i >= ed->del_atom->used ) /* NB: ed->del_atom->used may be increased within this loop */ { break; } - for (j = 0; (size_t)j < max_atoms; j++) + for ( j = 0; (size_t)j < max_atoms; j++ ) { atnums[j] = orig_at_data->at[j].orig_at_number; /*j+1;*/ } sg = subgraf_new(orig_at_data, max_atoms, (int*)atnums); memset(atnums, 0, max_atoms * sizeof(int)); /* djb-rwth: memset_s C11/Annex K variant? */ - if (!sg) + if ( !sg ) { ret = _IS_ERROR; goto exit_function; } spf = subgraf_pathfinder_new(sg, orig_at_data, iatom, iatom); - if (!spf) + if ( !spf ) { ret = _IS_ERROR; goto exit_function; @@ -3198,8 +3267,9 @@ int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, spf->start = iatom; spf->nseen = 0; natnums = subgraf_pathfinder_collect_all(spf, 0, NULL, (int*)atnums); - if (natnums) + if ( natnums ) { + for (j = 0; j < natnums && j < max_atoms; j++) /* djb-rwth: fixing buffer overruns */ { fail = IntArray_AppendIfAbsent(ed->del_atom, atnums[j]); @@ -3216,17 +3286,17 @@ int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, } /* if (ed->del_side_chains) */ - for (i = max_atoms - 1; i >= 0; i--) + for ( i = max_atoms - 1; i >= 0; i-- ) { int orig_num = i + 1; /* NB: ed->del_atom->item contains orig# which are (OAD# + 1) */ - if (is_in_the_ilist(ed->del_atom->item, orig_num, ed->del_atom->used)) + if ( is_in_the_ilist(ed->del_atom->item, orig_num, ed->del_atom->used) ) { /* mark as deleted atnum */ at_renum[i] = -1; /* shift other atnums */ - for (j = max_atoms - 1; j > i; j--) + for ( j = max_atoms - 1; j > i; j-- ) { - if (at_renum[j] != -1) + if ( at_renum[j] != -1 ) { at_renum[j]--; } @@ -3236,7 +3306,7 @@ int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, exit_function: - if (atnums) + if ( atnums ) { inchi_free(atnums); } @@ -3246,8 +3316,8 @@ int mark_atoms_to_delete_or_renumber( ORIG_ATOM_DATA *orig_at_data, #if (BUILD_WITH_ENG_OPTIONS==1) #if ALLOW_SUBSTRUCTURE_FILTERING==1 -int check_presence_of_the_encoded_substructure(ORIG_ATOM_DATA *orig_inp_data); -int OrigAtData_CheckForSubstructure(ORIG_ATOM_DATA *orig_inp_data) +int check_presence_of_the_encoded_substructure(ORIG_ATOM_DATA* orig_inp_data); +int OrigAtData_CheckForSubstructure(ORIG_ATOM_DATA* orig_inp_data) { int ok = 0; @@ -3255,21 +3325,21 @@ int OrigAtData_CheckForSubstructure(ORIG_ATOM_DATA *orig_inp_data) return ok; } -int check_presence_of_the_encoded_substructure(ORIG_ATOM_DATA *oad) +int check_presence_of_the_encoded_substructure(ORIG_ATOM_DATA* oad) { int i, ok; /* Place sub-structure filtering code below. Return 1 if structure matches some hard-coded pattern - + In this example pattern is a presence of a pseudo atom. */ ok = 0; - for (i = 0; i < oad->num_inp_atoms; i++) + for ( i = 0; i < oad->num_inp_atoms; i++ ) { - if (oad->at[i].el_number == EL_NUMBER_ZZ || oad->at[i].el_number == EL_NUMBER_ZY) + if ( oad->at[i].el_number == EL_NUMBER_ZZ || oad->at[i].el_number == EL_NUMBER_ZY ) { ok = 1; break; diff --git a/INCHI-1-SRC/INCHI_BASE/src/runichi3.c b/INCHI-1-SRC/INCHI_BASE/src/runichi3.c index b3c191c0..42fe13c7 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/runichi3.c +++ b/INCHI-1-SRC/INCHI_BASE/src/runichi3.c @@ -76,63 +76,63 @@ #include "bcf_s.h" /* Local prototypes */ -static int OrigAtData_bCheckUnusualValences( ORIG_ATOM_DATA *orig_at_data, - int bAddIsoH, - char *pStrErrStruct, - int bNoWarnings); +static int OrigAtData_bCheckUnusualValences(ORIG_ATOM_DATA* orig_at_data, + int bAddIsoH, + char* pStrErrStruct, + int bNoWarnings); -static void OAD_PolymerUnit_RemoveLinkFromCRUChain( int at1, int at2, int *nbonds, int **bonds ); +static void OAD_PolymerUnit_RemoveLinkFromCRUChain(int at1, int at2, int* nbonds, int** bonds); /**************************************************************************** Check inp_ATOM's for unusual valence ****************************************************************************/ -int OrigAtData_bCheckUnusualValences( ORIG_ATOM_DATA *orig_at_data, - int bAddIsoH, - char *pStrErrStruct, - int bNoWarnings) +int OrigAtData_bCheckUnusualValences(ORIG_ATOM_DATA* orig_at_data, + int bAddIsoH, + char* pStrErrStruct, + int bNoWarnings) { int i, val, num_found = 0; char msg[32]; int len, num_H; - int already_here = ( orig_at_data && orig_at_data->num_inp_atoms > 0 ); + int already_here = (orig_at_data && orig_at_data->num_inp_atoms > 0); - inp_ATOM *at = already_here ? orig_at_data->at : NULL; + inp_ATOM* at = already_here ? orig_at_data->at : NULL; - if (at) + if ( at ) { - for (i = 0, num_found = 0; i < orig_at_data->num_inp_atoms; i++) + for ( i = 0, num_found = 0; i < orig_at_data->num_inp_atoms; i++ ) { - num_H = bAddIsoH ? NUMH( at, i ) : at[i].num_H; + num_H = bAddIsoH ? NUMH(at, i) : at[i].num_H; - val = detect_unusual_el_valence( at[i].el_number, - at[i].charge, - at[i].radical, - at[i].chem_bonds_valence, - num_H, - at[i].valence ); - if (val) + val = detect_unusual_el_valence(at[i].el_number, + at[i].charge, + at[i].radical, + at[i].chem_bonds_valence, + num_H, + at[i].valence); + if ( val ) { num_found++; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErrStruct, "Accepted unusual valence(s):" ); + WarningMessage(pStrErrStruct, "Accepted unusual valence(s):"); } len = sprintf(msg, "%s", at[i].elname); - if (at[i].charge) + if ( at[i].charge ) { len += sprintf(msg + len, "%+d", at[i].charge); } - if (at[i].radical) + if ( at[i].radical ) { len += sprintf(msg + len, ",%s", at[i].radical == RADICAL_SINGLET ? "s" : at[i].radical == RADICAL_DOUBLET ? "d" : at[i].radical == RADICAL_TRIPLET ? "t" : "?"); } len += sprintf(msg + len, "(%d)", val); - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErrStruct, msg ); + WarningMessage(pStrErrStruct, msg); } } } @@ -145,92 +145,92 @@ int OrigAtData_bCheckUnusualValences( ORIG_ATOM_DATA *orig_at_data, /**************************************************************************** Make a copy of ORIG_ATOM_DATA ****************************************************************************/ -int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, - ORIG_ATOM_DATA *orig_atom ) +int OrigAtData_Duplicate(ORIG_ATOM_DATA* new_orig_atom, + ORIG_ATOM_DATA* orig_atom) { - inp_ATOM *at = NULL; - AT_NUMB *nCurAtLen = NULL; - AT_NUMB *nOldCompNumber = NULL; + inp_ATOM* at = NULL; + AT_NUMB* nCurAtLen = NULL; + AT_NUMB* nOldCompNumber = NULL; int k, m, nn; int orig_nat = orig_atom->num_inp_atoms; int ret = -1; /* fail; 0 - OK */ - if (new_orig_atom->at && - new_orig_atom->num_inp_atoms >= orig_nat) + if ( new_orig_atom->at && + new_orig_atom->num_inp_atoms >= orig_nat ) { at = new_orig_atom->at; } else { - at = (inp_ATOM *) inchi_calloc( (long long)orig_nat + 1, sizeof( at[0] ) ); /* djb-rwth: cast operator added */ - if (!at) + at = (inp_ATOM*)inchi_calloc((long long)orig_nat + 1, sizeof(at[0])); /* djb-rwth: cast operator added */ + if ( !at ) { goto exit_function; } } - if (new_orig_atom->nOldCompNumber && - new_orig_atom->num_components >= orig_atom->num_components) + if ( new_orig_atom->nOldCompNumber && + new_orig_atom->num_components >= orig_atom->num_components ) { nCurAtLen = new_orig_atom->nCurAtLen; } else { - nCurAtLen = (AT_NUMB *) inchi_calloc( (long long)orig_atom->num_components + 1, sizeof( nCurAtLen[0] ) ); /* djb-rwth: cast operator added */ - if (!nCurAtLen) + nCurAtLen = (AT_NUMB*)inchi_calloc((long long)orig_atom->num_components + 1, sizeof(nCurAtLen[0])); /* djb-rwth: cast operator added */ + if ( !nCurAtLen ) { goto exit_function; } } - if (new_orig_atom->nCurAtLen && - new_orig_atom->num_components >= orig_atom->num_components) + if ( new_orig_atom->nCurAtLen && + new_orig_atom->num_components >= orig_atom->num_components ) { nOldCompNumber = new_orig_atom->nOldCompNumber; } else { - nOldCompNumber = (AT_NUMB *) inchi_calloc( (long long)orig_atom->num_components + 1, - sizeof( nOldCompNumber[0] ) ); /* djb-rwth: cast operator added */ - if (!nOldCompNumber) + nOldCompNumber = (AT_NUMB*)inchi_calloc((long long)orig_atom->num_components + 1, + sizeof(nOldCompNumber[0])); /* djb-rwth: cast operator added */ + if ( !nOldCompNumber ) { goto exit_function; } } - if (at && nCurAtLen && nOldCompNumber) + if ( at && nCurAtLen && nOldCompNumber ) { /* Copy */ - if (orig_atom->at) + if ( orig_atom->at ) { memcpy(at, orig_atom->at, orig_nat * sizeof(new_orig_atom->at[0])); } - if (orig_atom->nCurAtLen) + if ( orig_atom->nCurAtLen ) { memcpy(nCurAtLen, orig_atom->nCurAtLen, orig_atom->num_components * sizeof(nCurAtLen[0])); } - if (orig_atom->nOldCompNumber) + if ( orig_atom->nOldCompNumber ) { memcpy(nOldCompNumber, orig_atom->nOldCompNumber, orig_atom->num_components * sizeof(nOldCompNumber[0])); } /* Deallocate */ - if (new_orig_atom->at && new_orig_atom->at != at) + if ( new_orig_atom->at && new_orig_atom->at != at ) { - inchi_free( new_orig_atom->at ); + inchi_free(new_orig_atom->at); } - if (new_orig_atom->nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen) + if ( new_orig_atom->nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen ) { - inchi_free( new_orig_atom->nCurAtLen ); + inchi_free(new_orig_atom->nCurAtLen); } - if (new_orig_atom->nOldCompNumber && - new_orig_atom->nOldCompNumber != nOldCompNumber) + if ( new_orig_atom->nOldCompNumber && + new_orig_atom->nOldCompNumber != nOldCompNumber ) { - inchi_free( new_orig_atom->nOldCompNumber ); + inchi_free(new_orig_atom->nOldCompNumber); } *new_orig_atom = *orig_atom; @@ -240,57 +240,57 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, /* Data that are not to be copied */ new_orig_atom->nNumEquSets = 0; - memset( new_orig_atom->bSavedInINCHI_LIB, 0, sizeof( new_orig_atom->bSavedInINCHI_LIB ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( new_orig_atom->bPreprocessed, 0, sizeof( new_orig_atom->bPreprocessed ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(new_orig_atom->bSavedInINCHI_LIB, 0, sizeof(new_orig_atom->bSavedInINCHI_LIB)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(new_orig_atom->bPreprocessed, 0, sizeof(new_orig_atom->bPreprocessed)); /* djb-rwth: memset_s C11/Annex K variant? */ - new_orig_atom->szCoord = NULL; - if (orig_atom->szCoord) + new_orig_atom->szCoord = NULL; + if ( orig_atom->szCoord ) { - new_orig_atom->szCoord = (MOL_COORD *) inchi_calloc(orig_nat, sizeof(new_orig_atom->szCoord[0])); - if (!new_orig_atom->szCoord) + new_orig_atom->szCoord = (MOL_COORD*)inchi_calloc(orig_nat, sizeof(new_orig_atom->szCoord[0])); + if ( !new_orig_atom->szCoord ) { goto exit_function; } memcpy(new_orig_atom->szCoord, orig_atom->szCoord, orig_nat * sizeof(new_orig_atom->szCoord[0])); } - + /* Arrays that are not to be copied */ - + new_orig_atom->nEquLabels = NULL; new_orig_atom->nSortedOrder = NULL; new_orig_atom->polymer = NULL; - if (orig_atom->polymer) + if ( orig_atom->polymer ) { /* Polymer stuff -- deep copy */ - OAD_Polymer *oldp = orig_atom->polymer; - OAD_Polymer *newp = NULL; + OAD_Polymer* oldp = orig_atom->polymer; + OAD_Polymer* newp = NULL; - newp = (OAD_Polymer *) inchi_calloc( 1, sizeof( OAD_Polymer ) ); - if (!newp) + newp = (OAD_Polymer*)inchi_calloc(1, sizeof(OAD_Polymer)); + if ( !newp ) { inchi_free(newp); /* djb-rwth: avoiding memory leak */ goto exit_function; } memcpy(newp, orig_atom->polymer, sizeof(OAD_Polymer)); - newp->units = (OAD_PolymerUnit**) inchi_calloc( newp->n, sizeof(OAD_PolymerUnit*) ); /* djb-rwth: inchi_calloc must return OAD_PolymerUnit** */ - if (!newp->units) + newp->units = (OAD_PolymerUnit**)inchi_calloc(newp->n, sizeof(OAD_PolymerUnit*)); /* djb-rwth: inchi_calloc must return OAD_PolymerUnit** */ + if ( !newp->units ) { inchi_free(newp); /* djb-rwth: avoiding memory leak */ goto exit_function; } - for (k = 0; k < orig_atom->polymer->n; k++) + for ( k = 0; k < orig_atom->polymer->n; k++ ) { - newp->units[k] = OAD_PolymerUnit_CreateCopy( orig_atom->polymer->units[k] ); + newp->units[k] = OAD_PolymerUnit_CreateCopy(orig_atom->polymer->units[k]); } - if (oldp->n_pzz > 0) + if ( oldp->n_pzz > 0 ) { newp->n_pzz = oldp->n_pzz; - newp->pzz = (int *) inchi_calloc( newp->n_pzz, sizeof( int ) ); - if (!newp->pzz) + newp->pzz = (int*)inchi_calloc(newp->n_pzz, sizeof(int)); + if ( !newp->pzz ) { inchi_free(newp->units); /* djb-rwth: fixing coverity CID #499546 */ inchi_free(newp); /* djb-rwth: avoiding memory leak */ @@ -302,50 +302,50 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, } new_orig_atom->v3000 = NULL; - if (orig_atom->v3000) + if ( orig_atom->v3000 ) { /* V3000 features -- deep copy */ - OAD_V3000 *new_v3000 = NULL; - new_v3000 = (OAD_V3000 *) inchi_calloc( 1, sizeof( OAD_V3000 ) ); - if (!new_v3000) + OAD_V3000* new_v3000 = NULL; + new_v3000 = (OAD_V3000*)inchi_calloc(1, sizeof(OAD_V3000)); + if ( !new_v3000 ) { inchi_free(new_v3000); /* djb-rwth: avoiding memory leak */ goto exit_function; } memcpy(new_v3000, orig_atom->v3000, sizeof(OAD_V3000)); - if (orig_atom->v3000->atom_index_orig) + if ( orig_atom->v3000->atom_index_orig ) { - new_v3000->atom_index_orig = (int *) inchi_calloc( orig_nat, sizeof( int ) ); + new_v3000->atom_index_orig = (int*)inchi_calloc(orig_nat, sizeof(int)); /* if ( NULL==new_v3000->atom_index_orig ) {TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; } */ - if (!new_v3000->atom_index_orig) + if ( !new_v3000->atom_index_orig ) { inchi_free(new_v3000); /* djb-rwth: avoiding memory leak */ goto exit_function; } memcpy(new_v3000->atom_index_orig, orig_atom->v3000->atom_index_orig, orig_nat * sizeof(int)); } - if (orig_atom->v3000->atom_index_fin) + if ( orig_atom->v3000->atom_index_fin ) { - new_v3000->atom_index_fin = (int *) inchi_calloc( orig_nat, sizeof( int ) ); + new_v3000->atom_index_fin = (int*)inchi_calloc(orig_nat, sizeof(int)); /* if ( NULL==new_v3000->atom_index_fin ) {TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; } */ - if (!new_v3000->atom_index_fin) + if ( !new_v3000->atom_index_fin ) { inchi_free(new_v3000); /* djb-rwth: avoiding memory leak */ goto exit_function; } memcpy(new_v3000->atom_index_fin, orig_atom->v3000->atom_index_fin, orig_nat * sizeof(int)); } - if (orig_atom->v3000->n_haptic_bonds && orig_atom->v3000->lists_haptic_bonds) + if ( orig_atom->v3000->n_haptic_bonds && orig_atom->v3000->lists_haptic_bonds ) { - new_v3000->lists_haptic_bonds = (int **) inchi_calloc( orig_atom->v3000->n_haptic_bonds, sizeof( int* ) ); + new_v3000->lists_haptic_bonds = (int**)inchi_calloc(orig_atom->v3000->n_haptic_bonds, sizeof(int*)); /* if ( NULL==new_v3000->lists_haptic_bonds ) { TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; }*/ - for (m = 0; m < orig_atom->v3000->n_haptic_bonds; m++) + for ( m = 0; m < orig_atom->v3000->n_haptic_bonds; m++ ) { - int *lst = NULL; - int *old_lst = orig_atom->v3000->lists_haptic_bonds[m]; + int* lst = NULL; + int* old_lst = orig_atom->v3000->lists_haptic_bonds[m]; nn = old_lst[2] + 3; - lst = new_v3000->lists_haptic_bonds[m] = (int *) inchi_calloc( nn, sizeof( int ) ); - if (!lst) + lst = new_v3000->lists_haptic_bonds[m] = (int*)inchi_calloc(nn, sizeof(int)); + if ( !lst ) { inchi_free(new_v3000->lists_haptic_bonds); /* djb-rwth: fixing coverity CID #499504 */ inchi_free(new_v3000->atom_index_orig); /* djb-rwth: fixing coverity CID #499540 */ @@ -356,17 +356,17 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, memcpy(lst, old_lst, nn * sizeof(int)); } } - if (orig_atom->v3000->n_steabs && orig_atom->v3000->lists_steabs) + if ( orig_atom->v3000->n_steabs && orig_atom->v3000->lists_steabs ) { - new_v3000->lists_steabs = (int **) inchi_calloc( orig_atom->v3000->n_steabs, sizeof( int* ) ); + new_v3000->lists_steabs = (int**)inchi_calloc(orig_atom->v3000->n_steabs, sizeof(int*)); /* if ( NULL==new_v3000->lists_steabs ) { TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; }*/ - for (m = 0; m < orig_atom->v3000->n_steabs; m++) + for ( m = 0; m < orig_atom->v3000->n_steabs; m++ ) { - int *lst = NULL; - int *old_lst = orig_atom->v3000->lists_steabs[m]; + int* lst = NULL; + int* old_lst = orig_atom->v3000->lists_steabs[m]; nn = old_lst[1] + 2; - lst = new_v3000->lists_steabs[m] = (int *) inchi_calloc( nn, sizeof( int ) ); - if (!lst) + lst = new_v3000->lists_steabs[m] = (int*)inchi_calloc(nn, sizeof(int)); + if ( !lst ) { inchi_free(new_v3000->lists_haptic_bonds); /* djb-rwth: fixing coverity CID #499504 */ inchi_free(new_v3000->lists_steabs); /* djb-rwth: fixing coverity CID #499543 */ @@ -378,23 +378,23 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, memcpy(lst, old_lst, nn * sizeof(int)); } } - if (orig_atom->v3000->n_sterel && orig_atom->v3000->lists_sterel) + if ( orig_atom->v3000->n_sterel && orig_atom->v3000->lists_sterel ) { - new_v3000->lists_sterel = (int **) inchi_calloc( orig_atom->v3000->n_sterel, sizeof( int* ) ); - if (!new_v3000) + new_v3000->lists_sterel = (int**)inchi_calloc(orig_atom->v3000->n_sterel, sizeof(int*)); + if ( !new_v3000 ) { inchi_free(new_v3000); /* djb-rwth: avoiding memory leak */ goto exit_function; } /* if ( NULL==new_v3000->lists_sterel ) { TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; }*/ - for (m = 0; m < orig_atom->v3000->n_sterel; m++) + for ( m = 0; m < orig_atom->v3000->n_sterel; m++ ) { - int *lst = NULL; - int *old_lst = orig_atom->v3000->lists_sterel[m]; + int* lst = NULL; + int* old_lst = orig_atom->v3000->lists_sterel[m]; nn = old_lst[1] + 2; - if (new_v3000->lists_sterel) /* djb-rwth: fixing a NULL pointer dereference */ - lst = new_v3000->lists_sterel[m] = (int *) inchi_calloc( nn, sizeof( int ) ); - if (!lst) + if ( new_v3000->lists_sterel ) /* djb-rwth: fixing a NULL pointer dereference */ + lst = new_v3000->lists_sterel[m] = (int*)inchi_calloc(nn, sizeof(int)); + if ( !lst ) { inchi_free(new_v3000->lists_haptic_bonds); /* djb-rwth: fixing coverity CID #499504 */ inchi_free(new_v3000->lists_steabs); /* djb-rwth: fixing coverity CID #499543 */ @@ -407,19 +407,19 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, memcpy(lst, old_lst, nn * sizeof(int)); } } - if (orig_atom->v3000->n_sterac && orig_atom->v3000->lists_sterac) + if ( orig_atom->v3000->n_sterac && orig_atom->v3000->lists_sterac ) { - new_v3000->lists_sterac = (int **) inchi_calloc( orig_atom->v3000->n_sterac, sizeof( int* ) ); + new_v3000->lists_sterac = (int**)inchi_calloc(orig_atom->v3000->n_sterac, sizeof(int*)); /* if ( NULL==new_v3000->lists_sterac ) { TREAT_ERR( err, 9001, "Out of RAM"); goto exit_function; }*/ - if (new_v3000->lists_sterac) /* djb-rwth: fixing a NULL pointer dereference */ + if ( new_v3000->lists_sterac ) /* djb-rwth: fixing a NULL pointer dereference */ { - for (m = 0; m < orig_atom->v3000->n_sterac; m++) + for ( m = 0; m < orig_atom->v3000->n_sterac; m++ ) { int* lst = NULL; int* old_lst = orig_atom->v3000->lists_sterac[m]; nn = old_lst[1] + 2; lst = new_v3000->lists_sterac[m] = (int*)inchi_calloc(nn, sizeof(int)); - if (!lst) + if ( !lst ) { inchi_free(new_v3000->lists_haptic_bonds); /* djb-rwth: fixing coverity CID #499504 */ inchi_free(new_v3000->lists_steabs); /* djb-rwth: fixing coverity CID #499543 */ @@ -444,14 +444,14 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, exit_function: - if (ret != 0) + if ( ret != 0 ) { - if (at && new_orig_atom->at != at) - inchi_free( at ); - if (nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen) - inchi_free( nCurAtLen ); - if (nOldCompNumber && new_orig_atom->nOldCompNumber != nOldCompNumber) - inchi_free( nOldCompNumber ); + if ( at && new_orig_atom->at != at ) + inchi_free(at); + if ( nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen ) + inchi_free(nCurAtLen); + if ( nOldCompNumber && new_orig_atom->nOldCompNumber != nOldCompNumber ) + inchi_free(nOldCompNumber); } return ret; @@ -485,11 +485,11 @@ int OrigAtData_Duplicate( ORIG_ATOM_DATA *new_orig_atom, - save reconnected structure in prep_inp_data+1 if requested - make Disconnected structure in prep_inp_data ****************************************************************************/ -int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, - STRUCT_DATA *sd, - INPUT_PARMS *ip, - ORIG_ATOM_DATA *orig_inp_data, - ORIG_ATOM_DATA *prep_inp_data ) +int PreprocessOneStructure(struct tagINCHI_CLOCK* ic, + STRUCT_DATA* sd, + INPUT_PARMS* ip, + ORIG_ATOM_DATA* orig_inp_data, + ORIG_ATOM_DATA* prep_inp_data) { int i; INCHI_MODE bTautFlags = 0; @@ -497,16 +497,16 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* 1. Copy orig_inp_data --> prep_inp_data */ - if (0 > OrigAtData_Duplicate( prep_inp_data, orig_inp_data )) + if ( 0 > OrigAtData_Duplicate(prep_inp_data, orig_inp_data) ) { - AddErrorMessage( sd->pStrErrStruct, "Out of RAM" ); + AddErrorMessage(sd->pStrErrStruct, "Out of RAM"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; goto exit_function; } #if ( bRELEASE_VERSION == 0 && (EXTR_HAS_METAL_ATOM & (EXTR_MASK | EXTR_FLAG) ) ) - if (bHasMetalAtom( orig_inp_data )) + if ( bHasMetalAtom(orig_inp_data) ) { sd->bExtract |= EXTR_HAS_METAL_ATOM; } @@ -514,14 +514,14 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* 2. Fix odd things in prep_inp_data */ - if (0 < fix_odd_things( prep_inp_data->num_inp_atoms, prep_inp_data->at, /*0*/ip->bTautFlags & TG_FLAG_FIX_SP3_BUG, ip->bFixNonUniformDraw )) + if ( 0 < fix_odd_things(prep_inp_data->num_inp_atoms, prep_inp_data->at, /*0*/ip->bTautFlags & TG_FLAG_FIX_SP3_BUG, ip->bFixNonUniformDraw) ) { /* changed 2010-03-17 DT */ - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Charges were rearranged" ); + WarningMessage(sd->pStrErrStruct, "Charges were rearranged"); } - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } @@ -529,9 +529,9 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, } #if ( FIX_ADJ_RAD == 1 ) - if (ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS) + if ( ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS ) { - if (0 < FixAdjacentRadicals( prep_inp_data->num_inp_atoms, prep_inp_data->at )) + if ( 0 < FixAdjacentRadicals(prep_inp_data->num_inp_atoms, prep_inp_data->at) ) { sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_FIX_ADJ_RADICALS_DONE; } @@ -539,7 +539,7 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, #endif #if ( bRELEASE_VERSION == 0 && (EXTR_FLAGS & EXTR_HAS_FEATURE) ) - if (bFoundFeature( prep_inp_data->at, prep_inp_data->num_inp_atoms )) + if ( bFoundFeature(prep_inp_data->at, prep_inp_data->num_inp_atoms) ) { sd->bExtract |= EXTR_HAS_FEATURE; } @@ -551,9 +551,14 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* Needs salt disconnection? */ - if (ip->bTautFlags & TG_FLAG_DISCONNECT_SALTS) + /* (@nnuk -> Nauman Ullah Khan) :: In case of Metal Salts with MolecularInorganics parameter we need to skip this pre-processing of Salts */ + if ( ip->bMolecularInorganics ) + { + ; + } + else if ( ip->bTautFlags & TG_FLAG_DISCONNECT_SALTS ) { - prep_inp_data->bDisconnectSalts = ( 0 < DisconnectSalts( prep_inp_data, 0 ) ); + prep_inp_data->bDisconnectSalts = (0 < DisconnectSalts(prep_inp_data, 0)); } else { @@ -562,14 +567,14 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* Needs metal disconnection? */ - if (ip->bTautFlags & TG_FLAG_DISCONNECT_COORD) + if ( ip->bTautFlags & TG_FLAG_DISCONNECT_COORD ) { - i = ( 0 != ( ip->bTautFlags & TG_FLAG_CHECK_VALENCE_COORD ) ); - bMayDisconnectMetals( prep_inp_data, i, &bTautFlagsDone ); /* changes prep_inp_data->bDisconnectCoord */ + i = (0 != (ip->bTautFlags & TG_FLAG_CHECK_VALENCE_COORD)); + bMayDisconnectMetals(prep_inp_data, i, &bTautFlagsDone); /* changes prep_inp_data->bDisconnectCoord */ sd->bTautFlagsDone[INCHI_BAS] |= bTautFlagsDone; /* whether any disconnection has been rejected because of the metal proper valence */ #if ( bRELEASE_VERSION == 0 ) - if (i && ( bTautFlagsDone & TG_FLAG_CHECK_VALENCE_COORD_DONE )) + if ( i && (bTautFlagsDone & TG_FLAG_CHECK_VALENCE_COORD_DONE) ) { sd->bExtract |= EXTR_METAL_WAS_NOT_DISCONNECTED; } @@ -585,24 +590,24 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* 3. if( orig_inp_data->bDisconnectSalts ) then disconnect salts in prep_inp_data */ - if (( ip->bTautFlags & TG_FLAG_DISCONNECT_SALTS ) && prep_inp_data->bDisconnectSalts && - 0 < ( i = DisconnectSalts( prep_inp_data, 1 ) )) /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + if ( (ip->bTautFlags & TG_FLAG_DISCONNECT_SALTS) && prep_inp_data->bDisconnectSalts && + 0 < (i = DisconnectSalts(prep_inp_data, 1)) ) /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Salt was disconnected" ); + WarningMessage(sd->pStrErrStruct, "Salt was disconnected"); } sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_DISCONNECT_SALTS_DONE; - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } - if ((i = ReconcileAllCmlBondParities( prep_inp_data->at, prep_inp_data->num_inp_atoms, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ( (i = ReconcileAllCmlBondParities(prep_inp_data->at, prep_inp_data->num_inp_atoms, 0)) ) /* djb-rwth: addressing LLVM warning */ { char szErrCode[16]; sprintf(szErrCode, "%d", i); - AddErrorMessage( sd->pStrErrStruct, "0D Parities Reconciliation failed:" ); - AddErrorMessage( sd->pStrErrStruct, szErrCode ); + AddErrorMessage(sd->pStrErrStruct, "0D Parities Reconciliation failed:"); + AddErrorMessage(sd->pStrErrStruct, szErrCode); } #if ( bRELEASE_VERSION == 0 ) @@ -616,11 +621,11 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* Mark the (disconnected) components in prep_inp_data */ - prep_inp_data->num_components = MarkDisconnectedComponents( prep_inp_data, 0 ); + prep_inp_data->num_components = MarkDisconnectedComponents(prep_inp_data, 0); - if (prep_inp_data->num_components < 0) + if ( prep_inp_data->num_components < 0 ) { - AddErrorMessage( sd->pStrErrStruct, "Out of RAM" ); + AddErrorMessage(sd->pStrErrStruct, "Out of RAM"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; goto exit_function; @@ -629,13 +634,13 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* Detect isotopic H on heteroatoms -- necessary condition for global isotopic tautomerism */ - if ((i = bNumHeterAtomHasIsotopicH( prep_inp_data->at, prep_inp_data->num_inp_atoms ))) /* djb-rwth: addressing LLVM warning */ + if ( (i = bNumHeterAtomHasIsotopicH(prep_inp_data->at, prep_inp_data->num_inp_atoms)) ) /* djb-rwth: addressing LLVM warning */ { - if (i & 1) + if ( i & 1 ) { sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_FOUND_ISOTOPIC_H_DONE; } - if (i & 2) + if ( i & 2 ) { sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE; } @@ -643,7 +648,7 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, /* 4a. Detect unusual valences */ - if (OrigAtData_bCheckUnusualValences( prep_inp_data, 1, sd->pStrErrStruct, ip->bNoWarnings )) + if ( OrigAtData_bCheckUnusualValences(prep_inp_data, 1, sd->pStrErrStruct, ip->bNoWarnings) ) { #if ( bRELEASE_VERSION == 0 ) sd->bExtract |= EXTR_UNUSUAL_VALENCES; @@ -657,24 +662,29 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, -- copy prep_inp_data --> prep_inp_data+1 -- disconnect metals in prep_inp_data */ - if (prep_inp_data->bDisconnectCoord) + /* (@nnuk -> Nauman Ullah Khan) :: In case of Metals with MolecularInorganics parameter we need to skip this pre-processing of Metals */ + if ( ip->bMolecularInorganics ) + { + return 0; /* Skipping over current functionality */ + } + else if ( prep_inp_data->bDisconnectCoord ) { - prep_inp_data->num_components = MarkDisconnectedComponents( prep_inp_data, 0 ); - if (prep_inp_data->num_components < 0) + prep_inp_data->num_components = MarkDisconnectedComponents(prep_inp_data, 0); + if ( prep_inp_data->num_components < 0 ) { - AddErrorMessage( sd->pStrErrStruct, "Out of RAM" ); + AddErrorMessage(sd->pStrErrStruct, "Out of RAM"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; goto exit_function; } /* Save reconnected structure in prep_inp_data+1 if requested */ - if (0 != ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD )) + if ( 0 != (ip->bTautFlags & TG_FLAG_RECONNECT_COORD) ) { - if (0 > OrigAtData_Duplicate( prep_inp_data + 1, prep_inp_data )) + if ( 0 > OrigAtData_Duplicate(prep_inp_data + 1, prep_inp_data) ) { - AddErrorMessage( sd->pStrErrStruct, "Out of RAM" ); + AddErrorMessage(sd->pStrErrStruct, "Out of RAM"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; goto exit_function; @@ -684,11 +694,11 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, { /* Remove "parity undefined in disconnected structure" flag from reconnected structure */ int k, m; /* djb-rwth: removing redundant variables */ - inp_ATOM *at = ( prep_inp_data + 1 )->at; - int num_at = ( prep_inp_data + 1 )->num_inp_atoms; - for (k = 0; k < num_at; k++) + inp_ATOM* at = (prep_inp_data + 1)->at; + int num_at = (prep_inp_data + 1)->num_inp_atoms; + for ( k = 0; k < num_at; k++ ) { - for (m = 0; m < MAX_NUM_STEREO_BONDS && at[k].sb_parity[m]; m++) /* djb-rwth: removing redundant code */ + for ( m = 0; m < MAX_NUM_STEREO_BONDS && at[k].sb_parity[m]; m++ ) /* djb-rwth: removing redundant code */ { at[k].sb_parity[m] &= SB_PARITY_MASK; } @@ -697,18 +707,18 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, } /* Make disconnected structure in prep_inp_data */ - i = ( 0 != ( ip->bTautFlags & TG_FLAG_CHECK_VALENCE_COORD ) ); + i = (0 != (ip->bTautFlags & TG_FLAG_CHECK_VALENCE_COORD)); /* prep_inp_data->bDisconnectCoord > 1 means add prep_inp_data->bDisconnectCoord-1 explicit H atoms */ - if (0 < ( i = DisconnectMetals( prep_inp_data, i, &bTautFlagsDone ) )) + if ( 0 < (i = DisconnectMetals(prep_inp_data, i, &bTautFlagsDone)) ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Metal was disconnected" ); + WarningMessage(sd->pStrErrStruct, "Metal was disconnected"); } sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_DISCONNECT_COORD_DONE; - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } @@ -718,11 +728,11 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, #endif /* last parm=1 means find link between unchanged by Metal Disconnection components */ - prep_inp_data->num_components = MarkDisconnectedComponents( prep_inp_data, 1 ); + prep_inp_data->num_components = MarkDisconnectedComponents(prep_inp_data, 1); - if (prep_inp_data->num_components < 0) + if ( prep_inp_data->num_components < 0 ) { - AddErrorMessage( sd->pStrErrStruct, "Out of RAM" ); + AddErrorMessage(sd->pStrErrStruct, "Out of RAM"); sd->nStructReadError = 99; sd->nErrorType = _IS_FATAL; goto exit_function; @@ -731,36 +741,36 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, { /* Set parities for the disconnected structure */ int k, m, p; - inp_ATOM *at = ( prep_inp_data )->at; - int num_at = ( prep_inp_data )->num_inp_atoms; - for (k = 0; k < num_at; k++) + inp_ATOM* at = (prep_inp_data)->at; + int num_at = (prep_inp_data)->num_inp_atoms; + for ( k = 0; k < num_at; k++ ) { - for (m = 0; m < MAX_NUM_STEREO_BONDS && ( p = at[k].sb_parity[m] ); m++) + for ( m = 0; m < MAX_NUM_STEREO_BONDS && (p = at[k].sb_parity[m]); m++ ) { - if (p & SB_PARITY_FLAG) + if ( p & SB_PARITY_FLAG ) { - at[k].sb_parity[m] = ( p >> SB_PARITY_SHFT ) & SB_PARITY_MASK; + at[k].sb_parity[m] = (p >> SB_PARITY_SHFT) & SB_PARITY_MASK; } } } } - if ((i = ReconcileAllCmlBondParities( prep_inp_data->at, prep_inp_data->num_inp_atoms, 1 ))) /* djb-rwth: addressing LLVM warning */ + if ( (i = ReconcileAllCmlBondParities(prep_inp_data->at, prep_inp_data->num_inp_atoms, 1)) ) /* djb-rwth: addressing LLVM warning */ { char szErrCode[16]; sprintf(szErrCode, "%d", i); - AddErrorMessage( sd->pStrErrStruct, "0D Parities Reconciliation failed:" ); - AddErrorMessage( sd->pStrErrStruct, szErrCode ); + AddErrorMessage(sd->pStrErrStruct, "0D Parities Reconciliation failed:"); + AddErrorMessage(sd->pStrErrStruct, szErrCode); } #if ( REMOVE_ION_PAIRS_DISC_STRU == 1 ) - if (0 < remove_ion_pairs( prep_inp_data->num_inp_atoms, prep_inp_data->at )) + if ( 0 < remove_ion_pairs(prep_inp_data->num_inp_atoms, prep_inp_data->at) ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Charges were rearranged" ); + WarningMessage(sd->pStrErrStruct, "Charges were rearranged"); } - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } @@ -774,9 +784,9 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, component #(i+1) in prep_inp_data is identical to component #(iINChI+1) in prep_inp_data+1 */ } - else if (i < 0) + else if ( i < 0 ) { - AddErrorMessage( sd->pStrErrStruct, "Cannot disconnect metal error" ); + AddErrorMessage(sd->pStrErrStruct, "Cannot disconnect metal error"); sd->nStructReadError = i; sd->nErrorType = _IS_ERROR; goto exit_function; @@ -786,11 +796,11 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, { /* Remove "disconnected structure parities" from the structure */ int k, m; /* djb-rwth: removing redundant variables */ - inp_ATOM *at = ( prep_inp_data )->at; - int num_at = ( prep_inp_data )->num_inp_atoms; - for (k = 0; k < num_at; k++) + inp_ATOM* at = (prep_inp_data)->at; + int num_at = (prep_inp_data)->num_inp_atoms; + for ( k = 0; k < num_at; k++ ) { - for (m = 0; m < MAX_NUM_STEREO_BONDS && at[k].sb_parity[m]; m++) /* djb-rwth: removing redundant code */ + for ( m = 0; m < MAX_NUM_STEREO_BONDS && at[k].sb_parity[m]; m++ ) /* djb-rwth: removing redundant code */ { at[k].sb_parity[m] &= SB_PARITY_MASK; } @@ -799,30 +809,30 @@ int PreprocessOneStructure( struct tagINCHI_CLOCK *ic, exit_function: -if (sd->nErrorType < _IS_ERROR && prep_inp_data) + if ( sd->nErrorType < _IS_ERROR && prep_inp_data ) { - if (0 < post_fix_odd_things( prep_inp_data->num_inp_atoms, prep_inp_data->at )) + if ( 0 < post_fix_odd_things(prep_inp_data->num_inp_atoms, prep_inp_data->at) ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Charges were rearranged" ); + WarningMessage(sd->pStrErrStruct, "Charges were rearranged"); } - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } sd->bTautFlagsDone[INCHI_BAS] |= TG_FLAG_FIX_ODD_THINGS_DONE; } - if (( sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE ) && - ( prep_inp_data + 1 )->at && ( prep_inp_data + 1 )->num_inp_atoms > 0) + if ( (sd->bTautFlagsDone[INCHI_BAS] & TG_FLAG_DISCONNECT_COORD_DONE) && + (prep_inp_data + 1)->at && (prep_inp_data + 1)->num_inp_atoms > 0 ) { - if (0 < post_fix_odd_things( ( prep_inp_data + 1 )->num_inp_atoms, ( prep_inp_data + 1 )->at )) + if ( 0 < post_fix_odd_things((prep_inp_data + 1)->num_inp_atoms, (prep_inp_data + 1)->at) ) { - if (!ip->bNoWarnings) + if ( !ip->bNoWarnings ) { - WarningMessage( sd->pStrErrStruct, "Charges were rearranged" ); + WarningMessage(sd->pStrErrStruct, "Charges were rearranged"); } - if (sd->nErrorType < _IS_WARNING) + if ( sd->nErrorType < _IS_WARNING ) { sd->nErrorType = _IS_WARNING; } @@ -843,83 +853,83 @@ if (sd->nErrorType < _IS_ERROR && prep_inp_data) /****************************************************************************/ -int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, - INP_ATOM_DATA2 *all_inp_norm_data, - int num_components ) +int CreateCompositeNormAtom(COMP_ATOM_DATA* composite_norm_data, + INP_ATOM_DATA2* all_inp_norm_data, + int num_components) { int i, j, jj, k, n, m, tot_num_at, tot_num_H, cur_num_at, cur_num_H; /* djb-rwth: removing redundant variables */ int num_comp[TAUT_NUM + 1], num_taut[TAUT_NUM + 1], num_del[TAUT_NUM + 1], num_at[TAUT_NUM + 1], num_inp_at[TAUT_NUM + 1]; int ret = 0, indicator = 1; - inp_ATOM *at, *at_from; - memset( num_comp, 0, sizeof( num_comp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( num_taut, 0, sizeof( num_taut ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( num_del, 0, sizeof( num_taut ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + inp_ATOM* at, * at_from; + memset(num_comp, 0, sizeof(num_comp)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(num_taut, 0, sizeof(num_taut)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(num_del, 0, sizeof(num_taut)); /* djb-rwth: memset_s C11/Annex K variant? */ /* count taut and non-taut components */ - for (j = 0; j < TAUT_NUM; j++) + for ( j = 0; j < TAUT_NUM; j++ ) { num_comp[j] = num_taut[j] = 0; - for (i = 0; i < num_components; i++) + for ( i = 0; i < num_components; i++ ) { - if (all_inp_norm_data[i][j].bExists) + if ( all_inp_norm_data[i][j].bExists ) { - num_del[j] += ( 0 != all_inp_norm_data[i][j].bDeleted ); - num_comp[j] ++; - num_taut[j] += ( 0 != all_inp_norm_data[i][j].bTautomeric ); + num_del[j] += (0 != all_inp_norm_data[i][j].bDeleted); + num_comp[j]++; + num_taut[j] += (0 != all_inp_norm_data[i][j].bTautomeric); } } } /* count intermediate taut structure components */ - if (num_comp[TAUT_YES] > num_del[TAUT_YES] && num_taut[TAUT_YES]) + if ( num_comp[TAUT_YES] > num_del[TAUT_YES] && num_taut[TAUT_YES] ) { /* num_comp[TAUT_INI] = num_comp[TAUT_YES] - num_del[TAUT_YES]; */ - for (i = 0, j = TAUT_YES; i < num_components; i++) + for ( i = 0, j = TAUT_YES; i < num_components; i++ ) { - if (all_inp_norm_data[i][j].bExists && - ( all_inp_norm_data[i][j].bDeleted || + if ( all_inp_norm_data[i][j].bExists && + (all_inp_norm_data[i][j].bDeleted || (all_inp_norm_data[i][j].bTautomeric && - all_inp_norm_data[i][j].at_fixed_bonds && - all_inp_norm_data[i][j].bTautPreprocessed) )) /* djb-rwth: addressing LLVM warning */ + all_inp_norm_data[i][j].at_fixed_bonds && + all_inp_norm_data[i][j].bTautPreprocessed)) ) /* djb-rwth: addressing LLVM warning */ { - num_comp[TAUT_INI] ++; + num_comp[TAUT_INI]++; } } } /* count atoms and allocate composite atom data */ - for (jj = 0; jj <= TAUT_INI; jj++) + for ( jj = 0; jj <= TAUT_INI; jj++ ) { num_at[jj] = num_inp_at[jj] = 0; - j = inchi_min( jj, TAUT_YES ); - if (num_comp[jj]) + j = inchi_min(jj, TAUT_YES); + if ( num_comp[jj] ) { - for (i = 0; i < num_components; i++) + for ( i = 0; i < num_components; i++ ) { - if (all_inp_norm_data[i][j].bDeleted) + if ( all_inp_norm_data[i][j].bDeleted ) { continue; } /* find k = the normaized structure index */ - if (jj == TAUT_INI) + if ( jj == TAUT_INI ) { - if (all_inp_norm_data[i][j].bExists && - all_inp_norm_data[i][j].at_fixed_bonds) + if ( all_inp_norm_data[i][j].bExists && + all_inp_norm_data[i][j].at_fixed_bonds ) { k = j; } else - if (all_inp_norm_data[i][ALT_TAUT( j )].bExists && !all_inp_norm_data[i][ALT_TAUT( j )].bDeleted && - !all_inp_norm_data[i][j].bDeleted) + if ( all_inp_norm_data[i][ALT_TAUT(j)].bExists && !all_inp_norm_data[i][ALT_TAUT(j)].bDeleted && + !all_inp_norm_data[i][j].bDeleted ) { - k = ALT_TAUT( j ); + k = ALT_TAUT(j); } else { - if (all_inp_norm_data[i][j].bExists) + if ( all_inp_norm_data[i][j].bExists ) { k = j; } @@ -931,15 +941,15 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, } else { - if (all_inp_norm_data[i][j].bExists) + if ( all_inp_norm_data[i][j].bExists ) { k = j; } else { - if (all_inp_norm_data[i][ALT_TAUT( j )].bExists && !all_inp_norm_data[i][ALT_TAUT( j )].bDeleted) + if ( all_inp_norm_data[i][ALT_TAUT(j)].bExists && !all_inp_norm_data[i][ALT_TAUT(j)].bDeleted ) { - k = ALT_TAUT( j ); + k = ALT_TAUT(j); } else { @@ -950,9 +960,9 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, num_inp_at[jj] += all_inp_norm_data[i][k].num_at; /* all atoms including terminal H */ num_at[jj] += all_inp_norm_data[i][k].num_at - all_inp_norm_data[i][k].num_removed_H; } - if (num_inp_at[jj]) + if ( num_inp_at[jj] ) { - if (!CreateCompAtomData( composite_norm_data + jj, num_inp_at[jj], num_components, jj == TAUT_INI )) + if ( !CreateCompAtomData(composite_norm_data + jj, num_inp_at[jj], num_components, jj == TAUT_INI) ) { goto exit_error; } @@ -962,19 +972,19 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, } /* fill out composite atom */ - for (jj = 0; jj <= TAUT_INI; jj++, indicator <<= 1) + for ( jj = 0; jj <= TAUT_INI; jj++, indicator <<= 1 ) { - j = inchi_min( jj, TAUT_YES ); - if (num_comp[jj]) + j = inchi_min(jj, TAUT_YES); + if ( num_comp[jj] ) { tot_num_at = 0; tot_num_H = 0; - for (i = 0; i < num_components; i++) + for ( i = 0; i < num_components; i++ ) { - if (all_inp_norm_data[i][j].bDeleted) + if ( all_inp_norm_data[i][j].bDeleted ) { composite_norm_data[jj].nNumRemovedProtons += all_inp_norm_data[i][j].nNumRemovedProtons; - for (n = 0; n < NUM_H_ISOTOPES; n++) + for ( n = 0; n < NUM_H_ISOTOPES; n++ ) { composite_norm_data[jj].nNumRemovedProtonsIsotopic[n] += all_inp_norm_data[i][j].nNumRemovedProtonsIsotopic[n]; } @@ -982,21 +992,21 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, } /* djb-rwth: removing redundant code */ /* find k = the normaized structure index */ - if (jj == TAUT_INI) + if ( jj == TAUT_INI ) { - if (all_inp_norm_data[i][j].bExists && all_inp_norm_data[i][j].at_fixed_bonds) + if ( all_inp_norm_data[i][j].bExists && all_inp_norm_data[i][j].at_fixed_bonds ) { k = j; } else { - if (all_inp_norm_data[i][ALT_TAUT( j )].bExists) + if ( all_inp_norm_data[i][ALT_TAUT(j)].bExists ) { - k = ALT_TAUT( j ); + k = ALT_TAUT(j); } else { - if (all_inp_norm_data[i][j].bExists && !all_inp_norm_data[i][ALT_TAUT( j )].bDeleted) + if ( all_inp_norm_data[i][j].bExists && !all_inp_norm_data[i][ALT_TAUT(j)].bDeleted ) { k = j; } @@ -1009,15 +1019,15 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, } else { - if (all_inp_norm_data[i][j].bExists) + if ( all_inp_norm_data[i][j].bExists ) { k = j; } else { - if (all_inp_norm_data[i][ALT_TAUT( j )].bExists && !all_inp_norm_data[i][ALT_TAUT( j )].bDeleted) + if ( all_inp_norm_data[i][ALT_TAUT(j)].bExists && !all_inp_norm_data[i][ALT_TAUT(j)].bDeleted ) { - k = ALT_TAUT( j ); + k = ALT_TAUT(j); } else { @@ -1029,33 +1039,33 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, cur_num_H = all_inp_norm_data[i][k].num_removed_H; /* number of terminal H atoms */ cur_num_at = all_inp_norm_data[i][k].num_at - cur_num_H; /* number of all but explicit terminal H atoms */ - if (( tot_num_at + cur_num_at ) > num_at[jj] || - ( num_at[jj] + tot_num_H + cur_num_H ) > num_inp_at[jj]) + if ( (tot_num_at + cur_num_at) > num_at[jj] || + (num_at[jj] + tot_num_H + cur_num_H) > num_inp_at[jj] ) { goto exit_error; /* miscount */ } at = composite_norm_data[jj].at + tot_num_at; /* points to the 1st destination atom */ - at_from = ( jj == TAUT_INI && k == TAUT_YES && all_inp_norm_data[i][k].at_fixed_bonds ) ? + at_from = (jj == TAUT_INI && k == TAUT_YES && all_inp_norm_data[i][k].at_fixed_bonds) ? all_inp_norm_data[i][k].at_fixed_bonds : all_inp_norm_data[i][k].at; - memcpy(at, at_from, sizeof(composite_norm_data[0].at[0])* cur_num_at); /* copy atoms except terminal H */ + memcpy(at, at_from, sizeof(composite_norm_data[0].at[0]) * cur_num_at); /* copy atoms except terminal H */ /* shift neighbors of main atoms */ - for (n = 0; n < cur_num_at; n++, at++) + for ( n = 0; n < cur_num_at; n++, at++ ) { - for (m = 0; m < at->valence; m++) + for ( m = 0; m < at->valence; m++ ) { at->neighbor[m] += tot_num_at; } } /* copy explicit H */ - if (cur_num_H) + if ( cur_num_H ) { at = composite_norm_data[jj].at + num_at[jj] + tot_num_H; /* points to the 1st destination atom */ memcpy(at, at_from + cur_num_at, - sizeof(composite_norm_data[0].at[0])* cur_num_H); + sizeof(composite_norm_data[0].at[0]) * cur_num_H); /* shift neighbors of explicit H atoms */ - for (n = 0; n < cur_num_H; n++, at++) + for ( n = 0; n < cur_num_H; n++, at++ ) { - for (m = 0; m < at->valence; m++) + for ( m = 0; m < at->valence; m++ ) { at->neighbor[m] += tot_num_at; } @@ -1065,9 +1075,9 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, composite_norm_data[jj].bHasIsotopicLayer |= all_inp_norm_data[i][k].bHasIsotopicLayer; composite_norm_data[jj].num_isotopic += all_inp_norm_data[i][k].num_isotopic; composite_norm_data[jj].num_bonds += all_inp_norm_data[i][k].num_bonds; - composite_norm_data[jj].bTautomeric += ( j == jj ) && all_inp_norm_data[i][k].bTautomeric; + composite_norm_data[jj].bTautomeric += (j == jj) && all_inp_norm_data[i][k].bTautomeric; composite_norm_data[jj].nNumRemovedProtons += all_inp_norm_data[i][k].nNumRemovedProtons; - for (n = 0; n < NUM_H_ISOTOPES; n++) + for ( n = 0; n < NUM_H_ISOTOPES; n++ ) { composite_norm_data[jj].nNumRemovedProtonsIsotopic[n] += all_inp_norm_data[i][k].nNumRemovedProtonsIsotopic[n]; composite_norm_data[jj].num_iso_H[n] += all_inp_norm_data[i][k].num_iso_H[n]; @@ -1080,18 +1090,18 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, tot_num_at += cur_num_at; tot_num_H += cur_num_H; /* offset for the next component */ - if (composite_norm_data[jj].nOffsetAtAndH) + if ( composite_norm_data[jj].nOffsetAtAndH ) { composite_norm_data[jj].nOffsetAtAndH[2 * i] = tot_num_at; composite_norm_data[jj].nOffsetAtAndH[2 * i + 1] = num_at[jj] + tot_num_H; } } - if (tot_num_at != num_at[jj] || - num_at[jj] + tot_num_H != num_inp_at[jj]) + if ( tot_num_at != num_at[jj] || + num_at[jj] + tot_num_H != num_inp_at[jj] ) { goto exit_error; /* miscount */ } - composite_norm_data[jj].bExists = ( tot_num_at > 0 ); + composite_norm_data[jj].bExists = (tot_num_at > 0); ret |= indicator; } } @@ -1105,44 +1115,44 @@ int CreateCompositeNormAtom( COMP_ATOM_DATA *composite_norm_data, /****************************************************************************/ -void OrigAtData_DebugTrace( ORIG_ATOM_DATA* d ) +void OrigAtData_DebugTrace(ORIG_ATOM_DATA* d) { int i, k; - ITRACE_( "\n\n*********************************************************************\n* ORIG_ATOM_DATA @ 0x%p", d ); - ITRACE_( "\n* num_inp_atoms = %-d\n* num_inp_bonds = %-d\n* num_dimensions = %-d\n* num_components = %-d", - d->num_inp_atoms, d->num_inp_bonds, d->num_dimensions, d->num_components ); - ITRACE_( "\n* ATOMS" ); - for (i = 0; i < d->num_inp_atoms; i++) + ITRACE_("\n\n*********************************************************************\n* ORIG_ATOM_DATA @ 0x%p", d); + ITRACE_("\n* num_inp_atoms = %-d\n* num_inp_bonds = %-d\n* num_dimensions = %-d\n* num_components = %-d", + d->num_inp_atoms, d->num_inp_bonds, d->num_dimensions, d->num_components); + ITRACE_("\n* ATOMS"); + for ( i = 0; i < d->num_inp_atoms; i++ ) { - ITRACE_( "\n* #%-5d %s%-d ( charge %-d, rad %-d nH %-d val %-d) [%-f %-f %-f]", + ITRACE_("\n* #%-5d %s%-d ( charge %-d, rad %-d nH %-d val %-d) [%-f %-f %-f]", i, d->at[i].elname, d->at[i].orig_at_number, d->at[i].charge, d->at[i].radical, d->at[i].num_H, d->at[i].valence, - d->at[i].x, d->at[i].y, d->at[i].z ); - if (d->at[i].valence > 0) + d->at[i].x, d->at[i].y, d->at[i].z); + if ( d->at[i].valence > 0 ) { - ITRACE_( "\n bonds to " ); - for (k = 0; k < d->at[i].valence; k++) + ITRACE_("\n bonds to "); + for ( k = 0; k < d->at[i].valence; k++ ) { int nbr = d->at[i].neighbor[k]; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ - ITRACE_( "%s%-3d ", d->at[nbr].elname, nbr + 1 ); + ITRACE_("%s%-3d ", d->at[nbr].elname, nbr + 1); } } - if (d->at[i].valence > 0) + if ( d->at[i].valence > 0 ) { - ITRACE_( "\n bond types " ); - for (k = 0; k < d->at[i].valence; k++) - ITRACE_( "%-3d ", d->at[i].bond_type[k] ); + ITRACE_("\n bond types "); + for ( k = 0; k < d->at[i].valence; k++ ) + ITRACE_("%-3d ", d->at[i].bond_type[k]); } } /*OAD_Polymer_DebugTrace( d->polymer );*/ - ITRACE_( "\n* V3000 INFO @ 0x%-p", d->v3000 ); - ITRACE_( "\n*\n" ); - if (d->v3000) + ITRACE_("\n* V3000 INFO @ 0x%-p", d->v3000); + ITRACE_("\n*\n"); + if ( d->v3000 ) { - ITRACE_( "\n* n_star_atoms = %-d\n* n_haptic_bonds = %-d\n* n_collections = %-d", - d->v3000->n_star_atoms, d->v3000->n_haptic_bonds, d->v3000->n_collections ); + ITRACE_("\n* n_star_atoms = %-d\n* n_haptic_bonds = %-d\n* n_collections = %-d", + d->v3000->n_star_atoms, d->v3000->n_haptic_bonds, d->v3000->n_collections); } - ITRACE_( "\n*\n* End ORIG_ATOM_DATA\n*********************************************************************\n" ); + ITRACE_("\n*\n* End ORIG_ATOM_DATA\n*********************************************************************\n"); return; } @@ -1159,26 +1169,26 @@ void OrigAtData_DebugTrace( ORIG_ATOM_DATA* d ) /**************************************************************************** Create a new OAD_PolymerUnit ****************************************************************************/ -OAD_PolymerUnit* OAD_PolymerUnit_New( int maxatoms, - int maxbonds, - int id, - int label, - int type, - int subtype, - int conn, - char *smt, - int na, - INT_ARRAY *alist, - int nb, - INT_ARRAY *blist, - int nbkbonds, - int **bkbonds ) +OAD_PolymerUnit* OAD_PolymerUnit_New(int maxatoms, + int maxbonds, + int id, + int label, + int type, + int subtype, + int conn, + char* smt, + int na, + INT_ARRAY* alist, + int nb, + INT_ARRAY* blist, + int nbkbonds, + int** bkbonds) { int k, err = 0; - OAD_PolymerUnit *u2 = NULL; + OAD_PolymerUnit* u2 = NULL; - u2 = (OAD_PolymerUnit*) inchi_calloc( 1, sizeof( OAD_PolymerUnit ) ); - if (NULL == u2) + u2 = (OAD_PolymerUnit*)inchi_calloc(1, sizeof(OAD_PolymerUnit)); + if ( NULL == u2 ) { err = 1; goto exit_function; @@ -1193,7 +1203,7 @@ OAD_PolymerUnit* OAD_PolymerUnit_New( int maxatoms, u2->nb = nb; u2->cyclizable = CLOSING_SRU_NOT_APPLICABLE; u2->cyclized = 0; - for (k = 0; k < 4; k++) + for ( k = 0; k < 4; k++ ) { u2->xbr1[k] = 0.0; u2->xbr2[k] = 0.0; @@ -1209,44 +1219,44 @@ OAD_PolymerUnit* OAD_PolymerUnit_New( int maxatoms, u2->cap2_is_undef = 0; u2->alist = NULL; - if (na > 0 || maxatoms > 0) + if ( na > 0 || maxatoms > 0 ) { - u2->alist = (int *) inchi_calloc( na > 0 ? na : maxatoms, sizeof( int ) ); - if (!u2->alist ) + u2->alist = (int*)inchi_calloc(na > 0 ? na : maxatoms, sizeof(int)); + if ( !u2->alist ) { err = 2; goto exit_function; } - for (k = 0; k < na; k++) + for ( k = 0; k < na; k++ ) { - u2->alist[k] = alist->item[k]; + u2->alist[k] = alist->item[k]; } } u2->blist = NULL; - if (nb > 0 || maxbonds > 0) + if ( nb > 0 || maxbonds > 0 ) { - u2->blist = (int *) inchi_calloc( nb > 0 ? 2 * nb : 2 * maxbonds, sizeof( int ) ); - if (!u2->blist) + u2->blist = (int*)inchi_calloc(nb > 0 ? 2 * nb : 2 * maxbonds, sizeof(int)); + if ( !u2->blist ) { err = 3; goto exit_function; } - if (blist) + if ( blist ) { - for (k = 0; k < 2 * nb; k++) + for ( k = 0; k < 2 * nb; k++ ) { - u2->blist[k] = blist->item[k]; + u2->blist[k] = blist->item[k]; } } - + } u2->bkbonds = NULL; - + exit_function: - if (err) + if ( err ) { - OAD_PolymerUnit_Free( u2 ); + OAD_PolymerUnit_Free(u2); return NULL; } @@ -1257,13 +1267,13 @@ OAD_PolymerUnit* OAD_PolymerUnit_New( int maxatoms, /**************************************************************************** Create a copy of OAD_PolymerUnit ****************************************************************************/ -OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy( OAD_PolymerUnit *u ) +OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy(OAD_PolymerUnit* u) { int k, err = 0; - OAD_PolymerUnit *u2 = NULL; + OAD_PolymerUnit* u2 = NULL; - u2 = (OAD_PolymerUnit*) inchi_calloc( 1, sizeof( OAD_PolymerUnit ) ); - if (NULL == u2) + u2 = (OAD_PolymerUnit*)inchi_calloc(1, sizeof(OAD_PolymerUnit)); + if ( NULL == u2 ) { err = 1; goto exit_function; @@ -1280,7 +1290,7 @@ OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy( OAD_PolymerUnit *u ) u2->cap1_is_undef = u->cap1_is_undef; u2->cap2_is_undef = u->cap2_is_undef; - for (k = 0; k < 4; k++) + for ( k = 0; k < 4; k++ ) { u2->xbr1[k] = u->xbr1[k]; u2->xbr2[k] = u->xbr2[k]; @@ -1293,34 +1303,34 @@ OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy( OAD_PolymerUnit *u ) u2->cap2 = u->cap2; u2->end_atom2 = u->end_atom2; u2->nbkbonds = u->nbkbonds; - u2->maxbkbonds = inchi_max( u->maxbkbonds, u->nbkbonds ); + u2->maxbkbonds = inchi_max(u->maxbkbonds, u->nbkbonds); - u2->alist = (int *) inchi_calloc( u2->na, sizeof( int ) ); - if (!u2->alist) + u2->alist = (int*)inchi_calloc(u2->na, sizeof(int)); + if ( !u2->alist ) { err = 2; goto exit_function; } - for (k = 0; k < u2->na; k++) + for ( k = 0; k < u2->na; k++ ) { - u2->alist[k] = u->alist[k]; + u2->alist[k] = u->alist[k]; } - u2->blist = (int *) inchi_calloc( 2 * (long long)u2->nb, sizeof( int ) ); /* djb-rwth: cast operator added */ - if (!u2->blist) + u2->blist = (int*)inchi_calloc(2 * (long long)u2->nb, sizeof(int)); /* djb-rwth: cast operator added */ + if ( !u2->blist ) { err = 2; goto exit_function; } - for (k = 0; k < 2 * u2->nb; k++) + for ( k = 0; k < 2 * u2->nb; k++ ) { - u2->blist[k] = u->blist[k]; + u2->blist[k] = u->blist[k]; } - err = imat_new( u2->maxbkbonds, 2, &( u2->bkbonds ) ); - if (!err) + err = imat_new(u2->maxbkbonds, 2, &(u2->bkbonds)); + if ( !err ) { - for (k = 0; k < u2->nbkbonds; k++) + for ( k = 0; k < u2->nbkbonds; k++ ) { u2->bkbonds[k][0] = u->bkbonds[k][0]; u2->bkbonds[k][1] = u->bkbonds[k][1]; @@ -1328,9 +1338,9 @@ OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy( OAD_PolymerUnit *u ) } exit_function: - if (err) + if ( err ) { - OAD_PolymerUnit_Free( u2 ); + OAD_PolymerUnit_Free(u2); return NULL; } @@ -1339,32 +1349,32 @@ OAD_PolymerUnit* OAD_PolymerUnit_CreateCopy( OAD_PolymerUnit *u ) /****************************************************************************/ -void OAD_PolymerUnit_Free( OAD_PolymerUnit *unit ) +void OAD_PolymerUnit_Free(OAD_PolymerUnit* unit) { - ITRACE_( "\n************** About to free OAD_PolymerUnit @ %-p\n", unit ); - OAD_PolymerUnit_DebugTrace( unit ); + ITRACE_("\n************** About to free OAD_PolymerUnit @ %-p\n", unit); + OAD_PolymerUnit_DebugTrace(unit); - if (unit) + if ( unit ) { - if (unit->alist) + if ( unit->alist ) { - inchi_free( unit->alist ); + inchi_free(unit->alist); unit->alist = NULL; } - if (unit->blist) + if ( unit->blist ) { - inchi_free( unit->blist ); + inchi_free(unit->blist); unit->blist = NULL; } - if (unit->bkbonds) + if ( unit->bkbonds ) { - imat_free( unit->maxbkbonds, unit->bkbonds ); + imat_free(unit->maxbkbonds, unit->bkbonds); unit->bkbonds = NULL; } } - inchi_free( unit ); + inchi_free(unit); return; } @@ -1374,20 +1384,20 @@ void OAD_PolymerUnit_Free( OAD_PolymerUnit *unit ) Compare two polymer units, modified lexicographic order Modification: unit with smaller alist always go first ****************************************************************************/ -int OAD_PolymerUnit_CompareAtomListsMod( OAD_PolymerUnit *u1, - OAD_PolymerUnit *u2 ) +int OAD_PolymerUnit_CompareAtomListsMod(OAD_PolymerUnit* u1, + OAD_PolymerUnit* u2) { int i; int n1 = u1->na; int n2 = u2->na; int n = n1; - if (n1 < n2) return -1; - if (n1 > n2) return 1; + if ( n1 < n2 ) return -1; + if ( n1 > n2 ) return 1; /* n1 == n2 == n */ - for (i = 0; i < n; i++) + for ( i = 0; i < n; i++ ) { - if (u1->alist[i] < u2->alist[i]) return -1; - if (u1->alist[i] > u2->alist[i]) return 1; + if ( u1->alist[i] < u2->alist[i] ) return -1; + if ( u1->alist[i] > u2->alist[i] ) return 1; } return 0; @@ -1397,32 +1407,32 @@ int OAD_PolymerUnit_CompareAtomListsMod( OAD_PolymerUnit *u1, /**************************************************************************** Compare two polymer units, lexicographic order ****************************************************************************/ -int OAD_PolymerUnit_CompareAtomLists( OAD_PolymerUnit *u1, - OAD_PolymerUnit *u2 ) +int OAD_PolymerUnit_CompareAtomLists(OAD_PolymerUnit* u1, + OAD_PolymerUnit* u2) { int i; int n1 = u1->na; int n2 = u2->na; - int n = inchi_min( n1, n2 ); + int n = inchi_min(n1, n2); - for (i = 0; i < n; i++) + for ( i = 0; i < n; i++ ) { - if (u1->alist[i] < u2->alist[i]) + if ( u1->alist[i] < u2->alist[i] ) { return -1; } - if (u1->alist[i] > u2->alist[i]) + if ( u1->alist[i] > u2->alist[i] ) { return 1; } } - if (n1 < n2) + if ( n1 < n2 ) { return -1; } - if (n1 > n2) + if ( n1 > n2 ) { return 1; } @@ -1434,14 +1444,14 @@ int OAD_PolymerUnit_CompareAtomLists( OAD_PolymerUnit *u1, /**************************************************************************** Sort SRU bond lists atoms and bonds themselves ****************************************************************************/ -int OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves( OAD_PolymerUnit *u, - int n_star_atoms, - int *star_atoms ) +int OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves(OAD_PolymerUnit* u, + int n_star_atoms, + int* star_atoms) { int k; /* Sort bond atoms */ - for (k = 0; k < u->nb; k++) + for ( k = 0; k < u->nb; k++ ) { /* Place not-in-unit bond end to first place */ int a1 = u->blist[2 * k]; @@ -1451,32 +1461,32 @@ int OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves( OAD_PolymerUnit *u, int a2_is_not_in_alist = 0; int a2_is_star_atom = 0; - if (!is_in_the_ilist( u->alist, a1, u->na )) + if ( !is_in_the_ilist(u->alist, a1, u->na) ) { a1_is_not_in_alist = 1; } - if (is_in_the_ilist( star_atoms, a1, n_star_atoms )) + if ( is_in_the_ilist(star_atoms, a1, n_star_atoms) ) { a1_is_star_atom = 1; } - if (!is_in_the_ilist( u->alist, a2, u->na )) + if ( !is_in_the_ilist(u->alist, a2, u->na) ) { a2_is_not_in_alist = 1; } - if (is_in_the_ilist( star_atoms, a2, n_star_atoms )) + if ( is_in_the_ilist(star_atoms, a2, n_star_atoms) ) { a2_is_star_atom = 1; } - if (( a1_is_not_in_alist || a1_is_star_atom ) && - ( a2_is_not_in_alist || a2_is_star_atom )) + if ( (a1_is_not_in_alist || a1_is_star_atom) && + (a2_is_not_in_alist || a2_is_star_atom) ) { /* Both the ends are out of unit: the crossing bond is invalid */ return 1; } /* If a2 is star atom or non-star external to the current unit, swap(a2,a1) */ - if (a2_is_star_atom || a2_is_not_in_alist) + if ( a2_is_star_atom || a2_is_not_in_alist ) { u->blist[2 * k] = a2; u->blist[2 * k + 1] = a1; @@ -1486,13 +1496,13 @@ int OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves( OAD_PolymerUnit *u, /* Sort bond themselves for now, consider only the simplest cases of 2 bonds */ - if (u->nb == 2) /* two bonds in SBL */ + if ( u->nb == 2 ) /* two bonds in SBL */ { int b1a1 = u->blist[0]; int b1a2 = u->blist[1]; int b2a1 = u->blist[2]; int b2a2 = u->blist[3]; - if (b1a1 > b2a1) + if ( b1a1 > b2a1 ) { /* swap */ u->blist[0] = b2a1; u->blist[1] = b2a2; @@ -1513,74 +1523,74 @@ int OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves( OAD_PolymerUnit *u, Parse pseudoelement and polymer data (unit, types, subtypes, connections, etc.) ****************************************************************************/ -int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, - int treat_polymers, - int bNPZz, - char *pStrErr, - int bNoWarnings) +int OAD_ValidatePolymerAndPseudoElementData(ORIG_ATOM_DATA* orig_at_data, + int treat_polymers, + int bNPZz, + char* pStrErr, + int bNoWarnings) { int i, k, kk, type, subtype, representation, err = 0; int nat = orig_at_data->num_inp_atoms; int nsgroups = 0; OAD_PolymerUnit* u = NULL; - OAD_Polymer *pd = orig_at_data->polymer; + OAD_Polymer* pd = orig_at_data->polymer; /* Assign polymer type and subunits type and check polymer data for consistency */ - + orig_at_data->valid_polymer = 0; - if (treat_polymers && pd) + if ( treat_polymers && pd ) { orig_at_data->valid_polymer = 1; } - if (orig_at_data->valid_polymer) + if ( orig_at_data->valid_polymer ) { nsgroups = pd->n; } - if (nsgroups == 1) + if ( nsgroups == 1 ) { /* Check if copolymer */ type = pd->units[0]->type; - if (type == POLYMER_STY_COP) + if ( type == POLYMER_STY_COP ) { - TREAT_ERR( err, 9001, "Copolymer must contain more than one unit" ); + TREAT_ERR(err, 9001, "Copolymer must contain more than one unit"); goto exit_function; } /* Check if copolymer subtype */ subtype = pd->units[0]->subtype; - if (subtype == POLYMER_SST_RAN || subtype == POLYMER_SST_ALT || subtype == POLYMER_SST_BLK) + if ( subtype == POLYMER_SST_RAN || subtype == POLYMER_SST_ALT || subtype == POLYMER_SST_BLK ) { - TREAT_ERR( err, 9002, "Single polymer unit may not be RAN/ALT/BLO" ); + TREAT_ERR(err, 9002, "Single polymer unit may not be RAN/ALT/BLO"); goto exit_function; } } /* For each CRU */ - for (i = 0; i < nsgroups; i++) + for ( i = 0; i < nsgroups; i++ ) { /* Check if unit data makes sense */ u = pd->units[i]; - if (u->nb != 0 && u->nb != 2) + if ( u->nb != 0 && u->nb != 2 ) { - TREAT_ERR( err, 9003, "Number of crossing bonds in polymer unit is not 0 or 2" ); + TREAT_ERR(err, 9003, "Number of crossing bonds in polymer unit is not 0 or 2"); goto exit_function; } - if (u->na < 1) + if ( u->na < 1 ) { - TREAT_ERR( err, 9004, "Empty polymer unit" ); + TREAT_ERR(err, 9004, "Empty polymer unit"); goto exit_function; } - if (u->na > nat) + if ( u->na > nat ) { - TREAT_ERR( err, 9005, "Too large polymer unit" ); + TREAT_ERR(err, 9005, "Too large polymer unit"); goto exit_function; } - for (k = 0; k < u->na; k++) + for ( k = 0; k < u->na; k++ ) { int atom = u->alist[k]; - if (atom < 1 || atom > nat) + if ( atom < 1 || atom > nat ) { - TREAT_ERR( err, 9006, "Invalid atom number in polymer unit" ); + TREAT_ERR(err, 9006, "Invalid atom number in polymer unit"); goto exit_function; } /* was not accounting for COP ... @@ -1592,32 +1602,32 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, */ } - OAD_PolymerUnit_SetEndsAndCaps( u, orig_at_data, &err, pStrErr ); - /* Reveal and store CRU caps and ends('stars and partners') - Also set `unit->cap1_is_undef`, `unit->cap2_is_undef`, `unit->cyclizable` - */ - if (err) + OAD_PolymerUnit_SetEndsAndCaps(u, orig_at_data, &err, pStrErr); + /* Reveal and store CRU caps and ends('stars and partners') + Also set `unit->cap1_is_undef`, `unit->cap2_is_undef`, `unit->cyclizable` + */ + if ( err ) { goto exit_function; } - + /* Set possibly missing unit parameters */ u->nbkbonds = 0; u->cyclizable = CLOSING_SRU_NOT_APPLICABLE; u->cyclized = 0; } - - OAD_ValidateAndSortOutPseudoElementAtoms( orig_at_data, treat_polymers, bNPZz, &err, pStrErr ); + + OAD_ValidateAndSortOutPseudoElementAtoms(orig_at_data, treat_polymers, bNPZz, &err, pStrErr); /* Here we: Make more polymer and pseudoatom data checks Convert both "*" and "Zz" temporarily to "Zy" (polymer-unrelated interal pseudoatoms) - If applicable, check each CRU and back-convert "Zy" to "Zz" (polymer-related + If applicable, check each CRU and back-convert "Zy" to "Zz" (polymer-related pseudoelement atoms) if they are for valid bi-undef-end CRU */ - - if (err) + + if ( err ) { /* already treated TREAT_ERR( err, 9040, "Improper pseudoelement atoms" ); */ goto exit_function; @@ -1627,40 +1637,40 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, /* Make more polymer and pseudoatom data checks */ /* Check if non-polymer-related Zz/star atoms enabled */ - if (orig_at_data->n_zy > 0 && bNPZz==0 ) + if ( orig_at_data->n_zy > 0 && bNPZz == 0 ) { - TREAT_ERR( err, 9, "Non-polymer-related Zz/star atoms are not allowed" ); + TREAT_ERR(err, 9, "Non-polymer-related Zz/star atoms are not allowed"); goto exit_function; } - if (!pd || !orig_at_data->valid_polymer ) + if ( !pd || !orig_at_data->valid_polymer ) { goto exit_function; } - if (pd->n_pzz > 0) + if ( pd->n_pzz > 0 ) { /* Allocate memory for polymer-related pseudoatoms */ - if ( pd->treat == POLYMERS_NO) + if ( pd->treat == POLYMERS_NO ) { - TREAT_ERR( err, 9, "Pseudoelement endgroups are not allowed" ); + TREAT_ERR(err, 9, "Pseudoelement endgroups are not allowed"); goto exit_function; } - if (pd->pzz) + if ( pd->pzz ) { inchi_free(pd->pzz); pd->pzz = NULL; } - pd->pzz = (int *) inchi_calloc( pd->n_pzz, sizeof( int ) ); - if (!pd->pzz) + pd->pzz = (int*)inchi_calloc(pd->n_pzz, sizeof(int)); + if ( !pd->pzz ) { - TREAT_ERR( err, 9010, "Not enough memory" ); + TREAT_ERR(err, 9010, "Not enough memory"); goto exit_function; } kk = 0; - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { - if (!strcmp( orig_at_data->at[k].elname, "Zz" )) + if ( !strcmp(orig_at_data->at[k].elname, "Zz") ) { pd->pzz[kk++] = k + 1; /* djb-rwth: buffer overrun avoided implicitly */ } @@ -1668,22 +1678,22 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, } /* Check copolymers and ensure that COP includes > 1 SRU */ - for (i = 0; i < pd->n; i++) + for ( i = 0; i < pd->n; i++ ) { u = pd->units[i]; if ( u->type == POLYMER_STY_COP || - u->type == POLYMER_STY_SRU /* what drawn as 'SRU' [xyz]n may be actually copolymer [xyz]co */ - ) + u->type == POLYMER_STY_SRU /* what drawn as 'SRU' [xyz]n may be actually copolymer [xyz]co */ + ) { int j, in_units = 0; - if (u->nb > 0) + if ( u->nb > 0 ) { /* crossing bonds present, either valid SRU or invalid copolymer */ - if (u->type == POLYMER_STY_COP) + if ( u->type == POLYMER_STY_COP ) { - TREAT_ERR( err, 9026, "Polymer COP unit contains bracket-crossing bonds, not supported" ); + TREAT_ERR(err, 9026, "Polymer COP unit contains bracket-crossing bonds, not supported"); goto exit_function; } else @@ -1692,208 +1702,208 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, } } /* now we have no crossing bonds units */ - for (j = 0; j < pd->n; j++) + for ( j = 0; j < pd->n; j++ ) { - if (pd->units[j]->type == POLYMER_STY_COP) + if ( pd->units[j]->type == POLYMER_STY_COP ) { continue; } - if (is_ilist_inside( pd->units[j]->alist, pd->units[j]->na, pd->units[i]->alist, pd->units[i]->na )) + if ( is_ilist_inside(pd->units[j]->alist, pd->units[j]->na, pd->units[i]->alist, pd->units[i]->na) ) { in_units++; - if (in_units == 2) + if ( in_units == 2 ) { break; } } } - if (in_units > 1) + if ( in_units > 1 ) { - if (u->type != POLYMER_STY_COP) + if ( u->type != POLYMER_STY_COP ) { u->type = POLYMER_STY_COP; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Convert multiple-subunits unit to copolymer" ); + WarningMessage(pStrErr, "Convert multiple-subunits unit to copolymer"); } } } else /* in_units <= 1)*/ { - if (u->type == POLYMER_STY_COP) + if ( u->type == POLYMER_STY_COP ) { - TREAT_ERR( err, 9027, "Polymer COP unit contains a single SRU instead of multiple" ); + TREAT_ERR(err, 9027, "Polymer COP unit contains a single SRU instead of multiple"); goto exit_function; } } } } - representation = OAD_Polymer_GetRepresentation( pd ); + representation = OAD_Polymer_GetRepresentation(pd); /* Make more polymer data checks and perform some corrections*/ - if (representation == POLYMER_REPRESENTATION_SOURCE_BASED) + if ( representation == POLYMER_REPRESENTATION_SOURCE_BASED ) { - for (i = 0; i < nsgroups; i++) + for ( i = 0; i < nsgroups; i++ ) { /* Replace source-based 'SRU' with 'MON' */ - if (pd->units[i]->type == POLYMER_STY_SRU) + if ( pd->units[i]->type == POLYMER_STY_SRU ) { pd->units[i]->type = POLYMER_STY_MON; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Converted src-based polymer unit type to MON" ); + WarningMessage(pStrErr, "Converted src-based polymer unit type to MON"); } } - if (pd->units[i]->type == POLYMER_STY_COP) + if ( pd->units[i]->type == POLYMER_STY_COP ) { /* Set missing copolymer subtype to RAN */ - if (pd->units[i]->subtype == POLYMER_SST_NON) + if ( pd->units[i]->subtype == POLYMER_SST_NON ) { pd->units[i]->subtype = POLYMER_SST_RAN; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Set missing copolymer subtype to RAN" ); + WarningMessage(pStrErr, "Set missing copolymer subtype to RAN"); } } } /* Suppress connectivity ("HH", "HT", "EU") */ - if (pd->units[i]->conn != POLYMER_CONN_NON) + if ( pd->units[i]->conn != POLYMER_CONN_NON ) { pd->units[i]->conn = POLYMER_CONN_NON; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Ignore connection pattern for src-based polymer unit" ); + WarningMessage(pStrErr, "Ignore connection pattern for src-based polymer unit"); } } } } #ifdef ALLOW_MIXED_SRU_AND_MON - else if (representation == POLYMER_REPRESENTATION_STRUCTURE_BASED || - representation == POLYMER_REPRESENTATION_MIXED) + else if ( representation == POLYMER_REPRESENTATION_STRUCTURE_BASED || + representation == POLYMER_REPRESENTATION_MIXED ) #else - else if (representation == POLYMER_REPRESENTATION_STRUCTURE_BASED) + else if ( representation == POLYMER_REPRESENTATION_STRUCTURE_BASED ) #endif { - for (i = 0; i < nsgroups; i++) + for ( i = 0; i < nsgroups; i++ ) { int a1, a2, a1_is_not_in_alist, a1_is_star_atom, a2_is_not_in_alist, a2_is_star_atom; u = pd->units[i]; /* SRU that is copolymer unit embedding other SRU's */ - if (u->nb == 0) + if ( u->nb == 0 ) { - if (u->type == POLYMER_STY_COP) + if ( u->type == POLYMER_STY_COP ) { ; } - else if (u->type == POLYMER_STY_SRU) + else if ( u->type == POLYMER_STY_SRU ) { u->type = POLYMER_STY_COP; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Set copolymer embedding unit mark to COP" ); + WarningMessage(pStrErr, "Set copolymer embedding unit mark to COP"); } } } - if (u->type == POLYMER_STY_COP) + if ( u->type == POLYMER_STY_COP ) { u->cyclizable = CLOSING_SRU_NOT_APPLICABLE; /* Set possibly missing copolymer subtype to RAN */ - if (u->subtype == POLYMER_SST_NON) + if ( u->subtype == POLYMER_SST_NON ) { u->subtype = POLYMER_SST_RAN; - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Set missing copolymer subtype to RAN" ); + WarningMessage(pStrErr, "Set missing copolymer subtype to RAN"); } } continue; } #ifdef ALLOW_MIXED_SRU_AND_MON - if (u->type == POLYMER_STY_MON) + if ( u->type == POLYMER_STY_MON ) { continue; } #endif /* SRU with endgroups or stars. Check it. */ - for (k = 0; k < u->nb; k++) + for ( k = 0; k < u->nb; k++ ) { /* Check that there are no H end groups */ a1 = u->blist[2 * k]; a2 = u->blist[2 * k + 1]; - if (!strcmp( orig_at_data->at[a1 - 1].elname, "H" ) || - !strcmp( orig_at_data->at[a1 - 1].elname, "D" ) || - !strcmp( orig_at_data->at[a1 - 1].elname, "T" )) + if ( !strcmp(orig_at_data->at[a1 - 1].elname, "H") || + !strcmp(orig_at_data->at[a1 - 1].elname, "D") || + !strcmp(orig_at_data->at[a1 - 1].elname, "T") ) { - TREAT_ERR( err, 9030, "H as polymer end group is not supported" ); + TREAT_ERR(err, 9030, "H as polymer end group is not supported"); goto exit_function; } - if ( !strcmp( orig_at_data->at[a2 - 1].elname, "H" ) || - !strcmp( orig_at_data->at[a2 - 1].elname, "D" ) || - !strcmp( orig_at_data->at[a2 - 1].elname, "T" )) + if ( !strcmp(orig_at_data->at[a2 - 1].elname, "H") || + !strcmp(orig_at_data->at[a2 - 1].elname, "D") || + !strcmp(orig_at_data->at[a2 - 1].elname, "T") ) { - TREAT_ERR( err, 9031, "H as polymer end group is not supported" ); + TREAT_ERR(err, 9031, "H as polymer end group is not supported"); goto exit_function; } /* Ensure that caps of polymer unit lie outside it */ a1_is_not_in_alist = a1_is_star_atom = 0; a2_is_not_in_alist = a2_is_star_atom = 0; - if (!is_in_the_ilist( u->alist, a1, u->na )) + if ( !is_in_the_ilist(u->alist, a1, u->na) ) { a1_is_not_in_alist = 1; } - if (is_in_the_ilist( pd->pzz, a1, pd->n_pzz )) + if ( is_in_the_ilist(pd->pzz, a1, pd->n_pzz) ) { a1_is_star_atom = 1; } - if (!is_in_the_ilist( u->alist, a2, u->na )) + if ( !is_in_the_ilist(u->alist, a2, u->na) ) { a2_is_not_in_alist = 1; } - if (is_in_the_ilist( pd->pzz, a2, pd->n_pzz )) + if ( is_in_the_ilist(pd->pzz, a2, pd->n_pzz) ) { a2_is_star_atom = 1; } - if (( a1_is_not_in_alist || a1_is_star_atom ) && - ( a2_is_not_in_alist || a2_is_star_atom )) + if ( (a1_is_not_in_alist || a1_is_star_atom) && + (a2_is_not_in_alist || a2_is_star_atom) ) { - TREAT_ERR( err, 9032, "Caps of polymer unit lie inside it" ); + TREAT_ERR(err, 9032, "Caps of polymer unit lie inside it"); goto exit_function; } } - if (u->type == POLYMER_STY_SRU || u->type == POLYMER_STY_MOD || - u->type == POLYMER_STY_CRO || u->type == POLYMER_STY_MER) + if ( u->type == POLYMER_STY_SRU || u->type == POLYMER_STY_MOD || + u->type == POLYMER_STY_CRO || u->type == POLYMER_STY_MER ) { /* If SRU connection is missing, set to default ('either') */ - if (u->conn == POLYMER_CONN_NON) + if ( u->conn == POLYMER_CONN_NON ) { - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Set missing copolymer unit connection to EU" ); + WarningMessage(pStrErr, "Set missing copolymer unit connection to EU"); } u->conn = POLYMER_CONN_EU; } - if (u->cap1 && u->cap2) + if ( u->cap1 && u->cap2 ) { /* Set SRU closure type */ - if (u->na == 1) + if ( u->na == 1 ) { #ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL u->cyclizable = CLOSING_SRU_DIRADICAL; #else u->cyclizable = CLOSING_SRU_NOT_APPLICABLE; #ifdef CLOSING_STARRED_SRU_IS_A_MUST - TREAT_ERR( err, 9029, "Could not perform SRU closure" ); + TREAT_ERR(err, 9029, "Could not perform SRU closure"); goto exit_function; #endif #endif } - else if (u->na == 2) + else if ( u->na == 2 ) { #ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND @@ -1901,7 +1911,7 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, #else u->cyclizable = CLOSING_SRU_NOT_APPLICABLE; #ifdef CLOSING_STARRED_SRU_IS_A_MUST - TREAT_ERR( err, 9029, "Could not perform SRU closure" ); + TREAT_ERR(err, 9029, "Could not perform SRU closure"); goto exit_function; #endif #endif @@ -1912,25 +1922,25 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, } } - if (u->conn != POLYMER_CONN_HT) + if ( u->conn != POLYMER_CONN_HT ) { /* frame shift/SRU cyclization is for head-to-tail connections only */ u->cyclizable = CLOSING_SRU_NOT_APPLICABLE; } - if (u->cyclizable != CLOSING_SRU_NOT_APPLICABLE) + if ( u->cyclizable != CLOSING_SRU_NOT_APPLICABLE ) { /* Allocate PS (frame-shiftable) bonds */ - if (u->bkbonds) + if ( u->bkbonds ) { imat_free(u->maxbkbonds, u->bkbonds); u->bkbonds = NULL; } u->maxbkbonds = orig_at_data->num_inp_bonds + 2; - err = imat_new( u->maxbkbonds, 2, &( u->bkbonds ) ); - if (err) + err = imat_new(u->maxbkbonds, 2, &(u->bkbonds)); + if ( err ) { - TREAT_ERR( err, 9034, "Not enough memory (polymers)" ); + TREAT_ERR(err, 9034, "Not enough memory (polymers)"); goto exit_function; } } @@ -1940,14 +1950,14 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, } else { - TREAT_ERR( err, 9035, "Invalid kind of polymer representation" ); - goto exit_function; + TREAT_ERR(err, 9035, "Invalid kind of polymer representation"); + goto exit_function; } orig_at_data->valid_polymer = 1; exit_function: - if (err) + if ( err ) { orig_at_data->valid_polymer = 0; } @@ -1957,10 +1967,10 @@ int OAD_ValidatePolymerAndPseudoElementData( ORIG_ATOM_DATA *orig_at_data, /****************************************************************************/ -int UnMarkRingSystemsInp( inp_ATOM *at, int num_atoms ) +int UnMarkRingSystemsInp(inp_ATOM* at, int num_atoms) { int i; - for (i = 0; i < num_atoms; i++) + for ( i = 0; i < num_atoms; i++ ) { at[i].bCutVertex = 0; at[i].nRingSystem = 0; @@ -1975,58 +1985,58 @@ int UnMarkRingSystemsInp( inp_ATOM *at, int num_atoms ) /**************************************************************************** Preprocess OAD_Polymer (NB: frame shift is invoked from here) ****************************************************************************/ -int OAD_Polymer_CyclizeCloseableUnits( ORIG_ATOM_DATA *orig_at_data, - int treat_polymers, - char *pStrErr, - int bNoWarnings ) +int OAD_Polymer_CyclizeCloseableUnits(ORIG_ATOM_DATA* orig_at_data, + int treat_polymers, + char* pStrErr, + int bNoWarnings) { int i, err = 0; /* djb-rwth: removing redundant variables */ - for (i = 0; i < orig_at_data->polymer->n; i++) + for ( i = 0; i < orig_at_data->polymer->n; i++ ) { - OAD_PolymerUnit *unit = orig_at_data->polymer->units[i]; + OAD_PolymerUnit* unit = orig_at_data->polymer->units[i]; - if (!unit->cyclizable) + if ( !unit->cyclizable ) { continue; } /* Find stars and their partners */ - OAD_PolymerUnit_SetEndsAndCaps( unit, orig_at_data, &err, pStrErr ); - /* Reveal and store CRU caps and ends('stars and partners') - Also set `unit->cap1_is_undef`, `unit->cap2_is_undef`, `unit->cyclizable` - */ - if (err) + OAD_PolymerUnit_SetEndsAndCaps(unit, orig_at_data, &err, pStrErr); + /* Reveal and store CRU caps and ends('stars and partners') + Also set `unit->cap1_is_undef`, `unit->cap2_is_undef`, `unit->cyclizable` + */ + if ( err ) { break; } - if (!unit->cyclizable) + if ( !unit->cyclizable ) { continue; } - if (OAD_PolymerUnit_HasMetal( unit, orig_at_data->at )) + if ( OAD_PolymerUnit_HasMetal(unit, orig_at_data->at) ) { /*unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;*/ - if (unit->cyclizable == CLOSING_SRU_RING) + if ( unit->cyclizable == CLOSING_SRU_RING ) { /*unit->cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND;*/ - if (!bNoWarnings) + if ( !bNoWarnings ) { - WarningMessage( pStrErr, "Frame shift in metallated polymer unit may be missed" ); + WarningMessage(pStrErr, "Frame shift in metallated polymer unit may be missed"); } } } /* Now remove bonds to cap ("star atoms and cyclize a SRU */ - OAD_PolymerUnit_UnlinkCapsAndConnectEndAtoms( unit, orig_at_data, &err, pStrErr ); + OAD_PolymerUnit_UnlinkCapsAndConnectEndAtoms(unit, orig_at_data, &err, pStrErr); - if (err) + if ( err ) { break; } - if (!unit->cyclizable) + if ( !unit->cyclizable ) { continue; } @@ -2051,12 +2061,12 @@ int OAD_Polymer_CyclizeCloseableUnits( ORIG_ATOM_DATA *orig_at_data, /**************************************************************************** Check if SRU contains metal ****************************************************************************/ -int OAD_PolymerUnit_HasMetal( OAD_PolymerUnit *u, inp_ATOM *at ) +int OAD_PolymerUnit_HasMetal(OAD_PolymerUnit* u, inp_ATOM* at) { int i; - for (i = 0; i < u->na; i++) + for ( i = 0; i < u->na; i++ ) { - if (is_el_a_metal( at[u->alist[i] - 1].el_number )) + if ( is_el_a_metal(at[u->alist[i] - 1].el_number) ) { return 1; } @@ -2067,28 +2077,28 @@ int OAD_PolymerUnit_HasMetal( OAD_PolymerUnit *u, inp_ATOM *at ) /****************************************************************************/ -void OAD_Polymer_Free( OAD_Polymer *pd ) +void OAD_Polymer_Free(OAD_Polymer* pd) { - if (pd) + if ( pd ) { - if (pd->pzz) + if ( pd->pzz ) { - inchi_free( pd->pzz ); + inchi_free(pd->pzz); pd->pzz = NULL; pd->n_pzz = 0; } - if (pd->n && pd->units) + if ( pd->n && pd->units ) { int k; - for (k = 0; k < pd->n; k++) + for ( k = 0; k < pd->n; k++ ) { - OAD_PolymerUnit_Free( pd->units[k] ); + OAD_PolymerUnit_Free(pd->units[k]); } - inchi_free( pd->units ); + inchi_free(pd->units); pd->units = NULL; pd->n = 0; } - inchi_free( pd ); + inchi_free(pd); pd = NULL; } @@ -2097,81 +2107,81 @@ void OAD_Polymer_Free( OAD_Polymer *pd ) /****************************************************************************/ -void OAD_PolymerUnit_UnlinkCapsAndConnectEndAtoms( OAD_PolymerUnit *unit, - ORIG_ATOM_DATA *orig_inp_data, - int *err, - char *pStrErr ) +void OAD_PolymerUnit_UnlinkCapsAndConnectEndAtoms(OAD_PolymerUnit* unit, + ORIG_ATOM_DATA* orig_inp_data, + int* err, + char* pStrErr) { int bond_type, bond_stereo; *err = 0; - if (!unit->cyclizable) + if ( !unit->cyclizable ) { return; } - if (unit->cyclizable == CLOSING_SRU_RING) + if ( unit->cyclizable == CLOSING_SRU_RING ) { /* Disconnect both star atoms */ - OrigAtData_RemoveBond( unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); + OrigAtData_RemoveBond(unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); - OrigAtData_RemoveBond( unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); + OrigAtData_RemoveBond(unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); - OrigAtData_AddSingleStereolessBond( unit->end_atom1 - 1, unit->end_atom2 - 1, - orig_inp_data->at, &orig_inp_data->num_inp_bonds ); + OrigAtData_AddSingleStereolessBond(unit->end_atom1 - 1, unit->end_atom2 - 1, + orig_inp_data->at, &orig_inp_data->num_inp_bonds); } - else if (unit->cyclizable == CLOSING_SRU_HIGHER_ORDER_BOND) + else if ( unit->cyclizable == CLOSING_SRU_HIGHER_ORDER_BOND ) { int elevated; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - elevated = OrigAtData_IncreaseBondOrder( unit->end_atom1 - 1, unit->end_atom2 - 1, orig_inp_data->at ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + elevated = OrigAtData_IncreaseBondOrder(unit->end_atom1 - 1, unit->end_atom2 - 1, orig_inp_data->at); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ #if 0 -/* the bond may already be broken at metal disconnection, so ignore the result here */ - if (!elevated) + /* the bond may already be broken at metal disconnection, so ignore the result here */ + if ( !elevated ) { /* *err = 1; */ - WarningMessage( pStrErr, "SRU closure via higher order bond failed" ); + WarningMessage(pStrErr, "SRU closure via higher order bond failed"); unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE; return; } #endif - OrigAtData_RemoveBond( unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); - OrigAtData_RemoveBond( unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); + OrigAtData_RemoveBond(unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); + OrigAtData_RemoveBond(unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); } - else if (unit->cyclizable == CLOSING_SRU_DIRADICAL) + else if ( unit->cyclizable == CLOSING_SRU_DIRADICAL ) { orig_inp_data->at[unit->end_atom1 - 1].radical = RADICAL_TRIPLET; - OrigAtData_RemoveBond( unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); - OrigAtData_RemoveBond( unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, - &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds ); + OrigAtData_RemoveBond(unit->cap1 - 1, unit->end_atom1 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); + OrigAtData_RemoveBond(unit->cap2 - 1, unit->end_atom2 - 1, orig_inp_data->at, + &bond_type, &bond_stereo, &orig_inp_data->num_inp_bonds); } - if (!*err) + if ( !*err ) { unit->cyclized = 1; } - + return; } /****************************************************************************/ -void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, - ORIG_ATOM_DATA *orig_at_data, - int *end1, - int *cap1, - int *cap1_is_star, - int *end2, - int *cap2, - int *cap2_is_star, - int *err, - char *pStrErr ) +void OAD_PolymerUnit_FindEndsAndCaps(OAD_PolymerUnit* unit, + ORIG_ATOM_DATA* orig_at_data, + int* end1, + int* cap1, + int* cap1_is_star, + int* end2, + int* cap2, + int* cap2_is_star, + int* err, + char* pStrErr) { int i, j, i_inside = 0, j_inside = 0; int num_atoms = orig_at_data->num_inp_atoms; @@ -2180,7 +2190,7 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, *cap1_is_star = *cap2_is_star = 0; *err = 0; - if (!unit->blist || unit->nb < 1) + if ( !unit->blist || unit->nb < 1 ) { return; } @@ -2189,12 +2199,12 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, j = unit->blist[1]; i_inside = (NULL != is_in_the_ilist(unit->alist, i, unit->na)); j_inside = (NULL != is_in_the_ilist(unit->alist, j, unit->na)); - if (i_inside && j_inside) + if ( i_inside && j_inside ) { TREAT_ERR(*err, 9032, "Polymer CRU cap(s) lie inside CRU"); return; } - if (i_inside) + if ( i_inside ) { *end1 = i; *cap1 = j; @@ -2204,7 +2214,7 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, *end1 = j; *cap1 = i; } - if (!strcmp(orig_at_data->at[*cap1 - 1].elname, "Zz")) + if ( !strcmp(orig_at_data->at[*cap1 - 1].elname, "Zz") ) { *cap1_is_star = 1; } @@ -2213,11 +2223,11 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, j = unit->blist[3]; i_inside = NULL != is_in_the_ilist(unit->alist, i, unit->na); j_inside = NULL != is_in_the_ilist(unit->alist, j, unit->na); - if (i_inside && j_inside) + if ( i_inside && j_inside ) { TREAT_ERR(*err, 9032, "Polymer CRU cap(s) lie inside CRU"); } - if (i_inside) + if ( i_inside ) { *end2 = i; *cap2 = j; @@ -2227,22 +2237,22 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, *end2 = j; *cap2 = i; } - if (!strcmp(orig_at_data->at[*cap2 - 1].elname, "Zz")) + if ( !strcmp(orig_at_data->at[*cap2 - 1].elname, "Zz") ) { *cap2_is_star = 1; } /* Checks */ - if (*end1 <= 0 || *end1 > num_atoms || *cap1 <= 0 || *cap1 > num_atoms) + if ( *end1 <= 0 || *end1 > num_atoms || *cap1 <= 0 || *cap1 > num_atoms ) { TREAT_ERR(*err, 9090, "Invalid polymer CRU crossing bond"); return; } - if (*end2 <= 0 || *end2 > num_atoms || *cap2 <= 0 || *cap2 > num_atoms) + if ( *end2 <= 0 || *end2 > num_atoms || *cap2 <= 0 || *cap2 > num_atoms ) { TREAT_ERR(*err, 9091, "Invalid polymer CRU crossing bond"); return; } - if ( *cap1 == *cap2 ) /* || (*end1 == *end2 && unit->na>1) */ + if ( *cap1 == *cap2 ) /* || (*end1 == *end2 && unit->na>1) */ { TREAT_ERR(*err, 9090, "Invalid polymer CRU surrounding"); return; @@ -2257,15 +2267,15 @@ void OAD_PolymerUnit_FindEndsAndCaps( OAD_PolymerUnit *unit, *err = 0; return; } - - + + /**************************************************************************** Reveal and store CRU caps and ends ('stars and partners') ****************************************************************************/ -void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit, - ORIG_ATOM_DATA *orig_at_data, - int *err, - char *pStrErr ) +void OAD_PolymerUnit_SetEndsAndCaps(OAD_PolymerUnit* unit, + ORIG_ATOM_DATA* orig_at_data, + int* err, + char* pStrErr) { int k; @@ -2273,22 +2283,22 @@ void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit, unit->end_atom1 = unit->end_atom2 = unit->cap1 = unit->cap2 = -1; unit->cap1_is_undef = unit->cap2_is_undef = 0; - OAD_PolymerUnit_FindEndsAndCaps( unit, orig_at_data, - &unit->end_atom1, &unit->cap1, &unit->cap1_is_undef, - &unit->end_atom2, &unit->cap2, &unit->cap2_is_undef, - err, pStrErr); + OAD_PolymerUnit_FindEndsAndCaps(unit, orig_at_data, + &unit->end_atom1, &unit->cap1, &unit->cap1_is_undef, + &unit->end_atom2, &unit->cap2, &unit->cap2_is_undef, + err, pStrErr); - if (*err) + if ( *err ) { goto exit_function; } #if ( defined(DEBUG_POLYMERS) && ( DEBUG_POLYMERS != 0 ) ) - ITRACE_( "Cap-end_atom pairs (numbers are from 1) are: %-d-%-d and %-d-%-d\n", - unit->cap1, unit->end_atom1, unit->cap2, unit->end_atom2 ); + ITRACE_("Cap-end_atom pairs (numbers are from 1) are: %-d-%-d and %-d-%-d\n", + unit->cap1, unit->end_atom1, unit->cap2, unit->end_atom2); #endif - if (!unit->cap1_is_undef && !unit->cap2_is_undef) + if ( !unit->cap1_is_undef && !unit->cap2_is_undef ) { goto exit_function; } @@ -2296,7 +2306,7 @@ void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit, /* The rest is applicable only to *---SRU---* case */ /* Stars are separated by one atom - that's not error but do nothing */ - if (unit->end_atom1 == unit->end_atom2) + if ( unit->end_atom1 == unit->end_atom2 ) { #ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL unit->cyclizable = CLOSING_SRU_DIRADICAL; @@ -2307,9 +2317,9 @@ void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit, } /* Stars are separated by two atoms - that's not error but do nothing */ - for (k = 0; k < orig_at_data->at[unit->end_atom1 - 1].valence; k++) + for ( k = 0; k < orig_at_data->at[unit->end_atom1 - 1].valence; k++ ) { - if (orig_at_data->at[unit->end_atom1 - 1].neighbor[k] == unit->end_atom2 - 1) + if ( orig_at_data->at[unit->end_atom1 - 1].neighbor[k] == unit->end_atom2 - 1 ) { #ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND unit->cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND; @@ -2338,15 +2348,15 @@ void OAD_PolymerUnit_SetEndsAndCaps( OAD_PolymerUnit *unit, unum numbers of units (0..p->n) as they go when sorted by alist's in lexicographic orders ****************************************************************************/ -int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, - int *cano_nums, - int *compnt_nums, - OAD_PolymerUnit **units2, /* allocd by caller, to be filled */ - int *unum ) /* allocd by caller, to be filled */ +int OAD_Polymer_PrepareWorkingSet(OAD_Polymer* p, + int* cano_nums, + int* compnt_nums, + OAD_PolymerUnit** units2, /* allocd by caller, to be filled */ + int* unum) /* allocd by caller, to be filled */ { int i, k, err = 0, cano_num1 = -1, cano_num2 = -1; - OAD_PolymerUnit *u; + OAD_PolymerUnit* u; /*OAD_Polymer_DebugTrace( p );*/ @@ -2354,10 +2364,10 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, /* Note that we use 'cano1 nums', that is, 1-based (InChI internal 'cano nums' are 0-based)*/ /* Also remove from the list atoms who mapped to cano number 0 ( == -1 + 1_offset ), */ /* they are explicit H's which have already been deleted. */ - for (k = 0; k < p->n_pzz; k++) + for ( k = 0; k < p->n_pzz; k++ ) { cano_num1 = cano_nums[p->pzz[k]] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { /* we shouldn't arrive here */ err = 10; @@ -2366,25 +2376,25 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, p->pzz[k] = cano_num1; } - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { int na_new = -1; u = units2[i]; - for (k = 0; k < u->na; k++) + for ( k = 0; k < u->na; k++ ) { cano_num1 = cano_nums[u->alist[k]] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { continue; } u->alist[++na_new] = cano_num1; } u->na = na_new + 1; - for (k = 0; k < 2 * u->nb; k++) + for ( k = 0; k < 2 * u->nb; k++ ) { cano_num1 = cano_nums[u->blist[k]] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { /* Can not proceed further as one of PU crossing bond ends leads to explicit H which has been removed already */ @@ -2395,7 +2405,7 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, } cano_num1 = cano_nums[u->cap1] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { err = 11; goto exit_function; @@ -2403,7 +2413,7 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, u->cap1 = cano_num1; cano_num1 = cano_nums[u->cap2] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { err = 11; goto exit_function; @@ -2411,7 +2421,7 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, u->cap2 = cano_num1; cano_num1 = cano_nums[u->end_atom1] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { err = 11; goto exit_function; @@ -2419,37 +2429,37 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, u->end_atom1 = cano_num1; cano_num1 = cano_nums[u->end_atom2] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { err = 11; goto exit_function; } u->end_atom2 = cano_num1; - for (k = 0; k < u->nbkbonds; k++) + for ( k = 0; k < u->nbkbonds; k++ ) { cano_num1 = cano_nums[u->bkbonds[k][0]] + 1; - if (cano_num1 == 0) + if ( cano_num1 == 0 ) { continue; } cano_num2 = cano_nums[u->bkbonds[k][1]] + 1; - if (cano_num2 == 0) + if ( cano_num2 == 0 ) { continue; } - u->bkbonds[k][0] = inchi_min( cano_num1, cano_num2 ); - u->bkbonds[k][1] = inchi_max( cano_num1, cano_num2 ); + u->bkbonds[k][0] = inchi_min(cano_num1, cano_num2); + u->bkbonds[k][1] = inchi_max(cano_num1, cano_num2); } } /* Sort the atoms and the bonds in all units */ - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { u = units2[i]; /* sort atoms (alist) */ - iisort( u->alist, u->na ); + iisort(u->alist, u->na); /*ITRACE_( "\n*** Polymer unit %-d : ( ", i ); for (k = 0; k < u->na - 1; k++) @@ -2459,8 +2469,8 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, ITRACE_( "%-d )\n", u->alist[u->na - 1] );*/ /* Sort bonds (blist) */ - err = OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves( u, p->n_pzz, p->pzz ); - if (err) + err = OAD_PolymerUnit_OrderBondAtomsAndBondsThemselves(u, p->n_pzz, p->pzz); + if ( err ) { /* crossing bonds in blist are invalid */ err = 12; @@ -2472,31 +2482,31 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, { int icompnt; icompnt = compnt_nums[u->alist[0] - 1]; - for (k = 1; k < u->na; k++) + for ( k = 1; k < u->na; k++ ) { - if (compnt_nums[u->alist[k] - 1] != icompnt) + if ( compnt_nums[u->alist[k] - 1] != icompnt ) { u->disjoint = 1; break; } } - } + } #endif } - /* Sort all units in modified alist's lexicographic order + /* Sort all units in modified alist's lexicographic order (modification is: longer list always go first ) */ - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { unum[i] = i; } - for (i = 1; i < p->n; i++) + for ( i = 1; i < p->n; i++ ) { int tmp = unum[i]; int j = i - 1; - while (j >= 0 && OAD_PolymerUnit_CompareAtomListsMod( units2[unum[j]], units2[tmp] ) > 0) - /*while ( j >= 0 && OAD_PolymerUnit_CompareAtomLists( units2[ unum[j] ], units2[ tmp ] ) > 0 )*/ + while ( j >= 0 && OAD_PolymerUnit_CompareAtomListsMod(units2[unum[j]], units2[tmp]) > 0 ) + /*while ( j >= 0 && OAD_PolymerUnit_CompareAtomLists( units2[ unum[j] ], units2[ tmp ] ) > 0 )*/ { unum[j + 1] = unum[j]; j--; @@ -2513,22 +2523,22 @@ int OAD_Polymer_PrepareWorkingSet( OAD_Polymer *p, /**************************************************************************** Helper for cyclizing CRU. NB: 0-based ****************************************************************************/ -int OrigAtData_RemoveHalfBond( int this_atom, - int other_atom, - inp_ATOM *at, - int *bond_type, - int *bond_stereo ) +int OrigAtData_RemoveHalfBond(int this_atom, + int other_atom, + inp_ATOM* at, + int* bond_type, + int* bond_stereo) { int k, kk; /* djb-rwth: fixing oss-fuzz issues #68286, #30342 */ - if (at && (this_atom >= 0) && (other_atom >= 0)) + if ( at && (this_atom >= 0) && (other_atom >= 0) ) { inp_ATOM* a = &(at[this_atom]); - if (a) + if ( a ) { - for (k = 0; k < a->valence; k++) + for ( k = 0; k < a->valence; k++ ) { - if (a->neighbor[k] != other_atom) + if ( a->neighbor[k] != other_atom ) { continue; } @@ -2538,13 +2548,13 @@ int OrigAtData_RemoveHalfBond( int this_atom, a->neighbor[k] = a->bond_type[k] = a->bond_stereo[k] = 0; - for (kk = k + 1; kk < a->valence; kk++) + for ( kk = k + 1; kk < a->valence; kk++ ) { a->neighbor[kk - 1] = a->neighbor[kk]; a->bond_type[kk - 1] = a->bond_type[kk]; a->bond_stereo[kk - 1] = a->bond_stereo[kk]; } - for (kk = a->valence - 1; kk < MAXVAL; kk++) + for ( kk = a->valence - 1; kk < MAXVAL; kk++ ) { a->neighbor[kk] = 0; a->bond_type[kk] = (U_CHAR)0; @@ -2560,10 +2570,10 @@ int OrigAtData_RemoveHalfBond( int this_atom, /****************************************************************************/ -int OrigAtData_RemoveAtom(ORIG_ATOM_DATA *orig_at_data, int iatom) +int OrigAtData_RemoveAtom(ORIG_ATOM_DATA* orig_at_data, int iatom) { - if (0) + if ( 0 ) { return 1; } @@ -2573,21 +2583,21 @@ int OrigAtData_RemoveAtom(ORIG_ATOM_DATA *orig_at_data, int iatom) /****************************************************************************/ -int OrigAtData_RemoveBond( int this_atom, - int other_atom, - inp_ATOM *at, - int *bond_type, - int *bond_stereo, - int *num_inp_bonds ) +int OrigAtData_RemoveBond(int this_atom, + int other_atom, + inp_ATOM* at, + int* bond_type, + int* bond_stereo, + int* num_inp_bonds) { int del = 0; - - if (at && (this_atom >= 0) && (other_atom >= 0)) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ + + if ( at && (this_atom >= 0) && (other_atom >= 0) ) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ { del = OrigAtData_RemoveHalfBond(this_atom, other_atom, at, bond_type, bond_stereo); del += OrigAtData_RemoveHalfBond(other_atom, this_atom, at, bond_type, bond_stereo); - if (del == 2) + if ( del == 2 ) { (*num_inp_bonds)--; at[this_atom].valence--; @@ -2603,41 +2613,41 @@ int OrigAtData_RemoveBond( int this_atom, /****************************************************************************/ -int OrigAtData_AddBond( int this_atom, - int other_atom, - inp_ATOM *at, - int bond_type, - int bond_stereo, - int *num_bonds ) +int OrigAtData_AddBond(int this_atom, + int other_atom, + inp_ATOM* at, + int bond_type, + int bond_stereo, + int* num_bonds) { - if (at) + if ( at ) { /* djb-rwth: fixing oss-fuzz issue #68286 */ int i, k, already_here; inp_ATOM* a = &(at[this_atom]); - if (at[this_atom].valence >= MAXVAL || - at[other_atom].valence >= MAXVAL) + if ( at[this_atom].valence >= MAXVAL || + at[other_atom].valence >= MAXVAL ) { return 0; } - if (bond_type != INCHI_BOND_TYPE_DOUBLE && bond_type != INCHI_BOND_TYPE_TRIPLE) + if ( bond_type != INCHI_BOND_TYPE_DOUBLE && bond_type != INCHI_BOND_TYPE_TRIPLE ) { bond_type = INCHI_BOND_TYPE_SINGLE; } k = a->valence; already_here = 0; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] == other_atom) + if ( a->neighbor[i] == other_atom ) { already_here = 1; break; } } - if (!already_here) + if ( !already_here ) { a->neighbor[k] = other_atom; a->bond_type[k] = (U_CHAR)bond_type; @@ -2649,15 +2659,15 @@ int OrigAtData_AddBond( int this_atom, a = &(at[other_atom]); k = a->valence; already_here = 0; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] == this_atom) + if ( a->neighbor[i] == this_atom ) { already_here = 1; break; } } - if (!already_here && (k < MAXVAL)) /* djb-rwth: condition added to prevent buffer overrun */ + if ( !already_here && (k < MAXVAL) ) /* djb-rwth: condition added to prevent buffer overrun */ { a->neighbor[k] = this_atom; a->bond_type[k] = (U_CHAR)bond_type; @@ -2678,39 +2688,39 @@ int OrigAtData_AddBond( int this_atom, /****************************************************************************/ -int OrigAtData_AddSingleStereolessBond( int this_atom, - int other_atom, - inp_ATOM *at, - int *num_bonds ) +int OrigAtData_AddSingleStereolessBond(int this_atom, + int other_atom, + inp_ATOM* at, + int* num_bonds) { - return OrigAtData_AddBond( this_atom, other_atom, at, INCHI_BOND_TYPE_SINGLE, 0, num_bonds ); + return OrigAtData_AddBond(this_atom, other_atom, at, INCHI_BOND_TYPE_SINGLE, 0, num_bonds); } /****************************************************************************/ -int OrigAtData_IncreaseBondOrder( int this_atom, int other_atom, inp_ATOM *at ) +int OrigAtData_IncreaseBondOrder(int this_atom, int other_atom, inp_ATOM* at) { int i, k, n_up = 0; - inp_ATOM *a; + inp_ATOM* a; - if (at[this_atom].valence >= MAXVAL || - at[other_atom].valence >= MAXVAL) + if ( at[this_atom].valence >= MAXVAL || + at[other_atom].valence >= MAXVAL ) { return 0; } - a = &( at[this_atom] ); - if (a->chem_bonds_valence > MAXVAL - 1) + a = &(at[this_atom]); + if ( a->chem_bonds_valence > MAXVAL - 1 ) { return 0; } k = a->valence; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] != other_atom) + if ( a->neighbor[i] != other_atom ) continue; - if (a->bond_type[i] > 3) + if ( a->bond_type[i] > 3 ) return 0; a->bond_type[i]++; a->chem_bonds_valence++; @@ -2718,20 +2728,20 @@ int OrigAtData_IncreaseBondOrder( int this_atom, int other_atom, inp_ATOM *at ) break; } - a = &( at[other_atom] ); - if (a->chem_bonds_valence > MAXVAL - 1) + a = &(at[other_atom]); + if ( a->chem_bonds_valence > MAXVAL - 1 ) { return 0; } k = a->valence; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] != this_atom) + if ( a->neighbor[i] != this_atom ) { continue; } - if (a->bond_type[i] > 3) + if ( a->bond_type[i] > 3 ) { return 0; } @@ -2746,27 +2756,27 @@ int OrigAtData_IncreaseBondOrder( int this_atom, int other_atom, inp_ATOM *at ) /****************************************************************************/ -int OrigAtData_DecreaseBondOrder( int this_atom, - int other_atom, - inp_ATOM *at ) +int OrigAtData_DecreaseBondOrder(int this_atom, + int other_atom, + inp_ATOM* at) { int i, k, n_dn = 0; - inp_ATOM *a; + inp_ATOM* a; - a = &( at[this_atom] ); - if (a->chem_bonds_valence > MAXVAL - 1) + a = &(at[this_atom]); + if ( a->chem_bonds_valence > MAXVAL - 1 ) { return 0; } k = a->valence; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] != other_atom) + if ( a->neighbor[i] != other_atom ) { continue; } - if (a->bond_type[i] < 2) + if ( a->bond_type[i] < 2 ) { return 0; } @@ -2776,15 +2786,15 @@ int OrigAtData_DecreaseBondOrder( int this_atom, break; } - a = &( at[other_atom] ); + a = &(at[other_atom]); k = a->valence; - for (i = 0; i < k; i++) + for ( i = 0; i < k; i++ ) { - if (a->neighbor[i] != this_atom) + if ( a->neighbor[i] != this_atom ) { continue; } - if (a->bond_type[i] < 2) + if ( a->bond_type[i] < 2 ) { return 0; } @@ -2801,63 +2811,63 @@ int OrigAtData_DecreaseBondOrder( int this_atom, /**************************************************************************** Collect bonds and optionally atoms of fragment ****************************************************************************/ -void OAD_CollectFragmentBondsAndAtoms( ORIG_ATOM_DATA *orig_at_data, - int nforbidden, /* number of edges forbidden for traversal */ - int *forbidden_orig, /* atom nums of forbidden edges */ - /* [edge1at1,edge1at2, edge2at1, edge2at2, ... ] */ - int *n_fragbonds, - int **fragbonds, - int *n_fragatoms, - int *fragatoms, - int *err, - char *pStrErr) +void OAD_CollectFragmentBondsAndAtoms(ORIG_ATOM_DATA* orig_at_data, + int nforbidden, /* number of edges forbidden for traversal */ + int* forbidden_orig, /* atom nums of forbidden edges */ + /* [edge1at1,edge1at2, edge2at1, edge2at2, ... ] */ + int* n_fragbonds, + int** fragbonds, + int* n_fragatoms, + int* fragatoms, + int* err, + char* pStrErr) { int i; int max_atoms = orig_at_data->num_inp_atoms; - int *atnums = NULL; - subgraf *sg = NULL; - subgraf_pathfinder *spf = NULL; + int* atnums = NULL; + subgraf* sg = NULL; + subgraf_pathfinder* spf = NULL; *err = 0; - atnums = (int *)inchi_calloc(max_atoms, sizeof(int)); - if (!atnums) + atnums = (int*)inchi_calloc(max_atoms, sizeof(int)); + if ( !atnums ) { TREAT_ERR(*err, 9045, "Not enough memory"); goto exit_function; } - for (i = 0; i < max_atoms; i++) + for ( i = 0; i < max_atoms; i++ ) { atnums[i] = orig_at_data->at[i].orig_at_number; /* i+1 normally*/ } sg = subgraf_new(orig_at_data, max_atoms, atnums); - if (!sg) + if ( !sg ) { TREAT_ERR(*err, 9045, "Not enough memory"); goto exit_function; } spf = subgraf_pathfinder_new(sg, orig_at_data, 0, 0); /* start = end = 0th node */ - if (!spf) + if ( !spf ) { TREAT_ERR(*err, 9045, "Not enough memory"); goto exit_function; } - spf->seen[0] = spf->start; + spf->seen[0] = spf->start; spf->nseen = 1; *n_fragbonds = 0; *n_fragatoms = 0; - subgraf_pathfinder_run( spf, - nforbidden, forbidden_orig, /* this corrects cinnectivity of subgraf... */ - n_fragbonds, fragbonds, - n_fragatoms, fragatoms); + subgraf_pathfinder_run(spf, + nforbidden, forbidden_orig, /* this corrects cinnectivity of subgraf... */ + n_fragbonds, fragbonds, + n_fragatoms, fragatoms); exit_function: subgraf_free(sg); subgraf_pathfinder_free(spf); - if (atnums) + if ( atnums ) { inchi_free(atnums); } @@ -2868,59 +2878,59 @@ void OAD_CollectFragmentBondsAndAtoms( ORIG_ATOM_DATA *orig_at_data, /**************************************************************************** For all CRUs detect the bonds potentially involved in frame shift ****************************************************************************/ -void OAD_Polymer_FindBackbones( ORIG_ATOM_DATA *at_data, - COMP_ATOM_DATA *composite_norm_data, - int *err, - char *pStrErr ) +void OAD_Polymer_FindBackbones(ORIG_ATOM_DATA* at_data, + COMP_ATOM_DATA* composite_norm_data, + int* err, + char* pStrErr) { int i; *err = 0; - for (i = 0; i < at_data->polymer->n; i++) + for ( i = 0; i < at_data->polymer->n; i++ ) { - if (!at_data->polymer->units[i]->cyclizable) + if ( !at_data->polymer->units[i]->cyclizable ) { continue; } - OAD_CollectBackboneBonds( at_data, - at_data->polymer->units[i]->na, - at_data->polymer->units[i]->alist, - at_data->polymer->units[i]->end_atom1, - at_data->polymer->units[i]->end_atom2, - &(at_data->polymer->units[i]->nbkbonds), - at_data->polymer->units[i]->bkbonds, - err, pStrErr ); - if (*err) + OAD_CollectBackboneBonds(at_data, + at_data->polymer->units[i]->na, + at_data->polymer->units[i]->alist, + at_data->polymer->units[i]->end_atom1, + at_data->polymer->units[i]->end_atom2, + &(at_data->polymer->units[i]->nbkbonds), + at_data->polymer->units[i]->bkbonds, + err, pStrErr); + if ( *err ) { at_data->polymer->units[i]->cyclizable = CLOSING_SRU_NOT_APPLICABLE; continue; } - if (at_data->polymer->units[i]->nbkbonds < 1) + if ( at_data->polymer->units[i]->nbkbonds < 1 ) { continue; } - if (at_data->polymer->units[i]->nbkbonds == 1) + if ( at_data->polymer->units[i]->nbkbonds == 1 ) { /* Special case: we got only one bond between end_atom1 and */ /* end_atom2 (this may be the result of metal disconnection) */ continue; } - OAD_PolymerUnit_DelistIntraRingBackboneBonds( at_data->polymer->units[i], at_data, err, pStrErr ); - if (*err) + OAD_PolymerUnit_DelistIntraRingBackboneBonds(at_data->polymer->units[i], at_data, err, pStrErr); + if ( *err ) { continue; } - OAD_PolymerUnit_DelistHighOrderBackboneBonds( at_data->polymer->units[i], - at_data, composite_norm_data, - err, pStrErr ); - if (*err) + OAD_PolymerUnit_DelistHighOrderBackboneBonds(at_data->polymer->units[i], + at_data, composite_norm_data, + err, pStrErr); + if ( *err ) { continue; } - if (at_data->polymer->units[i]->nbkbonds == 0) + if ( at_data->polymer->units[i]->nbkbonds == 0 ) { /* We already cyclized frame-shiftable unit and preprocessed it (in 'prep_inp_data'). */ /* Despite that, now we discovered that there are no bonds eligible for frame shift */ @@ -2942,57 +2952,57 @@ void OAD_Polymer_FindBackbones( ORIG_ATOM_DATA *at_data, /**************************************************************************** Collect all backbone atoms - of main chain(s), side chains being ignored ****************************************************************************/ -void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA *at_data, - int na, - int *alist, - int end_atom1, - int end_atom2, - int *nbkatoms, - int *bkatoms, - int *err, - char *pStrErr) +void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA* at_data, + int na, + int* alist, + int end_atom1, + int end_atom2, + int* nbkatoms, + int* bkatoms, + int* err, + char* pStrErr) { int start = 0, end = 0; - subgraf *sg = NULL; - subgraf_pathfinder *spf = NULL; - int nbkbonds=0; - int **bkbonds=NULL; /* list of [breakable] backbone bonds [ (a1,a2), (a3,a4), ... ] */ + subgraf* sg = NULL; + subgraf_pathfinder* spf = NULL; + int nbkbonds = 0; + int** bkbonds = NULL; /* list of [breakable] backbone bonds [ (a1,a2), (a3,a4), ... ] */ int maxbkbonds; *nbkatoms = 0; maxbkbonds = at_data->num_inp_bonds + 2; *err = imat_new(maxbkbonds, 2, &(bkbonds)); - if (*err) + if ( *err ) { TREAT_ERR(*err, 9034, "Not enough memory (polymers)"); goto exit_function; } nbkbonds = 0; sg = subgraf_new(at_data, na, alist); - if (!sg) + if ( !sg ) { TREAT_ERR(*err, 9037, "Not enough memory (polymers)"); goto exit_function; } start = sg->orig2node[end_atom1]; end = sg->orig2node[end_atom2]; - if (start > end) + if ( start > end ) { int tmp = end; end = start; start = tmp; } spf = subgraf_pathfinder_new(sg, at_data, start, end); - if (!spf) + if ( !spf ) { TREAT_ERR(*err, 9039, "Not enough memory (polymers)"); goto exit_function; } - spf->seen[0] = spf->start; spf->nseen = 1; + spf->seen[0] = spf->start; spf->nseen = 1; nbkbonds = 0; *nbkatoms = 0; - + subgraf_pathfinder_run(spf, 0, NULL, &nbkbonds, bkbonds, nbkatoms, bkatoms); subgraf_free(sg); @@ -3001,11 +3011,11 @@ void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA *at_data, exit_function: - if (bkbonds) + if ( bkbonds ) { imat_free(maxbkbonds, bkbonds); bkbonds = NULL; - } + } return; } @@ -3014,44 +3024,44 @@ void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA *at_data, /**************************************************************************** Collect all atoms reachable from start_atom ****************************************************************************/ -int OAD_CollectReachableAtoms( ORIG_ATOM_DATA *orig_at_data, - int start_atom, - int nforbidden_bonds, - int *forbidden_bond_atoms, - int *n_reachable, - int *reachable, - int *err, - char *pStrErr) +int OAD_CollectReachableAtoms(ORIG_ATOM_DATA* orig_at_data, + int start_atom, + int nforbidden_bonds, + int* forbidden_bond_atoms, + int* n_reachable, + int* reachable, + int* err, + char* pStrErr) { int iatom, natnums, max_atoms, j, ret = _IS_OKAY; int max_n_reachable = *n_reachable; - int *atnums = NULL; - subgraf *sg = NULL; - subgraf_pathfinder *spf = NULL; + int* atnums = NULL; + subgraf* sg = NULL; + subgraf_pathfinder* spf = NULL; /* djb-rwth: removing redundant code */ max_atoms = orig_at_data->num_inp_atoms; iatom = start_atom - 1; *n_reachable = 0; - atnums = (int *)inchi_calloc(max_atoms, sizeof(int)); - if (!atnums) + atnums = (int*)inchi_calloc(max_atoms, sizeof(int)); + if ( !atnums ) { ret = _IS_ERROR; goto exit_function; } - for (j = 0; j < max_atoms; j++) + for ( j = 0; j < max_atoms; j++ ) { atnums[j] = orig_at_data->at[j].orig_at_number; } sg = subgraf_new(orig_at_data, max_atoms, atnums); - if (!sg) + if ( !sg ) { ret = _IS_ERROR; goto exit_function; } spf = subgraf_pathfinder_new(sg, orig_at_data, iatom, iatom); - if (!spf) + if ( !spf ) { ret = _IS_ERROR; goto exit_function; @@ -3059,14 +3069,14 @@ int OAD_CollectReachableAtoms( ORIG_ATOM_DATA *orig_at_data, /* move from orig# to node# */ spf->start = iatom; - for (j = 0; j < nforbidden_bonds; j++) + for ( j = 0; j < nforbidden_bonds; j++ ) { - forbidden_bond_atoms[2 * j] = sg->orig2node[forbidden_bond_atoms[2 * j] ]; - forbidden_bond_atoms[2 * j + 1] = sg->orig2node[forbidden_bond_atoms[2 * j + 1] ]; + forbidden_bond_atoms[2 * j] = sg->orig2node[forbidden_bond_atoms[2 * j]]; + forbidden_bond_atoms[2 * j + 1] = sg->orig2node[forbidden_bond_atoms[2 * j + 1]]; } /*memset(atnums, -1, max_atoms * sizeof(int));*/ - for (j = 0; j < max_atoms; j++) + for ( j = 0; j < max_atoms; j++ ) { atnums[j] = -1; } @@ -3074,9 +3084,9 @@ int OAD_CollectReachableAtoms( ORIG_ATOM_DATA *orig_at_data, spf->nseen = 0; natnums = subgraf_pathfinder_collect_all(spf, nforbidden_bonds, forbidden_bond_atoms, atnums); - if (natnums) + if ( natnums ) { - if (natnums > max_n_reachable) + if ( natnums > max_n_reachable ) { ret = _IS_ERROR; goto exit_function; @@ -3091,11 +3101,11 @@ int OAD_CollectReachableAtoms( ORIG_ATOM_DATA *orig_at_data, exit_function: subgraf_free(sg); subgraf_pathfinder_free(spf); - if (atnums) + if ( atnums ) { inchi_free(atnums); } - + return ret; } @@ -3104,56 +3114,56 @@ int OAD_CollectReachableAtoms( ORIG_ATOM_DATA *orig_at_data, Collect all backbone bonds - of main chain(s), side chains being ignored (for polymer CRU, these are the bonds potentially involved in frame shift) ****************************************************************************/ -void OAD_CollectBackboneBonds(ORIG_ATOM_DATA *at_data, - int na, - int *alist, - int end_atom1, - int end_atom2, - int *nbkbonds, - int **bkbonds, - int *err, - char *pStrErr ) +void OAD_CollectBackboneBonds(ORIG_ATOM_DATA* at_data, + int na, + int* alist, + int end_atom1, + int end_atom2, + int* nbkbonds, + int** bkbonds, + int* err, + char* pStrErr) { int start = 0, end = 0, dummy; - subgraf *sg = NULL; - subgraf_pathfinder *spf = NULL; + subgraf* sg = NULL; + subgraf_pathfinder* spf = NULL; /* Establish subgraph for na atoms of the alist */ *nbkbonds = 0; - sg = subgraf_new( at_data, na, alist ); - if (!sg) + sg = subgraf_new(at_data, na, alist); + if ( !sg ) { - TREAT_ERR( *err, 9037, "Not enough memory (polymers)" ); + TREAT_ERR(*err, 9037, "Not enough memory (polymers)"); /* unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE; */ return; } - start = sg->orig2node[end_atom1]; + start = sg->orig2node[end_atom1]; end = sg->orig2node[end_atom2]; #if 0 - if (start > end) + if ( start > end ) { int tmp = end; end = start; start = tmp; } #endif - spf = subgraf_pathfinder_new( sg, at_data, start, end ); - if (!spf) + spf = subgraf_pathfinder_new(sg, at_data, start, end); + if ( !spf ) { - TREAT_ERR( *err, 9039, "Not enough memory (polymers)" ); + TREAT_ERR(*err, 9039, "Not enough memory (polymers)"); /*unit->cyclizable = CLOSING_SRU_NOT_APPLICABLE;*/ return; } - spf->seen[0] = spf->start; - spf->nseen = 1; + spf->seen[0] = spf->start; + spf->nseen = 1; *nbkbonds = 0; - subgraf_pathfinder_run( spf, 0, NULL, - nbkbonds, - bkbonds, /* we will collect backbone CRU bonds here */ - &dummy, - NULL ); - - subgraf_free( sg ); - subgraf_pathfinder_free( spf ); + subgraf_pathfinder_run(spf, 0, NULL, + nbkbonds, + bkbonds, /* we will collect backbone CRU bonds here */ + &dummy, + NULL); + + subgraf_free(sg); + subgraf_pathfinder_free(spf); *err = 0; return; @@ -3163,19 +3173,19 @@ void OAD_CollectBackboneBonds(ORIG_ATOM_DATA *at_data, /**************************************************************************** Remove intra-ring bonds from the list of frame-shiftable bonds ****************************************************************************/ -void OAD_PolymerUnit_DelistIntraRingBackboneBonds( OAD_PolymerUnit *unit, - ORIG_ATOM_DATA *at_data, - int *err, - char *pStrErr ) +void OAD_PolymerUnit_DelistIntraRingBackboneBonds(OAD_PolymerUnit* unit, + ORIG_ATOM_DATA* at_data, + int* err, + char* pStrErr) { int nrings = 0; - int *num_ring_sys = NULL; + int* num_ring_sys = NULL; - if (!unit) + if ( !unit ) { return; } - if (unit->nbkbonds < 1) + if ( unit->nbkbonds < 1 ) { return; } @@ -3183,45 +3193,45 @@ void OAD_PolymerUnit_DelistIntraRingBackboneBonds( OAD_PolymerUnit *unit, /* Establish ring systems assignments for all related atoms */ *err = 1; - num_ring_sys = (int *) inchi_calloc( (long long)at_data->num_inp_atoms + 1, sizeof( int ) ); /* djb-rwth: cast operator added */ - if (!num_ring_sys) + num_ring_sys = (int*)inchi_calloc((long long)at_data->num_inp_atoms + 1, sizeof(int)); /* djb-rwth: cast operator added */ + if ( !num_ring_sys ) { goto exit_function; } *err = 0; - nrings = OAD_Polymer_FindRingSystems( at_data->polymer, at_data->at, at_data->num_inp_atoms, &at_data->num_inp_bonds, - num_ring_sys, NULL, unit->end_atom1 - 1 ); /* NB: start dfs within connected compt! */ + nrings = OAD_Polymer_FindRingSystems(at_data->polymer, at_data->at, at_data->num_inp_atoms, &at_data->num_inp_bonds, + num_ring_sys, NULL, unit->end_atom1 - 1); /* NB: start dfs within connected compt! */ - if (nrings == 0) + if ( nrings == 0 ) { goto exit_function; } else { int at1, at2, j = 0; -repeatj: + repeatj: at1 = unit->bkbonds[j][0]; at2 = unit->bkbonds[j][1]; - if (( num_ring_sys[at1] == num_ring_sys[at2] ) && ( num_ring_sys[at1] != -1 )) + if ( (num_ring_sys[at1] == num_ring_sys[at2]) && (num_ring_sys[at1] != -1) ) { - OAD_PolymerUnit_RemoveLinkFromCRUChain( at1, at2, &unit->nbkbonds, unit->bkbonds ); + OAD_PolymerUnit_RemoveLinkFromCRUChain(at1, at2, &unit->nbkbonds, unit->bkbonds); } else { ++j; } - if (j < unit->nbkbonds) + if ( j < unit->nbkbonds ) { goto repeatj; } } exit_function: - if (num_ring_sys) + if ( num_ring_sys ) { - inchi_free( num_ring_sys ); + inchi_free(num_ring_sys); } return; @@ -3231,71 +3241,71 @@ void OAD_PolymerUnit_DelistIntraRingBackboneBonds( OAD_PolymerUnit *unit, /**************************************************************************** Find ring systems (exclude possible cyclizing bonds) in all polymer SRU's ****************************************************************************/ -int OAD_Polymer_FindRingSystems( OAD_Polymer *pd, - inp_ATOM *at, - int nat, - int *num_inp_bonds, - int *num_ring_sys, - int *size_ring_sys, - int start ) +int OAD_Polymer_FindRingSystems(OAD_Polymer* pd, + inp_ATOM* at, + int nat, + int* num_inp_bonds, + int* num_ring_sys, + int* size_ring_sys, + int start) { int i, j, nrings = 0, bond_type, bond_stereo; - if (NULL == num_ring_sys) + if ( NULL == num_ring_sys ) { return 0; } /* Remove polymer SRU 'cyclizing' bonds if any */ - for (j = 0; j < pd->n; j++) + for ( j = 0; j < pd->n; j++ ) { - if (pd->units[j]->cyclized) + if ( pd->units[j]->cyclized ) { - OrigAtData_RemoveBond( pd->units[j]->end_atom1 - 1, - pd->units[j]->end_atom2 - 1, - at, &bond_type, &bond_stereo, - num_inp_bonds ); + OrigAtData_RemoveBond(pd->units[j]->end_atom1 - 1, + pd->units[j]->end_atom2 - 1, + at, &bond_type, &bond_stereo, + num_inp_bonds); } } - MarkRingSystemsInp( at, nat, start ); /*0 );*/ + MarkRingSystemsInp(at, nat, start); /*0 );*/ - for (i = 0; i <= nat; i++) + for ( i = 0; i <= nat; i++ ) { num_ring_sys[i] = -1; } - for (i = 0; i < nat; i++) + for ( i = 0; i < nat; i++ ) { - if (at[i].nNumAtInRingSystem > 2) + if ( at[i].nNumAtInRingSystem > 2 ) { int atnum = at[i].orig_at_number; num_ring_sys[atnum] = at[i].nRingSystem; - if (NULL != size_ring_sys) + if ( NULL != size_ring_sys ) { size_ring_sys[atnum] = at[i].nNumAtInRingSystem; } } } - UnMarkRingSystemsInp( at, nat ); + UnMarkRingSystemsInp(at, nat); - for (i = 0; i < nat; i++) + for ( i = 0; i < nat; i++ ) { - if (num_ring_sys[i] > -1) + if ( num_ring_sys[i] > -1 ) { nrings++; } } /* Restore polymer SRU 'cyclizing' bonds if applicable */ - for (j = 0; j < pd->n; j++) + for ( j = 0; j < pd->n; j++ ) { - if (pd->units[j]->cyclized) + if ( pd->units[j]->cyclized ) { - OrigAtData_AddSingleStereolessBond( pd->units[j]->end_atom1 - 1, - pd->units[j]->end_atom2 - 1, - at, - num_inp_bonds ); + OrigAtData_AddSingleStereolessBond(pd->units[j]->end_atom1 - 1, + pd->units[j]->end_atom2 - 1, + at, + num_inp_bonds); } } @@ -3307,21 +3317,21 @@ int OAD_Polymer_FindRingSystems( OAD_Polymer *pd, Fill atomic properties (OrigAtData ) necessary to calc seniority in polymer SRUs ****************************************************************************/ -void OAD_Polymer_SetAtProps( OAD_Polymer *pd, - inp_ATOM *at, - int nat, - int *num_inp_bonds, - OAD_AtProps *aprops, - int *cano_nums ) +void OAD_Polymer_SetAtProps(OAD_Polymer* pd, + inp_ATOM* at, + int nat, + int* num_inp_bonds, + OAD_AtProps* aprops, + int* cano_nums) { -/* Max rank for in-ring atom is 216 which is achieved for N (element number 7 in Periodic system & erank_rule2[] ),*/ -/* then goes O with rank 215 (element number 8), and so on... lowest rank is 1 for H . */ -/* */ -/* This follows to IUPAC rule 2 [Pure Appl. Chem., Vol. 74, No. 10, 2002, p. 1926] which states: */ -/* a. a ring or ring system containing nitrogen; */ -/* b. a ring or ring system containing the heteroatom occurring earliest in the order given in Rule 4; */ -/* ( which is O > S > Se > Te > N > P > As > Sb > Bi > Si > Ge > Sn > Pb > B > Hg ) */ -/* ... */ + /* Max rank for in-ring atom is 216 which is achieved for N (element number 7 in Periodic system & erank_rule2[] ),*/ + /* then goes O with rank 215 (element number 8), and so on... lowest rank is 1 for H . */ + /* */ + /* This follows to IUPAC rule 2 [Pure Appl. Chem., Vol. 74, No. 10, 2002, p. 1926] which states: */ + /* a. a ring or ring system containing nitrogen; */ + /* b. a ring or ring system containing the heteroatom occurring earliest in the order given in Rule 4; */ + /* ( which is O > S > Se > Te > N > P > As > Sb > Bi > Si > Ge > Sn > Pb > B > Hg ) */ + /* ... */ int erank_rule2[] = { 0,1,198,197,196,202,2,216,215,191,190,189,188,187,206,210,214,183,182,181,180,179,178,177,176, 175,174,173,172,171,170,169,205,209,213,165,164,163,162,161,160,159,158,157,156,155,154,153,152, @@ -3348,26 +3358,26 @@ void OAD_Polymer_SetAtProps( OAD_Polymer *pd, int i, j, k, nrings = 0; int a1, a2, dummy = 0, bond_type = -1, bond_stereo = -1; - int *num_ring_sys = NULL, *size_ring_sys = NULL; + int* num_ring_sys = NULL, * size_ring_sys = NULL; /* djb-rwth: fixing oss-fuzz issue #68112 */ int err2_len = sizeof(erank_rule2) / sizeof(erank_rule2[0]); int err4_len = sizeof(erank_rule4) / sizeof(erank_rule4[0]); - if ((NULL == aprops) || !at || !pd) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ + if ( (NULL == aprops) || !at || !pd ) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ { return; } /* Establish element ranks for atoms */ - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { int atnum = at[k].orig_at_number, index = k; U_CHAR err4_ind = at[k].el_number; - if (cano_nums) + if ( cano_nums ) { index = cano_nums[atnum]; } - if (index >= 0 && err4_ind < err4_len) + if ( index >= 0 && err4_ind < err4_len ) { aprops[index].erank = erank_rule4[err4_ind]; aprops[index].ring_erank = 0; @@ -3383,102 +3393,102 @@ void OAD_Polymer_SetAtProps( OAD_Polymer *pd, } /* Establish ring systems assignments for atoms */ - num_ring_sys = (int *) inchi_calloc( (long long)nat + 1, sizeof( int ) ); /* djb-rwth: cast operator added */ - if (NULL == num_ring_sys) + num_ring_sys = (int*)inchi_calloc((long long)nat + 1, sizeof(int)); /* djb-rwth: cast operator added */ + if ( NULL == num_ring_sys ) { goto exit_function; } - size_ring_sys = (int *) inchi_calloc( (long long)nat + 1, sizeof( int ) ); /* djb-rwth: cast operator added */ - if (NULL == size_ring_sys) + size_ring_sys = (int*)inchi_calloc((long long)nat + 1, sizeof(int)); /* djb-rwth: cast operator added */ + if ( NULL == size_ring_sys ) { goto exit_function; } /* Note that we get here on the way of InChI2Struct conversion. */ /* Break temporarily any of (actually, the first) SRU 'cyclizing' bonds */ - for (j = 0; j < pd->n; j++) + for ( j = 0; j < pd->n; j++ ) { - if (pd->units[j]->na > 2 && pd->units[j]->nbkbonds > 0 && - pd->units[j]->cyclized == 0 && - pd->units[j]->cyclizable == CLOSING_SRU_RING) + if ( pd->units[j]->na > 2 && pd->units[j]->nbkbonds > 0 && + pd->units[j]->cyclized == 0 && + pd->units[j]->cyclizable == CLOSING_SRU_RING ) { a1 = pd->units[j]->bkbonds[0][0] - 1; a2 = pd->units[j]->bkbonds[0][1] - 1; - OrigAtData_RemoveBond( a1, a2, at, &bond_type, &bond_stereo, &dummy ); + OrigAtData_RemoveBond(a1, a2, at, &bond_type, &bond_stereo, &dummy); } } - nrings = OAD_Polymer_FindRingSystems( pd, at, nat, num_inp_bonds, num_ring_sys, size_ring_sys, 0 ); + nrings = OAD_Polymer_FindRingSystems(pd, at, nat, num_inp_bonds, num_ring_sys, size_ring_sys, 0); /* Immediately restore just broken bond(s) */ - for (j = 0; j < pd->n; j++) + for ( j = 0; j < pd->n; j++ ) { - if (pd->units[j]->na > 2 && - pd->units[j]->nbkbonds > 0 && - pd->units[j]->cyclized == 0 && - pd->units[j]->cyclizable == CLOSING_SRU_RING) + if ( pd->units[j]->na > 2 && + pd->units[j]->nbkbonds > 0 && + pd->units[j]->cyclized == 0 && + pd->units[j]->cyclizable == CLOSING_SRU_RING ) { a1 = pd->units[j]->bkbonds[0][0] - 1; a2 = pd->units[j]->bkbonds[0][1] - 1; /* OrigAtData_AddSingleStereolessBond( a1, a2, at, &dummy ); */ - OrigAtData_AddBond( a1, a2, at, bond_type, bond_stereo, &dummy ); + OrigAtData_AddBond(a1, a2, at, bond_type, bond_stereo, &dummy); } } - if (nrings) + if ( nrings ) { int max_ring_num = 0; /* SRU contains ring[s], proceed with them following (not totally) the IUPAC guidelines */ - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { /* Browse 0-based original atoms, go to 1-based cano nums domain if cano_nums mapping is suppied */ int atnum = at[k].orig_at_number, index = k; - if (cano_nums) + if ( cano_nums ) { index = cano_nums[atnum] + 1; } - if (num_ring_sys[atnum] >= 0) + if ( num_ring_sys[atnum] >= 0 ) { aprops[index].ring_num = num_ring_sys[atnum]; /* temporarily */ - if (max_ring_num < aprops[index].ring_num) + if ( max_ring_num < aprops[index].ring_num ) max_ring_num = aprops[index].ring_num; /* NB: OAD_Polymer_FindRingSystems may return num_ring_sys[] */ - /* which is not a list of consecutive numbers */ + /* which is not a list of consecutive numbers */ aprops[index].ring_size = size_ring_sys[atnum]; /* Size of ring system which includes the atom k . */ - /* It is used as an additional score for in-ring */ - /* atoms' prioritizing (instead of criteria in */ - /* 2c-2h of IUPAC rule 2 which deal with ring sizes). */ + /* It is used as an additional score for in-ring */ + /* atoms' prioritizing (instead of criteria in */ + /* 2c-2h of IUPAC rule 2 which deal with ring sizes). */ } } - for (i = 0; i <= max_ring_num; i++) + for ( i = 0; i <= max_ring_num; i++ ) { int erank, max_erank = 0; - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { int atnum = at[k].orig_at_number, index = k; - if (cano_nums) + if ( cano_nums ) { index = cano_nums[atnum] + 1; } - if (aprops[index].ring_num == i) + if ( aprops[index].ring_num == i ) { erank = erank_rule2[at[k].el_number]; - if (erank > max_erank) + if ( erank > max_erank ) max_erank = erank; } } - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { int atnum = at[k].orig_at_number, index = k; - if (cano_nums) + if ( cano_nums ) { index = cano_nums[atnum] + 1; } - if (aprops[index].ring_num == i) + if ( aprops[index].ring_num == i ) { - if (aprops[index].ring_size > 2) + if ( aprops[index].ring_size > 2 ) { aprops[index].ring_erank = max_erank; } @@ -3488,13 +3498,13 @@ void OAD_Polymer_SetAtProps( OAD_Polymer *pd, } exit_function: - if (num_ring_sys) + if ( num_ring_sys ) { - inchi_free( num_ring_sys ); + inchi_free(num_ring_sys); } - if (size_ring_sys) + if ( size_ring_sys ) { - inchi_free( size_ring_sys ); + inchi_free(size_ring_sys); } return; @@ -3504,40 +3514,40 @@ void OAD_Polymer_SetAtProps( OAD_Polymer *pd, /**************************************************************************** Exclude higher order bonds from list of bkbonds ****************************************************************************/ -void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit, - ORIG_ATOM_DATA *orig_at_data, - COMP_ATOM_DATA *composite_norm_data, - int *err, - char *pStrErr ) +void OAD_PolymerUnit_DelistHighOrderBackboneBonds(OAD_PolymerUnit* unit, + ORIG_ATOM_DATA* orig_at_data, + COMP_ATOM_DATA* composite_norm_data, + int* err, + char* pStrErr) { int at1, at2, j = 0, k, check_taut = 0, remove; /* djb-rwth: removing redundant variables/code */ - int *orig_num = NULL, *curr_num = NULL; + int* orig_num = NULL, * curr_num = NULL; int bond_is_untouchable = 0, btype; /* DT: moved from below 2024-09-01 DT */ - if (unit->na < 2) + if ( unit->na < 2 ) { return; } - if (unit->nb < 2) + if ( unit->nb < 2 ) { return; } - if (unit->nbkbonds < 1) + if ( unit->nbkbonds < 1 ) { return; } /* Care on tautomeric bonds */ - if (composite_norm_data) + if ( composite_norm_data ) { check_taut = 1; - orig_num = (int *) inchi_calloc( (long long)orig_at_data->num_inp_atoms + 2, sizeof( int ) ); /* djb-rwth: cast operator added */ - curr_num = (int *) inchi_calloc( (long long)orig_at_data->num_inp_atoms + 2, sizeof( int ) ); /* djb-rwth: cast operator added */ - if (orig_num && curr_num) + orig_num = (int*)inchi_calloc((long long)orig_at_data->num_inp_atoms + 2, sizeof(int)); /* djb-rwth: cast operator added */ + curr_num = (int*)inchi_calloc((long long)orig_at_data->num_inp_atoms + 2, sizeof(int)); /* djb-rwth: cast operator added */ + if ( orig_num && curr_num ) { check_taut = 1; - CompAtomData_GetNumMapping( composite_norm_data, orig_num, curr_num ); + CompAtomData_GetNumMapping(composite_norm_data, orig_num, curr_num); } } repeatj: @@ -3545,54 +3555,54 @@ void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit, at1 = unit->bkbonds[j][0]; at2 = unit->bkbonds[j][1]; /* djb-rwth: removing redundant code */ - for (k = 0; k < orig_at_data->at[at1 - 1].valence; k++) + for ( k = 0; k < orig_at_data->at[at1 - 1].valence; k++ ) { - if (orig_at_data->at[at1 - 1].neighbor[k] != at2 - 1) + if ( orig_at_data->at[at1 - 1].neighbor[k] != at2 - 1 ) continue; /* djb-rwth: removing redundant code */ } /*if ( border > 1 ) */ /* djb-rwth: removing redundant code */ bond_is_untouchable = 0; - if (check_taut && composite_norm_data && composite_norm_data->at && curr_num) /* djb-rwth: fixing a NULL pointer dereference */ + if ( check_taut && composite_norm_data && composite_norm_data->at && curr_num ) /* djb-rwth: fixing a NULL pointer dereference */ { - for (k = 0; k < composite_norm_data->at[curr_num[at1]].valence; k++) + for ( k = 0; k < composite_norm_data->at[curr_num[at1]].valence; k++ ) { - if (composite_norm_data->at[curr_num[at1]].neighbor[k] != curr_num[at2]) + if ( composite_norm_data->at[curr_num[at1]].neighbor[k] != curr_num[at2] ) { continue; } btype = composite_norm_data->at[curr_num[at1]].bond_type[k]; - bond_is_untouchable = ( btype == BOND_TAUTOM ); /*|| btype == BOND_ALTERN );*/ + bond_is_untouchable = (btype == BOND_TAUTOM); /*|| btype == BOND_ALTERN );*/ break; } } - if (bond_is_untouchable) + if ( bond_is_untouchable ) { remove = 1; } - if (remove) + if ( remove ) { - OAD_PolymerUnit_RemoveLinkFromCRUChain( at1, at2, &unit->nbkbonds, unit->bkbonds ); + OAD_PolymerUnit_RemoveLinkFromCRUChain(at1, at2, &unit->nbkbonds, unit->bkbonds); } else { ++j; } - if (j < unit->nbkbonds) + if ( j < unit->nbkbonds ) { goto repeatj; } - if (orig_num) + if ( orig_num ) { - inchi_free( orig_num ); + inchi_free(orig_num); } - if (curr_num) + if ( curr_num ) { - inchi_free( curr_num ); + inchi_free(curr_num); } return; @@ -3602,30 +3612,30 @@ void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit, /**************************************************************************** Remove bond (at1, at2) ****************************************************************************/ -void OAD_PolymerUnit_RemoveLinkFromCRUChain( int at1, - int at2, - int *nbonds, - int **bonds ) +void OAD_PolymerUnit_RemoveLinkFromCRUChain(int at1, + int at2, + int* nbonds, + int** bonds) { int p, q; #if 0 - if (at1 > at2) + if ( at1 > at2 ) { int tmp = at1; at1 = at2; at2 = tmp; } #endif - for (p = 0; p < *nbonds; p++) + for ( p = 0; p < *nbonds; p++ ) { - if (bonds[p][0] == at1 && bonds[p][1] == at2) + if ( bonds[p][0] == at1 && bonds[p][1] == at2 ) { - for (q = p + 1; q < *nbonds; q++) + for ( q = p + 1; q < *nbonds; q++ ) { bonds[q - 1][0] = bonds[q][0]; bonds[q - 1][1] = bonds[q][1]; } - ( *nbonds )--; + (*nbonds)--; break; } } @@ -3637,62 +3647,62 @@ void OAD_PolymerUnit_RemoveLinkFromCRUChain( int at1, /**************************************************************************** Debug print polymer data for a given SRU ****************************************************************************/ -void OAD_PolymerUnit_DebugTrace( OAD_PolymerUnit *u ) +void OAD_PolymerUnit_DebugTrace(OAD_PolymerUnit* u) { - char *conn = "ABSENT", *typ = "ABSENT", *styp = "ABSENT"; + char* conn = "ABSENT", * typ = "ABSENT", * styp = "ABSENT"; - if (!u) + if ( !u ) { return; } - if (u->conn == 1) + if ( u->conn == 1 ) { conn = "HT"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->conn == 2) + else if ( u->conn == 2 ) { conn = "HH"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->conn == 3) + else if ( u->conn == 3 ) { conn = "EU"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - if (u->type == 0) + if ( u->type == 0 ) { typ = "NONE"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->type == 1) + else if ( u->type == 1 ) { typ = "SRU"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->type == 2) + else if ( u->type == 2 ) { typ = "MON"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->type == 3) + else if ( u->type == 3 ) { typ = "COP"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->type == 4) + else if ( u->type == 4 ) { typ = "MOD"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->type == 5) + else if ( u->type == 5 ) { typ = "MER"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - if (u->subtype == 1) + if ( u->subtype == 1 ) { styp = "ALT"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->subtype == 2) + else if ( u->subtype == 2 ) { styp = "RAN"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } - else if (u->subtype == 3) + else if ( u->subtype == 3 ) { styp = "BLK"; /* djb-rwth: ignoring LLVM warning: possible presence of global variables */ } @@ -3703,47 +3713,47 @@ void OAD_PolymerUnit_DebugTrace( OAD_PolymerUnit *u ) ITRACE_("\n\nPOLYMER UNIT @ %-p", u); - ITRACE_( "\n\tid=%-d label=%-d type=%-s subtype=%-s conn=%-s subscr='%-s'\n", - u->id, u->label, typ, styp, conn, u->smt ); + ITRACE_("\n\tid=%-d label=%-d type=%-s subtype=%-s conn=%-s subscr='%-s'\n", + u->id, u->label, typ, styp, conn, u->smt); - ITRACE_( "\tBracket1 coords: %-f, %-f, %-f, %-f\n", u->xbr1[0], u->xbr1[1], u->xbr1[2], u->xbr1[3] ); - ITRACE_( "\tBracket2 coords: %-f, %-f, %-f, %-f\n", u->xbr2[0], u->xbr2[1], u->xbr2[2], u->xbr2[3] ); + ITRACE_("\tBracket1 coords: %-f, %-f, %-f, %-f\n", u->xbr1[0], u->xbr1[1], u->xbr1[2], u->xbr1[3]); + ITRACE_("\tBracket2 coords: %-f, %-f, %-f, %-f\n", u->xbr2[0], u->xbr2[1], u->xbr2[2], u->xbr2[3]); na = u->na; - ITRACE_( "\t%-d atoms { ", na ); - for (k = 0; k < na - 1; k++) + ITRACE_("\t%-d atoms { ", na); + for ( k = 0; k < na - 1; k++ ) { - ITRACE_( " %-d, ", u->alist[k] ); + ITRACE_(" %-d, ", u->alist[k]); } - ITRACE_( " %-d }\n", u->alist[na - 1] ); + ITRACE_(" %-d }\n", u->alist[na - 1]); nb = u->nb; - ITRACE_( "\t%-d bonds crossing unit borders { ", nb ); + ITRACE_("\t%-d bonds crossing unit borders { ", nb); - for (k = 0; k < nb; k++) + for ( k = 0; k < nb; k++ ) { - ITRACE_( " %-d-%-d ", u->blist[2 * k], u->blist[2 * k + 1] ); + ITRACE_(" %-d-%-d ", u->blist[2 * k], u->blist[2 * k + 1]); } - ITRACE_( "}\n" ); + ITRACE_("}\n"); - ITRACE_( "\tCRU caps and end atoms { " ); + ITRACE_("\tCRU caps and end atoms { "); - ITRACE_( "*%-d-[-%-d(end1) ... ", u->cap1, u->end_atom1 ); - ITRACE_( "%-d(end2)-]-*%-d", u->end_atom2, u->cap2 ); - ITRACE_( " }\n" ); + ITRACE_("*%-d-[-%-d(end1) ... ", u->cap1, u->end_atom1); + ITRACE_("%-d(end2)-]-*%-d", u->end_atom2, u->cap2); + ITRACE_(" }\n"); - ITRACE_( "\tBackbone bonds (may include 'artificially cyclizing' one) : %-d bonds ", u->nbkbonds ); - if (u->nbkbonds) + ITRACE_("\tBackbone bonds (may include 'artificially cyclizing' one) : %-d bonds ", u->nbkbonds); + if ( u->nbkbonds ) { ITRACE_(" { "); - for (i = 0; i < u->nbkbonds; i++) + for ( i = 0; i < u->nbkbonds; i++ ) { - ITRACE_( "(%-d, %-d) ", u->bkbonds[i][0], u->bkbonds[i][1] ); + ITRACE_("(%-d, %-d) ", u->bkbonds[i][0], u->bkbonds[i][1]); } ITRACE_("}\n"); } } - + return; } @@ -3752,114 +3762,114 @@ void OAD_PolymerUnit_DebugTrace( OAD_PolymerUnit *u ) /**************************************************************************** Debug print the whole polymer data ****************************************************************************/ -void OAD_Polymer_DebugTrace( OAD_Polymer *p ) +void OAD_Polymer_DebugTrace(OAD_Polymer* p) { int i; - if (!p) + if ( !p ) { return; } - ITRACE_( "\n\n* POLYMER INFO @ %-p (%-d group(s))", p, p->n ); - ITRACE_( "\n\n* %-d star atoms: ", p->n_pzz ); - for (i = 0; i < p->n_pzz; i++) + ITRACE_("\n\n* POLYMER INFO @ %-p (%-d group(s))", p, p->n); + ITRACE_("\n\n* %-d star atoms: ", p->n_pzz); + for ( i = 0; i < p->n_pzz; i++ ) { - ITRACE_( " %-d", p->pzz[i] ); + ITRACE_(" %-d", p->pzz[i]); } - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { - ITRACE_( "\n* Polymer unit %-d", i ); - OAD_PolymerUnit_DebugTrace( p->units[i] ); + ITRACE_("\n* Polymer unit %-d", i); + OAD_PolymerUnit_DebugTrace(p->units[i]); } - ITRACE_( "\n* Really-do-PS = %-d", p->really_do_frame_shift ); - ITRACE_( "\n* Frame_shift_scheme = %-d", p->frame_shift_scheme ); - ITRACE_( "\n* Edit-repeats = %-d", p->edit_repeats ); - ITRACE_( "\n* End POLYMER INFO\n" ); + ITRACE_("\n* Really-do-PS = %-d", p->really_do_frame_shift); + ITRACE_("\n* Frame_shift_scheme = %-d", p->frame_shift_scheme); + ITRACE_("\n* Edit-repeats = %-d", p->edit_repeats); + ITRACE_("\n* End POLYMER INFO\n"); return; } /****************************************************************************/ -int OAD_Polymer_GetRepresentation( OAD_Polymer *p ) +int OAD_Polymer_GetRepresentation(OAD_Polymer* p) { int i, n_source_based_units = 0, n_structure_based_units = 0; - if (!p) + if ( !p ) { return NO_POLYMER; } - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { - if (p->units[i]->nb == 2 || p->units[i]->nbkbonds > 0 || - ( ( p->units[i]->cap1 > 0 ) && ( p->units[i]->cap2 > 0 ) )) + if ( p->units[i]->nb == 2 || p->units[i]->nbkbonds > 0 || + ((p->units[i]->cap1 > 0) && (p->units[i]->cap2 > 0)) ) { p->units[i]->representation = POLYMER_REPRESENTATION_STRUCTURE_BASED; n_structure_based_units++; } - else if (p->units[i]->nb == 0) + else if ( p->units[i]->nb == 0 ) { p->units[i]->representation = POLYMER_REPRESENTATION_SOURCE_BASED; n_source_based_units++; } } - if (p->n == n_source_based_units) + if ( p->n == n_source_based_units ) { return POLYMER_REPRESENTATION_SOURCE_BASED; } - else if (p->n == n_structure_based_units) + else if ( p->n == n_structure_based_units ) { return POLYMER_REPRESENTATION_STRUCTURE_BASED; } - else if (n_source_based_units && - n_structure_based_units && - ( n_source_based_units + n_structure_based_units ) == p->n) + else if ( n_source_based_units && + n_structure_based_units && + (n_source_based_units + n_structure_based_units) == p->n ) { /* TODO: check if SRU/MON are embedded in a single COP (is this check really necessary? ??) */ return POLYMER_REPRESENTATION_MIXED; } #if 0 - else if (p->n == ( n_source_based_units + n_structure_based_units )) + else if ( p->n == (n_source_based_units + n_structure_based_units) ) { /* Structure based presentation may include no-crossing bond units which only serve as embedding for ( >1 ) structure-based SRU's. The code below accounts for this. */ - if (n_source_based_units < n_structure_based_units) + if ( n_source_based_units < n_structure_based_units ) { int j, atom, atom_is_shared_with_struct_based_unit = 0; - for (i = 0; i < p->n; i++) + for ( i = 0; i < p->n; i++ ) { int k; - if (p->units[i]->representation != POLYMER_REPRESENTATION_SOURCE_BASED) + if ( p->units[i]->representation != POLYMER_REPRESENTATION_SOURCE_BASED ) continue; - for (k = 0; k < p->units[i]->na; k++) + for ( k = 0; k < p->units[i]->na; k++ ) { atom = p->units[i]->alist[k]; - if (is_in_the_ilist( p->pzz, atom, p->n_pzz )) + if ( is_in_the_ilist(p->pzz, atom, p->n_pzz) ) continue; atom_is_shared_with_struct_based_unit = 0; - for (j = 0; j < p->n; j++) + for ( j = 0; j < p->n; j++ ) { - if (p->units[j]->representation != POLYMER_REPRESENTATION_STRUCTURE_BASED) + if ( p->units[j]->representation != POLYMER_REPRESENTATION_STRUCTURE_BASED ) continue; - if (is_in_the_ilist( p->units[j]->alist, atom, p->units[j]->na )) + if ( is_in_the_ilist(p->units[j]->alist, atom, p->units[j]->na) ) { atom_is_shared_with_struct_based_unit = 1; break; } } - if (!atom_is_shared_with_struct_based_unit) + if ( !atom_is_shared_with_struct_based_unit ) break; } - if (!atom_is_shared_with_struct_based_unit) + if ( !atom_is_shared_with_struct_based_unit ) break; } - if (atom_is_shared_with_struct_based_unit) + if ( atom_is_shared_with_struct_based_unit ) return POLYMER_REPRESENTATION_STRUCTURE_BASED; } return POLYMER_REPRESENTATION_MIXED; @@ -3873,33 +3883,33 @@ int OAD_Polymer_GetRepresentation( OAD_Polymer *p ) /**************************************************************************** Open pre-cyclized CRUs appropriately (i.e., make frame shift) ****************************************************************************/ -void OAD_Polymer_SmartReopenCyclizedUnits( OAD_Polymer *p, - inp_ATOM *at, - int nat, - int *num_inp_bonds ) +void OAD_Polymer_SmartReopenCyclizedUnits(OAD_Polymer* p, + inp_ATOM* at, + int nat, + int* num_inp_bonds) { int i; /* djb-rwth: fixing oss-fuzz issue #68329 */ - OAD_AtProps *aprops = (OAD_AtProps*)inchi_calloc((long long)nat + 1, sizeof(OAD_AtProps)); /* djb-rwth: cast operator added */ + OAD_AtProps* aprops = (OAD_AtProps*)inchi_calloc((long long)nat + 1, sizeof(OAD_AtProps)); /* djb-rwth: cast operator added */ /* nat + 1: add extra element for possibe 1-based indexing */ - if (!p) + if ( !p ) { inchi_free(aprops); /* djb-rwth: avoiding memory leak */ return; } - if (p->n < 1) + if ( p->n < 1 ) { inchi_free(aprops); /* djb-rwth: avoiding memory leak */ return; } - if (!p->really_do_frame_shift) + if ( !p->really_do_frame_shift ) { inchi_free(aprops); /* djb-rwth: avoiding memory leak */ return; } /* djb-rwth: fixing oss-fuzz issue #68329 */ - if (nat <= 0) + if ( nat <= 0 ) { inchi_free(aprops); /* djb-rwth: avoiding memory leak */ return; @@ -3909,29 +3919,29 @@ void OAD_Polymer_SmartReopenCyclizedUnits( OAD_Polymer *p, OAD_Polymer_DebugTrace( p );*/ /* Set atom properties for sorting */ - if (!aprops || !at) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ + if ( !aprops || !at ) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ { inchi_free(aprops); /* djb-rwth: avoiding memory leak */ return; } - OAD_Polymer_SetAtProps( p, at, nat, num_inp_bonds, aprops, NULL ); /* NULL as we alredy are in 1-based cano_nums while at i2s/i2i*/ - for (i = 0; i < p->n; i++) + OAD_Polymer_SetAtProps(p, at, nat, num_inp_bonds, aprops, NULL); /* NULL as we alredy are in 1-based cano_nums while at i2s/i2i*/ + for ( i = 0; i < p->n; i++ ) { - if (p->units[i]) /* djb-rwth: fixing oss-fuzz issue #68329 */ + if ( p->units[i] ) /* djb-rwth: fixing oss-fuzz issue #68329 */ { - OAD_PolymerUnit *u = p->units[i]; - if (p->frame_shift_scheme == FSS_NONE) + OAD_PolymerUnit* u = p->units[i]; + if ( p->frame_shift_scheme == FSS_NONE ) { continue; } if ( /* !u->cyclizable || u->cyclized || */ u->nbkbonds < 1 || u->cap1 < 1 || u->cap2 < 1 || - u->cap1 > nat || u->cap2 > nat) + u->cap1 > nat || u->cap2 > nat ) { continue; } - if (OAD_PolymerUnit_SetReopeningDetails(u, at)) + if ( OAD_PolymerUnit_SetReopeningDetails(u, at) ) { int senior_bond; OAD_PolymerUnit_SortBackboneBondsAndSetSeniors(u, at, aprops, &senior_bond); @@ -3941,53 +3951,53 @@ void OAD_Polymer_SmartReopenCyclizedUnits( OAD_Polymer *p, } p->really_do_frame_shift = 0; - inchi_free( aprops ); + inchi_free(aprops); return; } /****************************************************************************/ -void OAD_PolymerUnit_ReopenCyclized( OAD_PolymerUnit *u, - inp_ATOM *at, - OAD_AtProps *aprops, - int nat, - int *num_inp_bonds ) +void OAD_PolymerUnit_ReopenCyclized(OAD_PolymerUnit* u, + inp_ATOM* at, + OAD_AtProps* aprops, + int nat, + int* num_inp_bonds) { int bond_type, bond_stereo; - if (u->cyclizable == CLOSING_SRU_RING) + if ( u->cyclizable == CLOSING_SRU_RING ) { /* Decyclize artificially introduced bond */ - OrigAtData_RemoveBond( u->end_atom1 - 1, u->end_atom2 - 1, - at, &bond_type, &bond_stereo, num_inp_bonds ); + OrigAtData_RemoveBond(u->end_atom1 - 1, u->end_atom2 - 1, + at, &bond_type, &bond_stereo, num_inp_bonds); } - else if (u->cyclizable == CLOSING_SRU_HIGHER_ORDER_BOND) + else if ( u->cyclizable == CLOSING_SRU_HIGHER_ORDER_BOND ) { - OrigAtData_DecreaseBondOrder( u->end_atom1 - 1, u->end_atom2 - 1, at ); + OrigAtData_DecreaseBondOrder(u->end_atom1 - 1, u->end_atom2 - 1, at); } - else if (u->cyclizable == CLOSING_SRU_DIRADICAL) + else if ( u->cyclizable == CLOSING_SRU_DIRADICAL ) { - if (at[u->end_atom1 - 1].radical == RADICAL_TRIPLET) + if ( at[u->end_atom1 - 1].radical == RADICAL_TRIPLET ) { at[u->end_atom1 - 1].radical = 0; } } /* Add explicitly connections to star atoms */ - OrigAtData_AddSingleStereolessBond( u->cap1 - 1, u->end_atom1 - 1, - at, num_inp_bonds ); - OrigAtData_AddSingleStereolessBond( u->cap2 - 1, u->end_atom2 - 1, - at, num_inp_bonds ); + OrigAtData_AddSingleStereolessBond(u->cap1 - 1, u->end_atom1 - 1, + at, num_inp_bonds); + OrigAtData_AddSingleStereolessBond(u->cap2 - 1, u->end_atom2 - 1, + at, num_inp_bonds); /* Create crossing bonds */ u->nb = 2; u->nbkbonds = 0; - if (!u->blist) + if ( !u->blist ) { - u->blist = (int *) inchi_calloc( 2 * (long long)u->nb, sizeof( int ) ); /* djb-rwth: cast operator added */ + u->blist = (int*)inchi_calloc(2 * (long long)u->nb, sizeof(int)); /* djb-rwth: cast operator added */ } - if (!u->blist) + if ( !u->blist ) { return; } @@ -4002,23 +4012,23 @@ void OAD_PolymerUnit_ReopenCyclized( OAD_PolymerUnit *u, /****************************************************************************/ -int OAD_PolymerUnit_SetReopeningDetails( OAD_PolymerUnit *u, inp_ATOM *at ) +int OAD_PolymerUnit_SetReopeningDetails(OAD_PolymerUnit* u, inp_ATOM* at) { int k; /* Check reopening type */ /* Caps are separated by one atom - that's not error but do nothing */ - if (u->nbkbonds == 0) + if ( u->nbkbonds == 0 ) { ; } - else if (u->nbkbonds == 1) + else if ( u->nbkbonds == 1 ) { u->end_atom1 = u->bkbonds[0][0]; u->end_atom2 = u->bkbonds[0][1]; - if (u->end_atom1 == u->end_atom2) + if ( u->end_atom1 == u->end_atom2 ) { #ifdef ALLOW_CLOSING_SRU_VIA_DIRADICAL u->cyclizable = CLOSING_SRU_DIRADICAL; @@ -4029,17 +4039,17 @@ int OAD_PolymerUnit_SetReopeningDetails( OAD_PolymerUnit *u, inp_ATOM *at ) else { /* If caps are separated by two atoms - that's not error but do nothing */ - for (k = 0; k < at[u->end_atom1 - 1].valence; k++) + for ( k = 0; k < at[u->end_atom1 - 1].valence; k++ ) { - if (at[u->end_atom1 - 1].neighbor[k] == u->end_atom2 - 1) + if ( at[u->end_atom1 - 1].neighbor[k] == u->end_atom2 - 1 ) { - if (at[u->end_atom1 - 1].bond_type[k] > 1) + if ( at[u->end_atom1 - 1].bond_type[k] > 1 ) #ifdef ALLOW_CLOSING_SRU_VIA_HIGHER_ORDER_BOND u->cyclizable = CLOSING_SRU_HIGHER_ORDER_BOND; #else -/* u->cyclizable = CLOSING_SRU_NOT_APPLICABLE;*/ + /* u->cyclizable = CLOSING_SRU_NOT_APPLICABLE;*/ #endif -break; + break; } } } @@ -4051,33 +4061,33 @@ break; /****************************************************************************/ -void OAD_PolymerUnit_SortBackboneBondsAndSetSeniors( OAD_PolymerUnit *u, - inp_ATOM *at, - OAD_AtProps *aprops, - int *senior_bond ) +void OAD_PolymerUnit_SortBackboneBondsAndSetSeniors(OAD_PolymerUnit* u, + inp_ATOM* at, + OAD_AtProps* aprops, + int* senior_bond) { - int j, *bnum = NULL; + int j, * bnum = NULL; *senior_bond = 0; /* Sort backbone (== frame shiftable) bonds if necessary */ - if (u->nbkbonds > 1) + if ( u->nbkbonds > 1 ) { - bnum = (int *) inchi_calloc( u->nbkbonds, sizeof( int ) ); - if (bnum) + bnum = (int*)inchi_calloc(u->nbkbonds, sizeof(int)); + if ( bnum ) { - for (j = 0; j < u->nbkbonds; j++) + for ( j = 0; j < u->nbkbonds; j++ ) { bnum[j] = j; } - OAD_PolymerUnit_SortBackboneBonds( u, aprops, bnum ); + OAD_PolymerUnit_SortBackboneBonds(u, aprops, bnum); *senior_bond = bnum[0]; - inchi_free( bnum ); + inchi_free(bnum); } } /* v. 1.05+ : place senior atom the first ("left") in the senior bond */ - if (OAD_Polymer_IsFirstAtomRankLower( u->bkbonds[*senior_bond][0], u->bkbonds[*senior_bond][1], aprops ) == 1) + if ( OAD_Polymer_IsFirstAtomRankLower(u->bkbonds[*senior_bond][0], u->bkbonds[*senior_bond][1], aprops) == 1 ) { int tmp = u->bkbonds[*senior_bond][0]; u->bkbonds[*senior_bond][0] = u->bkbonds[*senior_bond][1]; @@ -4092,21 +4102,21 @@ void OAD_PolymerUnit_SortBackboneBondsAndSetSeniors( OAD_PolymerUnit *u, /****************************************************************************/ -void OAD_PolymerUnit_SortBackboneBonds( OAD_PolymerUnit *u, - OAD_AtProps *aprops, - int *bnum ) +void OAD_PolymerUnit_SortBackboneBonds(OAD_PolymerUnit* u, + OAD_AtProps* aprops, + int* bnum) { int i, j, tmp; int n = u->nbkbonds; - if (NULL == bnum) + if ( NULL == bnum ) { return; } - for (i = 1; i < n; i++) + for ( i = 1; i < n; i++ ) { tmp = bnum[i]; j = i - 1; - while (j >= 0 && OAD_Polymer_CompareBackboneBondsSeniority( u->bkbonds[bnum[j]], u->bkbonds[tmp], aprops ) > 0) + while ( j >= 0 && OAD_Polymer_CompareBackboneBondsSeniority(u->bkbonds[bnum[j]], u->bkbonds[tmp], aprops) > 0 ) { bnum[j + 1] = bnum[j]; j--; @@ -4123,20 +4133,20 @@ void OAD_PolymerUnit_SortBackboneBonds( OAD_PolymerUnit *u, In general: favor greater max-rank end if max ends are the same, favor lesser min-rank end ****************************************************************************/ -int OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *aprops ) +int OAD_Polymer_CompareBackboneBondsSeniority(int* b1, int* b2, OAD_AtProps* aprops) { int b1min, b1max, b2min, b2max, tmp, cmp = 0; /* Find min and max ext-ranked ends of the both bonds */ b1max = b1[0]; b1min = b1[1]; b2max = b2[0]; b2min = b2[1]; - if (OAD_Polymer_IsFirstAtomRankLower( b1min, b1max, aprops ) == -1) + if ( OAD_Polymer_IsFirstAtomRankLower(b1min, b1max, aprops) == -1 ) { tmp = b1max; b1max = b1min; b1min = tmp; } - if (OAD_Polymer_IsFirstAtomRankLower( b2min, b2max, aprops ) == -1) + if ( OAD_Polymer_IsFirstAtomRankLower(b2min, b2max, aprops) == -1 ) { tmp = b2max; b2max = b2min; @@ -4148,12 +4158,12 @@ int OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *a /* First, favor the bond which has greater ext-rank end NB: the result may be 0, that is, equal max ext. ranks */ - cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1max, b2max, aprops ); - if (cmp == 1) + cmp = OAD_Polymer_CompareRanksOfTwoAtoms(b1max, b2max, aprops); + if ( cmp == 1 ) { return 1; /* rank(b1max) < rank(b2max), so bond2 is senior */ } - else if (cmp == -1) + else if ( cmp == -1 ) { return -1; /* rank(b1max) > rank(b2max), so bond1 is senior */ } @@ -4161,13 +4171,13 @@ int OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *a /* Max ends are of the same rank, so favor the bond with lesser min-rank end NB: the result may NOT be 0, that is, the case is always resolved */ - cmp = OAD_Polymer_CompareRanksOfTwoAtoms( b1min, b2min, aprops ); /*OAD_Polymer_IsFirstAtomRankLower( b1min, b2min, aprops );*/ + cmp = OAD_Polymer_CompareRanksOfTwoAtoms(b1min, b2min, aprops); /*OAD_Polymer_IsFirstAtomRankLower( b1min, b2min, aprops );*/ - if (cmp == 1) + if ( cmp == 1 ) { return -1; /* rank(b1min) < rank(b2min), so bond1 is senior */ } - else if (cmp == -1) + else if ( cmp == -1 ) { return 1; /* rank(b1min) > rank(b2min), so bond2 is senior */ } @@ -4175,22 +4185,22 @@ int OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *a /* Min ends are of the same rank. Here is the time to compare directly which canonical number is larger of max-ends ... */ - if (b1max < b2max) + if ( b1max < b2max ) { return 1; } - if (b1max > b2max) + if ( b1max > b2max ) { return -1; } /* ... they are the same, so compare which canonical number is larger for min-ends ... */ - if (b1min < b2min) + if ( b1min < b2min ) { return -1; /* b1min < b2min, so bond1 is senior */ } - if (b1min > b2min) + if ( b1min > b2min ) { return 1; /* b1min > b2min, so bond2 is senior */ } @@ -4204,10 +4214,10 @@ int OAD_Polymer_CompareBackboneBondsSeniority( int* b1, int* b2, OAD_AtProps *a loosely following IUPAC guidelines. NB: no last resort check here, so 0 (=='same seniority') may be returned ****************************************************************************/ -int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprops ) +int OAD_Polymer_CompareRanksOfTwoAtoms(int atom1, int atom2, OAD_AtProps* aprops) { const int HETEROCYC = 3, HETEROAT = 2, CARBOCYC = 1, CARBOAT = 0; - /* NB: Carbon's rank is always 2, next to the lowest */ + /* NB: Carbon's rank is always 2, next to the lowest */ int a1 = atom1 - 1; int a2 = atom2 - 1; @@ -4215,14 +4225,14 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop int a2typ = CARBOAT; /* djb-rwth: fixing oss-fuzz issue #69501, #68277 */ - if ((a1 < 0) || (a2 < 0)) + if ( (a1 < 0) || (a2 < 0) ) { return 0; } - if (aprops[a1].ring_size > 2) + if ( aprops[a1].ring_size > 2 ) { - if (aprops[a1].ring_erank <= 2) + if ( aprops[a1].ring_erank <= 2 ) { a1typ = CARBOCYC; } @@ -4233,7 +4243,7 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop } else { - if (aprops[a1].erank == 2) + if ( aprops[a1].erank == 2 ) { a1typ = CARBOAT; } @@ -4243,9 +4253,9 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop } } - if (aprops[a2].ring_size > 2) + if ( aprops[a2].ring_size > 2 ) { - if (aprops[a2].ring_erank <= 2) + if ( aprops[a2].ring_erank <= 2 ) { a2typ = CARBOCYC; } @@ -4256,7 +4266,7 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop } else { - if (aprops[a2].erank == 2) + if ( aprops[a2].erank == 2 ) { a2typ = CARBOAT; } @@ -4275,82 +4285,82 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop > carbocyclic rings and ring systems > acyclic carbon chains' */ - if (a1typ == HETEROCYC && a2typ == HETEROCYC) /* a1 and a2 are HETEROCYC */ + if ( a1typ == HETEROCYC && a2typ == HETEROCYC ) /* a1 and a2 are HETEROCYC */ { /* Try resolving by senior-heteroatom ring */ - if (aprops[a1].ring_erank < aprops[a2].ring_erank) + if ( aprops[a1].ring_erank < aprops[a2].ring_erank ) { return 1; } - if (aprops[a1].ring_erank > aprops[a2].ring_erank) + if ( aprops[a1].ring_erank > aprops[a2].ring_erank ) { return -1; } /* Same senior-heteroatom rings, try resolving by total ring size */ - if (aprops[a1].ring_size < aprops[a2].ring_size) + if ( aprops[a1].ring_size < aprops[a2].ring_size ) { return 1; } - if (aprops[a1].ring_size > aprops[a2].ring_size) + if ( aprops[a1].ring_size > aprops[a2].ring_size ) { return -1; } /* Could not resolve... */ return 0; } - else if (a1typ == HETEROCYC) + else if ( a1typ == HETEROCYC ) { return -1; /* a1 is HETEROCYC, a2 is any other (==junior) */ } - else if (a2typ == HETEROCYC) + else if ( a2typ == HETEROCYC ) { return 1; /* a2 is HETEROCYC, a1 is any other (==junior) */ } /* HETEROCYC left out */ - if (a1typ == HETEROAT && a2typ == HETEROAT) /* a1 and a2 are HETEROAT */ + if ( a1typ == HETEROAT && a2typ == HETEROAT ) /* a1 and a2 are HETEROAT */ { - if (aprops[a1].erank < aprops[a2].erank) + if ( aprops[a1].erank < aprops[a2].erank ) { return 1; } - if (aprops[a1].erank > aprops[a2].erank) + if ( aprops[a1].erank > aprops[a2].erank ) { return -1; } /* Could not resolve... */ return 0; } - else if (a1typ == HETEROAT) + else if ( a1typ == HETEROAT ) { return -1; /* a1 is HETEROAT, a2 is any other (==junior) */ } - else if (a2typ == HETEROAT) + else if ( a2typ == HETEROAT ) { return 1; /* a2 is HETEROAT, a1 is any other (==junior) */ } /* HETEROAT left out */ - if (a1typ == CARBOCYC && a2typ == CARBOCYC) /* a1 and a2 are CARBOCYC */ + if ( a1typ == CARBOCYC && a2typ == CARBOCYC ) /* a1 and a2 are CARBOCYC */ { /* Same senior-atom (C) ring, try resolving by total ring size */ - if (aprops[a1].ring_size < aprops[a2].ring_size) + if ( aprops[a1].ring_size < aprops[a2].ring_size ) { return 1; } - if (aprops[a1].ring_size > aprops[a2].ring_size) + if ( aprops[a1].ring_size > aprops[a2].ring_size ) { return -1; } /* Could not resolve... */ return 0; } - else if (a1typ == CARBOCYC) + else if ( a1typ == CARBOCYC ) { return -1; } - else if (a2typ == CARBOCYC) + else if ( a2typ == CARBOCYC ) { return 1; } @@ -4364,23 +4374,23 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop loosely following IUPAC guidelines. Always return non-zero result, that is, resolve the case. ****************************************************************************/ -int OAD_Polymer_IsFirstAtomRankLower( int atom1, int atom2, OAD_AtProps *aprops ) +int OAD_Polymer_IsFirstAtomRankLower(int atom1, int atom2, OAD_AtProps* aprops) { /* Compare ext-ranks */ - int result = OAD_Polymer_CompareRanksOfTwoAtoms( atom1, atom2, aprops ); + int result = OAD_Polymer_CompareRanksOfTwoAtoms(atom1, atom2, aprops); - if (result) + if ( result ) { return result; } /* Could not resolve who is junior by extended-ranks... */ /* As a last resort, simply check which canonical number is lesser */ - if (atom1 < atom2) + if ( atom1 < atom2 ) { return 1; } - if (atom1 > atom2) + if ( atom1 > atom2 ) { return -1; } @@ -4391,52 +4401,52 @@ int OAD_Polymer_IsFirstAtomRankLower( int atom1, int atom2, OAD_AtProps *aprops /****************************************************************************/ -void OAD_ValidateAndSortOutPseudoElementAtoms( ORIG_ATOM_DATA *orig_at_data, - int treat_polymers, - int bNPZz, - int *err, - char *pStrErr ) +void OAD_ValidateAndSortOutPseudoElementAtoms(ORIG_ATOM_DATA* orig_at_data, + int treat_polymers, + int bNPZz, + int* err, + char* pStrErr) { int i, k, n_pseudo = 0; int nsgroups = 0, nzz = 0; int nat = orig_at_data->num_inp_atoms; - OAD_Polymer *pd = orig_at_data->polymer; + OAD_Polymer* pd = orig_at_data->polymer; OAD_PolymerUnit* u = NULL; int pseudos_allowed = (bNPZz == 1) || (treat_polymers != POLYMERS_NO); - for (k = 0; k < nat; k++) + for ( k = 0; k < nat; k++ ) { - int is_zz = 0, is_star = 0, is_zy=0; + int is_zz = 0, is_star = 0, is_zy = 0; /* Though "Zy" is present in our internal Periodic Table, _input_ "Zy" atoms are prohibited. */ - if (!strcmp( orig_at_data->at[k].elname, "Zy" )) + if ( !strcmp(orig_at_data->at[k].elname, "Zy") ) { is_zy = 1; #if 0 - Disabled 2020-04-07 - TREAT_ERR(*err, (70 + 5), "Invalid element(s):"); + Disabled 2020 - 04 - 07 + TREAT_ERR(*err, (70 + 5), "Invalid element(s):"); TREAT_ERR(*err, (70 + 5), orig_at_data->at[k].elname); continue; #endif } - is_star = !strcmp( orig_at_data->at[k].elname, "*" ); - if (!is_star) + is_star = !strcmp(orig_at_data->at[k].elname, "*"); + if ( !is_star ) { - is_zz = !strcmp( orig_at_data->at[k].elname, "Zz" ); + is_zz = !strcmp(orig_at_data->at[k].elname, "Zz"); } - if (is_star || is_zz || is_zy) + if ( is_star || is_zz || is_zy ) { n_pseudo++; - if (0==pseudos_allowed) + if ( 0 == pseudos_allowed ) { /* That's an error */ - TREAT_ERR( *err, ( 70 + 5 ), "Invalid element(s):" ); - TREAT_ERR( *err, ( 70 + 5 ), orig_at_data->at[k].elname ); + TREAT_ERR(*err, (70 + 5), "Invalid element(s):"); + TREAT_ERR(*err, (70 + 5), orig_at_data->at[k].elname); continue; } @@ -4444,39 +4454,39 @@ void OAD_ValidateAndSortOutPseudoElementAtoms( ORIG_ATOM_DATA *orig_at_data, /* Should be strictly univalent and single-bonded */ /* Should not have isotopic enrichment */ - if ( orig_at_data->at[k].valence > 1 || - orig_at_data->at[k].chem_bonds_valence>1 /* || orig_at_data->at[k].iso_atw_diff != 0 */ - ) + if ( orig_at_data->at[k].valence > 1 || + orig_at_data->at[k].chem_bonds_valence > 1 /* || orig_at_data->at[k].iso_atw_diff != 0 */ + ) { - TREAT_ERR( *err, ( 70 + 7 ), "Invalid pseudo element(s) bonding" ); + TREAT_ERR(*err, (70 + 7), "Invalid pseudo element(s) bonding"); /*TREAT_ERR( *err, ( 70 + 7 ), orig_at_data->at[k].elname );*/ continue; } /* Now convert both "*" and "Zz" temporarily to "Zy" */ - mystrncpy( orig_at_data->at[k].elname, "Zy", sizeof( "Zy" ) ); + mystrncpy(orig_at_data->at[k].elname, "Zy", sizeof("Zy")); } } orig_at_data->n_zy = 0; nzz = 0; - if (orig_at_data->valid_polymer) + if ( orig_at_data->valid_polymer ) { nsgroups = pd->n; /* If applicable, check each CRU and back-convert "Zy" to "Zz" (polymer-related pseudoelement atoms) if they are from valid paired CRU crossing bond out-of-bracket caps */ - for (i = 0; i < nsgroups; i++) + for ( i = 0; i < nsgroups; i++ ) { u = pd->units[i]; - if (u) + if ( u ) { - if (u->cap1_is_undef && u->cap2_is_undef) + if ( u->cap1_is_undef && u->cap2_is_undef ) { /* valid pair: CRU is capped with two undefined-nature atoms, call them "Zz", finally */ - strcpy( orig_at_data->at[u->cap1 - 1].elname, "Zz" ); - strcpy( orig_at_data->at[u->cap2 - 1].elname, "Zz" ); - nzz+= 2; + strcpy(orig_at_data->at[u->cap1 - 1].elname, "Zz"); + strcpy(orig_at_data->at[u->cap2 - 1].elname, "Zz"); + nzz += 2; } } } @@ -4484,16 +4494,16 @@ void OAD_ValidateAndSortOutPseudoElementAtoms( ORIG_ATOM_DATA *orig_at_data, } orig_at_data->n_zy = n_pseudo - nzz; - if (orig_at_data->n_zy) + if ( orig_at_data->n_zy ) { /* Have non-polymer-related pseudoelement atoms */ - if (0==bNPZz) + if ( 0 == bNPZz ) { - TREAT_ERR( *err, ( 70 + 4 ), "Polymer-unrelated pseudoatoms are not allowed" ); + TREAT_ERR(*err, (70 + 4), "Polymer-unrelated pseudoatoms are not allowed"); } } - if (*err) + if ( *err ) { orig_at_data->valid_polymer = 0; } @@ -4502,15 +4512,15 @@ void OAD_ValidateAndSortOutPseudoElementAtoms( ORIG_ATOM_DATA *orig_at_data, /****************************************************************************/ -int Inp_Atom_GetBondType(inp_ATOM *at, int iatom1, int iatom2) +int Inp_Atom_GetBondType(inp_ATOM* at, int iatom1, int iatom2) { int i; - for (i = 0; i < at[iatom1].valence; i++) + for ( i = 0; i < at[iatom1].valence; i++ ) { - if (at[iatom1].neighbor[i] == iatom2) + if ( at[iatom1].neighbor[i] == iatom2 ) { - return at[iatom1].bond_type[i]; + return at[iatom1].bond_type[i]; } } diff --git a/INCHI-1-SRC/INCHI_BASE/src/strutil.c b/INCHI-1-SRC/INCHI_BASE/src/strutil.c index 89f8d7d1..e0f915cf 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/strutil.c +++ b/INCHI-1-SRC/INCHI_BASE/src/strutil.c @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. -* -* The InChI library and programs are free software developed under the + * + * The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,19 +36,21 @@ * * info@inchi-trust.org * -*/ + */ #include #include #include #include +#include #include "mode.h" - +#include "ichinorm.h" /* @nnuk */ #include "strutil.h" #include "ichister.h" #include "ichi_io.h" #include "ichimain.h" +#include "ichidrp.h" /* @nnuk */ #include "bcf_s.h" @@ -57,12 +59,13 @@ #ifndef COMPILE_ALL_CPP #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #endif /* Defined in ichisort.c, prototype in ichicomn.h */ -int insertions_sort_AT_RANK( AT_RANK *base, int num ); + int insertions_sort_AT_RANK(AT_RANK *base, int num); #ifndef COMPILE_ALL_CPP #ifdef __cplusplus @@ -70,116 +73,112 @@ int insertions_sort_AT_RANK( AT_RANK *base, int num ); #endif #endif - -typedef struct tagTreeAtom { - AT_NUMB neighbor[MAXVAL]; /* positions (from 0) of the neighbors in the inp_ATOM array */ - S_CHAR valence; /* number of bonds = number of neighbors */ - AT_NUMB nRingSystem; - AT_NUMB nBlockSystem; - S_CHAR bCutVertex; +typedef struct tagTreeAtom +{ + AT_NUMB neighbor[MAXVAL]; /* positions (from 0) of the neighbors in the inp_ATOM array */ + S_CHAR valence; /* number of bonds = number of neighbors */ + AT_NUMB nRingSystem; + AT_NUMB nBlockSystem; + S_CHAR bCutVertex; } tre_ATOM; - /* Local prototypes */ -int cmp_iso_atw_diff_component_no( const void *a1, const void *a2 ); -int cmp_components( const void *a1, const void *a2 ); +int cmp_iso_atw_diff_component_no(const void *a1, const void *a2); +int cmp_components(const void *a1, const void *a2); /* int mark_one_struct_component( inp_ATOM* at, int j, AT_NUMB *mark, AT_NUMB num_disconnected_components ); */ -INChI_Stereo *Alloc_INChI_Stereo( int num_at, int num_bonds ); -int RemoveInpAtBond( inp_ATOM *at, int iat, int k ); -int DisconnectInpAtBond( inp_ATOM *at, - AT_NUMB *nOldCompNumber, - int iat, - int neigh_ord ); -int move_explicit_Hcation( inp_ATOM *at, - int num_at, - int iat, - int iat_H, - int bInAllComponents ); -int DisconnectOneLigand( inp_ATOM *at, - AT_NUMB *nOldCompNumber, - S_CHAR *bMetal, - char *elnumber_Heteroat, - int num_halogens, - int num_atoms, - int iMetal, - int jLigand, - INCHI_MODE *bTautFlagsDone ); -int bIsAmmoniumSalt( inp_ATOM *at, - int i, - int *piO, - int *pk, - S_CHAR *num_explicit_H ); -int DisconnectAmmoniumSalt( inp_ATOM *at, - int i, - int iO, - int k, - S_CHAR *num_explicit_H ); +INChI_Stereo *Alloc_INChI_Stereo(int num_at, int num_bonds); +int RemoveInpAtBond(inp_ATOM *at, int iat, int k); +int DisconnectInpAtBond(inp_ATOM *at, + AT_NUMB *nOldCompNumber, + int iat, + int neigh_ord); +int move_explicit_Hcation(inp_ATOM *at, + int num_at, + int iat, + int iat_H, + int bInAllComponents); +int DisconnectOneLigand(inp_ATOM *at, + AT_NUMB *nOldCompNumber, + S_CHAR *bMetal, + char *elnumber_Heteroat, + int num_halogens, + int num_atoms, + int iMetal, + int jLigand, + INCHI_MODE *bTautFlagsDone); +int bIsAmmoniumSalt(inp_ATOM *at, + int i, + int *piO, + int *pk, + S_CHAR *num_explicit_H); +int DisconnectAmmoniumSalt(inp_ATOM *at, + int i, + int iO, + int k, + S_CHAR *num_explicit_H); /*int bIsMetalSalt( inp_ATOM *at, int i ); - moved to strutil,h */ -int DisconnectMetalSalt( inp_ATOM *at, int i ); -int bIsMetalToDisconnect( inp_ATOM *at, int i, int bCheckMetalValence ); -int get_iat_number( int el_number ); -int tot_unsat( int unsat[] ); -int max_unsat( int unsat[] ); -double dist3D( inp_ATOM *at1, inp_ATOM *at2 ); -double dist2D( inp_ATOM *at1, inp_ATOM *at2 ); -double dist_from_segm( double x, double y, - double x1, double y1, - double x2, double y2 ); -int segments_intersect( double x11, double y11, - double x12, double y12, /* segment #1 */ - double x21, double y21, - double x22, double y22 ); -double GetMinDistDistribution( inp_ATOM *at, - int num_at, - int iat, - int iat_H, - int bInAllComponents, - double min_dist[], - int num_segm ); -int nFindOneOM( inp_ATOM *at, - int at_no, - int ord_OM[], - int num_OM ); -int the_only_doublet_neigh( inp_ATOM *at, int i1, int *ineigh1, int *ineigh2 ); -int fix_non_uniform_drawn_oxoanions( int num_atoms, inp_ATOM *at, int *num_changes ); -int fix_non_uniform_drawn_amidiniums( int num_atoms, inp_ATOM *at, int *num_changes ); - - -void add_bond_if_unseen( subgraf_pathfinder *spf, - int node0, int node, - int *nbonds, int **bonds ); +int DisconnectMetalSalt(inp_ATOM *at, int i); +int bIsMetalToDisconnect(inp_ATOM *at, int i, int bCheckMetalValence); +int get_iat_number(int el_number); +int tot_unsat(int unsat[]); +int max_unsat(int unsat[]); +double dist3D(inp_ATOM *at1, inp_ATOM *at2); +double dist2D(inp_ATOM *at1, inp_ATOM *at2); +double dist_from_segm(double x, double y, + double x1, double y1, + double x2, double y2); +int segments_intersect(double x11, double y11, + double x12, double y12, /* segment #1 */ + double x21, double y21, + double x22, double y22); +double GetMinDistDistribution(inp_ATOM *at, + int num_at, + int iat, + int iat_H, + int bInAllComponents, + double min_dist[], + int num_segm); +int nFindOneOM(inp_ATOM *at, + int at_no, + int ord_OM[], + int num_OM); +int the_only_doublet_neigh(inp_ATOM *at, int i1, int *ineigh1, int *ineigh2); +int fix_non_uniform_drawn_oxoanions(int num_atoms, inp_ATOM *at, int *num_changes); +int fix_non_uniform_drawn_amidiniums(int num_atoms, inp_ATOM *at, int *num_changes); + +void add_bond_if_unseen(subgraf_pathfinder *spf, + int node0, int node, + int *nbonds, int **bonds); /****************************************************************************/ #ifndef NUMH -#define NUM_ISO_H(AT,N) (AT[N].num_iso_H[0]+AT[N].num_iso_H[1]+AT[N].num_iso_H[2]) -#define NUMH(AT,N) (AT[N].num_H+NUM_ISO_H(AT,N)) +#define NUM_ISO_H(AT, N) (AT[N].num_iso_H[0] + AT[N].num_iso_H[1] + AT[N].num_iso_H[2]) +#define NUMH(AT, N) (AT[N].num_H + NUM_ISO_H(AT, N)) #endif /****************************************************************************/ - /****************************************************************************/ -int cmp_iso_atw_diff_component_no( const void *a1, const void *a2 ) +int cmp_iso_atw_diff_component_no(const void *a1, const void *a2) { - int ret = (int) ( (const inp_ATOM*) a1 )->iso_atw_diff - (int) ( (const inp_ATOM*) a2 )->iso_atw_diff; + int ret = (int)((const inp_ATOM *)a1)->iso_atw_diff - (int)((const inp_ATOM *)a2)->iso_atw_diff; if (!ret) /* make the sort stable */ { - ret = (int) ( (const inp_ATOM*) a1 )->component - (int) ( (const inp_ATOM*) a2 )->component; + ret = (int)((const inp_ATOM *)a1)->component - (int)((const inp_ATOM *)a2)->component; } return ret; } - /****************************************************************************/ -int the_only_doublet_neigh( inp_ATOM *at, - int i1, - int *ineigh1, - int *ineigh2 ) +int the_only_doublet_neigh(inp_ATOM *at, + int i1, + int *ineigh1, + int *ineigh2) { int i, neigh1, num_rad1 = 0, num_rad2 = 0; @@ -190,7 +189,7 @@ int the_only_doublet_neigh( inp_ATOM *at, } for (i = 0; i < a->valence; i++) { - b = at + ( (int) a->neighbor[i] ); /* djb-rwth: removing redundant code */ + b = at + ((int)a->neighbor[i]); /* djb-rwth: removing redundant code */ if (RADICAL_DOUBLET == b->radical) { num_rad1++; @@ -200,10 +199,10 @@ int the_only_doublet_neigh( inp_ATOM *at, if (1 == num_rad1) { - a = at + ( neigh1 = (int) a->neighbor[*ineigh1] ); + a = at + (neigh1 = (int)a->neighbor[*ineigh1]); for (i = 0; i < a->valence; i++) { - b = at + (int) a->neighbor[i]; + b = at + (int)a->neighbor[i]; if (RADICAL_DOUBLET == b->radical) { num_rad2++; @@ -220,13 +219,12 @@ int the_only_doublet_neigh( inp_ATOM *at, return -1; } - /**************************************************************************** Correct non-uniformly drawn oxoanions ****************************************************************************/ -int fix_non_uniform_drawn_oxoanions( int num_atoms, - inp_ATOM *at, - int *num_changes ) +int fix_non_uniform_drawn_oxoanions(int num_atoms, + inp_ATOM *at, + int *num_changes) { /* For central halogen, apply the following correction rules: @@ -318,16 +316,25 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, */ - /* constants for element numbers */ enum elems { - dNone, dCl = 17, dBr = 35, dI = 53, dAt = 85, dO = 8, - dS = 16, dSe = 34, dTe = 52, dP = 15, dC = 6, dN = 7 + dNone, + dCl = 17, + dBr = 35, + dI = 53, + dAt = 85, + dO = 8, + dS = 16, + dSe = 34, + dTe = 52, + dP = 15, + dC = 6, + dN = 7 }; - static U_CHAR allowed_elnums_center_halogen[] = { dCl, dBr, dI, dAt }; - static U_CHAR allowed_elnums_center_halcogen[] = { dS, dSe, dTe }; + static U_CHAR allowed_elnums_center_halogen[] = {dCl, dBr, dI, dAt}; + static U_CHAR allowed_elnums_center_halcogen[] = {dS, dSe, dTe}; int en_center; int i, j, k; @@ -343,10 +350,10 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, } en_center = at[i].el_number; /* from eligible element list ... */ - if (!memchr( allowed_elnums_center_halogen, en_center, sizeof( allowed_elnums_center_halogen ) )) + if (!memchr(allowed_elnums_center_halogen, en_center, sizeof(allowed_elnums_center_halogen))) { /* central atom is not not halogen; check if it is halcogen */ - if (memchr( allowed_elnums_center_halcogen, en_center, sizeof( allowed_elnums_center_halcogen ) )) + if (memchr(allowed_elnums_center_halcogen, en_center, sizeof(allowed_elnums_center_halcogen))) { if (at[i].chem_bonds_valence < 7) { @@ -363,7 +370,7 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, /* OK, found central halogen or eligible central halcogen. */ /* non-radical... */ - if (at[i].radical && ( at[i].radical != RADICAL_SINGLET )) + if (at[i].radical && (at[i].radical != RADICAL_SINGLET)) { continue; } @@ -394,7 +401,7 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, continue; } /* non-radical */ - if (at[j].radical && ( at[j].radical != RADICAL_SINGLET )) + if (at[j].radical && (at[j].radical != RADICAL_SINGLET)) { continue; } @@ -402,17 +409,30 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, en_term = at[j].el_number; switch (en_term) { - case dO: break; - case dS: if (( en_center == dSe ) || ( en_center == dAt ) || ( en_center == dTe )) break; continue; - case dSe: if (( en_center == dAt ) || ( en_center == dTe )) break; continue; - case dTe: if (en_center == dAt) break; continue; - default: continue; + case dO: + break; + case dS: + if ((en_center == dSe) || (en_center == dAt) || (en_center == dTe)) + break; + continue; + case dSe: + if ((en_center == dAt) || (en_center == dTe)) + break; + continue; + case dTe: + if (en_center == dAt) + break; + continue; + default: + continue; } /* From several candidates, select one with less el. number (==more electronegative). */ if (en_term < min_en) { - min_en = en_term; kk = k; jj = j; + min_en = en_term; + kk = k; + jj = j; min_iso = at[j].iso_atw_diff > 0 ? at[i].iso_atw_diff - 1 : at[i].iso_atw_diff; continue; } @@ -422,12 +442,15 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, iso = at[j].iso_atw_diff > 0 ? at[i].iso_atw_diff - 1 : at[i].iso_atw_diff; if (iso < min_iso) { - min_iso = iso; kk = k; jj = j; continue; + min_iso = iso; + kk = k; + jj = j; + continue; } } } /* end of checking nbrs. */ - /* If OK, apply changes. */ + /* If OK, apply changes. */ if (jj >= 0) { at[i].charge = 0; @@ -437,21 +460,20 @@ int fix_non_uniform_drawn_oxoanions( int num_atoms, at[i].bond_stereo[kk] = at[jj].bond_stereo[0] = 0; at[i].chem_bonds_valence--; at[jj].chem_bonds_valence--; - ( *num_changes )++; + (*num_changes)++; } } - } /* end of search for candidate centers. */ + } /* end of search for candidate centers. */ return 0; } - /**************************************************************************** Correct non-uniformly drawn amidinium cations. ****************************************************************************/ -int fix_non_uniform_drawn_amidiniums( int num_atoms, - inp_ATOM *at, - int *num_changes ) +int fix_non_uniform_drawn_amidiniums(int num_atoms, + inp_ATOM *at, + int *num_changes) { /* Amidines include carboxamidines RC(=NR)NR2, @@ -481,11 +503,21 @@ int fix_non_uniform_drawn_amidiniums( int num_atoms, /* constants for element numbers */ enum elems { - dNone, dCl = 17, dBr = 35, dI = 53, dAt = 85, dO = 8, - dS = 16, dSe = 34, dTe = 52, dP = 15, dC = 6, dN = 7 + dNone, + dCl = 17, + dBr = 35, + dI = 53, + dAt = 85, + dO = 8, + dS = 16, + dSe = 34, + dTe = 52, + dP = 15, + dC = 6, + dN = 7 }; - static U_CHAR allowed_elnums_center[] = { dC, dS, dP }; + static U_CHAR allowed_elnums_center[] = {dC, dS, dP}; int en_center; int i, j, k, jj, kk, k1; int mismatch = 0, nuH = 0, nuN = 0, nitrogens[MAXVAL]; @@ -501,7 +533,7 @@ int fix_non_uniform_drawn_amidiniums( int num_atoms, } en_center = at[i].el_number; /* from eligible element list ... */ - if (!memchr( allowed_elnums_center, en_center, sizeof( allowed_elnums_center ) )) + if (!memchr(allowed_elnums_center, en_center, sizeof(allowed_elnums_center))) { continue; } @@ -516,14 +548,14 @@ int fix_non_uniform_drawn_amidiniums( int num_atoms, } /* non-radical. */ - if (at[i].radical && ( at[i].radical != RADICAL_SINGLET )) + if (at[i].radical && (at[i].radical != RADICAL_SINGLET)) { continue; } /* NB: center must have neutral neighbours, two of them are aliphatic N's of which at least one bears H. */ - mismatch = nuH = nuN = kk = 0; /* djb-rwth: removing redundant code */ - memset( nitrogens, 0, sizeof( nitrogens ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + mismatch = nuH = nuN = kk = 0; /* djb-rwth: removing redundant code */ + memset(nitrogens, 0, sizeof(nitrogens)); /* djb-rwth: memset_s C11/Annex K variant? */ jj = -1; for (k = 0; k < at[i].valence; k++) { @@ -536,12 +568,12 @@ int fix_non_uniform_drawn_amidiniums( int num_atoms, } if (at[j].el_number == dN) { - if (( at[j].valence > 3 ) || ( at[j].chem_bonds_valence > 3 )) + if ((at[j].valence > 3) || (at[j].chem_bonds_valence > 3)) { mismatch = 1; break; } - nuH += NUMH( at, j ); + nuH += NUMH(at, j); nuN++; if (jj < 0) { @@ -576,14 +608,13 @@ int fix_non_uniform_drawn_amidiniums( int num_atoms, at[jj].chem_bonds_valence++; /* NB: do nothing with wedge stereo bonds (retain wedge) */ - ( *num_changes )++; + (*num_changes)++; } - } /* end of search for candidate centers. */ + } /* end of search for candidate centers. */ return 0; } - /**************************************************************************** Not used -- int FixAromaticOxygenAndSulfur( inp_ATOM *atom ) @@ -598,12 +629,11 @@ return 0; } ****************************************************************************/ - /****************************************************************************/ -int fix_odd_things( int num_atoms, - inp_ATOM *at, - int bFixBug, - int bFixNonUniformDraw ) +int fix_odd_things(int num_atoms, + inp_ATOM *at, + int bFixBug, + int bFixNonUniformDraw) { /* N;P;As;Sb;O;S;Se;Te;C;Si */ static const U_CHAR en[] = { @@ -614,32 +644,31 @@ int fix_odd_things( int num_atoms, EL_NUMBER_O, EL_NUMBER_S, EL_NUMBER_SE, - EL_NUMBER_TE - }; - static int ne = sizeof(en)/sizeof(en[0]); + EL_NUMBER_TE}; + static int ne = sizeof(en) / sizeof(en[0]); -#define FIRST_NEIGHB2 4 -#define FIRST_CENTER2 5 +#define FIRST_NEIGHB2 4 +#define FIRST_CENTER2 5 int i1, i2, k1, k2, c = -1, num_changes = 0; /* djb-rwth: removing redundant variables */ if (bFixNonUniformDraw) { - int ret1; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - ret1 = fix_non_uniform_drawn_oxoanions( num_atoms, at, &num_changes ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - ret1 = fix_non_uniform_drawn_amidiniums( num_atoms, at, &num_changes ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + int ret1; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret1 = fix_non_uniform_drawn_oxoanions(num_atoms, at, &num_changes); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret1 = fix_non_uniform_drawn_amidiniums(num_atoms, at, &num_changes); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ } /* H(-)-X -> H-X(-); H(+)-X -> H-X(+) */ for (i1 = 0; i1 < num_atoms; i1++) { if (1 == at[i1].valence && - 1 == abs( at[i1].charge ) && - ( 0 == at[i1].radical || RADICAL_SINGLET == at[i1].radical ) && - BOND_TYPE_SINGLE == at[i1].bond_type[0] && - EL_NUMBER_H == at[i1].el_number && EL_NUMBER_H != at[i2 = (int) at[i1].neighbor[0]].el_number && - !NUMH( at, i1 ) && !NUMH( at, i2 )) + 1 == abs(at[i1].charge) && + (0 == at[i1].radical || RADICAL_SINGLET == at[i1].radical) && + BOND_TYPE_SINGLE == at[i1].bond_type[0] && + EL_NUMBER_H == at[i1].el_number && EL_NUMBER_H != at[i2 = (int)at[i1].neighbor[0]].el_number && + !NUMH(at, i1) && !NUMH(at, i2)) { at[i2].charge += at[i1].charge; at[i1].charge = 0; @@ -650,29 +679,29 @@ int fix_odd_things( int num_atoms, for (i1 = 0; i1 < num_atoms; i1++) { if (1 != at[i1].charge || - (at[i1].radical && RADICAL_SINGLET != at[i1].radical) || - at[i1].chem_bonds_valence == at[i1].valence || - !memchr( en, at[i1].el_number, ne ) || - get_el_valence( at[i1].el_number, at[i1].charge, 0 ) != at[i1].chem_bonds_valence + NUMH( at, i1 )) /* djb-rwth: addressing LLVM warning */ + (at[i1].radical && RADICAL_SINGLET != at[i1].radical) || + at[i1].chem_bonds_valence == at[i1].valence || + !memchr(en, at[i1].el_number, ne) || + get_el_valence(at[i1].el_number, at[i1].charge, 0) != at[i1].chem_bonds_valence + NUMH(at, i1)) /* djb-rwth: addressing LLVM warning */ { continue; } /* found a candidate at[i1] for X in XHn(+) */ if (1 == at[i1].valence && - BOND_TYPE_DOUBLE == at[i1].bond_type[0]) + BOND_TYPE_DOUBLE == at[i1].bond_type[0]) { - c = (int) at[i1].neighbor[0]; + c = (int)at[i1].neighbor[0]; for (k2 = 0; k2 < at[c].valence; k2++) { i2 = at[c].neighbor[k2]; if (1 == at[i2].valence && - -1 == at[i2].charge && - at[i2].el_number == at[i1].el_number && /* exact match */ - ( 0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical ) && - BOND_TYPE_SINGLE == at[i2].bond_type[0] && - /*memchr(en, at[i2].el_number, ne) &&*/ - get_el_valence( at[i2].el_number, at[i2].charge, 0 ) == at[i2].chem_bonds_valence + NUMH( at, i2 )) + -1 == at[i2].charge && + at[i2].el_number == at[i1].el_number && /* exact match */ + (0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical) && + BOND_TYPE_SINGLE == at[i2].bond_type[0] && + /*memchr(en, at[i2].el_number, ne) &&*/ + get_el_valence(at[i2].el_number, at[i2].charge, 0) == at[i2].chem_bonds_valence + NUMH(at, i2)) { /* found both X(-) and X(+); change bonds and remove charges */ for (k1 = 0; k1 < at[c].valence && i1 != at[c].neighbor[k1]; k1++) @@ -697,13 +726,13 @@ int fix_odd_things( int num_atoms, if (at[neigh].el_number == EL_NUMBER_H) { if (at[neigh].chem_bonds_valence == 1 && - ( 0 == at[neigh].radical || RADICAL_SINGLET == at[neigh].radical )) + (0 == at[neigh].radical || RADICAL_SINGLET == at[neigh].radical)) { num_H_i1++; /* found H-neighbor */ } else { - break; /* wrong neighbor */ + break; /* wrong neighbor */ } } else if (at[i1].bond_type[ineigh] == BOND_TYPE_DOUBLE) @@ -720,10 +749,10 @@ int fix_odd_things( int num_atoms, for (k2 = 0; k2 < at[c].valence; k2++) { i2 = at[c].neighbor[k2]; - if (-1 == at[i2].charge && - at[i2].el_number == at[i1].el_number && /* exact match */ - ( 0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical ) && - get_el_valence( at[i2].el_number, at[i2].charge, 0 ) == at[i2].chem_bonds_valence + NUMH( at, i2 )) + if (-1 == at[i2].charge && + at[i2].el_number == at[i1].el_number && /* exact match */ + (0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical) && + get_el_valence(at[i2].el_number, at[i2].charge, 0) == at[i2].chem_bonds_valence + NUMH(at, i2)) { for (ineigh = 0, num_H_i2 = 0, i2_c = -1; ineigh < at[i2].valence; ineigh++) { @@ -731,9 +760,9 @@ int fix_odd_things( int num_atoms, if (at[neigh].el_number == EL_NUMBER_H) { if (at[neigh].chem_bonds_valence == 1 && - ( 0 == at[neigh].radical || RADICAL_SINGLET == at[neigh].radical )) + (0 == at[neigh].radical || RADICAL_SINGLET == at[neigh].radical)) { - num_H_i2++; /* found H-neighbor */ + num_H_i2++; /* found H-neighbor */ } else { @@ -752,7 +781,7 @@ int fix_odd_things( int num_atoms, } } } - if (num_H_i2 + ( i2_c >= 0 ) != at[i2].valence) + if (num_H_i2 + (i2_c >= 0) != at[i2].valence) { continue; } @@ -801,27 +830,27 @@ int fix_odd_things( int num_atoms, for (i1 = 0; i1 < num_atoms; i1++) { if (1 == at[i1].valence && - -1 == at[i1].charge && - ( 0 == at[i1].radical || RADICAL_SINGLET == at[i1].radical ) && - !NUMH( at, i1 ) && - BOND_TYPE_SINGLE == at[i1].bond_type[0] && - memchr( en + FIRST_NEIGHB2, at[i1].el_number, (long long)ne - FIRST_NEIGHB2 )) /* djb-rwth: cast operator added */ + -1 == at[i1].charge && + (0 == at[i1].radical || RADICAL_SINGLET == at[i1].radical) && + !NUMH(at, i1) && + BOND_TYPE_SINGLE == at[i1].bond_type[0] && + memchr(en + FIRST_NEIGHB2, at[i1].el_number, (long long)ne - FIRST_NEIGHB2)) /* djb-rwth: cast operator added */ { int charge, i; /* found a candidate for X */ - c = (int) at[i1].neighbor[0]; /* candidate for Y */ - if (( ( charge = 2 ) == at[c].charge && memchr( en + FIRST_CENTER2, at[c].el_number, (long long)ne - FIRST_CENTER2 ) /* djb-rwth: cast operator added */ + c = (int)at[i1].neighbor[0]; /* candidate for Y */ + if (((charge = 2) == at[c].charge && memchr(en + FIRST_CENTER2, at[c].el_number, (long long)ne - FIRST_CENTER2) /* djb-rwth: cast operator added */ #ifndef FIX_P_IV_Plus_O_Minus - || ( charge = 1 ) == at[c].charge && EL_NUMBER_P == at[c].el_number + || (charge = 1) == at[c].charge && EL_NUMBER_P == at[c].el_number #endif - ) && - 4 == at[c].valence && - ( 0 == at[c].radical || RADICAL_SINGLET == at[c].radical ) && - at[c].valence == at[c].chem_bonds_valence && - !NUMH( at, c )) + ) && + 4 == at[c].valence && + (0 == at[c].radical || RADICAL_SINGLET == at[c].radical) && + at[c].valence == at[c].chem_bonds_valence && + !NUMH(at, c)) { - ; /* accept */ + ; /* accept */ } else { @@ -835,12 +864,12 @@ int fix_odd_things( int num_atoms, continue; } if (1 == at[i2].valence && - -1 == at[i2].charge && - memchr( en + FIRST_NEIGHB2, at[i2].el_number, (long long)ne - FIRST_NEIGHB2 ) && /* djb-rwth: cast operator added */ - /*at[i2].el_number == at[i1].el_number &&*/ /* exact match */ - ( 0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical ) && - !NUMH( at, i2 ) && - BOND_TYPE_SINGLE == at[i2].bond_type[0]) + -1 == at[i2].charge && + memchr(en + FIRST_NEIGHB2, at[i2].el_number, (long long)ne - FIRST_NEIGHB2) && /* djb-rwth: cast operator added */ + /*at[i2].el_number == at[i1].el_number &&*/ /* exact match */ + (0 == at[i2].radical || RADICAL_SINGLET == at[i2].radical) && + !NUMH(at, i2) && + BOND_TYPE_SINGLE == at[i2].bond_type[0]) { /* found both X(-) and X(-); change bonds and remove charges */ for (k1 = 0; k1 < at[c].valence && i1 != at[c].neighbor[k1]; k1++) @@ -854,24 +883,26 @@ int fix_odd_things( int num_atoms, for the neutralization of the components */ switch (i) { - case 0: - at[i1].charge++; /* = 0; changed 2010-03-17 DT*/ - at[i1].bond_type[0] = at[c].bond_type[k1] = BOND_TYPE_DOUBLE; - at[i1].bond_stereo[0] = at[c].bond_stereo[k1] = 0; - at[i1].chem_bonds_valence++; - at[c].chem_bonds_valence++; - if (bFixBug) at[c].charge--; /* added 2010-03-17 DT*/ - num_changes++; - break; - case 1: - at[i2].charge++; /*= 0; changed 2010-03-17 DT*/ - at[i2].bond_type[0] = at[c].bond_type[k2] = BOND_TYPE_DOUBLE; - at[i2].bond_stereo[0] = at[c].bond_stereo[k2] = 0; - at[i2].chem_bonds_valence++; - at[c].chem_bonds_valence++; - if (bFixBug) at[c].charge--; /* added 2010-03-17 DT */ - num_changes++; - break; + case 0: + at[i1].charge++; /* = 0; changed 2010-03-17 DT*/ + at[i1].bond_type[0] = at[c].bond_type[k1] = BOND_TYPE_DOUBLE; + at[i1].bond_stereo[0] = at[c].bond_stereo[k1] = 0; + at[i1].chem_bonds_valence++; + at[c].chem_bonds_valence++; + if (bFixBug) + at[c].charge--; /* added 2010-03-17 DT*/ + num_changes++; + break; + case 1: + at[i2].charge++; /*= 0; changed 2010-03-17 DT*/ + at[i2].bond_type[0] = at[c].bond_type[k2] = BOND_TYPE_DOUBLE; + at[i2].bond_stereo[0] = at[c].bond_stereo[k2] = 0; + at[i2].chem_bonds_valence++; + at[c].chem_bonds_valence++; + if (bFixBug) + at[c].charge--; /* added 2010-03-17 DT */ + num_changes++; + break; } } @@ -896,13 +927,13 @@ int fix_odd_things( int num_atoms, for (i1 = 0; i1 < num_atoms; i1++) { if (RADICAL_DOUBLET == at[i1].radical && - 0 <= ( i2 = the_only_doublet_neigh( at, i1, &k1, &k2 ) )) + 0 <= (i2 = the_only_doublet_neigh(at, i1, &k1, &k2))) { if (at[i1].bond_type[k1] <= BOND_TYPE_DOUBLE) { - at[i1].bond_type[k1] ++; + at[i1].bond_type[k1]++; at[i1].chem_bonds_valence++; - at[i2].bond_type[k2] ++; + at[i2].bond_type[k2]++; at[i2].chem_bonds_valence++; at[i1].radical = 0; at[i2].radical = 0; @@ -910,26 +941,23 @@ int fix_odd_things( int num_atoms, } } -#if ( REMOVE_ION_PAIRS_EARLY == 1 ) - num_changes += remove_ion_pairs( num_atoms, at ); +#if (REMOVE_ION_PAIRS_EARLY == 1) + num_changes += remove_ion_pairs(num_atoms, at); #endif return num_changes; } - /****************************************************************************/ -int post_fix_odd_things( int num_atoms, inp_ATOM *at ) +int post_fix_odd_things(int num_atoms, inp_ATOM *at) { int num_changes = 0; /* currently does nothing */ - return - num_changes; + return num_changes; } - /****************************************************************************/ -int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) +int nFindOneOM(inp_ATOM *at, int at_no, int ord_OM[], int num_OM) { int i, n_OM, best_value, cur_value, diff; /* djb-rwth: removing redundant variables */ int num_best; @@ -945,13 +973,13 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) /* select neighbors with min. number of bonds */ num_best = 1; - n_OM = (int) at[at_no].neighbor[ord_OM[0]]; - best_value = (int) at[n_OM].valence; + n_OM = (int)at[at_no].neighbor[ord_OM[0]]; + best_value = (int)at[n_OM].valence; /* compare number of bonds; move indexes of the best neighbors to the first elements of ord_OM[] */ for (i = 1; i < num_OM; i++) { n_OM = at[at_no].neighbor[ord_OM[i]]; - cur_value = (int) at[n_OM].valence; + cur_value = (int)at[n_OM].valence; diff = cur_value - best_value; if (diff < 0) { @@ -961,7 +989,7 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) num_best = 1; } else if (diff == 0) - { /* was '=', pointed by WDI */ + { /* was '=', pointed by WDI */ ord_OM[num_best++] = ord_OM[i]; } } @@ -973,14 +1001,14 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) /* select neighbors with min. periodic numbers */ num_best = 1; - n_OM = (int) at[at_no].neighbor[ord_OM[0]]; - best_value = (int) at[n_OM].el_number; + n_OM = (int)at[at_no].neighbor[ord_OM[0]]; + best_value = (int)at[n_OM].el_number; /* compare periodic numbers; move indexes of the best neighbors to the first elements of ord_OM[] */ for (i = 1; i < num_OM; i++) { n_OM = at[at_no].neighbor[ord_OM[i]]; - cur_value = (int) at[n_OM].el_number; + cur_value = (int)at[n_OM].el_number; diff = cur_value - best_value; if (diff < 0) { @@ -990,7 +1018,7 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) num_best = 1; } else if (diff == 0) - { /* was '=', pointed by WDI */ + { /* was '=', pointed by WDI */ ord_OM[num_best++] = ord_OM[i]; } } @@ -1008,16 +1036,16 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) /* if neighbors are terminal atoms then the one without isotope or with lightest isotope */ num_best = 1; - n_OM = (int) at[at_no].neighbor[ord_OM[0]]; - best_value = (int) at[n_OM].iso_atw_diff; + n_OM = (int)at[at_no].neighbor[ord_OM[0]]; + best_value = (int)at[n_OM].iso_atw_diff; /* compare periodic numbers; move indexes of the best neighbors to the first elements of ord_OM[] */ for (i = 1; i < num_OM; i++) { n_OM = at[at_no].neighbor[ord_OM[i]]; - cur_value = (int) at[n_OM].el_number; + cur_value = (int)at[n_OM].el_number; diff = cur_value - best_value; - if (( !cur_value && best_value ) || diff < 0) + if ((!cur_value && best_value) || diff < 0) { /* djb-rwth: removing redundant code */ best_value = cur_value; @@ -1041,12 +1069,11 @@ int nFindOneOM( inp_ATOM *at, int at_no, int ord_OM[], int num_OM ) return ord_OM[0]; } - /**************************************************************************** NB: the bonds are fixed in fix_special_bonds() ****************************************************************************/ -int remove_ion_pairs( int num_atoms, inp_ATOM *at ) +int remove_ion_pairs(int num_atoms, inp_ATOM *at) { int num_changes = 0; #define MAX_NEIGH 6 @@ -1062,51 +1089,51 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) /****** count candidates ********/ for (i = 0, a = at; i < num_atoms; i++, a++) { - if (1 == ( chrg = a->charge ) || -1 == chrg) + if (1 == (chrg = a->charge) || -1 == chrg) { - switch (ion_el_group( a->el_number )) + switch (ion_el_group(a->el_number)) { - case EL_NUMBER_C: - if (chrg > 0) - { - num_C_plus++; - } - else - { - num_C_minus++; - } - break; - case EL_NUMBER_O: - if (chrg > 0) - { - num_O_plus++; - } - else - { - num_O_minus++; - } - break; - case EL_NUMBER_N: - if (chrg > 0) - { - num_N_plus++; - } - else - { - num_N_minus++; - } + case EL_NUMBER_C: + if (chrg > 0) + { + num_C_plus++; + } + else + { + num_C_minus++; + } + break; + case EL_NUMBER_O: + if (chrg > 0) + { + num_O_plus++; + } + else + { + num_O_minus++; + } + break; + case EL_NUMBER_N: + if (chrg > 0) + { + num_N_plus++; + } + else + { + num_N_minus++; + } #ifdef FIX_P_IV_Plus_O_Minus - num_P_IV_plus += a->el_number != EL_NUMBER_N && - chrg == 1 && - a->valence == 4 && - a->chem_bonds_valence == 4; /* added 2010-03-17 DT */ -#endif - break; + num_P_IV_plus += a->el_number != EL_NUMBER_N && + chrg == 1 && + a->valence == 4 && + a->chem_bonds_valence == 4; /* added 2010-03-17 DT */ +#endif + break; } } - else if (!chrg && a->chem_bonds_valence + NUMH( a, 0 ) == 2 && - get_el_valence( a->el_number, 0, 0 ) == 4 && - ion_el_group( a->el_number ) == EL_NUMBER_C) + else if (!chrg && a->chem_bonds_valence + NUMH(a, 0) == 2 && + get_el_valence(a->el_number, 0, 0) == 4 && + ion_el_group(a->el_number) == EL_NUMBER_C) { num_C_II++; } @@ -1136,30 +1163,30 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) for (type = 1; type <= 18; type++) { - if (( !type || 1 == type )) + if ((!type || 1 == type)) { for (i = 0; i < num_atoms && 0 < num_N_plus && 0 < num_O_minus; i++) { - if (1 == at[i].charge && 3 == nNoMetalNumBonds( at, i ) && - 4 == nNoMetalBondsValence( at, i ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_N) + if (1 == at[i].charge && 3 == nNoMetalNumBonds(at, i) && + 4 == nNoMetalBondsValence(at, i) && + ion_el_group(at[i].el_number) == EL_NUMBER_N) { int num_OM = 0, ord_OM[3]; /* -O(-) */ - int num_O = 0; /* =O */ + int num_O = 0; /* =O */ int num_O_other = 0; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (1 == nNoMetalNumBonds( at, n ) && 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number) == EL_NUMBER_O) /* djb-rwth: ignoring LLVM warning: variable used */ + if (1 == nNoMetalNumBonds(at, n) && 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O) /* djb-rwth: ignoring LLVM warning: variable used */ { if (BOND_TYPE_SINGLE == at[i].bond_type[i1] && - -1 == at[n].charge) + -1 == at[n].charge) { ord_OM[num_OM++] = i1; } else if (BOND_TYPE_DOUBLE == at[n].bond_type[0] && - 0 == at[n].charge) + 0 == at[n].charge) { num_O++; } @@ -1170,13 +1197,13 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (num_OM > 0 && num_O > 0 && !num_O_other && - 0 <= ( i1 = nFindOneOM( at, i, ord_OM, num_OM ) )) + 0 <= (i1 = nFindOneOM(at, i, ord_OM, num_OM))) { /* remove charges and increase bond order */ n = at[i].neighbor[i1]; - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; at[i].charge--; @@ -1207,21 +1234,21 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) for (i = 0; i < num_atoms && 0 < num_P_IV_plus /*&& 0 < num_N_plus*/ && 0 < num_O_minus; i++) { - if (1 == at[i].charge && 4 == nNoMetalNumBonds( at, i ) && - 4 == nNoMetalBondsValence( at, i ) && - at[i].el_number != EL_NUMBER_N && ion_el_group( at[i].el_number ) == EL_NUMBER_N) + if (1 == at[i].charge && 4 == nNoMetalNumBonds(at, i) && + 4 == nNoMetalBondsValence(at, i) && + at[i].el_number != EL_NUMBER_N && ion_el_group(at[i].el_number) == EL_NUMBER_N) { int num_OM = 0, ord_OM[4]; /* -O(-) */ - /*int num_O = 0;*/ /* =O */ - /* djb-rwth: removing redundant variables */ + /*int num_O = 0;*/ /* =O */ + /* djb-rwth: removing redundant variables */ for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (1 == nNoMetalNumBonds( at, n ) && 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number) == EL_NUMBER_O) /* djb-rwth: ignoring LLVM warning: variable used */ + if (1 == nNoMetalNumBonds(at, n) && 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O) /* djb-rwth: ignoring LLVM warning: variable used */ { if (BOND_TYPE_SINGLE == at[i].bond_type[i1] && - -1 == at[n].charge) + -1 == at[n].charge) { ord_OM[num_OM++] = i1; /* @@ -1235,13 +1262,13 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (num_OM > 0 /*&& num_O > 0 && !num_O_other*/ && - 0 <= ( i1 = nFindOneOM( at, i, ord_OM, num_OM ) )) + 0 <= (i1 = nFindOneOM(at, i, ord_OM, num_OM))) { /* remove charges and increase bond order */ n = at[i].neighbor[i1]; - i2 = is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + i2 = is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; at[i].charge--; @@ -1259,7 +1286,6 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) #endif /* FIX_P_IV_Plus_O_Minus */ } - /*------------------------------------------------------------------------- Terminal pair types: 2,3,4,5,6,7,8,9 N=N,P,As,Sb; O=O,S,Se,Te; C=C,Si ==================================== @@ -1278,39 +1304,39 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) { for (i = 0; i < num_atoms && 0 < num_All; i++) { - if (0 == at[i].charge && 1 == nNoMetalNumBonds( at, i ) && 2 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_O && - 0 <= ( i1 = nNoMetalNeighIndex( at, i ) ) && - at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) + if (0 == at[i].charge && 1 == nNoMetalNumBonds(at, i) && 2 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + ion_el_group(at[i].el_number) == EL_NUMBER_O && + 0 <= (i1 = nNoMetalNeighIndex(at, i)) && + at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) { /* terminal O= */ n = at[i].neighbor[i1]; - if (( !type || type == 2 ) && 0 < num_C_II) + if ((!type || type == 2) && 0 < num_C_II) { /* avoid alternating bonds */ if (0 == at[n].charge && - 2 == nNoMetalNumBonds( at, n ) && 3 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_N && - 0 <= ( i2 = nNoMetalOtherNeighIndex( at, n, i ) ) && - at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) + 2 == nNoMetalNumBonds(at, n) && 3 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_N && + 0 <= (i2 = nNoMetalOtherNeighIndex(at, n, i)) && + at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) { /* i2 = index of opposite to at[i] neighbor of at[n] */ /*i2 = (at[n].neighbor[0] == i);*/ n2 = at[n].neighbor[i2]; if (0 == at[n2].charge && - 2 == at[n2].valence && 2 == at[n2].chem_bonds_valence && - 0 == num_of_H( at, n2 ) && - ion_el_group( at[n2].el_number ) == EL_NUMBER_C) + 2 == at[n2].valence && 2 == at[n2].chem_bonds_valence && + 0 == num_of_H(at, n2) && + ion_el_group(at[n2].el_number) == EL_NUMBER_C) { /* i n n2 */ /* found O=N-C(II)- */ /* convert O=N-C(II)- => O=N#C- */ - i3 = ( at[n2].neighbor[0] != n ); /* index of at[n] neighbor of n2 */ - at[n].chem_bonds_valence = 5; /* N */ - at[n2].chem_bonds_valence = 4; /* C */ + i3 = (at[n2].neighbor[0] != n); /* index of at[n] neighbor of n2 */ + at[n].chem_bonds_valence = 5; /* N */ + at[n2].chem_bonds_valence = 4; /* C */ at[n].bond_type[i2] = BOND_TYPE_TRIPLE; at[n2].bond_type[i3] = BOND_TYPE_TRIPLE; at[n2].radical = 0; @@ -1322,28 +1348,28 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } - if (( !type || type == 3 ) && 0 < num_O_plus && 0 < num_C_minus) + if ((!type || type == 3) && 0 < num_O_plus && 0 < num_C_minus) { - if (1 == at[n].charge && 2 == nNoMetalNumBonds( at, n ) && 3 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_O && - 0 <= ( i2 = nNoMetalOtherNeighIndex( at, n, i ) ) && - at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) + if (1 == at[n].charge && 2 == nNoMetalNumBonds(at, n) && 3 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O && + 0 <= (i2 = nNoMetalOtherNeighIndex(at, n, i)) && + at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) { /* found O=O(+)- */ /* i2 = index of opposite to at[i] neighbor of at[n] */ /*i2 = (at[n].neighbor[0] == i);*/ n2 = at[n].neighbor[i2]; - if (-1 == at[n2].charge && 3 >= nNoMetalNumBonds( at, n2 ) && 3 == nNoMetalBondsValence( at, n2 ) + NUMH( at, n2 ) && - ion_el_group( at[n2].el_number ) == EL_NUMBER_C) + if (-1 == at[n2].charge && 3 >= nNoMetalNumBonds(at, n2) && 3 == nNoMetalBondsValence(at, n2) + NUMH(at, n2) && + ion_el_group(at[n2].el_number) == EL_NUMBER_C) { /* i n n2 */ /* found found O=O(+)-C(-)(III) */ /* convert O=O(+)-C(-)(III) => O=O=C(IV) */ - i3 = ( at[n2].neighbor[0] != n ); /* index of at[n] neighbor of n2 */ + i3 = (at[n2].neighbor[0] != n); /* index of at[n] neighbor of n2 */ at[n].charge--; at[n2].charge++; - at[n].chem_bonds_valence += 1; /* =O- => =O= */ + at[n].chem_bonds_valence += 1; /* =O- => =O= */ at[n2].chem_bonds_valence += 1; /* -C => =C */ at[n].bond_type[i2] = BOND_TYPE_DOUBLE; at[n2].bond_type[i3] = BOND_TYPE_DOUBLE; @@ -1358,33 +1384,33 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } else if (-1 == at[i].charge && - 0 < num_O_minus + num_N_minus && - 0 < num_N_plus + num_O_plus + num_C_plus && - 1 == nNoMetalNumBonds( at, i ) && 1 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_O && - 0 <= ( i1 = nNoMetalNeighIndex( at, i ) ) && - at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) + 0 < num_O_minus + num_N_minus && + 0 < num_N_plus + num_O_plus + num_C_plus && + 1 == nNoMetalNumBonds(at, i) && 1 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + ion_el_group(at[i].el_number) == EL_NUMBER_O && + 0 <= (i1 = nNoMetalNeighIndex(at, i)) && + at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) { /* terminal O(-)- */ n = at[i].neighbor[i1]; - if (( !type || type == 4 ) && 0 < num_O_minus && 0 < num_N_plus && /* O(-)-N(+)(IV) */ - 1 == at[n].charge && 3 >= nNoMetalNumBonds( at, n ) && 4 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_N /* except >O(+)- */ - ) + if ((!type || type == 4) && 0 < num_O_minus && 0 < num_N_plus && /* O(-)-N(+)(IV) */ + 1 == at[n].charge && 3 >= nNoMetalNumBonds(at, n) && 4 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_N /* except >O(+)- */ + ) { /* found O(-)-N(+)(IV) */ /* convert O(-)-N(+)(IV) => O=N(V) */ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); /* index of at[i] neighbor of at[n] */ + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); /* index of at[i] neighbor of at[n] */ at[i].charge++; at[n].charge--; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_O_minus--; num_N_plus--; @@ -1392,22 +1418,22 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) continue; } - if (( !type || type == 5 ) && 0 < num_O_minus && 0 < num_O_plus &&/* O(-)-O(+)(III) */ - 1 == at[n].charge && 3 >= nNoMetalNumBonds( at, n ) && 3 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_O /* except >O(+)- */ - ) + if ((!type || type == 5) && 0 < num_O_minus && 0 < num_O_plus && /* O(-)-O(+)(III) */ + 1 == at[n].charge && 3 >= nNoMetalNumBonds(at, n) && 3 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O /* except >O(+)- */ + ) { /* found O(+)(III) */ /* convert O(-)-O(+)(III) => O=O(IV) */ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); /* index of at[i] neighbor of at[n] */ + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); /* index of at[i] neighbor of at[n] */ at[i].charge++; at[n].charge--; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_O_minus--; num_O_plus--; @@ -1416,33 +1442,33 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } /* i n n2 */ - if (( !type || type == 6 ) && /* O(-)-O-C(+)(III) */ - 0 < num_O_minus && 0 < num_C_plus && - 0 == at[n].charge && 2 == nNoMetalNumBonds( at, n ) && 2 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_O && - 0 <= ( i2 = nNoMetalOtherNeighIndex( at, n, i ) ) && - at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) + if ((!type || type == 6) && /* O(-)-O-C(+)(III) */ + 0 < num_O_minus && 0 < num_C_plus && + 0 == at[n].charge && 2 == nNoMetalNumBonds(at, n) && 2 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O && + 0 <= (i2 = nNoMetalOtherNeighIndex(at, n, i)) && + at[n].bond_type[i2] <= BOND_TYPE_TRIPLE) { /* found O(-)-O- */ /* i2 = index of opposite to at[i] neighbor of at[n] */ /*i2 = (at[n].neighbor[0] == i);*/ n2 = at[n].neighbor[i2]; - if (1 == at[n2].charge && 3 >= nNoMetalNumBonds( at, n2 ) && - 3 == nNoMetalBondsValence( at, n2 ) + NUMH( at, n2 ) && - ion_el_group( at[n2].el_number ) == EL_NUMBER_C) + if (1 == at[n2].charge && 3 >= nNoMetalNumBonds(at, n2) && + 3 == nNoMetalBondsValence(at, n2) + NUMH(at, n2) && + ion_el_group(at[n2].el_number) == EL_NUMBER_C) { /* i n n2 */ /* found O(-)-O-C(+)(III) */ /* convert O(-)-O-C(+)(III) => O=O=C(IV) */ /*i3 = (at[n2].neighbor[0] != n);*/ /* i3 = index of at[n] neighbor of at[n2] */ - i3 = (int) ( is_in_the_list( at[n2].neighbor, (AT_NUMB) n, at[n2].valence ) - at[n2].neighbor ); + i3 = (int)(is_in_the_list(at[n2].neighbor, (AT_NUMB)n, at[n2].valence) - at[n2].neighbor); /*i4 = index of at[i] in the adjacency list of at[n] */ - i4 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i4 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge++; at[n2].charge--; - at[i].chem_bonds_valence += 1; /* O- => O= */ - at[n].chem_bonds_valence += 2; /* -O- => =O= */ + at[i].chem_bonds_valence += 1; /* O- => O= */ + at[n].chem_bonds_valence += 2; /* -O- => =O= */ at[n2].chem_bonds_valence += 1; /* -C => =C */ at[i].bond_type[i1] = BOND_TYPE_DOUBLE; at[n].bond_type[i4] = BOND_TYPE_DOUBLE; @@ -1457,70 +1483,70 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } else if (-1 == at[i].charge && 0 < num_N_minus && 0 < num_N_plus + num_O_plus + num_C_plus && - 1 == nNoMetalNumBonds( at, i ) && 2 == nNoMetalBondsValence( at, i ) + NUMH( at, i ) && - /*0 == num_of_H( at, i ) &&*/ - ion_el_group( at[i].el_number ) == EL_NUMBER_N && - 0 <= ( i1 = nNoMetalNeighIndex( at, i ) ) && - at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) + 1 == nNoMetalNumBonds(at, i) && 2 == nNoMetalBondsValence(at, i) + NUMH(at, i) && + /*0 == num_of_H( at, i ) &&*/ + ion_el_group(at[i].el_number) == EL_NUMBER_N && + 0 <= (i1 = nNoMetalNeighIndex(at, i)) && + at[i].bond_type[i1] <= BOND_TYPE_TRIPLE) { /* terminal N(-)= */ n = at[i].neighbor[i1 = 0]; - if (( !type || type == 7 ) && 0 < num_N_plus && /* N(-)=N(+)(IV) */ - 1 == at[n].charge && 3 >= nNoMetalNumBonds( at, n ) && 4 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_N) + if ((!type || type == 7) && 0 < num_N_plus && /* N(-)=N(+)(IV) */ + 1 == at[n].charge && 3 >= nNoMetalNumBonds(at, n) && 4 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_N) { /* found N(-)-N(+)(IV) */ /* convert N(-)=N(+)(IV) => N#N(V) */ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); /* index of at[i] neighbor of at[n] */ + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); /* index of at[i] neighbor of at[n] */ at[i].charge++; at[n].charge--; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_N_minus--; num_N_plus--; num_All -= 2; continue; } - if (( !type || type == 8 ) && 0 < num_O_plus && /* N(-)=O(+)(III) */ - 1 == at[n].charge && 2 == nNoMetalNumBonds( at, n ) && 3 == nNoMetalBondsValence( at, n ) && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_O) + if ((!type || type == 8) && 0 < num_O_plus && /* N(-)=O(+)(III) */ + 1 == at[n].charge && 2 == nNoMetalNumBonds(at, n) && 3 == nNoMetalBondsValence(at, n) && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_O) { /* found N(-)-O(+)(III) */ /* convert N(-)=O(+)(III) => N#O(IV)- */ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); /* index of at[i] neighbor of at[n] */ + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); /* index of at[i] neighbor of at[n] */ at[i].charge++; at[n].charge--; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_N_minus--; num_O_plus--; num_All -= 2; continue; } - if (( !type || type == 9 ) && 0 < num_C_plus && /* N(-)=C(+)(III) */ - 1 == at[n].charge && 2 == at[n].valence && 3 == at[n].chem_bonds_valence && - 0 == num_of_H( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + if ((!type || type == 9) && 0 < num_C_plus && /* N(-)=C(+)(III) */ + 1 == at[n].charge && 2 == at[n].valence && 3 == at[n].chem_bonds_valence && + 0 == num_of_H(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { /* found N(-)=C(+)(III) */ /* convert N(-)=C(+)(III) => N#C(IV)- */ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); /* index of at[i] neighbor of at[n] */ + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); /* index of at[i] neighbor of at[n] */ at[i].charge++; at[n].charge--; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_N_minus--; num_C_plus--; @@ -1551,22 +1577,22 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) for (i = 0; i < num_atoms && 0 < num_All; i++) { if (1 == at[i].charge && - 0 < num_N_plus + num_O_plus && 0 < num_C_minus + num_N_minus && - 4 >= nNoMetalNumBonds( at, i ) && 4 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_N) + 0 < num_N_plus + num_O_plus && 0 < num_C_minus + num_N_minus && + 4 >= nNoMetalNumBonds(at, i) && 4 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + ion_el_group(at[i].el_number) == EL_NUMBER_N) { /* found non-terminal N(+)(IV) */ - if (( !type || 10 == type ) && 0 < num_N_plus && 0 < num_C_minus) + if ((!type || 10 == type) && 0 < num_N_plus && 0 < num_C_minus) { int num_neigh = 0, pos_neigh = -1; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH( at, n ) && - /*0 == at[n].num_H &&*/ - at[i].bond_type[i1] == BOND_TYPE_SINGLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH(at, n) && + /*0 == at[n].num_H &&*/ + at[i].bond_type[i1] == BOND_TYPE_SINGLE && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { /* found N(+)(IV)-C(-)(III); prepare conversion to N(V)=C(IV) */ num_neigh++; @@ -1575,18 +1601,18 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } i1 = pos_neigh; if (1 == num_neigh && - at[i].bond_type[i1] <= BOND_TYPE_TRIPLE && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1] ) && - !has_other_ion_neigh( at, n, i )) + at[i].bond_type[i1] <= BOND_TYPE_TRIPLE && + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_C_minus--; num_N_plus--; @@ -1594,16 +1620,16 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) continue; } } - if (( !type || 11 == type ) && 0 < num_N_plus && 0 < num_C_minus) + if ((!type || 11 == type) && 0 < num_N_plus && 0 < num_C_minus) { int num_neigh = 0, pos_neigh = -1; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH( at, n ) && - /*0 == at[n].num_H &&*/ - at[i].bond_type[i1] == BOND_TYPE_DOUBLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH(at, n) && + /*0 == at[n].num_H &&*/ + at[i].bond_type[i1] == BOND_TYPE_DOUBLE && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { /* found N(+)(IV)=C(-)(III); prepare conversion to N(V)#C(IV) */ num_neigh++; @@ -1611,17 +1637,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (1 == num_neigh && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1 = pos_neigh]) && - !has_other_ion_neigh( at, n, i)) + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1 = pos_neigh]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_C_minus--; num_N_plus--; @@ -1635,11 +1661,11 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 2 >= nNoMetalNumBonds( at, n ) && - 2 == nNoMetalBondsValence( at, n ) + NUMH( at, n ) && - /*0 == num_of_H( at, n ) &&*/ - at[i].bond_type[i1] == BOND_TYPE_SINGLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_N) + if (-1 == at[n].charge && 2 >= nNoMetalNumBonds(at, n) && + 2 == nNoMetalBondsValence(at, n) + NUMH(at, n) && + /*0 == num_of_H( at, n ) &&*/ + at[i].bond_type[i1] == BOND_TYPE_SINGLE && + ion_el_group(at[n].el_number) == EL_NUMBER_N) { /* found N(+)(IV)=N(-)(II); prepare conversion to N(V)#N(III) */ num_neigh++; @@ -1647,17 +1673,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (1 == num_neigh && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1 = pos_neigh]) && - !has_other_ion_neigh( at, n, i)) + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1 = pos_neigh]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_N_minus--; num_N_plus--; @@ -1667,22 +1693,22 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } else if (1 == at[i].charge && - 0 < num_O_plus && 0 < num_C_minus + num_N_minus && - 3 >= nNoMetalNumBonds( at, i ) && 3 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_O) + 0 < num_O_plus && 0 < num_C_minus + num_N_minus && + 3 >= nNoMetalNumBonds(at, i) && 3 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + ion_el_group(at[i].el_number) == EL_NUMBER_O) { /* found non-terminal O(+)(III) */ - if (( !type || 13 == type ) && 0 < num_C_minus) + if ((!type || 13 == type) && 0 < num_C_minus) { int num_neigh = 0, pos_neigh = -1; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH( at, n ) && - /*0 == at[n].num_H &&*/ - at[i].bond_type[i1] == BOND_TYPE_SINGLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH(at, n) && + /*0 == at[n].num_H &&*/ + at[i].bond_type[i1] == BOND_TYPE_SINGLE && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { /* found O(+)(III)-C(-)(II); prepare conversion to O(IV)=C(IV) */ num_neigh++; @@ -1690,17 +1716,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (1 == num_neigh && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1 = pos_neigh]) && - !has_other_ion_neigh( at, n, i)) + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1 = pos_neigh]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_C_minus--; num_O_plus--; @@ -1708,16 +1734,16 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) continue; } } - if (( !type || 14 == type ) && 0 < num_C_minus) + if ((!type || 14 == type) && 0 < num_C_minus) { int num_neigh = 0, pos_neigh = -1; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH( at, n ) && - /*0 == at[n].num_H &&*/ - at[i].bond_type[i1] == BOND_TYPE_DOUBLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + if (-1 == at[n].charge && 3 >= at[n].valence && 3 == at[n].chem_bonds_valence + NUMH(at, n) && + /*0 == at[n].num_H &&*/ + at[i].bond_type[i1] == BOND_TYPE_DOUBLE && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { /* found O(+)(III)=C(-)(III); prepare conversion to O(IV)#C(IV) */ num_neigh++; @@ -1725,17 +1751,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (1 == num_neigh && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1 = pos_neigh]) && - !has_other_ion_neigh( at, n, i)) + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1 = pos_neigh]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_C_minus--; num_O_plus--; @@ -1743,17 +1769,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) continue; } } - if (( !type || 15 == type ) && 0 < num_N_minus) + if ((!type || 15 == type) && 0 < num_N_minus) { int num_neigh = 0, pos_neigh = -1; for (i1 = 0; i1 < at[i].valence; i1++) { n = at[i].neighbor[i1]; - if (-1 == at[n].charge && 2 >= nNoMetalNumBonds( at, n ) && - 2 == nNoMetalBondsValence( at, n ) + NUMH( at, n ) && - /*0 == num_of_H( at, n ) &&*/ - at[i].bond_type[i1] == BOND_TYPE_SINGLE && - ion_el_group( at[n].el_number ) == EL_NUMBER_N) + if (-1 == at[n].charge && 2 >= nNoMetalNumBonds(at, n) && + 2 == nNoMetalBondsValence(at, n) + NUMH(at, n) && + /*0 == num_of_H( at, n ) &&*/ + at[i].bond_type[i1] == BOND_TYPE_SINGLE && + ion_el_group(at[n].el_number) == EL_NUMBER_N) { /* found O(+)(III)=N(-)(II); prepare conversion to O(IV)#N(III) */ num_neigh++; @@ -1761,17 +1787,17 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (1 == num_neigh && - !has_other_ion_neigh( at, i, n = at[i].neighbor[i1 = pos_neigh]) && - !has_other_ion_neigh( at, n, i)) + !has_other_ion_neigh(at, i, n = at[i].neighbor[i1 = pos_neigh]) && + !has_other_ion_neigh(at, n, i)) { /*n = at[i].neighbor[i1=pos_neigh];*/ - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].charge--; at[n].charge++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; num_changes++; num_N_minus--; num_O_plus--; @@ -1798,42 +1824,42 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) */ - if (( !type || 16 == type ) && 0 < num_C_plus && 0 < num_N_minus) + if ((!type || 16 == type) && 0 < num_C_plus && 0 < num_N_minus) { int m[2], j[2], k; for (i = 0; i < num_atoms; i++) { - if (0 == at[i].charge && 2 == nNoMetalNumBonds( at, i ) && 2 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - 0 <= ( j[0] = nNoMetalNeighIndex( at, i ) ) && - at[m[0] = at[i].neighbor[j[0]]].charge && - 0 <= ( j[1] = nNoMetalOtherNeighIndex( at, i, m[0] ) ) && - 0 == at[m[0]].charge + at[m[1] = at[i].neighbor[j[1]]].charge && - 5 >= nNoMetalBondsValence( at, m[0] ) + nNoMetalBondsValence( at, m[1] ) && - /*5 >= at[m[0]].chem_bonds_valence + at[m[1]].chem_bonds_valence &&*/ - ion_el_group( at[i].el_number ) == EL_NUMBER_O) + if (0 == at[i].charge && 2 == nNoMetalNumBonds(at, i) && 2 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + 0 <= (j[0] = nNoMetalNeighIndex(at, i)) && + at[m[0] = at[i].neighbor[j[0]]].charge && + 0 <= (j[1] = nNoMetalOtherNeighIndex(at, i, m[0])) && + 0 == at[m[0]].charge + at[m[1] = at[i].neighbor[j[1]]].charge && + 5 >= nNoMetalBondsValence(at, m[0]) + nNoMetalBondsValence(at, m[1]) && + /*5 >= at[m[0]].chem_bonds_valence + at[m[1]].chem_bonds_valence &&*/ + ion_el_group(at[i].el_number) == EL_NUMBER_O) { /* found non-terminal A(+)-O-B(-); chem_bond_val of A+B <= 5 */ int n_N = -1, n_C = -1, i_C = -1; for (k = 0; k < 2; k++) { n = m[k]; - if (-1 == at[n].charge && 2 == nNoMetalNumBonds( at, n ) + NUMH( at, n ) && - /*0 == num_of_H( at, n ) &&*/ - ion_el_group( at[n].el_number ) == EL_NUMBER_N) + if (-1 == at[n].charge && 2 == nNoMetalNumBonds(at, n) + NUMH(at, n) && + /*0 == num_of_H( at, n ) &&*/ + ion_el_group(at[n].el_number) == EL_NUMBER_N) { n_N = n; } - else if (1 == at[n].charge && 3 == at[n].chem_bonds_valence + NUMH( at, n ) && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + else if (1 == at[n].charge && 3 == at[n].chem_bonds_valence + NUMH(at, n) && + ion_el_group(at[n].el_number) == EL_NUMBER_C) { n_C = n; i_C = k; } } if (n_C < 0 || n_N < 0 || - has_other_ion_in_sphere_2( at, n_C, n_N) || - has_other_ion_in_sphere_2( at, n_N, n_C)) + has_other_ion_in_sphere_2(at, n_C, n_N) || + has_other_ion_in_sphere_2(at, n_N, n_C)) { continue; } @@ -1843,12 +1869,12 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) { n = k ? n_C : n_N; i1 = k ? j[i_C] : j[1 - i_C]; - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[n].charge += ( k ? -1 : 1 ); + at[n].charge += (k ? -1 : 1); } num_changes++; num_N_minus--; @@ -1858,24 +1884,20 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } - if (( !type || 17 == type ) && 0 < num_C_plus && 0 < num_C_minus) + if ((!type || 17 == type) && 0 < num_C_plus && 0 < num_C_minus) { int m[3], c[3], j[3], k; for (i = 0; i < num_atoms; i++) { - if (0 == at[i].charge && 3 == nNoMetalNumBonds( at, i ) && 3 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - 0 <= ( j[0] = nNoMetalNeighIndex( at, i ) ) && - 0 <= ( j[1] = nNoMetalOtherNeighIndex( at, i, m[0] = at[i].neighbor[j[0]] ) ) && - 0 <= ( j[2] = nNoMetalOtherNeighIndex2( at, i, m[0], m[1] = at[i].neighbor[j[1]] ) ) && - 1 == !( c[0] = at[m[0]].charge ) - + !( c[1] = at[m[1]].charge ) - + !( c[2] = at[m[2] = at[i].neighbor[j[2]]].charge ) && - 0 == c[0] + c[1] + c[2] && - 2 == ( 3 == ( c[0] ? at[m[0]].chem_bonds_valence + NUMH( at, m[0] ) : 0 ) ) - + ( 3 == ( c[1] ? at[m[1]].chem_bonds_valence + NUMH( at, m[1] ) : 0 ) ) - + ( 3 == ( c[2] ? at[m[2]].chem_bonds_valence + NUMH( at, m[2] ) : 0 ) ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_N) + if (0 == at[i].charge && 3 == nNoMetalNumBonds(at, i) && 3 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + 0 <= (j[0] = nNoMetalNeighIndex(at, i)) && + 0 <= (j[1] = nNoMetalOtherNeighIndex(at, i, m[0] = at[i].neighbor[j[0]])) && + 0 <= (j[2] = nNoMetalOtherNeighIndex2(at, i, m[0], m[1] = at[i].neighbor[j[1]])) && + 1 == !(c[0] = at[m[0]].charge) + !(c[1] = at[m[1]].charge) + !(c[2] = at[m[2] = at[i].neighbor[j[2]]].charge) && + 0 == c[0] + c[1] + c[2] && + 2 == (3 == (c[0] ? at[m[0]].chem_bonds_valence + NUMH(at, m[0]) : 0)) + (3 == (c[1] ? at[m[1]].chem_bonds_valence + NUMH(at, m[1]) : 0)) + (3 == (c[2] ? at[m[2]].chem_bonds_valence + NUMH(at, m[2]) : 0)) && + ion_el_group(at[i].el_number) == EL_NUMBER_N) { /* found non-terminal A(+)-O-B(-) */ int n_Cp = -1, n_Cm = -1, i_Cp = -1, i_Cm = -1; /* p = positive, m = negatice ion C */ @@ -1885,13 +1907,13 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) { n = m[k]; if (-1 == at[n].charge && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + ion_el_group(at[n].el_number) == EL_NUMBER_C) { n_Cm = n; i_Cm = k; } else if (1 == at[n].charge && - ion_el_group( at[n].el_number ) == EL_NUMBER_C) + ion_el_group(at[n].el_number) == EL_NUMBER_C) { n_Cp = n; i_Cp = k; @@ -1899,8 +1921,8 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } if (n_Cp < 0 || n_Cm < 0 || - has_other_ion_in_sphere_2( at, n_Cp, n_Cm) || - has_other_ion_in_sphere_2( at, n_Cm, n_Cp)) + has_other_ion_in_sphere_2(at, n_Cp, n_Cm) || + has_other_ion_in_sphere_2(at, n_Cm, n_Cp)) { continue; } @@ -1911,12 +1933,12 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) { n = k ? n_Cp : n_Cm; i1 = k ? j[i_Cp] : j[i_Cm]; - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); - at[i].bond_type[i1] ++; - at[n].bond_type[i2] ++; + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); + at[i].bond_type[i1]++; + at[n].bond_type[i2]++; at[i].chem_bonds_valence++; at[n].chem_bonds_valence++; - at[n].charge += ( k ? -1 : 1 ); + at[n].charge += (k ? -1 : 1); } num_changes++; num_C_minus--; @@ -1926,23 +1948,21 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } } - if (( !type || 18 == type ) && ( (0 < num_C_plus && 0 < num_C_minus) || 0 < num_C_II )) /* djb-rwth: addressing LLVM warning */ + if ((!type || 18 == type) && ((0 < num_C_plus && 0 < num_C_minus) || 0 < num_C_II)) /* djb-rwth: addressing LLVM warning */ { int m[2], v[2], j[2], k; for (i = 0; i < num_atoms; i++) { - if (0 == at[i].charge && 2 == nNoMetalNumBonds( at, i ) && 3 == nNoMetalBondsValence( at, i ) && - 0 == num_of_H( at, i ) && - 0 <= ( j[0] = nNoMetalNeighIndex( at, i ) ) && - 0 <= ( j[1] = nNoMetalOtherNeighIndex( at, i, m[0] = at[i].neighbor[j[0]] ) ) && - 0 == at[m[0]].charge - + at[m[1] = at[i].neighbor[j[1]]].charge && - 6 == ( v[0] = at[m[0]].chem_bonds_valence + NUMH( at, m[0] ) ) - + ( v[1] = at[m[1]].chem_bonds_valence + NUMH( at, m[1] ) ) && - 2 >= abs( v[0] - v[1] ) && - ion_el_group( at[i].el_number ) == EL_NUMBER_N && - ion_el_group( at[m[0]].el_number ) == EL_NUMBER_C && - ion_el_group( at[m[1]].el_number ) == EL_NUMBER_C) + if (0 == at[i].charge && 2 == nNoMetalNumBonds(at, i) && 3 == nNoMetalBondsValence(at, i) && + 0 == num_of_H(at, i) && + 0 <= (j[0] = nNoMetalNeighIndex(at, i)) && + 0 <= (j[1] = nNoMetalOtherNeighIndex(at, i, m[0] = at[i].neighbor[j[0]])) && + 0 == at[m[0]].charge + at[m[1] = at[i].neighbor[j[1]]].charge && + 6 == (v[0] = at[m[0]].chem_bonds_valence + NUMH(at, m[0])) + (v[1] = at[m[1]].chem_bonds_valence + NUMH(at, m[1])) && + 2 >= abs(v[0] - v[1]) && + ion_el_group(at[i].el_number) == EL_NUMBER_N && + ion_el_group(at[m[0]].el_number) == EL_NUMBER_C && + ion_el_group(at[m[1]].el_number) == EL_NUMBER_C) { /* n_Cm i n_Cp */ /* found non-terminal C(-)(III)-N=C(+)(III) or C(IV)=N-C(II): Cm-N-Cp */ @@ -1962,7 +1982,7 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) i_Cp = k; } } - if (n_Cp < 0 || n_Cm < 0 || at[n_Cp].valence + NUMH( at, n_Cp ) != 2) + if (n_Cp < 0 || n_Cm < 0 || at[n_Cp].valence + NUMH(at, n_Cp) != 2) { continue; /* guarantees at[n_Cp].valence <= 2 */ } @@ -1972,7 +1992,7 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) { /* neighbor of at[n_Cp] opposite to at[i] */ k = at[n_Cp].neighbor[at[n_Cp].neighbor[0] == i]; - if (ion_el_group( at[k].el_number ) == EL_NUMBER_N) + if (ion_el_group(at[k].el_number) == EL_NUMBER_N) { continue; } @@ -1980,8 +2000,8 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) } else if (at[n_Cp].charge) { - if (has_other_ion_in_sphere_2( at, n_Cp, n_Cm) || - has_other_ion_in_sphere_2( at, n_Cm, n_Cp)) + if (has_other_ion_in_sphere_2(at, n_Cp, n_Cm) || + has_other_ion_in_sphere_2(at, n_Cm, n_Cp)) { continue; } @@ -2009,14 +2029,14 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) for (k = 0; k < 2; k++) { n = k ? n_Cp : n_Cm; - i3 = k ? i_Cp : i_Cm; /* added to fix the bug */ - /*i1 = k? j[i_Cp] : j[i_Cm];*/ /* replaced with next line */ + i3 = k ? i_Cp : i_Cm; /* added to fix the bug */ + /*i1 = k? j[i_Cp] : j[i_Cm];*/ /* replaced with next line */ i1 = j[i3]; if (v[i3 /*was i1*/] < 4) { /* WDI found a bug here: bounds violation */ int delta = 4 - v[i3 /*was i1*/]; - i2 = (int) ( is_in_the_list( at[n].neighbor, (AT_NUMB) i, at[n].valence ) - at[n].neighbor ); + i2 = (int)(is_in_the_list(at[n].neighbor, (AT_NUMB)i, at[n].valence) - at[n].neighbor); at[i].bond_type[i1] += delta; at[n].bond_type[i2] += delta; at[i].chem_bonds_valence += delta; @@ -2036,19 +2056,15 @@ int remove_ion_pairs( int num_atoms, inp_ATOM *at ) return num_changes; } - - - /*#if ( DISCONNECT_SALTS == 1 )*/ /* { */ - - /****************************************************************************/ -int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) +/****************************************************************************/ +int RemoveInpAtBond(inp_ATOM *atom, int iat, int k) { - int i, j, m, m2; /* djb-rwth: removing redundant variables */ + int i, j, m, m2; /* djb-rwth: removing redundant variables */ inp_ATOM *at = atom + iat; inp_ATOM *at2 = NULL; - int val = at->valence - 1; + int val = at->valence - 1; if (val >= 0) { @@ -2056,7 +2072,7 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) if (bond > BOND_TYPE_TRIPLE) bond = BOND_TYPE_SINGLE; /* added 08-06-2003 */ - /* update CML tetrahedral atom parity. */ + /* update CML tetrahedral atom parity. */ if (at->p_parity) { for (m = 0; m < MAX_NUM_STEREO_ATOM_NEIGH; m++) @@ -2072,7 +2088,7 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) /* p_orig_at_num is a fixed size array of MAX_NUM_STEREO_ATOM_NEIGH (4) elements */ for (m = 0; m < at->valence && m < MAX_NUM_STEREO_ATOM_NEIGH; m++) /* djb-rwth: fixing GH PR #72 */ { - if (atom[(int) at->neighbor[k]].orig_at_number == at->p_orig_at_num[m]) + if (atom[(int)at->neighbor[k]].orig_at_number == at->p_orig_at_num[m]) { break; } @@ -2088,19 +2104,18 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) } } - /* update CML stereogenic bond parities; at this point no removed explicit H exist yet */ if (at->sb_parity[0]) { - for (m = 0; m < MAX_NUM_STEREO_BONDS && at->sb_parity[m]; ) + for (m = 0; m < MAX_NUM_STEREO_BONDS && at->sb_parity[m];) { - if (k == at->sb_ord[m] || (k == at->sn_ord[m] && val < 2 && ATOM_PARITY_WELL_DEF( at->sb_parity[m] ))) /* djb-rwth: addressing LLVM warning */ + if (k == at->sb_ord[m] || (k == at->sn_ord[m] && val < 2 && ATOM_PARITY_WELL_DEF(at->sb_parity[m]))) /* djb-rwth: addressing LLVM warning */ { /* !!! FLAW: does take into account removed H !!! */ /* stereogenic bond is being removed OR */ /* remove stereogenic bond because its only neighbor is being removed */ int pnxt_atom, pinxt2cur, pinxt_sb_parity_ord; - int len = get_opposite_sb_atom( atom, iat, at->sb_ord[m], &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord ); + int len = get_opposite_sb_atom(atom, iat, at->sb_ord[m], &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord); if (len) { i = pinxt_sb_parity_ord; @@ -2125,9 +2140,9 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) /* remove bond parity from at */ if (m < MAX_NUM_STEREO_BONDS - 1) { - memmove(at->sb_parity + m, at->sb_parity + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sb_parity[0])); /* djb-rwth: cast operator added */ - memmove(at->sb_ord + m, at->sb_ord + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sb_ord[0])); /* djb-rwth: cast operator added */ - memmove(at->sn_ord + m, at->sn_ord + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sn_ord[0])); /* djb-rwth: cast operator added */ + memmove(at->sb_parity + m, at->sb_parity + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sb_parity[0])); /* djb-rwth: cast operator added */ + memmove(at->sb_ord + m, at->sb_ord + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sb_ord[0])); /* djb-rwth: cast operator added */ + memmove(at->sn_ord + m, at->sn_ord + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sn_ord[0])); /* djb-rwth: cast operator added */ memmove(at->sn_orig_at_num + m, at->sn_orig_at_num + m + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m) * sizeof(at->sn_orig_at_num[0])); /* djb-rwth: cast operator added */ } at->sb_parity[MAX_NUM_STEREO_BONDS - 1] = 0; @@ -2137,9 +2152,9 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) /* remove bond parity from at2 */ if (m2 < MAX_NUM_STEREO_BONDS - 1) { - memmove(at2->sb_parity + m2, at2->sb_parity + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sb_parity[0])); /* djb-rwth: cast operator added */ - memmove(at2->sb_ord + m2, at2->sb_ord + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sb_ord[0])); /* djb-rwth: cast operator added */ - memmove(at2->sn_ord + m2, at2->sn_ord + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sn_ord[0])); /* djb-rwth: cast operator added */ + memmove(at2->sb_parity + m2, at2->sb_parity + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sb_parity[0])); /* djb-rwth: cast operator added */ + memmove(at2->sb_ord + m2, at2->sb_ord + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sb_ord[0])); /* djb-rwth: cast operator added */ + memmove(at2->sn_ord + m2, at2->sn_ord + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sn_ord[0])); /* djb-rwth: cast operator added */ memmove(at2->sn_orig_at_num + m2, at2->sn_orig_at_num + m2 + 1, (MAX_NUM_STEREO_BONDS - 1 - (long long)m2) * sizeof(at2->sn_orig_at_num[0])); /* djb-rwth: cast operator added */ } at2->sb_parity[MAX_NUM_STEREO_BONDS - 1] = 0; @@ -2168,31 +2183,31 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) /* i is the position of the neighbor that will become a new neighbor */ /*************************************************************************** - * at->sb_parity[m] is the direction (EVEN=clockwise, ODD=counterclockwise) - * from stereobond to the neighbor. If the neighbor is removed then - * the parity should invert, otherwise it should be unchanged. - ***************************************************************************/ + * at->sb_parity[m] is the direction (EVEN=clockwise, ODD=counterclockwise) + * from stereobond to the neighbor. If the neighbor is removed then + * the parity should invert, otherwise it should be unchanged. + ***************************************************************************/ if (i < 0) { /* no alternative neighbor is available */ - if (ATOM_PARITY_WELL_DEF( at->sb_parity[m] )) + if (ATOM_PARITY_WELL_DEF(at->sb_parity[m])) { /* parity cannot be not well-defined anymore */ int pnxt_atom, pinxt2cur, pinxt_sb_parity_ord; - int len = get_opposite_sb_atom( atom, iat, at->sb_ord[m], &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord ); + int len = get_opposite_sb_atom(atom, iat, at->sb_ord[m], &pnxt_atom, &pinxt2cur, &pinxt_sb_parity_ord); if (len > 0) { atom[pnxt_atom].sb_parity[pinxt_sb_parity_ord] = at->sb_parity[m] = AB_PARITY_UNDF; } } - at->sn_ord[m] = -99; /* sb neighbor has been disconnected */ - at->sb_ord[m] -= ( at->sb_ord[m] > k ); /* same as above */ + at->sn_ord[m] = -99; /* sb neighbor has been disconnected */ + at->sb_ord[m] -= (at->sb_ord[m] > k); /* same as above */ at->sn_orig_at_num[m] = 0; } else if (i < at->valence) { /* choose another stereogenic bond neighbor, its ord. number is i before bond removal */ - if (ATOM_PARITY_WELL_DEF( at->sb_parity[m] )) + if (ATOM_PARITY_WELL_DEF(at->sb_parity[m])) { /* ALL WRONG: 'move' previous stereo bond neighbor to the last position (pos. 2 out of 0,1,2) */ /* the parity of the transpositions is (2 - at->sn_ord[m])%2 = at->sn_ord[m] % 2 */ @@ -2205,9 +2220,9 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) /*=== parity should be INVERTED ===*/ at->sb_parity[m] = 3 - at->sb_parity[m]; } - at->sn_ord[m] = i - ( i > k ); /* ord. number shifted because preceding bond is removed */ - at->sb_ord[m] -= ( at->sb_ord[m] > k ); /* same as above */ - at->sn_orig_at_num[m] = atom[(int) at->neighbor[i]].orig_at_number; + at->sn_ord[m] = i - (i > k); /* ord. number shifted because preceding bond is removed */ + at->sb_ord[m] -= (at->sb_ord[m] > k); /* same as above */ + at->sn_orig_at_num[m] = atom[(int)at->neighbor[i]].orig_at_number; /*at->sb_parity[m] = 2 - ( at->sb_parity[m] + 1 ) % 2;*/ } else @@ -2219,19 +2234,19 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) else { /* removing another neighbor, k: first move it to the last position (pos. 2 out of 0,1,2) */ - if (k < 2 && ATOM_PARITY_WELL_DEF( at->sb_parity[m] )) + if (k < 2 && ATOM_PARITY_WELL_DEF(at->sb_parity[m])) { /*at->sb_parity[m] = 2 - ( at->sb_parity[m] + k ) % 2;*/ /*at->sb_parity[m] = 2 - ( at->sb_parity[m] + (at->sn_ord[m] > k) + (at->sb_ord[m] > k) ) % 2;*/ - ;/*==== Parity should remain UNCHANGED ===*/ + ; /*==== Parity should remain UNCHANGED ===*/ } if (at->sb_ord[m] > k) { - at->sb_ord[m] --; + at->sb_ord[m]--; } if (at->sn_ord[m] > k) { - at->sn_ord[m] --; + at->sn_ord[m]--; } m++; } @@ -2240,9 +2255,9 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) if (k < val) { - memmove(at->neighbor + k, at->neighbor + k + 1, sizeof(at->neighbor[0])* ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ - memmove(at->bond_stereo + k, at->bond_stereo + k + 1, sizeof(at->bond_stereo[0])* ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ - memmove(at->bond_type + k, at->bond_type + k + 1, sizeof(at->bond_type[0])* ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ + memmove(at->neighbor + k, at->neighbor + k + 1, sizeof(at->neighbor[0]) * ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ + memmove(at->bond_stereo + k, at->bond_stereo + k + 1, sizeof(at->bond_stereo[0]) * ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ + memmove(at->bond_type + k, at->bond_type + k + 1, sizeof(at->bond_type[0]) * ((long long)val - (long long)k)); /* djb-rwth: cast operators added */ } at->neighbor[val] = 0; @@ -2256,12 +2271,11 @@ int RemoveInpAtBond( inp_ATOM *atom, int iat, int k ) return 0; } - /****************************************************************************/ -int DisconnectInpAtBond( inp_ATOM *at, - AT_NUMB *nOldCompNumber, - int iat, - int neigh_ord ) +int DisconnectInpAtBond(inp_ATOM *at, + AT_NUMB *nOldCompNumber, + int iat, + int neigh_ord) { int neigh, i, ret = 0; int component; @@ -2269,7 +2283,7 @@ int DisconnectInpAtBond( inp_ATOM *at, for (i = 0; i < at[neigh].valence; i++) { - if (iat == (int) at[neigh].neighbor[i]) + if (iat == (int)at[neigh].neighbor[i]) { break; } @@ -2277,8 +2291,8 @@ int DisconnectInpAtBond( inp_ATOM *at, if (i < at[neigh].valence) { - ret += RemoveInpAtBond( at, iat, neigh_ord ); - ret += RemoveInpAtBond( at, neigh, i ); + ret += RemoveInpAtBond(at, iat, neigh_ord); + ret += RemoveInpAtBond(at, neigh, i); if (nOldCompNumber && ret) { if ((component = at[iat].component)) /* djb-rwth: addressing LLVM warning */ @@ -2292,16 +2306,15 @@ int DisconnectInpAtBond( inp_ATOM *at, } } - return ( ret == 2 ); + return (ret == 2); } - /****************************************************************************/ -int bIsAmmoniumSalt( inp_ATOM *at, - int i, - int *piO, - int *pk, - S_CHAR *num_explicit_H ) +int bIsAmmoniumSalt(inp_ATOM *at, + int i, + int *piO, + int *pk, + S_CHAR *num_explicit_H) { /* NH4(+charge)-O(-charge)-C -> NH3 + HO-C; any charge including 0, */ /* any C except charged or radical F, Cl, Br, I */ @@ -2316,29 +2329,29 @@ int bIsAmmoniumSalt( inp_ATOM *at, /* check for NH4-O-C... -> NH3 + HO-C... */ val = at[i].valence; - num_impl_iso_H = NUM_ISO_H( at, i ); + num_impl_iso_H = NUM_ISO_H(at, i); num_non_iso_H = at[i].num_H; num_H = num_non_iso_H + num_impl_iso_H; if (val + num_H == 5) { int num_O = 0; - memset( num_explicit_H, 0, ( NUM_H_ISOTOPES + 1 ) * sizeof( num_explicit_H[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(num_explicit_H, 0, (NUM_H_ISOTOPES + 1) * sizeof(num_explicit_H[0])); /* djb-rwth: memset_s C11/Annex K variant? */ for (j = 0; j < val; j++) { /* looking for O: H4N-O-C... */ neigh = at[i].neighbor[j]; if (at[neigh].num_H || - (at[neigh].charge && ( at[neigh].el_number != EL_NUMBER_O || at[neigh].charge + at[i].charge )) || - (at[neigh].radical && at[neigh].radical != RADICAL_SINGLET)) /* djb-rwth: addressing LLVM warnings */ + (at[neigh].charge && (at[neigh].el_number != EL_NUMBER_O || at[neigh].charge + at[i].charge)) || + (at[neigh].radical && at[neigh].radical != RADICAL_SINGLET)) /* djb-rwth: addressing LLVM warnings */ { bDisconnect = 0; break; /* reject */ } if (at[neigh].el_number == EL_NUMBER_H && at[neigh].valence == 1 && - !at[neigh].charge && !at[neigh].radical) + !at[neigh].charge && !at[neigh].radical) { num_H++; /* at this point at[].num_H does not include explicit H count */ - num_non_iso_H += ( 0 == at[neigh].iso_atw_diff ); - num_explicit_H[at[neigh].iso_atw_diff] ++; /* explicit H on N */ + num_non_iso_H += (0 == at[neigh].iso_atw_diff); + num_explicit_H[at[neigh].iso_atw_diff]++; /* explicit H on N */ } else if (at[neigh].el_number == EL_NUMBER_O && at[neigh].valence == 2 && !num_O) { @@ -2347,22 +2360,23 @@ int bIsAmmoniumSalt( inp_ATOM *at, k = j; iC = at[iO].neighbor[at[iO].neighbor[0] == i]; if (at[iC].el_number != EL_NUMBER_C || /* - at[iC].num_H || - at[iC].chem_bonds_valence != 4 || */ - at[iC].charge || - (at[iC].radical && at[iC].radical != RADICAL_SINGLET) /*|| - at[iC].valence == at[iC].chem_bonds_valence*/) /* djb-rwth: addressing LLVM warning */ + at[iC].num_H || + at[iC].chem_bonds_valence != 4 || */ + at[iC].charge || + (at[iC].radical && at[iC].radical != RADICAL_SINGLET) /*|| + at[iC].valence == at[iC].chem_bonds_valence*/ + ) /* djb-rwth: addressing LLVM warning */ { bDisconnect = 0; break; /* reject */ } } - else if (( at[neigh].el_number == EL_NUMBER_F || - at[neigh].el_number == EL_NUMBER_CL || - at[neigh].el_number == EL_NUMBER_BR || - at[neigh].el_number == EL_NUMBER_I ) && - at[neigh].valence == 1 && at[neigh].chem_bonds_valence == 1 && - !at[neigh].charge && !NUMH( at, neigh ) && !num_O) + else if ((at[neigh].el_number == EL_NUMBER_F || + at[neigh].el_number == EL_NUMBER_CL || + at[neigh].el_number == EL_NUMBER_BR || + at[neigh].el_number == EL_NUMBER_I) && + at[neigh].valence == 1 && at[neigh].chem_bonds_valence == 1 && + !at[neigh].charge && !NUMH(at, neigh) && !num_O) { num_O++; /* found O: N-O- */ iO = neigh; @@ -2372,10 +2386,10 @@ int bIsAmmoniumSalt( inp_ATOM *at, else { bDisconnect = 0; - break; /* reject */ + break; /* reject */ } } - if (bDisconnect && ( num_O != 1 || num_H != 4 )) + if (bDisconnect && (num_O != 1 || num_H != 4)) { bDisconnect = 0; /* reject */ } @@ -2393,13 +2407,12 @@ int bIsAmmoniumSalt( inp_ATOM *at, return bDisconnect; } - /****************************************************************************/ -int DisconnectAmmoniumSalt( inp_ATOM *at, - int iN, - int iO, - int k, - S_CHAR *num_explicit_H ) +int DisconnectAmmoniumSalt(inp_ATOM *at, + int iN, + int iO, + int k, + S_CHAR *num_explicit_H) { /* disconnect NH4-O from O */ @@ -2407,17 +2420,17 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, int nMove_H_iso_diff = -1; /* do not move explicit H */ int j, neigh, iso_diff, neigh_pos; - int val = at[iN].valence; + int val = at[iN].valence; - if (at[iN].charge && !( at[iN].charge + at[iO].charge )) + if (at[iN].charge && !(at[iN].charge + at[iO].charge)) { at[iN].charge = at[iO].charge = 0; /* remove charges */ } - neigh_pos = ( at[iO].valence == 2 ) ? ( at[iO].neighbor[1] == iN ) : 0; /* position of at[iN] in the neigh list of iO */ - /* disconnect bond O-N */ - RemoveInpAtBond( at, iO, neigh_pos ); - RemoveInpAtBond( at, iN, k ); + neigh_pos = (at[iO].valence == 2) ? (at[iO].neighbor[1] == iN) : 0; /* position of at[iN] in the neigh list of iO */ + /* disconnect bond O-N */ + RemoveInpAtBond(at, iO, neigh_pos); + RemoveInpAtBond(at, iN, k); val--; /* move 1 H from NH4 to O- or Cl */ @@ -2430,7 +2443,7 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, /* find non-isotopic H */ if (at[iN].num_H) { - at[iN].num_H--; /* move non-isotopic implicit H */ + at[iN].num_H--; /* move non-isotopic implicit H */ at[iO].num_H++; break; } @@ -2446,8 +2459,8 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, /* num_iso_H has length NUM_H_ISOTOPES; do not access out-of-bounds */ if ((iso_diff < NUM_H_ISOTOPES) && at[iN].num_iso_H[iso_diff]) /* djb-rwth: fixing GH PR #72 */ { - at[iN].num_iso_H[iso_diff] --; /* move implicit isotopic H, atw = 1 */ - at[iO].num_iso_H[iso_diff] ++; + at[iN].num_iso_H[iso_diff]--; /* move implicit isotopic H, atw = 1 */ + at[iO].num_iso_H[iso_diff]++; break; } else @@ -2465,16 +2478,16 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, { /* move explicit H, it is isotopic if nMove_H_iso_diff > 0 */ double dist2_H_O, min_dist2_H_O = -1.0; - int jH = -1, iH = -1; + int jH = -1, iH = -1; for (j = 0; j < val; j++) { /* looking H in N-H such that H-O is shortest */ neigh = at[iN].neighbor[j]; if (at[neigh].el_number == EL_NUMBER_H && - at[neigh].iso_atw_diff == nMove_H_iso_diff) + at[neigh].iso_atw_diff == nMove_H_iso_diff) { - dist2_H_O = ( at[neigh].x - at[iO].x ) * ( at[neigh].x - at[iO].x ) + - ( at[neigh].y - at[iO].y ) * ( at[neigh].y - at[iO].y ) + - ( at[neigh].z - at[iO].z ) * ( at[neigh].z - at[iO].z ); + dist2_H_O = (at[neigh].x - at[iO].x) * (at[neigh].x - at[iO].x) + + (at[neigh].y - at[iO].y) * (at[neigh].y - at[iO].y) + + (at[neigh].z - at[iO].z) * (at[neigh].z - at[iO].z); if (min_dist2_H_O < 0.0 || min_dist2_H_O > dist2_H_O) { min_dist2_H_O = dist2_H_O; @@ -2495,7 +2508,7 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, at[iH].bond_stereo[0] = 0; /* disconnect H from N */ - RemoveInpAtBond( at, iN, jH ); + RemoveInpAtBond(at, iN, jH); val--; if (k > jH) { @@ -2506,23 +2519,22 @@ int DisconnectAmmoniumSalt( inp_ATOM *at, return 1; } - /****************************************************************************/ -int bIsMetalSalt( inp_ATOM *at, int i ) +int bIsMetalSalt(inp_ATOM *at, int i) { int type, val, k, iO, iC, j, neigh; int bDisconnect = 1; /* check for a metal atom: metal atom should be connected and be a metal */ - if (!( val = at[i].valence ) || - !( type = get_el_type( at[i].el_number ) ) || - !( type & IS_METAL )) + if (!(val = at[i].valence) || + !(type = get_el_type(at[i].el_number)) || + !(type & IS_METAL)) { - bDisconnect = 0; /* reject */ + bDisconnect = 0; /* reject */ } else if (at[i].num_H) - /* metal atom should not have adjacent H or multiple bonds or radical */ + /* metal atom should not have adjacent H or multiple bonds or radical */ { bDisconnect = 0; /* reject */ } @@ -2530,10 +2542,10 @@ int bIsMetalSalt( inp_ATOM *at, int i ) { /* check valence */ if ((at[i].charge == 0 && - ( (( type & 1 ) && val == get_el_valence( at[i].el_number, 0, 0 )) || - (( type & 2 ) && val == get_el_valence( at[i].el_number, 0, 1 ) ))) || - (at[i].charge > 0 && - ( type & 1 ) && val == get_el_valence( at[i].el_number, at[i].charge, 0 ))) /* djb-rwth: addressing LLVM warnings */ + (((type & 1) && val == get_el_valence(at[i].el_number, 0, 0)) || + ((type & 2) && val == get_el_valence(at[i].el_number, 0, 1)))) || + (at[i].charge > 0 && + (type & 1) && val == get_el_valence(at[i].el_number, at[i].charge, 0))) /* djb-rwth: addressing LLVM warnings */ { ; /* accept */ } @@ -2546,20 +2558,20 @@ int bIsMetalSalt( inp_ATOM *at, int i ) if (bDisconnect) { /************************************************************************* - * | * - * check M neighbors. Disconnect if all neighbors are M-O-C# or M-O-C= * - * | * - *************************************************************************/ + * | * + * check M neighbors. Disconnect if all neighbors are M-O-C# or M-O-C= * + * | * + *************************************************************************/ for (k = 0; k < at[i].valence; k++) { iO = at[i].neighbor[k]; /* halogenide 2004-07-08 */ - if (( at[iO].el_number == EL_NUMBER_F || - at[iO].el_number == EL_NUMBER_CL || - at[iO].el_number == EL_NUMBER_BR || - at[iO].el_number == EL_NUMBER_I ) && - at[iO].valence == 1 && at[iO].chem_bonds_valence == 1 && - !at[iO].charge && !( at[iO].radical && at[iO].radical != RADICAL_SINGLET ) && !NUMH( at, iO )) + if ((at[iO].el_number == EL_NUMBER_F || + at[iO].el_number == EL_NUMBER_CL || + at[iO].el_number == EL_NUMBER_BR || + at[iO].el_number == EL_NUMBER_I) && + at[iO].valence == 1 && at[iO].chem_bonds_valence == 1 && + !at[iO].charge && !(at[iO].radical && at[iO].radical != RADICAL_SINGLET) && !NUMH(at, iO)) { ; /* found */ } @@ -2567,22 +2579,22 @@ int bIsMetalSalt( inp_ATOM *at, int i ) { /* -O-C= */ if (at[iO].el_number != EL_NUMBER_O || - NUMH( at, iO ) || - at[iO].valence != 2 || - at[iO].charge || - (at[iO].radical && at[iO].radical != RADICAL_SINGLET) || - at[iO].valence != at[iO].chem_bonds_valence) /* djb-rwth: addressing LLVM warning */ + NUMH(at, iO) || + at[iO].valence != 2 || + at[iO].charge || + (at[iO].radical && at[iO].radical != RADICAL_SINGLET) || + at[iO].valence != at[iO].chem_bonds_valence) /* djb-rwth: addressing LLVM warning */ { bDisconnect = 0; /* reject */ break; } iC = at[iO].neighbor[at[iO].neighbor[0] == i]; if (at[iC].el_number != EL_NUMBER_C || - at[iC].num_H || - at[iC].chem_bonds_valence != 4 || - at[iC].charge || - (at[iC].radical && at[iC].radical != RADICAL_SINGLET) || - at[iC].valence == at[iC].chem_bonds_valence) /* djb-rwth: addressing LLVM warning */ + at[iC].num_H || + at[iC].chem_bonds_valence != 4 || + at[iC].charge || + (at[iC].radical && at[iC].radical != RADICAL_SINGLET) || + at[iC].valence == at[iC].chem_bonds_valence) /* djb-rwth: addressing LLVM warning */ { bDisconnect = 0; /* reject */ break; @@ -2607,9 +2619,8 @@ int bIsMetalSalt( inp_ATOM *at, int i ) return bDisconnect; } - /****************************************************************************/ -int DisconnectMetalSalt( inp_ATOM *at, int i ) +int DisconnectMetalSalt(inp_ATOM *at, int i) { int k, iO; /* disconnect metal atom or ion at[i] */ @@ -2663,12 +2674,11 @@ int DisconnectMetalSalt( inp_ATOM *at, int i ) return k; } - /****************************************************************************/ -int DisconnectSalts( ORIG_ATOM_DATA *orig_inp_data, int bDisconnect ) +int DisconnectSalts(ORIG_ATOM_DATA *orig_inp_data, int bDisconnect) { int i, k, iO, num_changes, val; - S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; + S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; inp_ATOM *at = orig_inp_data->at; int num_at = orig_inp_data->num_inp_atoms; @@ -2676,29 +2686,29 @@ int DisconnectSalts( ORIG_ATOM_DATA *orig_inp_data, int bDisconnect ) for (i = 0, num_changes = 0; i < num_at; i++) { - if (!( val = at[i].valence ) || /* disconnected atom */ - val != at[i].chem_bonds_valence || /* a bond has higher multiplicity than 1 */ - (at[i].radical && at[i].radical != RADICAL_SINGLET) /* radical */) /* djb-rwth: addressing LLVM warning */ + if (!(val = at[i].valence) || /* disconnected atom */ + val != at[i].chem_bonds_valence || /* a bond has higher multiplicity than 1 */ + (at[i].radical && at[i].radical != RADICAL_SINGLET) /* radical */) /* djb-rwth: addressing LLVM warning */ { - continue; /* reject */ + continue; /* reject */ } - if (bIsAmmoniumSalt( at, i, &iO, &k, num_explicit_H )) + if (bIsAmmoniumSalt(at, i, &iO, &k, num_explicit_H)) { if (bDisconnect) { - DisconnectAmmoniumSalt( at, i, iO, k, num_explicit_H ); + DisconnectAmmoniumSalt(at, i, iO, k, num_explicit_H); orig_inp_data->num_inp_bonds--; } /* count disconnected atoms */ num_changes++; } - else if (bIsMetalSalt( at, i )) + else if (bIsMetalSalt(at, i)) { if (bDisconnect) { - k = DisconnectMetalSalt( at, i ); + k = DisconnectMetalSalt(at, i); orig_inp_data->num_inp_bonds -= k; } num_changes++; @@ -2708,7 +2718,6 @@ int DisconnectSalts( ORIG_ATOM_DATA *orig_inp_data, int bDisconnect ) return num_changes; } - /*****************************************************************************/ /* Important: Salt disconnection is independent from coord. disconnection: */ /* because different atoms are disconnected. */ @@ -2716,7 +2725,7 @@ int DisconnectSalts( ORIG_ATOM_DATA *orig_inp_data, int bDisconnect ) /* because metal disconnection may make certain atoms be eligible for salt */ /* disconnection */ /*****************************************************************************/ -int bIsMetalToDisconnect( inp_ATOM *at, int i, int bCheckMetalValence ) +int bIsMetalToDisconnect(inp_ATOM *at, int i, int bCheckMetalValence) { int type, at_valence, num_H; @@ -2724,13 +2733,13 @@ int bIsMetalToDisconnect( inp_ATOM *at, int i, int bCheckMetalValence ) if ( !at[i].valence ) */ - if (!( type = get_el_type( at[i].el_number ) ) || - !( type & IS_METAL )) + if (!(type = get_el_type(at[i].el_number)) || + !(type & IS_METAL)) { return 0; } - num_H = NUMH( at, i ); + num_H = NUMH(at, i); at_valence = num_H + at[i].chem_bonds_valence; if (!at_valence) @@ -2740,14 +2749,14 @@ int bIsMetalToDisconnect( inp_ATOM *at, int i, int bCheckMetalValence ) if (bCheckMetalValence) { - if (abs( at[i].charge ) > 1) + if (abs(at[i].charge) > 1) { return 1; /* multiple charges */ } - for (i = 0; i < 2 && ( i & type ); i++) + for (i = 0; i < 2 && (i & type); i++) { - if (at_valence == get_el_valence( at[i].el_number, at[i].charge, i )) + if (at_valence == get_el_valence(at[i].el_number, at[i].charge, i)) { return 2; /* atom has normal valence */ } @@ -2757,14 +2766,13 @@ int bIsMetalToDisconnect( inp_ATOM *at, int i, int bCheckMetalValence ) return 1; } - /****************************************************************************/ -int bMayDisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, - int bCheckMetalValence, - INCHI_MODE *bTautFlagsDone ) +int bMayDisconnectMetals(ORIG_ATOM_DATA *orig_inp_data, + int bCheckMetalValence, + INCHI_MODE *bTautFlagsDone) { int i, j, k, iO, num_changes, val, bRadOrMultBonds, num_impl_H = 0; - S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; + S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; inp_ATOM *at = orig_inp_data->at; int num_at = orig_inp_data->num_inp_atoms; int *nNumImplH = &orig_inp_data->bDisconnectCoord; @@ -2773,26 +2781,26 @@ int bMayDisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, for (i = 0, num_changes = 0; i < num_at; i++) { - if (!( val = at[i].valence ) && !NUMH( at, i )) + if (!(val = at[i].valence) && !NUMH(at, i)) { continue; /* disconnected atom */ } - bRadOrMultBonds = ( val == 0 ) || - ( val != at[i].chem_bonds_valence ) || /* a bond has higher multiplicity than 1 */ - ( at[i].radical && at[i].radical != RADICAL_SINGLET ); /* radical */ + bRadOrMultBonds = (val == 0) || + (val != at[i].chem_bonds_valence) || /* a bond has higher multiplicity than 1 */ + (at[i].radical && at[i].radical != RADICAL_SINGLET); /* radical */ - if (!bRadOrMultBonds && bIsAmmoniumSalt( at, i, &iO, &k, num_explicit_H )) + if (!bRadOrMultBonds && bIsAmmoniumSalt(at, i, &iO, &k, num_explicit_H)) { ; } - else if (!bRadOrMultBonds && bIsMetalSalt( at, i )) + else if (!bRadOrMultBonds && bIsMetalSalt(at, i)) { ; } - else if (1 == ( j = bIsMetalToDisconnect( at, i, bCheckMetalValence ) )) + else if (1 == (j = bIsMetalToDisconnect(at, i, bCheckMetalValence))) { - num_impl_H += NUMH( at, i ); + num_impl_H += NUMH(at, i); num_changes++; } else if (2 == j && bTautFlagsDone) @@ -2809,26 +2817,23 @@ int bMayDisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, return num_changes; } - /****************************************************************************/ - -#if ( bRELEASE_VERSION == 0 && (EXTR_HAS_METAL_ATOM & (EXTR_MASK | EXTR_FLAG) ) ) - +#if (bRELEASE_VERSION == 0 && (EXTR_HAS_METAL_ATOM & (EXTR_MASK | EXTR_FLAG))) /****************************************************************************/ -int bHasMetalAtom( ORIG_ATOM_DATA *orig_inp_data ) +int bHasMetalAtom(ORIG_ATOM_DATA *orig_inp_data) { int i; inp_ATOM *at; - if (orig_inp_data && ( at = orig_inp_data->at )) + if (orig_inp_data && (at = orig_inp_data->at)) { int num_at = orig_inp_data->num_inp_atoms; /* check each atom */ for (i = 0; i < num_at; i++) { - if (IS_METAL & get_el_type( at[i].el_number )) + if (IS_METAL & get_el_type(at[i].el_number)) { return 1; } @@ -2839,8 +2844,6 @@ int bHasMetalAtom( ORIG_ATOM_DATA *orig_inp_data ) } #endif - - /***************************************************************************** { "F", 19, 19, 18.998403220, 0 , 0, {{0,}, {0,}, {1,}, {2,}, {3,5}, },}, { "Cl", 35, 35, 34.968852730, 0 , 0, {{0,}, {0,}, {1,3,5,7}, {2,4,6}, {3,5,}, },}, @@ -2859,34 +2862,34 @@ int bHasMetalAtom( ORIG_ATOM_DATA *orig_inp_data ) { "B", 11, 11, 11.009300000, 0 , 0, {{3,}, {4,}, {3,}, {2,}, {1,}, },}, *****************************************************************************/ - - /****************************************************************************/ -int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, - int bCheckMetalValence, - INCHI_MODE *bTautFlagsDone ) +int DisconnectMetals(ORIG_ATOM_DATA *orig_inp_data, + int bCheckMetalValence, + INCHI_MODE *bTautFlagsDone) { int i, j, k, n, iO, num_changes, val, bRadOrMultBonds; int num_impl_H, num_at, err, num_disconnected; S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; - static char elnumber_Heteroat[16] = { '\0', }; - static int num_halogens = 0; + static char elnumber_Heteroat[16] = { + '\0', + }; + static int num_halogens = 0; int num_halogens2; - inp_ATOM *at = NULL; - S_CHAR *bMetal = NULL; - inp_ATOM *atom = orig_inp_data->at; - int num_atoms = orig_inp_data->num_inp_atoms; - int nNumExplH = ( orig_inp_data->bDisconnectCoord > 0 ) ? orig_inp_data->bDisconnectCoord - 1 : 0; - AT_NUMB *nOldCompNumber = orig_inp_data->nOldCompNumber; + inp_ATOM *at = NULL; + S_CHAR *bMetal = NULL; + inp_ATOM *atom = orig_inp_data->at; + int num_atoms = orig_inp_data->num_inp_atoms; + int nNumExplH = (orig_inp_data->bDisconnectCoord > 0) ? orig_inp_data->bDisconnectCoord - 1 : 0; + AT_NUMB *nOldCompNumber = orig_inp_data->nOldCompNumber; err = 0; num_impl_H = 0; num_at = num_atoms; num_disconnected = 0; - if (!( at = (inp_ATOM *) inchi_calloc( (long long)num_at + (long long)nNumExplH, sizeof( at[0] ) ) ) || /* djb-rwth: cast operators added */ - !( bMetal = (S_CHAR *) inchi_calloc( (long long)num_at + (long long)nNumExplH, sizeof( bMetal[0] ) ) )) /* djb-rwth: cast operators added */ + if (!(at = (inp_ATOM *)inchi_calloc((long long)num_at + (long long)nNumExplH, sizeof(at[0]))) || /* djb-rwth: cast operators added */ + !(bMetal = (S_CHAR *)inchi_calloc((long long)num_at + (long long)nNumExplH, sizeof(bMetal[0])))) /* djb-rwth: cast operators added */ { err = 1; goto exit_function; @@ -2896,23 +2899,23 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, { i = 0; /* halogens */ - elnumber_Heteroat[i++] = (char) EL_NUMBER_F; /* 0 */ - elnumber_Heteroat[i++] = (char) EL_NUMBER_CL; - elnumber_Heteroat[i++] = (char) EL_NUMBER_BR; - elnumber_Heteroat[i++] = (char) EL_NUMBER_I; - elnumber_Heteroat[i++] = (char) EL_NUMBER_AT; /* 4 */ + elnumber_Heteroat[i++] = (char)EL_NUMBER_F; /* 0 */ + elnumber_Heteroat[i++] = (char)EL_NUMBER_CL; + elnumber_Heteroat[i++] = (char)EL_NUMBER_BR; + elnumber_Heteroat[i++] = (char)EL_NUMBER_I; + elnumber_Heteroat[i++] = (char)EL_NUMBER_AT; /* 4 */ num_halogens2 = i; /* other non-metal */ - elnumber_Heteroat[i++] = (char) EL_NUMBER_N; - elnumber_Heteroat[i++] = (char) EL_NUMBER_P; - elnumber_Heteroat[i++] = (char) EL_NUMBER_AS; + elnumber_Heteroat[i++] = (char)EL_NUMBER_N; + elnumber_Heteroat[i++] = (char)EL_NUMBER_P; + elnumber_Heteroat[i++] = (char)EL_NUMBER_AS; /*elnumber_Heteroat[i++] = EL_NUMBER_SB;*/ /* metal 10-28-2003 */ - elnumber_Heteroat[i++] = (char) EL_NUMBER_O; - elnumber_Heteroat[i++] = (char) EL_NUMBER_S; - elnumber_Heteroat[i++] = (char) EL_NUMBER_SE; - elnumber_Heteroat[i++] = (char) EL_NUMBER_TE; + elnumber_Heteroat[i++] = (char)EL_NUMBER_O; + elnumber_Heteroat[i++] = (char)EL_NUMBER_S; + elnumber_Heteroat[i++] = (char)EL_NUMBER_SE; + elnumber_Heteroat[i++] = (char)EL_NUMBER_TE; /*elnumber_Heteroat[i++] = EL_NUMBER_PO;*/ /* metal 10-28-2003 */ - elnumber_Heteroat[i++] = (char) EL_NUMBER_B; + elnumber_Heteroat[i++] = (char)EL_NUMBER_B; elnumber_Heteroat[i++] = 0; num_halogens = num_halogens2; } @@ -2922,25 +2925,25 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, /* check each atom, mark metals */ for (i = 0, k = 0, num_changes = 0; i < num_atoms; i++) { - if (!( val = at[i].valence ) && !NUMH( at, i )) + if (!(val = at[i].valence) && !NUMH(at, i)) { continue; /* disconnected atom */ } - bRadOrMultBonds = ( val == 0 ) || - ( val != at[i].chem_bonds_valence ) || /* a bond has higher multiplicity than 1 */ - ( at[i].radical && at[i].radical != RADICAL_SINGLET ); /* radical */ + bRadOrMultBonds = (val == 0) || + (val != at[i].chem_bonds_valence) || /* a bond has higher multiplicity than 1 */ + (at[i].radical && at[i].radical != RADICAL_SINGLET); /* radical */ - if (!bRadOrMultBonds && bIsAmmoniumSalt( at, i, &iO, &k, num_explicit_H )) + if (!bRadOrMultBonds && bIsAmmoniumSalt(at, i, &iO, &k, num_explicit_H)) { ; } - else if (!bRadOrMultBonds && bIsMetalSalt( at, i )) + else if (!bRadOrMultBonds && bIsMetalSalt(at, i)) { ; } - else if (1 == ( j = bIsMetalToDisconnect( at, i, bCheckMetalValence ) )) + else if (1 == (j = bIsMetalToDisconnect(at, i, bCheckMetalValence))) { - num_impl_H += ( k = NUMH( at, i ) ); + num_impl_H += (k = NUMH(at, i)); bMetal[i] = 1 + k; num_changes++; } @@ -2974,17 +2977,17 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, goto exit_function; } at[num_at].elname[0] = 'H'; - at[num_at].el_number = get_periodic_table_number( at[num_at].elname ); + at[num_at].el_number = get_periodic_table_number(at[num_at].elname); at[num_at].iso_atw_diff = k; at[num_at].component = at[i].component; - move_explicit_Hcation( at, num_at + 1, i, num_at, 1 ); + move_explicit_Hcation(at, num_at + 1, i, num_at, 1); at[num_at].orig_at_number = num_at + 1; num_at++; num_impl_H--; - bMetal[i] --; + bMetal[i]--; if (k) { - at[i].num_iso_H[k - 1] --; + at[i].num_iso_H[k - 1]--; } else { @@ -3036,19 +3039,19 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, for (j = at[i].valence - 1; 0 <= j; j--) { - if (j < at[i].valence && !bMetal[(int) at[i].neighbor[j]]) + if (j < at[i].valence && !bMetal[(int)at[i].neighbor[j]]) { /* do not break metal-metal bond here */ - num_disconnected += DisconnectOneLigand( at, - nOldCompNumber, - bMetal, - elnumber_Heteroat, - num_halogens, - num_atoms, - i, - j, - bTautFlagsDone ); + num_disconnected += DisconnectOneLigand(at, + nOldCompNumber, + bMetal, + elnumber_Heteroat, + num_halogens, + num_atoms, + i, + j, + bTautFlagsDone); } } } @@ -3062,19 +3065,19 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, } for (j = at[i].valence - 1; 0 <= j; j--) { - if (j < at[i].valence && bMetal[(int) at[i].neighbor[j]]) + if (j < at[i].valence && bMetal[(int)at[i].neighbor[j]]) { /* break metal-metal bond here */ - num_disconnected += DisconnectOneLigand( at, - nOldCompNumber, - bMetal, - elnumber_Heteroat, - num_halogens, - num_atoms, - i, - j, - bTautFlagsDone ); + num_disconnected += DisconnectOneLigand(at, + nOldCompNumber, + bMetal, + elnumber_Heteroat, + num_halogens, + num_atoms, + i, + j, + bTautFlagsDone); } } } @@ -3087,16 +3090,16 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, } if (at && err) { - inchi_free( at ); + inchi_free(at); at = NULL; } if (atom && at) - { /* changed if ( at ) to if ( atom && at ) 2004-04-03 */ - inchi_free( atom ); + { /* changed if ( at ) to if ( atom && at ) 2004-04-03 */ + inchi_free(atom); atom = NULL; } if (bMetal) - inchi_free( bMetal ); + inchi_free(bMetal); if (at) { @@ -3107,17 +3110,16 @@ int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, return err ? -err : num_disconnected; } - /****************************************************************************/ -int DisconnectOneLigand( inp_ATOM *at, - AT_NUMB *nOldCompNumber, - S_CHAR *bMetal, - char *elnumber_Heteroat, - int num_halogens, - int num_atoms, - int iMetal, - int jLigand, - INCHI_MODE *bTautFlagsDone ) +int DisconnectOneLigand(inp_ATOM *at, + AT_NUMB *nOldCompNumber, + S_CHAR *bMetal, + char *elnumber_Heteroat, + int num_halogens, + int num_atoms, + int iMetal, + int jLigand, + INCHI_MODE *bTautFlagsDone) { int i, j, iLigand, neigh, val; int metal_neigh_ord[MAXVAL], num_neigh_arom_bonds[MAXVAL]; @@ -3134,7 +3136,7 @@ int DisconnectOneLigand( inp_ATOM *at, for (i = 0; i < at[iLigand].valence; i++) { num_neigh_arom_bonds[i] = 0; - neigh = (int) at[iLigand].neighbor[i]; + neigh = (int)at[iLigand].neighbor[i]; if (neigh < num_atoms && bMetal[neigh]) { metal_neigh_ord[num_metal_neigh++] = i; @@ -3143,12 +3145,12 @@ int DisconnectOneLigand( inp_ATOM *at, /* aromatic bond */ for (j = 0; j < at[neigh].valence; j++) { - num_neigh_arom_bonds[i] += ( at[neigh].bond_type[j] > BOND_TYPE_TRIPLE ); + num_neigh_arom_bonds[i] += (at[neigh].bond_type[j] > BOND_TYPE_TRIPLE); } num_del_arom_bonds++; } } - num_tot_arom_bonds += ( at[iLigand].bond_type[i] > BOND_TYPE_TRIPLE ); + num_tot_arom_bonds += (at[iLigand].bond_type[i] > BOND_TYPE_TRIPLE); } /* Disconnect */ @@ -3162,10 +3164,10 @@ int DisconnectOneLigand( inp_ATOM *at, if (num_neigh_arom_bonds[j]) { neigh = at[iLigand].neighbor[j]; - at[neigh].chem_bonds_valence -= num_neigh_arom_bonds[j] / 2 - ( num_neigh_arom_bonds[j] - 1 ) / 2; + at[neigh].chem_bonds_valence -= num_neigh_arom_bonds[j] / 2 - (num_neigh_arom_bonds[j] - 1) / 2; } } - at[iLigand].chem_bonds_valence -= num_tot_arom_bonds / 2 - ( num_tot_arom_bonds - num_del_arom_bonds ) / 2; + at[iLigand].chem_bonds_valence -= num_tot_arom_bonds / 2 - (num_tot_arom_bonds - num_del_arom_bonds) / 2; } /* disconnect in reverse order, otherwise the metal_neigh_ord[i] @@ -3173,22 +3175,22 @@ int DisconnectOneLigand( inp_ATOM *at, */ for (i = num_metal_neigh - 1; 0 <= i; i--) { - num_disconnections += DisconnectInpAtBond( at, - nOldCompNumber, - iLigand, - metal_neigh_ord[i] ); + num_disconnections += DisconnectInpAtBond(at, + nOldCompNumber, + iLigand, + metal_neigh_ord[i]); } /* attempt to change ligand charge to make its valence 'natural' */ i = num_tot_arom_bonds - num_del_arom_bonds; if ((i && i != 2 && i != 3) || - (at[iLigand].radical && at[iLigand].radical != RADICAL_SINGLET) || - !( p = strchr( elnumber_Heteroat, at[iLigand].el_number ) )) /* djb-rwth: addressing LLVM warnings */ + (at[iLigand].radical && at[iLigand].radical != RADICAL_SINGLET) || + !(p = strchr(elnumber_Heteroat, at[iLigand].el_number))) /* djb-rwth: addressing LLVM warnings */ { - goto exit_function; /* non-standard atom */ + goto exit_function; /* non-standard atom */ } - val = at[iLigand].chem_bonds_valence + NUMH( at, iLigand ); + val = at[iLigand].chem_bonds_valence + NUMH(at, iLigand); new_charge = MAX_ATOMS; /* impossible value */ if (!val) @@ -3202,7 +3204,7 @@ int DisconnectOneLigand( inp_ATOM *at, { for (i = -1; i <= 1; i++) { - if (val == get_el_valence( at[iLigand].el_number, i, 0 )) + if (val == get_el_valence(at[iLigand].el_number, i, 0)) { new_charge = i; /* found charge that fits chem. valence */ break; @@ -3212,13 +3214,13 @@ int DisconnectOneLigand( inp_ATOM *at, if (new_charge != MAX_ATOMS) { - if (( new_charge != at[iLigand].charge || - ( at[iLigand].radical && at[iLigand].radical != RADICAL_SINGLET ) ) && - 1 == num_metal_neigh) + if ((new_charge != at[iLigand].charge || + (at[iLigand].radical && at[iLigand].radical != RADICAL_SINGLET)) && + 1 == num_metal_neigh) { if (1 == new_charge && 4 == val && 2 == at[iLigand].valence && - 4 == at[iLigand].chem_bonds_valence && - at[iLigand].bond_type[0] == at[iLigand].bond_type[1]) + 4 == at[iLigand].chem_bonds_valence && + at[iLigand].bond_type[0] == at[iLigand].bond_type[1]) { ; /* do not add +1 charge to disconnected =N=, etc. 2004-10-27 */ } @@ -3240,38 +3242,35 @@ int DisconnectOneLigand( inp_ATOM *at, return num_disconnections; /* ret;*/ } - /****************************************************************************/ -double dist3D( inp_ATOM *at1, inp_ATOM *at2 ) +double dist3D(inp_ATOM *at1, inp_ATOM *at2) { double dx = at1->x - at2->x; double dy = at1->y - at2->y; double dz = at1->z - at2->z; - return sqrt( dx*dx + dy*dy + dz*dz ); + return sqrt(dx * dx + dy * dy + dz * dz); } - /****************************************************************************/ -#define MIN_BOND_LENGTH (1.0e-6) -#define MIN_COS (1.0e-6) -#define MIN_BOND_LENGTH2 (MIN_BOND_LENGTH*MIN_BOND_LENGTH) -#define MAX_BOND_LENGTH (1.0e30) +#define MIN_BOND_LENGTH (1.0e-6) +#define MIN_COS (1.0e-6) +#define MIN_BOND_LENGTH2 (MIN_BOND_LENGTH * MIN_BOND_LENGTH) +#define MAX_BOND_LENGTH (1.0e30) /****************************************************************************/ - /****************************************************************************/ -double GetMinDistDistribution( inp_ATOM *at, - int num_at, - int iat, - int iat_H, - int bInAllComponents, - double min_dist[], - int num_segm ) +double GetMinDistDistribution(inp_ATOM *at, + int num_at, + int iat, + int iat_H, + int bInAllComponents, + double min_dist[], + int num_segm) { /* const double one_pi = 2.0*atan2(1.0 , 0.0 ); */ const double one_pi = 3.14159265358979323846; /* M_PI */ - const double two_pi = 2.0*one_pi; + const double two_pi = 2.0 * one_pi; const double f_step = two_pi / num_segm; const double h_step = f_step / 2.0; int i, j, k, kk, ki, kn, n, num_bonds; @@ -3288,71 +3287,71 @@ double GetMinDistDistribution( inp_ATOM *at, for (i = 0; i < num_at; i++) { if (i != iat && i != iat_H && - ( bInAllComponents || at[i].component == at[iat].component )) + (bInAllComponents || at[i].component == at[iat].component)) { for (j = 0; j < at[i].valence; j++) { n = at[i].neighbor[j]; - if (( n > i && n != iat ) || n == iat_H) + if ((n > i && n != iat) || n == iat_H) { continue; } -#if ( bRELEASE_VERSION != 1 && defined(_DEBUG) ) +#if (bRELEASE_VERSION != 1 && defined(_DEBUG)) if (n == iat) { - int stop = 1; /* */ + int stop = 1; /* */ } #endif - xi = at[i].x - at[iat].x; /* ri; i != iat */ + xi = at[i].x - at[iat].x; /* ri; i != iat */ yi = at[i].y - at[iat].y; - xn = at[n].x - at[iat].x; /* rn; possibly n == iat */ + xn = at[n].x - at[iat].x; /* rn; possibly n == iat */ yn = at[n].y - at[iat].y; - cross_prod_in = xi*yn - xn*yi; /* ((r(i)-r(iat)) x (r(n)-r(iat)) */ - if (cross_prod_in < -0.01*MIN_BOND_LENGTH2) + cross_prod_in = xi * yn - xn * yi; /* ((r(i)-r(iat)) x (r(n)-r(iat)) */ + if (cross_prod_in < -0.01 * MIN_BOND_LENGTH2) { /* make sure the r(i)->r(n) vector is counterclockwise around at[iat] */ - inchi_swap( (char*) &xi, (char*) &xn, sizeof( xi ) ); - inchi_swap( (char*) &yi, (char*) &yn, sizeof( yi ) ); + inchi_swap((char *)&xi, (char *)&xn, sizeof(xi)); + inchi_swap((char *)&yi, (char *)&yn, sizeof(yi)); /* djb-rwth: removing redundant code */ } xni = xn - xi; /* r(n)->r(i) */ yni = yn - yi; - rni = xni*xni + yni*yni; - if (rni > 0.01*MIN_BOND_LENGTH2) + rni = xni * xni + yni * yni; + if (rni > 0.01 * MIN_BOND_LENGTH2) { /* vector length |ri->rn| is not too small */ /* arrowhead of the vector r(t) = ri + (rn-ri)*t; 0 <= t <= 1 points to the bond ri->rn */ /* r(tni) is perpendicular to the bond ri->rn so that min|r(t)| = r(tni) = |tni|*rni */ - tni = -( xni*xi + yni*yi ) / rni; + tni = -(xni * xi + yni * yi) / rni; /* find min. distance from n-i bond to at[iat] */ if (tni < 0.0) { - rmin = sqrt( xi*xi + yi*yi ); + rmin = sqrt(xi * xi + yi * yi); } else if (tni > 1.0) { - rmin = sqrt( xn*xn + yn*yn ); + rmin = sqrt(xn * xn + yn * yn); } else { - rmin = sqrt( tni*tni*rni ); + rmin = sqrt(tni * tni * rni); } - ave_bond_len += sqrt( rni ); + ave_bond_len += sqrt(rni); num_bonds++; } else { /* zero length i-n bond */ - tni = 0.5; /* fake */ - rmin = sqrt( xi*xi + yi*yi ); /* arbitrarily choose one */ + tni = 0.5; /* fake */ + rmin = sqrt(xi * xi + yi * yi); /* arbitrarily choose one */ } - if (rmin >= 0.1*MIN_BOND_LENGTH) + if (rmin >= 0.1 * MIN_BOND_LENGTH) { /* at[iat] does not belong to at[i]-at[n] bond */ - int bCalc_rt = 1; - fi = atan2( yi, xi ); - fn = ( n == iat ) ? fi : atan2( yn, xn ); + int bCalc_rt = 1; + fi = atan2(yi, xi); + fn = (n == iat) ? fi : atan2(yn, xn); if (fi > fn) { /* make sure fn - fi >= 0 */ @@ -3363,8 +3362,8 @@ double GetMinDistDistribution( inp_ATOM *at, fi += two_pi; fn += two_pi; } - ki = (int) floor( ( fi + h_step ) / f_step ); /* cast does not match function type */ - kn = (int) floor( ( fn + h_step ) / f_step ); + ki = (int)floor((fi + h_step) / f_step); /* cast does not match function type */ + kn = (int)floor((fn + h_step) / f_step); /* the bond may affect several segments */ for (k = ki; k <= kn; k++) @@ -3384,15 +3383,15 @@ double GetMinDistDistribution( inp_ATOM *at, else { double xt, yt; - xt = xi + xni*tni; - yt = yi + yni*tni; - ft = atan2( yt, xt ); - rt = sqrt( xt*xt + yt*yt ); + xt = xi + xni * tni; + yt = yi + yni * tni; + ft = atan2(yt, xt); + rt = sqrt(xt * xt + yt * yt); } bCalc_rt = 0; } fk = f_step * kk; - c = fabs( cos( fk - ft ) ); + c = fabs(cos(fk - ft)); if (c < MIN_COS) c = MIN_COS; rk = rt / c; @@ -3405,35 +3404,37 @@ double GetMinDistDistribution( inp_ATOM *at, else { /* rmin < 0.1*MIN_BOND_LENGTH */ - ri = xi*xi + yi*yi; - rn = xn*xn + yn*yn; + ri = xi * xi + yi * yi; + rn = xn * xn + yn * yn; if (ri > MIN_BOND_LENGTH2 && rn > MIN_BOND_LENGTH2) { - dot_prod_in = xn*xi + yn*yi; + dot_prod_in = xn * xi + yn * yi; /* a very short bond */ - if (dot_prod_in > 0.01*MIN_BOND_LENGTH2) + if (dot_prod_in > 0.01 * MIN_BOND_LENGTH2) { /* bond does not cross at[iat] */ - double fyixi = atan2( yi, xi ); - if (fyixi < 0.0) fyixi += two_pi; - kk = (int) floor( ( fyixi + h_step ) / f_step ) % num_segm; + double fyixi = atan2(yi, xi); + if (fyixi < 0.0) + fyixi += two_pi; + kk = (int)floor((fyixi + h_step) / f_step) % num_segm; if (min_dist[kk] > rmin) { min_dist[kk] = rmin; } } - else if (dot_prod_in < -0.01*MIN_BOND_LENGTH2) + else if (dot_prod_in < -0.01 * MIN_BOND_LENGTH2) { /* bond does cross at[iat] */ - double fyixi = atan2( yi, xi ); - if (fyixi < 0.0) fyixi += two_pi; - kk = (int) floor( ( fyixi + h_step ) / f_step ) % num_segm; + double fyixi = atan2(yi, xi); + if (fyixi < 0.0) + fyixi += two_pi; + kk = (int)floor((fyixi + h_step) / f_step) % num_segm; if (min_dist[kk] > rmin) { min_dist[kk] = rmin; } fyixi += one_pi; - kk = (int) floor( ( fyixi + h_step ) / f_step ) % num_segm; + kk = (int)floor((fyixi + h_step) / f_step) % num_segm; if (min_dist[kk] > rmin) { min_dist[kk] = rmin; @@ -3452,9 +3453,10 @@ double GetMinDistDistribution( inp_ATOM *at, else { /* one end of the bond coincides with at[iat] */ - fi = ri > rn ? atan2( yi, xi ) : atan2( yn, xn ); - if (fi < 0.0) fi += two_pi; - kk = (int) floor( ( fi + h_step ) / f_step ) % num_segm; + fi = ri > rn ? atan2(yi, xi) : atan2(yn, xn); + if (fi < 0.0) + fi += two_pi; + kk = (int)floor((fi + h_step) / f_step) % num_segm; if (min_dist[kk] > rmin) { min_dist[kk] = rmin; @@ -3467,7 +3469,7 @@ double GetMinDistDistribution( inp_ATOM *at, if (num_bonds) { - return ave_bond_len / (double) num_bonds; + return ave_bond_len / (double)num_bonds; } else { @@ -3475,20 +3477,19 @@ double GetMinDistDistribution( inp_ATOM *at, } } - /****************************************************************************/ -int move_explicit_Hcation( inp_ATOM *at, - int num_at, - int iat, - int iat_H, - int bInAllComponents ) +int move_explicit_Hcation(inp_ATOM *at, + int num_at, + int iat, + int iat_H, + int bInAllComponents) { #define NUM_SEGM 20 /* const double one_pi = 2.0*atan2(1.0 , 0.0 ); */ const double one_pi = 3.14159265358979323846; /* M_PI */ - const double two_pi = 2.0*one_pi; + const double two_pi = 2.0 * one_pi; const double f_step = two_pi / NUM_SEGM; const double h_step = f_step / 2.0; double min_dist[NUM_SEGM]; @@ -3507,21 +3508,20 @@ int move_explicit_Hcation( inp_ATOM *at, xd += at[next].x; yd += at[next].y; zd += at[next].z; - r += dist3D( at + iat, at + next ); + r += dist3D(at + iat, at + next); nB++; } - xd /= (double) nB; - yd /= (double) nB; - zd /= (double) nB; - r /= (double) nB; - r0 = sqrt( (double) ( xd - at[iat].x )*( xd - at[iat].x ) - + (double) ( yd - at[iat].y )*( yd - at[iat].y ) ); + xd /= (double)nB; + yd /= (double)nB; + zd /= (double)nB; + r /= (double)nB; + r0 = sqrt((double)(xd - at[iat].x) * (xd - at[iat].x) + (double)(yd - at[iat].y) * (yd - at[iat].y)); } else { if (at[iat_H].valence) { - r = dist3D( at + iat_H, at + (int) at[iat_H].neighbor[0] ); + r = dist3D(at + iat_H, at + (int)at[iat_H].neighbor[0]); } else { @@ -3530,9 +3530,9 @@ int move_explicit_Hcation( inp_ATOM *at, r0 = 0.0; } - ave_bond_len = GetMinDistDistribution( at, num_at, iat, iat_H, - bInAllComponents, min_dist, - NUM_SEGM ); + ave_bond_len = GetMinDistDistribution(at, num_at, iat, iat_H, + bInAllComponents, min_dist, + NUM_SEGM); if (r < MIN_BOND_LENGTH && ave_bond_len > MIN_BOND_LENGTH) { @@ -3543,9 +3543,9 @@ int move_explicit_Hcation( inp_ATOM *at, { /* process non-zero bond lengths */ double f; - if (10.0*r0 < r) + if (10.0 * r0 < r) { - xr = -r; /* arbitrary */ + xr = -r; /* arbitrary */ yr = 0.0; zr = 0.0; } @@ -3556,36 +3556,36 @@ int move_explicit_Hcation( inp_ATOM *at, r0 = 1.0; } */ - xr = r * ( at[iat].x - xd ) / r0; - yr = r * ( at[iat].y - yd ) / r0; /* length = r */ - zr = r * ( at[iat].z - zd ) / r0; + xr = r * (at[iat].x - xd) / r0; + yr = r * (at[iat].y - yd) / r0; /* length = r */ + zr = r * (at[iat].z - zd) / r0; /* -- test: opposire direction -- xr = -r * ( at[iat].x - xd )/r0; yr = -r * ( at[iat].y - yd )/r0; zr = -r * ( at[iat].z - zd )/r0; */ - if (xr*xr + yr*yr < 0.04*r*r) + if (xr * xr + yr * yr < 0.04 * r * r) { xr = -r; yr = 0.0; } } - r = sqrt( xr*xr + yr*yr ); - f = atan2( yr, xr ); + r = sqrt(xr * xr + yr * yr); + f = atan2(yr, xr); if (f < 0.0) { f += two_pi; } - kk = (int) floor( ( f + h_step ) / f_step ) % NUM_SEGM; + kk = (int)floor((f + h_step) / f_step) % NUM_SEGM; /* cast does not match function type by design */ - if (min_dist[kk] < 1.5* r) + if (min_dist[kk] < 1.5 * r) { - double dist = 1.5*r; + double dist = 1.5 * r; int start = -1, len = 0, start_max = -1, len_max = 0; again: @@ -3612,7 +3612,7 @@ int move_explicit_Hcation( inp_ATOM *at, } if (!len_max) { - if (dist > 0.1*r) + if (dist > 0.1 * r) { dist *= 0.75; goto again; @@ -3625,11 +3625,11 @@ int move_explicit_Hcation( inp_ATOM *at, else { /* found a good sector */ - f = f_step * ( (double)start_max + ((double)len_max - 1.0 ) / 2.0 ); /* djb-rwth: cast operators added */ + f = f_step * ((double)start_max + ((double)len_max - 1.0) / 2.0); /* djb-rwth: cast operators added */ r0 = dist / 1.5; - xr = r0 * cos( f ); - yr = r0 * sin( f ); - zr = zr / r*r0; + xr = r0 * cos(f); + yr = r0 * sin(f); + zr = zr / r * r0; } } } @@ -3647,7 +3647,7 @@ int move_explicit_Hcation( inp_ATOM *at, { if (at[next].neighbor[i] == iat_H) { - RemoveInpAtBond( at, next, i ); + RemoveInpAtBond(at, next, i); i = 0; /* success */ break; } @@ -3674,9 +3674,9 @@ int move_explicit_Hcation( inp_ATOM *at, /* connect H to at[iat] */ val = at[iat].valence; - -#pragma warning (push) -#pragma warning (disable: 6386) + +#pragma warning(push) +#pragma warning(disable : 6386) if (val < MAXVAL) { at[iat].neighbor[val] = iat_H; @@ -3685,7 +3685,7 @@ int move_explicit_Hcation( inp_ATOM *at, at[iat].chem_bonds_valence += at[iat_H].bond_type[0]; at[iat].valence = val + 1; }; -#pragma warning (pop) +#pragma warning(pop) at[iat_H].component = at[iat].component; at[iat_H].neighbor[0] = iat; @@ -3700,9 +3700,8 @@ int move_explicit_Hcation( inp_ATOM *at, return 0; /* failed */ } - /****************************************************************************/ -int add_DT_to_num_H( int num_atoms, inp_ATOM *at ) +int add_DT_to_num_H(int num_atoms, inp_ATOM *at) /* assume num_1H, num_D and num_T are not included in num_H */ { int i, j; @@ -3716,29 +3715,28 @@ int add_DT_to_num_H( int num_atoms, inp_ATOM *at ) return 0; } - /**************************************************************************** Return value: new number of atoms > 0 or -1=out of RAM ****************************************************************************/ -int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) +int remove_terminal_HDT(int num_atoms, inp_ATOM *at, int bFixTermHChrg) { - AT_NUMB *new_ord; - inp_ATOM *new_at; + AT_NUMB *new_ord; + inp_ATOM *new_at; char *p; static const char szHDT[] = "HDT"; - static const int kMax = sizeof( szHDT ); /* = 4 */ + static const int kMax = sizeof(szHDT); /* = 4 */ int ret = -1; - int num_hydrogens = 0, num_H = 0; /* number of terminal H, D, T */ + int num_hydrogens = 0, num_H = 0; /* number of terminal H, D, T */ int i, j, k, n, m; int val; AT_RANK new_HydrogenAt_order[NUM_H_ISOTOPES + 1]; AT_RANK new_OtherNeigh_order[MAXVAL]; - S_CHAR old_trans[MAX_NUM_STEREO_BONDS]; + S_CHAR old_trans[MAX_NUM_STEREO_BONDS]; - int num_OtherNeigh, num_HydrogenAt; + int num_OtherNeigh, num_HydrogenAt; - new_ord = (AT_NUMB *) inchi_calloc( num_atoms, sizeof( new_ord[0] ) ); /* changed malloc to calloc 9-11-2003 */ - new_at = (inp_ATOM *) inchi_malloc( sizeof( new_at[0] ) *num_atoms ); + new_ord = (AT_NUMB *)inchi_calloc(num_atoms, sizeof(new_ord[0])); /* changed malloc to calloc 9-11-2003 */ + new_at = (inp_ATOM *)inchi_malloc(sizeof(new_at[0]) * num_atoms); if (!new_ord || !new_at) { goto exit_function; @@ -3748,28 +3746,29 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) for (i = 0; i < num_atoms; i++) { at[i].component = i; /* temporarily save original numbering */ - /* get k = temp. hydrogen isotope/non-hydrogen atom type: */ - /* k=0:H, k=2:D, k=3:T, k=4=kMax: not a hydrogen */ - k = at[i].elname[1] ? kMax : ( p = (char*) strchr( szHDT, at[i].elname[0] ) ) ? (int) ( p - szHDT ) : kMax; + /* get k = temp. hydrogen isotope/non-hydrogen atom type: */ + /* k=0:H, k=2:D, k=3:T, k=4=kMax: not a hydrogen */ + k = at[i].elname[1] ? kMax : (p = (char *)strchr(szHDT, at[i].elname[0])) ? (int)(p - szHDT) + : kMax; /* set hydrogen isotope atw differences */ /* Notes: k-value of isotopic H is incremented to correct iso_atw_diff value later. */ /* 1H isotope cannot be detected here. */ if (k == ATW_H || k == ATW_H + 1) { /* D or T, k = 1 or 2 */ - at[i].elname[0] = 'H'; /* hydrogen isotope */ + at[i].elname[0] = 'H'; /* hydrogen isotope */ at[i].iso_atw_diff = ++k; /* increment k to make k = iso_atw_diff ( 2 for D, 3 for T ) */ } - num_H += ( k != kMax && at[i].valence == 1 && at[i].chem_bonds_valence == 1 && !NUMH( at, i ) ); + num_H += (k != kMax && at[i].valence == 1 && at[i].chem_bonds_valence == 1 && !NUMH(at, i)); } /* special case: HD, HT, DT, HH: the only non-isotopic H or - * the lightest isotopic H out of two is removed - * to become implicit (make the heavier H the "central atom"). - * Note: This must be consistent with MOL_FMT_to_atom() - * treatment of isotopic Hn aliases. - */ - if (2 == num_H && 2 == num_atoms && !NUMH( at, 0 ) && !NUMH( at, 1 )) + * the lightest isotopic H out of two is removed + * to become implicit (make the heavier H the "central atom"). + * Note: This must be consistent with MOL_FMT_to_atom() + * treatment of isotopic Hn aliases. + */ + if (2 == num_H && 2 == num_atoms && !NUMH(at, 0) && !NUMH(at, 1)) { if (at[0].iso_atw_diff >= at[1].iso_atw_diff) @@ -3796,18 +3795,18 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) /* general case except H-H */ for (i = 0; i < num_atoms; i++) { - k = ( at[i].elname[1] || NUMH( at, i ) ) ? kMax : ( at[i].elname[0] == 'H' ) ? at[i].iso_atw_diff : kMax; + k = (at[i].elname[1] || NUMH(at, i)) ? kMax : (at[i].elname[0] == 'H') ? at[i].iso_atw_diff + : kMax; if (k < kMax && at[i].valence == 1 && at[i].chem_bonds_valence == 1 && - /* the order of comparison is important */ - ( ( n = (int) at[i].neighbor[0] ) > i /* at[n] has not been encountered yet*/ || - (int) new_ord[n] < num_atoms - num_hydrogens ) /* at[n] might have been encountered; it has not been moved */) + /* the order of comparison is important */ + ((n = (int)at[i].neighbor[0]) > i /* at[n] has not been encountered yet*/ || + (int)new_ord[n] < num_atoms - num_hydrogens) /* at[n] might have been encountered; it has not been moved */) { /* found an explicit terminal hydrogen */ num_hydrogens++; if (k == 0 && ATW_H <= at[i].iso_atw_diff && at[i].iso_atw_diff < ATW_H + NUM_H_ISOTOPES) { k = at[i].iso_atw_diff; /* H isotope has already been marked above or elsewhere */ /* djb-rwth: ignoring LLVM warning: variable used */ - } if (at[i].charge) { @@ -3825,12 +3824,12 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) new_at[new_ord[n]].charge = at[n].charge; } } - new_ord[i] = num_atoms - num_hydrogens; /* move hydrogens to the end of the list */ + new_ord[i] = num_atoms - num_hydrogens; /* move hydrogens to the end of the list */ } else { /* atom is not an explicit terminal hydrogen */ - new_ord[i] = i - num_hydrogens; /* adjust non-hydrogens positions */ + new_ord[i] = i - num_hydrogens; /* adjust non-hydrogens positions */ } /* copy atom to the new position */ @@ -3845,41 +3844,41 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) { /* sort hydrogen isotopes in ascending order, */ /* orig, numbers being the secondary sorting key */ - qsort( new_at + num_others, num_hydrogens, sizeof( new_at[0] ), cmp_iso_atw_diff_component_no ); + qsort(new_at + num_others, num_hydrogens, sizeof(new_at[0]), cmp_iso_atw_diff_component_no); } /* save new numbering of hydrogen atoms using temporarily saved orig numbering */ for (i = num_others; i < num_atoms; i++) { - new_ord[(int) new_at[i].component] = i; + new_ord[(int)new_at[i].component] = i; } /* renumber neighbors according to new_ord[] and detach terminal hydrogens */ for (i = 0; i < num_others; i++) { - memset( new_HydrogenAt_order, 0, sizeof( new_HydrogenAt_order ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( new_OtherNeigh_order, 0, sizeof( new_OtherNeigh_order ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(new_HydrogenAt_order, 0, sizeof(new_HydrogenAt_order)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(new_OtherNeigh_order, 0, sizeof(new_OtherNeigh_order)); /* djb-rwth: memset_s C11/Annex K variant? */ num_OtherNeigh = 0; num_HydrogenAt = 0; num_H = 0; for (m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m++) { - old_trans[m] = 2 - ( new_at[i].sn_ord[m] + new_at[i].sb_ord[m] + ( new_at[i].sn_ord[m] > new_at[i].sb_ord[m] ) ) % 2; + old_trans[m] = 2 - (new_at[i].sn_ord[m] + new_at[i].sb_ord[m] + (new_at[i].sn_ord[m] > new_at[i].sb_ord[m])) % 2; } for (k = val = 0; k < new_at[i].valence; k++) /* djb-rwth: removing redundant variables/code */ { - if (num_others <= ( n = new_ord[new_at[i].neighbor[k]] )) + if (num_others <= (n = new_ord[new_at[i].neighbor[k]])) { /* discovered neighbor = disconnected explicit hydrogen - * i = new atom new_at[i] ordering number - * n = new number of the explicit H - * k = ordering number of the explicit H in new_at[i] adjacency list - */ + * i = new atom new_at[i] ordering number + * n = new number of the explicit H + * k = ordering number of the explicit H in new_at[i] adjacency list + */ if (0 < new_at[n].iso_atw_diff && new_at[n].iso_atw_diff < ATW_H + NUM_H_ISOTOPES) { /* make explicit isotopic H implicit */ - new_at[i].num_iso_H[new_at[n].iso_atw_diff - 1] ++; /* isotopic H */ + new_at[i].num_iso_H[new_at[n].iso_atw_diff - 1]++; /* isotopic H */ num_HydrogenAt += !new_HydrogenAt_order[new_at[n].iso_atw_diff]; new_HydrogenAt_order[new_at[n].iso_atw_diff] = k + 1; } @@ -3892,16 +3891,16 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) new_HydrogenAt_order[0] = k + 1; } /* decrement chem. bonds valence because one bond is removed */ - new_at[i].chem_bonds_valence = inchi_max( 0, new_at[i].chem_bonds_valence - 1 ); + new_at[i].chem_bonds_valence = inchi_max(0, new_at[i].chem_bonds_valence - 1); new_at[n].neighbor[0] = i; /* update removed hydrogen neighbor number */ if (new_at[i].sb_parity[0]) { /* if the removed H is an SB neighbor then mark it as removed */ for (m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m++) { - if (k == (int) new_at[i].sn_ord[m]) + if (k == (int)new_at[i].sn_ord[m]) { - new_at[i].sn_ord[m] = -( new_at[n].iso_atw_diff + 1 ); + new_at[i].sn_ord[m] = -(new_at[n].iso_atw_diff + 1); /* means the SB neighbor has been removed; (-4)=H, (-3)=1H, (-2)=D, (-1)=T */ } } @@ -3922,11 +3921,10 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) /* store new stereobond and sb-neighbor ordering numbers */ for (m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m++) { - if (k == (int) new_at[i].sb_ord[m]) + if (k == (int)new_at[i].sb_ord[m]) new_at[i].sb_ord[m] = val; - else - if (k == (int) new_at[i].sn_ord[m]) - new_at[i].sn_ord[m] = val; + else if (k == (int)new_at[i].sn_ord[m]) + new_at[i].sn_ord[m] = val; } } } @@ -3949,7 +3947,7 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) new_OtherNeigh_order[num_HydrogenAt - j] = new_HydrogenAt_order[k]; for (m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m++) { - if ((int) new_at[i].sn_ord[m] == -( k + 1 )) + if ((int)new_at[i].sn_ord[m] == -(k + 1)) { new_at[i].sn_ord[m] = -j; /* negative means explicit H isotope ord are @@ -3961,24 +3959,24 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) } /* at this point new_OtherNeigh_order[] contains incremented old ordering numbers in new order */ - k = insertions_sort_AT_RANK( new_OtherNeigh_order, num_HydrogenAt + num_OtherNeigh ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + k = insertions_sort_AT_RANK(new_OtherNeigh_order, num_HydrogenAt + num_OtherNeigh); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ /* djb-rwth: removing redundant code */ - /*if ( k ) {*/ - /* - for ( m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m ++ ) { - if ( PARITY_WELL_DEF(new_at[i].sb_parity[m]) ) { - if ( old_trans[m] != 2 - (4 + new_at[i].sn_ord[m] + new_at[i].sb_ord[m] + (new_at[i].sn_ord[m] > new_at[i].sb_ord[m]))%2 ) { - new_at[i].sb_parity[m] = 3 - new_at[i].sb_parity[m]; - } - } - } - */ - /*}*/ + /*if ( k ) {*/ + /* + for ( m = 0; m < MAX_NUM_STEREO_BONDS && new_at[i].sb_parity[m]; m ++ ) { + if ( PARITY_WELL_DEF(new_at[i].sb_parity[m]) ) { + if ( old_trans[m] != 2 - (4 + new_at[i].sn_ord[m] + new_at[i].sb_ord[m] + (new_at[i].sn_ord[m] > new_at[i].sb_ord[m]))%2 ) { + new_at[i].sb_parity[m] = 3 - new_at[i].sb_parity[m]; + } + } + } + */ + /*}*/ } } new_at[i].valence = val; } - memcpy(at, new_at, sizeof(at[0])* num_atoms); + memcpy(at, new_at, sizeof(at[0]) * num_atoms); ret = num_others; } else @@ -3990,17 +3988,16 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at, int bFixTermHChrg ) if (new_ord) { - inchi_free( new_ord ); + inchi_free(new_ord); } if (new_at) { - inchi_free( new_at ); + inchi_free(new_at); } return ret; } - /*#endif*/ /* } DISCONNECT_SALTS */ typedef enum tagIonAtomType @@ -4021,40 +4018,2699 @@ typedef enum tagIonAtomType } ION_ATOM_TYPE; /****************************************************************************/ -int get_iat_number( int el_number ) +int get_iat_number(int el_number) +{ + switch (el_number) + { + case EL_NUMBER_H: + return IAT_H; + case EL_NUMBER_C: + return IAT_C; + case EL_NUMBER_N: + return IAT_N; + case EL_NUMBER_P: + return IAT_P; + case EL_NUMBER_O: + return IAT_O; + case EL_NUMBER_S: + return IAT_S; + case EL_NUMBER_SE: + return IAT_Se; + case EL_NUMBER_TE: + return IAT_Te; + case EL_NUMBER_F: + return IAT_F; + case EL_NUMBER_CL: + return IAT_Cl; + case EL_NUMBER_BR: + return IAT_Br; + case EL_NUMBER_I: + return IAT_I; + default: + return -1; + } +} + +/***************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Array only to be used for molecular inorganics. It is seperate from the ElData + * array in util.c file. The need for duplicate array arrives as in molecular inorganics + * we need a change in metal type. Some changes include an upgrade from lower metal + * type to higher metal type (meaning : more valences of an atom can be used). + * Some changes include a degradation from higher metal type to a lower metal type + * where fewer number of valences for an atom are used. Due to these changes there + * is an urge to have a duplicate array so that the current functionality does + * not get affected. + * + * (Summary) : Type of the element has changed from METAL -> MolInOrg. + ******************************************************************************/ +const MolecularInorganicsElData MolecularInorganicsArray[] = + { + /* avg norm El No -------- Valence(s) of an ion or neutral atom -------------*/ + /* mw mass exact mw type neg H -2 -1 0 +1 +2 */ + {"H", 1, 1, 1.007825035, 0, 21, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"D", 2, 2, 2.014101778, 0, 21, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"T", 3, 3, 3.016049268, 0, 21, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"He", 4, 4, 4.002600000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"Li", 7, 7, 7.016000000, MolInOrg1, 10, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Be", 9, 9, 9.012180000, MolInOrg1, 15, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"B", 11, 11, 11.009300000, 0, 20, 0, {{ + 3, + }, + { + 4, + }, + { + 3, + }, + { + 2, + }, + { + 1, + }}}, + {"C", 12, 12, 12.000000000, 0, 25, 0, {{ + 2, + }, + { + 3, + }, + { + 4, + }, + { + 3, + }, + { + 2, + }}}, + {"N", 14, 14, 14.003074000, 0, 30, 0, {{ + 1, + }, + { + 2, + }, + {3, 5}, + { + 4, + }, + { + 3, + }}}, + {"O", 16, 16, 15.994914630, 0, 35, 0, {{ + 0, + }, + { + 1, + }, + { + 2, + }, + { + 3, + 5, + }, + { + 4, + }}}, + {"F", 19, 19, 18.998403220, 0, 40, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 2, + }, + {3, 5}}}, + {"Ne", 20, 20, 19.992440000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"Na", 23, 23, 22.989770000, MolInOrg1, 9, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Mg", 24, 24, 23.985000000, MolInOrg1, 12, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"Al", 27, 27, 26.981540000, MolInOrg1, 15, 0, {{ + 3, + 5, + }, + { + 4, + }, + { + 3, + }, + { + 2, + }, + { + 1, + }}}, + {"Si", 28, 28, 27.976927100, 0, 18, 0, {{ + 2, + }, + {3, 5}, + { + 4, + }, + { + 3, + }, + { + 2, + }}}, + {"P", 31, 31, 30.973762000, 0, 21, 0, {{ + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 4, + }, + { + 3, + }}}, + {"S", 32, 32, 31.972070700, 0, 25, 0, {{ + 0, + }, + { + 1, + 3, + 5, + 7, + }, + {2, 4, 6}, + { + 3, + 5, + }, + { + 4, + }}}, + {"Cl", 35, 35, 34.968852730, 0, 30, 0, {{ + 0, + }, + { + 0, + }, + {1, 3, 5, 7}, + {2, 4, 6}, + { + 3, + 5, + }}}, + {"Ar", 40, 40, 39.962400000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"K", 39, 39, 38.963700000, MolInOrg1, 8, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Ca", 40, 40, 39.962600000, MolInOrg1, 10, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"Sc", 45, 45, 44.955910000, MolInOrg1, 13, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Ti", 48, 48, 47.947950000, MolInOrg2, 15, 1, {{ + 0, + }, + { + 0, + }, + {3, 4}, + { + 0, + }, + { + 0, + }}}, + {"V", 51, 51, 50.943960000, MolInOrg4, 16, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 5, + }, + { + 0, + }, + { + 0, + }}}, + {"Cr", 52, 52, 51.940500000, MolInOrg2, 16, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Mn", 55, 55, 54.938050000, MolInOrg1, 15, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 6, + 7, + }, + { + 0, + }, + { + 0, + }}}, + {"Fe", 56, 56, 55.934900000, MolInOrg2, 18, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Co", 59, 59, 58.933200000, MolInOrg2, 18, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Ni", 59, 58, 57.935300000, MolInOrg1, 18, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Cu", 64, 63, 62.929600000, MolInOrg2, 19, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + 2, + }, + { + 0, + }, + { + 0, + }}}, + {"Zn", 65, 64, 63.929147000, MolInOrg1, 16, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 0, + }, + { + 0, + }}}, + {"Ga", 70, 69, 68.925600000, MolInOrg1, 18, 0, {{ + 3, + 5, + }, + { + 4, + }, + { + 3, + }, + { + 0, + }, + { + 1, + }}}, + {"Ge", 73, 74, 73.921177400, 0, 18, 0, {{ + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 4, + }, + { + 3, + }, + { + 0, + }}}, + {"As", 75, 75, 74.921594200, 0, 20, 0, {{ + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 4, + }, + { + 3, + }}}, + {"Se", 79, 80, 79.916519600, 0, 24, 0, {{ + 0, + }, + { + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 4, + }}}, + {"Br", 80, 79, 78.918336100, 0, 28, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }}}, + {"Kr", 84, 84, 83.911500000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"Rb", 85, 85, 84.911800000, MolInOrg1, 8, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Sr", 88, 88, 87.905600000, MolInOrg1, 10, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"Y", 89, 89, 88.905860000, MolInOrg1, 12, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Zr", 91, 90, 89.904700000, MolInOrg1, 14, 1, {{ + 0, + }, + { + 0, + }, + { + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Nb", 93, 93, 92.906400000, MolInOrg2, 16, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 5, + }, + { + 0, + }, + { + 0, + }}}, + {"Mo", 96, 98, 97.905400000, MolInOrg4, 18, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Tc", 98, 98, 97.907200000, MolInOrg1, 19, 1, {{ + 0, + }, + { + 0, + }, + { + 7, + }, + { + 0, + }, + { + 0, + }}}, + {"Ru", 101, 102, 101.904300000, MolInOrg2, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Rh", 103, 103, 102.905500000, MolInOrg2, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Pd", 106, 106, 105.903500000, MolInOrg1, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Ag", 108, 107, 106.905100000, MolInOrg1, 19, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Cd", 112, 114, 113.903400000, MolInOrg1, 17, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 0, + }, + { + 0, + }}}, + {"In", 115, 115, 114.903900000, MolInOrg1, 17, 0, {{ + 3, + 5, + }, + { + 2, + 4, + }, + { + 3, + }, + { + 0, + }, + { + 1, + }}}, + {"Sn", 119, 120, 119.902200000, MolInOrg2, 18, 0, {{ + 2, + 4, + 6, + }, + {3, 5}, + { + 2, + 4, + }, + { + 3, + }, + { + 0, + }}}, + {"Sb", 122, 121, 120.903800000, MolInOrg2, 19, 0, {{ + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 2, + 4, + }, + { + 3, + }}}, + {"Te", 128, 130, 129.906200000, 0, 21, 0, {{ + 0, + }, + { + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 2, + 4, + }}}, + {"I", 127, 127, 126.904500000, 0, 25, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + 3, + 5, + 7, + }, + {2, 4, 6}, + { + 3, + 5, + }}}, + {"Xe", 131, 132, 131.904100000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"Cs", 133, 133, 132.905430000, MolInOrg1, 7, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Ba", 137, 138, 137.905200000, MolInOrg1, 9, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"La", 139, 139, 138.906360000, MolInOrg1, 11, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Ce", 140, 140, 139.905400000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Pr", 141, 141, 140.907660000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Nd", 144, 142, 141.907719000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Pm", 145, 145, 144.912800000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Sm", 150, 152, 151.919700000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Eu", 152, 153, 152.921200000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Gd", 157, 158, 157.924099000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Tb", 159, 159, 158.925350000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Dy", 163, 164, 163.929200000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, /* mw rounding uncertain */ + {"Ho", 165, 165, 164.930300000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Er", 167, 166, 165.930300000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Tm", 169, 169, 168.934230000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Yb", 173, 174, 173.938900000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Lu", 175, 175, 174.940800000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Hf", 178, 180, 179.946600000, MolInOrg1, 13, 1, {{ + 0, + }, + { + 0, + }, + { + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Ta", 181, 181, 180.948010000, MolInOrg1, 15, 1, {{ + 0, + }, + { + 0, + }, + { + 5, + }, + { + 0, + }, + { + 0, + }}}, + {"W", 184, 184, 183.951000000, MolInOrg4, 17, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Re", 186, 187, 186.955800000, MolInOrg4, 19, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 4, + 6, + 7, + }, + { + 0, + }, + { + 0, + }}}, + {"Os", 190, 192, 191.961500000, MolInOrg3, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Ir", 192, 193, 192.962900000, MolInOrg2, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 3, + 4, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Pt", 195, 195, 194.964800000, MolInOrg1, 22, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Au", 197, 197, 196.966560000, MolInOrg2, 24, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Hg", 201, 202, 201.970617000, MolInOrg2, 19, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + 2, + }, + { + 0, + }, + { + 0, + }}}, + {"Tl", 204, 205, 204.974400000, MolInOrg1, 18, 0, {{ + 3, + 5, + }, + { + 2, + 4, + }, + { + 1, + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Pb", 207, 208, 207.976627000, MolInOrg1, 18, 0, {{ + 2, + 4, + 6, + }, + {3, 5}, + { + 2, + 4, + }, + { + 3, + }, + { + 0, + }}}, + {"Bi", 209, 209, 208.980390000, MolInOrg1, 19, 0, {{ + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 2, + 4, + }, + { + 3, + }}}, + {"Po", 209, 209, 208.982400000, MolInOrg2, 20, 0, {{ + 0, + }, + { + 1, + 3, + 5, + 7, + }, + { + 2, + 4, + 6, + }, + { + 3, + 5, + }, + { + 2, + 4, + }}}, + {"At", 210, 210, 209.987100000, 0, 22, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + 3, + 5, + 7, + }, + {2, 4, 6}, + { + 3, + 5, + }}}, + {"Rn", 222, 222, 222.017500000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, + {"Fr", 223, 223, 223.019700000, MolInOrg1, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Ra", 226, 226, 226.025410000, MolInOrg1, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 1, + }, + { + 0, + }}}, + {"Ac", 227, 227, 227.027750000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Th", 232, 232, 232.038050000, MolInOrg2, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Pa", 231, 231, 231.035880000, MolInOrg3, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + }, + { + 0, + }, + { + 0, + }}}, + {"U", 238, 238, 238.050790000, MolInOrg4, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Np", 237, 237, 237.048170000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Pu", 244, 244, 244.064200000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Am", 243, 243, 243.061370000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + 5, + 6, + }, + { + 0, + }, + { + 0, + }}}, + {"Cm", 247, 247, 247.070300000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Bk", 247, 247, 247.070300000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + 4, + }, + { + 0, + }, + { + 0, + }}}, + {"Cf", 251, 251, 251.079600000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Es", 252, 252, 252.082800000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Fm", 257, 257, 257.095100000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Md", 258, 258, 258.098600000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"No", 259, 259, 259.100900000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Lr", 260, 260, 260.105400000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Rf", 261, 261, 261.108700000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + + /* + The elements below were added after v. 1.03. + When available, the mass is given for isotope with the longest half-life. + Standard valences given here are just placeholders. + v. 1.04: added elements 105-112. + Ref.: M. E. WIESER AND T. B. COPLEN. + Atomic weights of the elements 2009 (IUPAC Technical Report). + Pure Appl. Chem., Vol. 83, No. 2, pp. 359-396, 2011. + v. 1.05: added elements 114 and 116; + updated data for elements 105-112. + Ref.: J. Meija, T.B. Coplen, M.Berglund et al. + Atomic weights of the elements 2013 (IUPAC Technical Report). + Pure Appl. Chem., Vol. 88, No. 3, pp. 265-291, 2016. + added elements 113, 115, 117, and 118, according to IUPAC provisional recommendations: + Ref.: L. Ohrstrom, J. Reedijk. + Names and Symbols of the Elements with Atomic Numbers 113, 115, 117 and 118. + Pure Appl. Chem., May 1, 2016, Manuscript ID PAC-REC-16-05-01 + http://iupac.org/cms/wp-content/uploads/2016/06/names-and-symbols-of-elements.pdf + */ + + /* 105 dubnium Db ? Like: Ta */ + {"Db", 270, 270, 270.131000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 106 seaborgium Sg ? Like: W */ + {"Sg", 269, 269, 269.129000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 107 bohrium Bh ? Like: Re */ + {"Bh", 270, 270, 270.133000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 108 hassium Hs ? Like: Os */ + {"Hs", 270, 270, 270.134000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 109 meitnerium Mt ? Like: Ir */ + {"Mt", 278, 278, 278.156000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 110 darmstadtium Ds ? Like: Pt */ + {"Ds", 281, 281, 281.165000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 111 roentgenium Rg ? Like: Au */ + {"Rg", 281, 281, 281.166000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 112 copernicium Cn ? Like: Hg */ + {"Cn", 285, 285, 285.177000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 113 nihonium Nh ? Like: ? */ + {"Nh", 278, 278, 278.000000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 114 flerovium Fl ? Like: Pb */ + {"Fl", 289, 289, 289.190000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 115 moscovium Mc ? Like: ? */ + {"Mc", 289, 289, 289.000000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 116 livermorium Lv ? Like: Po */ + {"Lv", 293, 293, 293.204000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 117 tennessine Ts ? Like: ? */ + {"Ts", 297, 297, 297.000000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* 118 oganesson Og ? Like: ? */ + {"Og", 294, 294, 294.000000000, MolInOrg1, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + /* End of added in v. 1.04 - 1.05 */ + {"Zy", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Zz", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, +#ifdef INCHI_ZFRAG + {"Zu", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + }, + { + 0, + }, + { + 0, + }}}, + {"Zv", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 2, + }, + { + 0, + }, + { + 0, + }}}, + {"Zw", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 3, + }, + { + 0, + }, + { + 0, + }}}, + {"Zx", 0, 0, 0.000000000, 0, 0, 1, {{ + 0, + }, + { + 0, + }, + { + 1, + 2, + }, + { + 0, + }, + { + 0, + }}}, +#endif + + {"", 0, 0, 0.000000000, 0, 0, 0, {{ + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }, + { + 0, + }}}, +}; + +/**************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Function retrieves the valence values from the MolecularInoragnicsArray + ****************************************************************************/ +int getElValenceforMolecularInorganics(int nPeriodicNum, int charge, int val_num) +{ + if (charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE || val_num >= MAX_NUM_VALENCES) + { + return 0; + } + + return MolecularInorganicsArray[nPeriodicNum > 1 ? nPeriodicNum + 1 : 0].cValence[NEUTRAL_STATE + charge][val_num]; +} + +/**************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Function retrieves the element type value from the MolecularInorganicsArray + ****************************************************************************/ +int getElTypeforMolecularInorganics(int nPeriodicNum) +{ + return MolecularInorganicsArray[nPeriodicNum + 1].nType; +} + +/***************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Function check for molecular inorganics if a metal atom has to be disconnected + * or not. + ******************************************************************************/ +int MolecularInorganicsIsMetalToDisconnect(inp_ATOM *at, int atom_idx) +{ + + int at_valence, num_H; + int type = getElTypeforMolecularInorganics(at[atom_idx].el_number); + int j; + + /* Calculate the actual valence of the atom + * It means that the total bounding capacity + * of the atom has to be taken into account + * which will further get equated within the + * elements array to a metal atom(neutral or an ion) */ + num_H = NUMH(at, atom_idx); + at_valence = num_H + at[atom_idx].chem_bonds_valence; + + if (!at_valence || (abs(at[atom_idx].charge) > 1)) + { + return 0; /* Isolated metal atom or Atom has multiple charges */ + } + + /* Check if the valence matches a known normal valence */ + for (j = 0; j < 4; j++) + { + const int bitmask = (1 << j); /* Create bitmask for the j-th bit */ + const bool is_valence_state_valid = (bitmask & type) != 0; /* Check if the j-th valence state is allowed */ + + if (is_valence_state_valid && at_valence == getElValenceforMolecularInorganics(at[atom_idx].el_number, at[atom_idx].charge, j)) + { + return 1; /* Atom has normal valence follows disconnection logic if applicable */ + } + } + + /* Default: Valence greater than usual or the atom is isolated hence no disconnection */ + return 0; +} + +#define NUM_ELEMENTS 118 /* Adjust according to the number of elements in the array */ +/***************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Elements Array for for molecular inorganics + ******************************************************************************/ + +ElementsMolecularInorganics elementListMolecularInorganics[NUM_ELEMENTS] = + { + {1, "H"}, {2, "He"}, {3, "Li"}, {4, "Be"}, {5, "B"}, {6, "C"}, {7, "N"}, {8, "O"}, {9, "F"}, {10, "Ne"}, {11, "Na"}, {12, "Mg"}, {13, "Al"}, {14, "Si"}, {15, "P"}, {16, "S"}, {17, "Cl"}, {18, "Ar"}, {19, "K"}, {20, "Ca"}, {21, "Sc"}, {22, "Ti"}, {23, "V"}, {24, "Cr"}, {25, "Mn"}, {26, "Fe"}, {27, "Co"}, {28, "Ni"}, {29, "Cu"}, {30, "Zn"}, {31, "Ga"}, {32, "Ge"}, {33, "As"}, {34, "Se"}, {35, "Br"}, {36, "Kr"}, {37, "Rb"}, {38, "Sr"}, {39, "Y"}, {40, "Zr"}, {41, "Nb"}, {42, "Mo"}, {43, "Tc"}, {44, "Ru"}, {45, "Rh"}, {46, "Pd"}, {47, "Ag"}, {48, "Cd"}, {49, "In"}, {50, "Sn"}, {51, "Sb"}, {52, "Te"}, {53, "I"}, {54, "Xe"}, {55, "Cs"}, {56, "Ba"}, {57, "La"}, {58, "Ce"}, {59, "Pr"}, {60, "Nd"}, {61, "Pm"}, {62, "Sm"}, {63, "Eu"}, {64, "Gd"}, {65, "Tb"}, {66, "Dy"}, {67, "Ho"}, {68, "Er"}, {69, "Tm"}, {70, "Yb"}, {71, "Lu"}, {72, "Hf"}, {73, "Ta"}, {74, "W"}, {75, "Re"}, {76, "Os"}, {77, "Ir"}, {78, "Pt"}, {79, "Au"}, {80, "Hg"}, {81, "Tl"}, {82, "Pb"}, {83, "Bi"}, {84, "Po"}, {85, "At"}, {86, "Rn"}, {87, "Fr"}, {88, "Ra"}, {89, "Ac"}, {90, "Th"}, {91, "Pa"}, {92, "U"}, {93, "Np"}, {94, "Pu"}, {95, "Am"}, {96, "Cm"}, {97, "Bk"}, {98, "Cf"}, {99, "Es"}, {100, "Fm"}, {101, "Md"}, {102, "No"}, {103, "Lr"}, {104, "Rf"}, {105, "Db"}, {106, "Sg"}, {107, "Bh"}, {108, "Hs"}, {109, "Mt"}, {110, "Ds"}, {111, "Rg"}, {112, "Cn"}, {113, "Nh"}, {114, "Fl"}, {115, "Mc"}, {116, "Lv"}, {117, "Ts"}, {118, "Og"}}; + +/************************************************************************* + * (@nnuk : NaumanUllahKhan) + * Binary Array of all the Electronegativity values between Elements + **************************************************************************/ + +const int binaryArrayMolecularInorganics[NUM_ELEMENTS][NUM_ELEMENTS] = { + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +}; + +/***************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Function to retrieve binary values for MolecularInorganicsPreprocessing + * Binary values are retrieved from the disconnection array "binaryArrayMolecularInorganics" + * "1" means that the bond between atom and the neighbouring atom has to be + * disconnected whereas, "0" means the bond has to be kept. + ******************************************************************************/ + +int shouldBondBeCut(int atom1, int atom2) +{ + int index1, index2, binaryValue; + + /* Get the indices corresponding to the atomic numbers */ + index1 = atom1 - 1; + index2 = atom2 - 1; + + /* Retrieve the binary value from the binary array */ + binaryValue = binaryArrayMolecularInorganics[index1][index2]; + + /* Output for debugging purposes */ + /*printf("Electronegativity binary value between the atom and it's neighbour is: %d\n", binaryValue); */ + + return binaryValue; +} + +/***************************************************************************** + * (@nnuk : Nauman Ullah Khan) + * Function to update the neighboring list of the atom for MolecularInorganicsPreprocessing. + ******************************************************************************/ + +void updateNeighborListMolecularInorganics(inp_ATOM *at, int atom_idx, int neighbor_idx) { - switch (el_number) { - case EL_NUMBER_H: return IAT_H; - case EL_NUMBER_C: return IAT_C; - case EL_NUMBER_N: return IAT_N; - case EL_NUMBER_P: return IAT_P; - case EL_NUMBER_O: return IAT_O; - case EL_NUMBER_S: return IAT_S; - case EL_NUMBER_SE: return IAT_Se; - case EL_NUMBER_TE: return IAT_Te; - case EL_NUMBER_F: return IAT_F; - case EL_NUMBER_CL: return IAT_Cl; - case EL_NUMBER_BR: return IAT_Br; - case EL_NUMBER_I: return IAT_I; - default: return -1; + + int valence = at[atom_idx].valence; + int i, j; + + for (i = 0; i < valence; i++) + { + if (at[atom_idx].neighbor[i] == neighbor_idx) + { + /* Shift remaining neighbors to fill the gap */ + for (j = i; j < valence - 1; j++) + { + at[atom_idx].neighbor[j] = at[atom_idx].neighbor[j + 1]; + } + at[atom_idx].valence--; /* Reduce the valence (number of neighbors) */ + + break; + } } } -#if ( READ_INCHI_STRING == 1 ) +/***************************************************************************** + * (@nnuk :: Nauman Ullah Khan) + * @brief Function to preprocess molecular inorganics structures by disconnecting metal bonds and handling salts + ammonium salts. + * + * This function processes a given molecular structure, identifies metal atoms, + * and performs bond disconnections based on electronegativity differences. After metal disconnections, + * it also checks for ammonium salt patterns and disconnects them where applicable. + * + * @param orig_at_data Pointer to the original atom data structure. + * @param ip Pointer to the input parameters structure. + * @return Number of successful disconnections or -1 on error. + *****************************************************************************/ + +int MolecularInorganicsPreprocessing(ORIG_ATOM_DATA *orig_at_data, INPUT_PARMS *ip) +{ + int ret_code = 0; + + if (!ip || !orig_at_data || !orig_at_data->at) + { + return -1; + } + + if (!ip->bMolecularInorganics) + { + return -1; + } + + /* Pointer to the array of input atoms from the original atom data structure */ + inp_ATOM *at = orig_at_data->at; + + /* Total number of input atoms present in the molecular structure */ + int num_at = orig_at_data->num_inp_atoms; + + /* Pointer to the array storing the old component numbers for each atom, used for tracking connectivity */ + AT_NUMB *nOldCompNumber = orig_at_data->nOldCompNumber; + + /* Track number of disconnections */ + int num_disconnected = 0; + + /* variables declared */ + int i, j, n, k, t; + int binaryValue; + int disconnectDecision; + int neighbor_idx, neigh_pos; + + /* memory allocation */ + S_CHAR* dfs_visited = (S_CHAR*)inchi_calloc(num_at, sizeof(S_CHAR)); + int* dfs_stack = (int*)inchi_malloc(num_at * sizeof(int)); + int* ligand_elem_array = (int*)inchi_malloc(num_at * sizeof(int)); + int* structure_id = (int*)inchi_malloc(num_at * sizeof(int)); + int* structure_metal_count = (int*)inchi_calloc(num_at, sizeof(int)); + + if (!dfs_visited || !dfs_stack || !ligand_elem_array || !structure_id || !structure_metal_count) + { + ret_code = -1; + goto cleanup; + } + + /* Function call to Mark ring systems */ + MarkRingSystemsInp(at, num_at, 0); + + /* Compute metal list */ + int num_metals = 0; + for (i = 0; i < num_at; i++) + { + if (is_el_a_metal(at[i].el_number)) + { + num_metals++; + } + } + + /* + * Precompute structure components (DFS RUN ONCE) to satisfy this rule below, + * (if there is a path from this metal to ANY other metal, + * keep all bonds for this metal) + */ + for (i = 0; i < num_at; i++) + { + structure_id[i] = -1; + } + + int current_component = 0; + + for (i = 0; i < num_at; i++) + { + if (structure_id[i] >= 0) + { + continue; + } + + int dfs_stack_size = 0; + dfs_stack[dfs_stack_size++] = i; + structure_id[i] = current_component; + + while (dfs_stack_size) + { + int current_atom = dfs_stack[--dfs_stack_size]; + + if (is_el_a_metal(at[current_atom].el_number)) + { + structure_metal_count[current_component]++; + } + + for (neigh_pos = 0; neigh_pos < at[current_atom].valence; neigh_pos++) + { + int neighbor_atom = at[current_atom].neighbor[neigh_pos]; + + if (neighbor_atom < 0 || neighbor_atom >= num_at) + { + continue; + } + if (structure_id[neighbor_atom] >= 0) + { + continue; + } + + structure_id[neighbor_atom] = current_component; + + if (dfs_stack_size < num_at) + { + dfs_stack[dfs_stack_size++] = neighbor_atom; + } + } + } + + current_component++; + } + + for (i = 0; i < num_at; i++) + { + if (!is_el_a_metal(at[i].el_number)) + { + continue; + } + + /*@nnuk + *If there exists any path between this metal and any other metal OR + *the atom belongs to a ring system containing at least one metal, then keep all bonds for this metal. + */ + int keep_all_ligand_for_this_metal = 0; + + /* @nnuk + *if this metal is part of a ring system that contains at least one metal, + *keep all bonds for this metal + */ + if (at[i].nRingSystem) + { + /* scan atoms that are in same ring system and check for a metal */ + AT_NUMB ring_id = at[i].nRingSystem; + + for (k = 0; k < num_at; k++) + { + if (k != i && at[k].nRingSystem == ring_id && is_el_a_metal(at[k].el_number)) + { + keep_all_ligand_for_this_metal = 1; + break; + } + } + } + + /*@nnuk + *if there is a path from this metal to ANY other metal, + *keep all bonds for this metal. + */ + if (!keep_all_ligand_for_this_metal && num_metals > 1) + { + int processed_structure = structure_id[i]; + + if (structure_metal_count[processed_structure] > 1) + { + keep_all_ligand_for_this_metal = 1; + } + } + + if (keep_all_ligand_for_this_metal) + { + ip->bMolecularInorganicsReconnectedInChI = 1; + continue; + } + + /*@nnuk + *If central metal is bound to different ligand atom element types + *AND at least one of the bonds must be kept according to existing bond rules, + *then keep ALL bonds + */ + { + int ligand_type_count = 0; + int must_keep_neighbor = 0; + + for (n = 0; n < at[i].valence; n++) + { + int neigh_idx = at[i].neighbor[n]; + + if (neigh_idx < 0 || neigh_idx >= num_at) + { + continue; + } + + int neigh_elem = at[neigh_idx].el_number; + int found = 0; + + for (t = 0; t < ligand_type_count; t++) + { + if (ligand_elem_array[t] == neigh_elem) + { + found = 1; + break; + } + } + + if (!found) + { + ligand_elem_array[ligand_type_count++] = neigh_elem; + } + + if (at[i].bond_type[n] > 1 || is_el_a_metal(at[neigh_idx].el_number)) + { + must_keep_neighbor = 1; + } + else + { + binaryValue = shouldBondBeCut(at[i].el_number, neigh_elem); + + if (binaryValue != 1) + { + must_keep_neighbor = 1; + } + } + } + + if (ligand_type_count > 1 && must_keep_neighbor) + { + ip->bMolecularInorganicsReconnectedInChI = 1; + continue; + } + } + + /* Call the MolecularInorganicsIsMetalToDisconnect function */ + disconnectDecision = MolecularInorganicsIsMetalToDisconnect(at, i); + + if (disconnectDecision != 1) /* If disconnectDecision = 1, then disconnection procedure will be followed if applicable */ + { + /* (@nnuk) : No disconnection if the metal atom bounding capacity is greater than + * the limit set inside Molecular Inorganics elements array or if the metal atom is + * isolated. */ + ip->bMolecularInorganicsReconnectedInChI = 1; + continue; + } + + /* Proceed with electronegativity and disconnection logic */ + for (n = at[i].valence - 1; n >= 0; n--) + { + neighbor_idx = at[i].neighbor[n]; + + /* Check if the neighboring atom has more than 1 bond connected to the metal atom or + * if the neighbour is also a metal atom. In both cases no disconnection has to be done */ + if (at[i].bond_type[n] > 1 || is_el_a_metal(at[neighbor_idx].el_number)) + { + ip->bMolecularInorganicsReconnectedInChI = 1; + continue; /* Skip disconnection for this bond */ + } + + binaryValue = shouldBondBeCut(at[i].el_number, at[neighbor_idx].el_number); + + if (binaryValue != 1) + { + /* (@nnuk : Keep the bonds, no disconnection) */ + ip->bMolecularInorganicsReconnectedInChI = 1; + continue; + } + + DisconnectInpAtBond(at, nOldCompNumber, i, n); + + /* Updating the metal as well as neighbor list */ + updateNeighborListMolecularInorganics(at, i, neighbor_idx); + updateNeighborListMolecularInorganics(at, neighbor_idx, i); + + at[i].charge += 1; /* Metal atom loses an electron -> +1 charge */ + at[neighbor_idx].charge -= 1; /* Neighbor atom gains an electron -> -1 charge */ + + num_disconnected++; + } + } + + /* After disconnection, invoke ammonium salt functions !!!!!TO-DO!!!!! */ + for (j = 0; j < num_at; j++) + { + int piO, pk; + S_CHAR num_explicit_H[NUM_H_ISOTOPES + 1]; + + if (bIsAmmoniumSalt(at, j, &piO, &pk, num_explicit_H)) + { + DisconnectAmmoniumSalt(at, j, piO, pk, num_explicit_H); + } + } + +cleanup: + if (dfs_visited) inchi_free(dfs_visited); + if (dfs_stack) inchi_free(dfs_stack); + if (ligand_elem_array) inchi_free(ligand_elem_array); + if (structure_id) inchi_free(structure_id); + if (structure_metal_count) inchi_free(structure_metal_count); + + return (ret_code < 0) ? ret_code : num_disconnected; +} + +#if (READ_INCHI_STRING == 1) /****************************************************************************/ -int bHeteroAtomMayHaveXchgIsoH( inp_ATOM *atom, int iat ) +int bHeteroAtomMayHaveXchgIsoH(inp_ATOM *atom, int iat) { inp_ATOM *at = atom + iat, *at2; int j, val, is_H = 0, num_H, iat_numb, bAccept; /* djb-rwth: removing redundant variables */ - if (0 > ( iat_numb = get_iat_number( at->el_number ) )) + if (0 > (iat_numb = get_iat_number(at->el_number))) { return 0; } - if (abs( at->charge ) > 1 || (at->radical && RADICAL_SINGLET != at->radical)) /* djb-rwth: addressing LLVM warning */ + if (abs(at->charge) > 1 || (at->radical && RADICAL_SINGLET != at->radical)) /* djb-rwth: addressing LLVM warning */ { return 0; } @@ -4062,44 +6718,44 @@ int bHeteroAtomMayHaveXchgIsoH( inp_ATOM *atom, int iat ) val = -1; switch (iat_numb) { - case IAT_N: - case IAT_P: - /* djb-rwth: removing redundant code */ - val = 3 + at->charge; - break; + case IAT_N: + case IAT_P: + /* djb-rwth: removing redundant code */ + val = 3 + at->charge; + break; - case IAT_O: - case IAT_S: - case IAT_Se: - case IAT_Te: - /* djb-rwth: removing redundant code */ - val = 2 + at->charge; - break; + case IAT_O: + case IAT_S: + case IAT_Se: + case IAT_Te: + /* djb-rwth: removing redundant code */ + val = 2 + at->charge; + break; - case IAT_F: - case IAT_Cl: - case IAT_Br: - case IAT_I: - if (at->charge == 0) - { - /* djb-rwth: removing redundant code */ - val = 1; - } - break; + case IAT_F: + case IAT_Cl: + case IAT_Br: + case IAT_I: + if (at->charge == 0) + { + /* djb-rwth: removing redundant code */ + val = 1; + } + break; - case IAT_H: - if (at->valence == 0 && - at->charge == 1) - { - is_H = 1; /* isolated proton */ - val = 0; - } + case IAT_H: + if (at->valence == 0 && + at->charge == 1) + { + is_H = 1; /* isolated proton */ + val = 0; + } } if (val < 0) { return 0; } - num_H = NUMH( at, 0 ); + num_H = NUMH(at, 0); if (val != at->chem_bonds_valence + num_H) { return 0; @@ -4113,9 +6769,9 @@ int bHeteroAtomMayHaveXchgIsoH( inp_ATOM *atom, int iat ) /* djb-rwth: removing redundant code */ for (j = 0, bAccept = 1; j < at->valence && bAccept; j++) { - at2 = atom + (int) at->neighbor[j]; + at2 = atom + (int)at->neighbor[j]; if ((at2->charge && at->charge) || - ( at2->radical && RADICAL_SINGLET != at2->radical )) /* djb-rwth: addressing LLVM warning */ + (at2->radical && RADICAL_SINGLET != at2->radical)) /* djb-rwth: addressing LLVM warning */ { return 0; /* adjacent charged/radical atoms: do not neutralizate */ } @@ -4125,12 +6781,10 @@ int bHeteroAtomMayHaveXchgIsoH( inp_ATOM *atom, int iat ) return 1; } - #endif - /****************************************************************************/ -int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms ) +int bNumHeterAtomHasIsotopicH(inp_ATOM *atom, int num_atoms) { int i, j, val, is_H = 0, num_H, iat_numb, bAccept, num_iso_H, cur_num_iso_H, num_iso_atoms; /* djb-rwth: removing redundant variables */ inp_ATOM *at, *at2; @@ -4141,15 +6795,15 @@ int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms ) for (i = 0, at = atom; i < num_atoms; i++, at++) { - num_iso_atoms += ( at->iso_atw_diff != 0 || NUM_ISO_H( at, 0 ) ); + num_iso_atoms += (at->iso_atw_diff != 0 || NUM_ISO_H(at, 0)); /* isotopic atoms and implicit isotopic H */ - if (0 >( iat_numb = get_iat_number( at->el_number ) )) + if (0 > (iat_numb = get_iat_number(at->el_number))) { continue; } - if (abs( at->charge ) > 1 || (at->radical && RADICAL_SINGLET != at->radical)) /* djb-rwth: addressing LLVM warning */ + if (abs(at->charge) > 1 || (at->radical && RADICAL_SINGLET != at->radical)) /* djb-rwth: addressing LLVM warning */ { continue; } @@ -4157,45 +6811,45 @@ int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms ) val = -1; switch (iat_numb) { - case IAT_N: - case IAT_P: - /* djb-rwth: removing redundant code */ - val = 3 + at->charge; - break; + case IAT_N: + case IAT_P: + /* djb-rwth: removing redundant code */ + val = 3 + at->charge; + break; - case IAT_O: - case IAT_S: - case IAT_Se: - case IAT_Te: - /* djb-rwth: removing redundant code */ - val = 2 + at->charge; - break; + case IAT_O: + case IAT_S: + case IAT_Se: + case IAT_Te: + /* djb-rwth: removing redundant code */ + val = 2 + at->charge; + break; - case IAT_F: - case IAT_Cl: - case IAT_Br: - case IAT_I: - if (at->charge == 0) - { - /* djb-rwth: removing redundant code */ - val = 1; - } - break; + case IAT_F: + case IAT_Cl: + case IAT_Br: + case IAT_I: + if (at->charge == 0) + { + /* djb-rwth: removing redundant code */ + val = 1; + } + break; - case IAT_H: - if (at->valence == 0 && - at->charge == 1) - { - is_H = 1; /* isolated proton */ - val = 0; - } + case IAT_H: + if (at->valence == 0 && + at->charge == 1) + { + is_H = 1; /* isolated proton */ + val = 0; + } } if (val < 0) { continue; } - num_H = NUMH( at, 0 ); + num_H = NUMH(at, 0); if (val != at->chem_bonds_valence + num_H) { continue; @@ -4204,22 +6858,22 @@ int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms ) if (is_H) { bAccept = 1; - cur_num_iso_H = ( at->iso_atw_diff != 0 ); + cur_num_iso_H = (at->iso_atw_diff != 0); } else { cur_num_iso_H = 0; for (j = 0, bAccept = 1; j < at->valence && bAccept; j++) { - at2 = atom + (int) at->neighbor[j]; + at2 = atom + (int)at->neighbor[j]; if ((at2->charge && at->charge) || - ( at2->radical && RADICAL_SINGLET != at2->radical )) /* djb-rwth: addressing LLVM warning */ + (at2->radical && RADICAL_SINGLET != at2->radical)) /* djb-rwth: addressing LLVM warning */ { bAccept = 0; /* adjacent charged/radical atoms: do not neutralizate */ break; } else if (at2->el_number == EL_NUMBER_H && - at2->valence == 1 && at2->iso_atw_diff) + at2->valence == 1 && at2->iso_atw_diff) { cur_num_iso_H++; /* isotopic explicit H */ } @@ -4227,65 +6881,62 @@ int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms ) if (bAccept) { - num_iso_atoms -= cur_num_iso_H; /* avoid counting explicit H as isotopic atom */ - cur_num_iso_H += NUM_ISO_H( at, 0 ); + num_iso_atoms -= cur_num_iso_H; /* avoid counting explicit H as isotopic atom */ + cur_num_iso_H += NUM_ISO_H(at, 0); } } - num_iso_H += ( bAccept && cur_num_iso_H ); /* number of acceptable heteroatoms that have isotopic H */ + num_iso_H += (bAccept && cur_num_iso_H); /* number of acceptable heteroatoms that have isotopic H */ } - return - ( ( num_iso_H ? 1 : 0 ) | ( num_iso_atoms ? 2 : 0 ) ); + return ((num_iso_H ? 1 : 0) | (num_iso_atoms ? 2 : 0)); } - /****************************************************/ /* Mark and count disconnected structure components */ /* by Depth-first searching each component */ /****************************************************/ -int cmp_components( const void *a1, const void *a2 ) +int cmp_components(const void *a1, const void *a2) { int ret; AT_NUMB n1; AT_NUMB n2; - n1 = ( (const AT_NUMB *) a1 )[0]; + n1 = ((const AT_NUMB *)a1)[0]; /* number of atoms in the component -- descending order */ - n2 = ( (const AT_NUMB *) a2 )[0]; + n2 = ((const AT_NUMB *)a2)[0]; - if ((ret = (int) n2 - (int) n1)) /* djb-rwth: addressing LLVM warning */ + if ((ret = (int)n2 - (int)n1)) /* djb-rwth: addressing LLVM warning */ { return ret; } /* stable sort */ - n1 = ( (const AT_NUMB *) a1 )[1]; + n1 = ((const AT_NUMB *)a1)[1]; /* component ordering number -- ascending order */ - n2 = ( (const AT_NUMB *) a2 )[1]; + n2 = ((const AT_NUMB *)a2)[1]; - ret = (int) n1 - (int) n2; + ret = (int)n1 - (int)n2; return ret; } - /**************************************************************************** Set the (disconnected) component numbers in ORIG_ATOM_DATA 'at[*].component' NB: components are (stable) sorted by number of heavy atoms ****************************************************************************/ -int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, - int bProcessOldCompNumbers ) +int MarkDisconnectedComponents(ORIG_ATOM_DATA *orig_at_data, + int bProcessOldCompNumbers) { typedef AT_NUMB AT_TRIPLE[3]; - inp_ATOM *at = orig_at_data->at; - int num_at = orig_at_data->num_inp_atoms; - AT_NUMB *nCurAtLen = NULL; + inp_ATOM *at = orig_at_data->at; + int num_at = orig_at_data->num_inp_atoms; + AT_NUMB *nCurAtLen = NULL; AT_NUMB *nNewCompNumber = NULL; AT_NUMB *nPrevAtom = NULL; - S_CHAR *iNeigh = NULL; + S_CHAR *iNeigh = NULL; AT_NUMB *nOldCompNumber = NULL; int i, j, num_components, ret; @@ -4293,12 +6944,12 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, AT_NUMB old_comp_no, another_comp_no, no_component; /* component_nbr[i][0] = number of atoms in the component i-1 - * component_nbr[i][1] = original component number (id-1) = i - * after sorting: - * component_nbr[j][2] = new number of component #(component_nbr[i][1]+1) - */ + * component_nbr[i][1] = original component number (id-1) = i + * after sorting: + * component_nbr[j][2] = new number of component #(component_nbr[i][1]+1) + */ AT_TRIPLE *component_nbr = NULL; - int fst_at, nxt_at, cur_at, cur_neq_fst; /* moved from below 2024-09-01 DT */ + int fst_at, nxt_at, cur_at, cur_neq_fst; /* moved from below 2024-09-01 DT */ /* initialize */ if (bProcessOldCompNumbers && !orig_at_data->nOldCompNumber) @@ -4320,11 +6971,11 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, return 0; } - nNewCompNumber = (AT_NUMB*)inchi_calloc(num_at, sizeof(nNewCompNumber[0])); - nPrevAtom = (AT_NUMB*)inchi_calloc(num_at, sizeof(nPrevAtom[0])); - iNeigh = (S_CHAR*)inchi_calloc(num_at, sizeof(iNeigh[0])); + nNewCompNumber = (AT_NUMB *)inchi_calloc(num_at, sizeof(nNewCompNumber[0])); + nPrevAtom = (AT_NUMB *)inchi_calloc(num_at, sizeof(nPrevAtom[0])); + iNeigh = (S_CHAR *)inchi_calloc(num_at, sizeof(iNeigh[0])); - if (!nNewCompNumber || !nPrevAtom || !iNeigh) /* nNewCompNumber: for non-recursive DFS only: */ + if (!nNewCompNumber || !nPrevAtom || !iNeigh) /* nNewCompNumber: for non-recursive DFS only: */ { goto exit_function; } @@ -4333,7 +6984,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, /* Mark and count; avoid deep DFS recursion: it may make verifying software unhappy */ /* nNewCompNumber[i] will contain new component number for atoms at[i], i=0..num_at-1 */ - + for (j = 0; j < num_at; j++) { if (!nNewCompNumber[j]) @@ -4347,7 +6998,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, /* first time at at[j] */ fst_at = cur_at; - nNewCompNumber[fst_at] = (AT_NUMB) num_components; + nNewCompNumber[fst_at] = (AT_NUMB)num_components; /* find next neighbor */ do @@ -4361,8 +7012,8 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, if (!nNewCompNumber[nxt_at]) { /* forward edge: found new atom */ - nNewCompNumber[nxt_at] = (AT_NUMB) num_components; - nPrevAtom[nxt_at] = (AT_NUMB) cur_at; + nNewCompNumber[nxt_at] = (AT_NUMB)num_components; + nPrevAtom[nxt_at] = (AT_NUMB)cur_at; cur_at = nxt_at; } } @@ -4379,17 +7030,17 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, } } - inchi_free( nPrevAtom ); + inchi_free(nPrevAtom); nPrevAtom = NULL; - inchi_free( iNeigh ); + inchi_free(iNeigh); iNeigh = NULL; /* Allocate more memory */ - i = inchi_max( num_components, orig_at_data->num_components ); + i = inchi_max(num_components, orig_at_data->num_components); - nCurAtLen = (AT_NUMB*)inchi_calloc((long long)num_components + 1, sizeof(nCurAtLen[0])); /* djb-rwth: cast operator added */ - nOldCompNumber = (AT_NUMB*)inchi_calloc((long long)i + 1, sizeof(nOldCompNumber[0])); /* djb-rwth: cast operator added */ - component_nbr = (AT_TRIPLE*)inchi_calloc((long long)num_components + 1, sizeof(component_nbr[0])); /* djb-rwth: cast operator added */ + nCurAtLen = (AT_NUMB *)inchi_calloc((long long)num_components + 1, sizeof(nCurAtLen[0])); /* djb-rwth: cast operator added */ + nOldCompNumber = (AT_NUMB *)inchi_calloc((long long)i + 1, sizeof(nOldCompNumber[0])); /* djb-rwth: cast operator added */ + component_nbr = (AT_TRIPLE *)inchi_calloc((long long)num_components + 1, sizeof(component_nbr[0])); /* djb-rwth: cast operator added */ if (!nCurAtLen || !nOldCompNumber || !component_nbr) { @@ -4405,7 +7056,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, for (j = 0; j < num_at; j++) { - component_nbr[(int) nNewCompNumber[j] - 1][0] ++; /* count atoms in each component */ + component_nbr[(int)nNewCompNumber[j] - 1][0]++; /* count atoms in each component */ } /* Sort settings @@ -4429,7 +7080,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, for (j = 0; j < num_at; j++) { /* new component number for at[j] */ - new_comp_no = component_nbr[(int) nNewCompNumber[j] - 1][2] - 1; /* starts from 0 */ + new_comp_no = component_nbr[(int)nNewCompNumber[j] - 1][2] - 1; /* starts from 0 */ if (bProcessOldCompNumbers) { /* old component number for at[j] */ @@ -4453,7 +7104,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, for (i = 0; i < num_components; i++) { if (nOldCompNumber[i] == old_comp_no || - nOldCompNumber[i] == another_comp_no) + nOldCompNumber[i] == another_comp_no) { nOldCompNumber[i] = no_component; } @@ -4479,7 +7130,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, nOldCompNumber[j] = 0; } else if (nOldCompNumber[j] && - !orig_at_data->nOldCompNumber[nOldCompNumber[j] - 1]) + !orig_at_data->nOldCompNumber[nOldCompNumber[j] - 1]) { /* the component has changed in the previous processing */ nOldCompNumber[j] = 0; @@ -4500,33 +7151,33 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, if (nNewCompNumber) { - inchi_free( nNewCompNumber ); + inchi_free(nNewCompNumber); } if (component_nbr) { - inchi_free( component_nbr ); + inchi_free(component_nbr); } if (ret < 0) { if (nPrevAtom) { - inchi_free( nPrevAtom ); + inchi_free(nPrevAtom); nPrevAtom = NULL; } if (iNeigh) { - inchi_free( iNeigh ); + inchi_free(iNeigh); iNeigh = NULL; } if (nCurAtLen) { - inchi_free( nCurAtLen ); + inchi_free(nCurAtLen); nCurAtLen = NULL; } if (nOldCompNumber) { - inchi_free( nOldCompNumber ); + inchi_free(nOldCompNumber); nOldCompNumber = NULL; } num_components = ret; @@ -4535,11 +7186,11 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, /* avoid memory leaks */ if (orig_at_data->nCurAtLen) { - inchi_free( orig_at_data->nCurAtLen ); + inchi_free(orig_at_data->nCurAtLen); } if (orig_at_data->nOldCompNumber) { - inchi_free( orig_at_data->nOldCompNumber ); + inchi_free(orig_at_data->nOldCompNumber); } orig_at_data->nCurAtLen = nCurAtLen; @@ -4547,25 +7198,24 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, orig_at_data->num_components = num_components; - return ret; /* number of disconnected components; - 1=>single connected structure */ + return ret; /* number of disconnected components; + 1=>single connected structure */ } - /**************************************************************************** Extract one (connected) component ****************************************************************************/ -int ExtractConnectedComponent( inp_ATOM *at, - int num_at, - int component_number, - inp_ATOM *component_at ) +int ExtractConnectedComponent(inp_ATOM *at, + int num_at, + int component_number, + inp_ATOM *component_at) { int i, j, num_component_at; AT_NUMB *number; - if (NULL == ( number = (AT_NUMB*) inchi_calloc( num_at, sizeof( AT_NUMB ) ) )) + if (NULL == (number = (AT_NUMB *)inchi_calloc(num_at, sizeof(AT_NUMB)))) { - return CT_OUT_OF_RAM; /* out of memory */ /* */ + return CT_OUT_OF_RAM; /* out of memory */ /* */ } /* copy atoms */ @@ -4581,64 +7231,61 @@ int ExtractConnectedComponent( inp_ATOM *at, /* renumber neighbors */ for (i = 0; i < num_component_at; i++) { - component_at[i].orig_compt_at_numb = (AT_NUMB) ( i + 1 ); + component_at[i].orig_compt_at_numb = (AT_NUMB)(i + 1); for (j = 0; j < component_at[i].valence; j++) { - component_at[i].neighbor[j] = number[(int) component_at[i].neighbor[j]]; + component_at[i].neighbor[j] = number[(int)component_at[i].neighbor[j]]; } } - inchi_free( number ); + inchi_free(number); return num_component_at; } - /****************************************************************************/ -int SetConnectedComponentNumber( inp_ATOM *at, int num_at, int component_number ) +int SetConnectedComponentNumber(inp_ATOM *at, int num_at, int component_number) { int i; for (i = 0; i < num_at; i++) { - at[i].component = (AT_NUMB) component_number; + at[i].component = (AT_NUMB)component_number; } return 0; } - /****************************************************************************/ -int Free_INChI_Stereo( INChI_Stereo *pINChI_Stereo ) +int Free_INChI_Stereo(INChI_Stereo *pINChI_Stereo) { if (pINChI_Stereo) { - qzfree( pINChI_Stereo->nNumber ); - qzfree( pINChI_Stereo->t_parity ); - qzfree( pINChI_Stereo->nNumberInv ); - qzfree( pINChI_Stereo->t_parityInv ); - qzfree( pINChI_Stereo->nBondAtom1 ); - qzfree( pINChI_Stereo->nBondAtom2 ); - qzfree( pINChI_Stereo->b_parity ); + qzfree(pINChI_Stereo->nNumber); + qzfree(pINChI_Stereo->t_parity); + qzfree(pINChI_Stereo->nNumberInv); + qzfree(pINChI_Stereo->t_parityInv); + qzfree(pINChI_Stereo->nBondAtom1); + qzfree(pINChI_Stereo->nBondAtom2); + qzfree(pINChI_Stereo->b_parity); } return 0; } - /****************************************************************************/ -INChI_Stereo *Alloc_INChI_Stereo( int num_at, int num_bonds ) +INChI_Stereo *Alloc_INChI_Stereo(int num_at, int num_bonds) { INChI_Stereo *pINChI_Stereo = (INChI_Stereo *) - inchi_calloc( 1, sizeof( INChI_Stereo ) ); + inchi_calloc(1, sizeof(INChI_Stereo)); if (pINChI_Stereo) { if (num_at && - ( pINChI_Stereo->nNumber = (AT_NUMB *) inchi_calloc( num_at, sizeof( pINChI_Stereo->nNumber[0] ) ) ) && - ( pINChI_Stereo->t_parity = (S_CHAR *) inchi_calloc( num_at, sizeof( pINChI_Stereo->t_parity[0] ) ) ) && - ( pINChI_Stereo->nNumberInv = (AT_NUMB *) inchi_calloc( num_at, sizeof( pINChI_Stereo->nNumberInv[0] ) ) ) && - ( pINChI_Stereo->t_parityInv = (S_CHAR *) inchi_calloc( num_at, sizeof( pINChI_Stereo->t_parityInv[0] ) ) )) + (pINChI_Stereo->nNumber = (AT_NUMB *)inchi_calloc(num_at, sizeof(pINChI_Stereo->nNumber[0]))) && + (pINChI_Stereo->t_parity = (S_CHAR *)inchi_calloc(num_at, sizeof(pINChI_Stereo->t_parity[0]))) && + (pINChI_Stereo->nNumberInv = (AT_NUMB *)inchi_calloc(num_at, sizeof(pINChI_Stereo->nNumberInv[0]))) && + (pINChI_Stereo->t_parityInv = (S_CHAR *)inchi_calloc(num_at, sizeof(pINChI_Stereo->t_parityInv[0])))) { ; } @@ -4648,9 +7295,9 @@ INChI_Stereo *Alloc_INChI_Stereo( int num_at, int num_bonds ) } if (num_bonds && - ( pINChI_Stereo->nBondAtom1 = (AT_NUMB *) inchi_calloc( num_bonds, sizeof( pINChI_Stereo->nBondAtom1[0] ) ) ) && - ( pINChI_Stereo->nBondAtom2 = (AT_NUMB *) inchi_calloc( num_bonds, sizeof( pINChI_Stereo->nBondAtom2[0] ) ) ) && - ( pINChI_Stereo->b_parity = (S_CHAR *) inchi_calloc( num_bonds, sizeof( pINChI_Stereo->b_parity[0] ) ) )) + (pINChI_Stereo->nBondAtom1 = (AT_NUMB *)inchi_calloc(num_bonds, sizeof(pINChI_Stereo->nBondAtom1[0]))) && + (pINChI_Stereo->nBondAtom2 = (AT_NUMB *)inchi_calloc(num_bonds, sizeof(pINChI_Stereo->nBondAtom2[0]))) && + (pINChI_Stereo->b_parity = (S_CHAR *)inchi_calloc(num_bonds, sizeof(pINChI_Stereo->b_parity[0])))) { ; } @@ -4663,16 +7310,15 @@ INChI_Stereo *Alloc_INChI_Stereo( int num_at, int num_bonds ) out_of_RAM: - Free_INChI_Stereo( pINChI_Stereo ); - qzfree( pINChI_Stereo ); + Free_INChI_Stereo(pINChI_Stereo); + qzfree(pINChI_Stereo); } /* if ( pINChI_Stereo ) */ return NULL; } - /****************************************************************************/ -int Free_INChI( INChI **ppINChI ) +int Free_INChI(INChI **ppINChI) { INChI *pINChI; @@ -4680,22 +7326,21 @@ int Free_INChI( INChI **ppINChI ) if ((pINChI = *ppINChI)) /* djb-rwth: addressing LLVM warning */ { -#if ( bREUSE_INCHI == 1 ) +#if (bREUSE_INCHI == 1) if (pINChI->nRefCount-- > 0) return 1; #endif - Free_INChI_Members( pINChI ); - qzfree( pINChI ); + Free_INChI_Members(pINChI); + qzfree(pINChI); *ppINChI = NULL; } return 0; } - /****************************************************************************/ -int Free_INChI_Members( INChI *pINChI ) +int Free_INChI_Members(INChI *pINChI) { if (pINChI) { @@ -4709,29 +7354,28 @@ int Free_INChI_Members( INChI *pINChI ) qzfree(pINChI->IsotopicAtom); qzfree(pINChI->IsotopicTGroup); qzfree(pINChI->nPossibleLocationsOfIsotopicH); - qzfree( pINChI->Stereo ); - qzfree( pINChI->StereoIsotopic ); - qzfree( pINChI->szHillFormula ); + qzfree(pINChI->Stereo); + qzfree(pINChI->StereoIsotopic); + qzfree(pINChI->szHillFormula); } return 0; } - /****************************************************************************/ -INChI *Alloc_INChI( inp_ATOM *at, - int num_at, - int *found_num_bonds, - int *found_num_isotopic, - int nAllocMode ) +INChI *Alloc_INChI(inp_ATOM *at, + int num_at, + int *found_num_bonds, + int *found_num_isotopic, + int nAllocMode) { - int i, num_bonds, num_isotopic_atoms; - INChI *pINChI; - int bIsotopic = ( nAllocMode & REQ_MODE_ISO ); + int i, num_bonds, num_isotopic_atoms; + INChI *pINChI; + int bIsotopic = (nAllocMode & REQ_MODE_ISO); /* int bTautomeric = (nAllocMode & REQ_MODE_TAUT); */ if (num_at <= 0 || - NULL == ( pINChI = (INChI *) inchi_calloc( 1, sizeof( INChI ) ) )) + NULL == (pINChI = (INChI *)inchi_calloc(1, sizeof(INChI)))) { return NULL; } @@ -4740,12 +7384,12 @@ INChI *Alloc_INChI( inp_ATOM *at, { num_bonds += at[i].valence; /* if ( bIsotopic ) { */ - num_isotopic_atoms += ( 0 != at[i].iso_atw_diff || - !strcmp( at[i].elname, "D" ) || - !strcmp( at[i].elname, "T" ) || - at[i].num_iso_H[0] || - at[i].num_iso_H[1] || - at[i].num_iso_H[2] ); + num_isotopic_atoms += (0 != at[i].iso_atw_diff || + !strcmp(at[i].elname, "D") || + !strcmp(at[i].elname, "T") || + at[i].num_iso_H[0] || + at[i].num_iso_H[1] || + at[i].num_iso_H[2]); /* } */ } num_bonds /= 2; @@ -4753,11 +7397,11 @@ INChI *Alloc_INChI( inp_ATOM *at, *found_num_bonds = num_bonds; *found_num_isotopic = num_isotopic_atoms; - if (( pINChI->nAtom = (U_CHAR*) inchi_calloc( num_at, sizeof( pINChI->nAtom[0] ) ) ) && - ( pINChI->nConnTable = (AT_NUMB*) inchi_calloc( (long long)num_at + (long long)num_bonds, sizeof( pINChI->nConnTable[0] ) ) ) && /* djb-rwth: cast operator added */ - ( pINChI->nTautomer = (AT_NUMB*) inchi_calloc( ( ( 3 + INCHI_T_NUM_MOVABLE )*(long long)num_at ) / 2 + 1, sizeof( pINChI->nTautomer[0] ) ) ) && /* djb-rwth: cast operator added */ - ( pINChI->nNum_H = (S_CHAR*) inchi_calloc( num_at, sizeof( pINChI->nNum_H[0] ) ) ) && - ( pINChI->nNum_H_fixed = (S_CHAR*) inchi_calloc( num_at, sizeof( pINChI->nNum_H_fixed[0] ) ) )) + if ((pINChI->nAtom = (U_CHAR *)inchi_calloc(num_at, sizeof(pINChI->nAtom[0]))) && + (pINChI->nConnTable = (AT_NUMB *)inchi_calloc((long long)num_at + (long long)num_bonds, sizeof(pINChI->nConnTable[0]))) && /* djb-rwth: cast operator added */ + (pINChI->nTautomer = (AT_NUMB *)inchi_calloc(((3 + INCHI_T_NUM_MOVABLE) * (long long)num_at) / 2 + 1, sizeof(pINChI->nTautomer[0]))) && /* djb-rwth: cast operator added */ + (pINChI->nNum_H = (S_CHAR *)inchi_calloc(num_at, sizeof(pINChI->nNum_H[0]))) && + (pINChI->nNum_H_fixed = (S_CHAR *)inchi_calloc(num_at, sizeof(pINChI->nNum_H_fixed[0])))) { ; /* nTautomer length: max. number of tautomeric groups is num_at/2 @@ -4788,8 +7432,8 @@ INChI *Alloc_INChI( inp_ATOM *at, if (bIsotopic) { if (num_isotopic_atoms && - ( pINChI->IsotopicAtom = (INChI_IsotopicAtom *) inchi_calloc( num_isotopic_atoms, sizeof( INChI_IsotopicAtom ) ) ) && - ( pINChI->IsotopicTGroup = (INChI_IsotopicTGroup *) inchi_calloc( num_isotopic_atoms, sizeof( INChI_IsotopicTGroup ) ) )) + (pINChI->IsotopicAtom = (INChI_IsotopicAtom *)inchi_calloc(num_isotopic_atoms, sizeof(INChI_IsotopicAtom))) && + (pINChI->IsotopicTGroup = (INChI_IsotopicTGroup *)inchi_calloc(num_isotopic_atoms, sizeof(INChI_IsotopicTGroup)))) { ; } @@ -4797,13 +7441,13 @@ INChI *Alloc_INChI( inp_ATOM *at, { goto out_of_RAM; } - if (!( pINChI->nPossibleLocationsOfIsotopicH = (AT_NUMB *) inchi_calloc( (long long)num_at + 1, sizeof( pINChI->nPossibleLocationsOfIsotopicH[0] ) ) )) /* djb-rwth: cast operator added */ + if (!(pINChI->nPossibleLocationsOfIsotopicH = (AT_NUMB *)inchi_calloc((long long)num_at + 1, sizeof(pINChI->nPossibleLocationsOfIsotopicH[0])))) /* djb-rwth: cast operator added */ { goto out_of_RAM; } } - if (( pINChI->Stereo = Alloc_INChI_Stereo( num_at, num_bonds ) )) + if ((pINChI->Stereo = Alloc_INChI_Stereo(num_at, num_bonds))) { ; } @@ -4814,7 +7458,7 @@ INChI *Alloc_INChI( inp_ATOM *at, if (bIsotopic) { - if (( pINChI->StereoIsotopic = Alloc_INChI_Stereo( num_at, num_bonds ) )) + if ((pINChI->StereoIsotopic = Alloc_INChI_Stereo(num_at, num_bonds))) { ; } @@ -4829,7 +7473,7 @@ INChI *Alloc_INChI( inp_ATOM *at, out_of_RAM: if (pINChI) { - Free_INChI( &pINChI ); + Free_INChI(&pINChI); /* inchi_free(pINChI); */ @@ -4838,25 +7482,24 @@ INChI *Alloc_INChI( inp_ATOM *at, return NULL; } - /****************************************************************************/ -int Free_INChI_Aux( INChI_Aux **ppINChI_Aux ) +int Free_INChI_Aux(INChI_Aux **ppINChI_Aux) { INChI_Aux *pINChI_Aux = *ppINChI_Aux; if (pINChI_Aux) { -#if ( bREUSE_INCHI == 1 ) +#if (bREUSE_INCHI == 1) if (pINChI_Aux->nRefCount-- > 0) return 1; #endif - qzfree( pINChI_Aux->nOrigAtNosInCanonOrd ); - qzfree( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd ); - qzfree( pINChI_Aux->nOrigAtNosInCanonOrdInv ); - qzfree( pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv ); - qzfree( pINChI_Aux->szOrigCoord ); - qzfree( pINChI_Aux->OrigInfo ); + qzfree(pINChI_Aux->nOrigAtNosInCanonOrd); + qzfree(pINChI_Aux->nIsotopicOrigAtNosInCanonOrd); + qzfree(pINChI_Aux->nOrigAtNosInCanonOrdInv); + qzfree(pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv); + qzfree(pINChI_Aux->szOrigCoord); + qzfree(pINChI_Aux->OrigInfo); /* qzfree( pINChI_Aux->nOriginalAtomNumber ); qzfree( pINChI_Aux->nCanonicalTGroupNumbers ); @@ -4868,41 +7511,40 @@ int Free_INChI_Aux( INChI_Aux **ppINChI_Aux ) qzfree( pINChI_Aux->nNontautomericEquNumbers ); qzfree( pINChI_Aux->nNontautomericIsotopicEquNumbers ); */ - qzfree( pINChI_Aux->nConstitEquNumbers ); - qzfree( pINChI_Aux->nConstitEquTGroupNumbers ); - qzfree( pINChI_Aux->nConstitEquIsotopicNumbers ); - qzfree( pINChI_Aux->nConstitEquIsotopicTGroupNumbers ); - qzfree( pINChI_Aux ); + qzfree(pINChI_Aux->nConstitEquNumbers); + qzfree(pINChI_Aux->nConstitEquTGroupNumbers); + qzfree(pINChI_Aux->nConstitEquIsotopicNumbers); + qzfree(pINChI_Aux->nConstitEquIsotopicTGroupNumbers); + qzfree(pINChI_Aux); *ppINChI_Aux = NULL; } return 0; } - /****************************************************************************/ -INChI_Aux *Alloc_INChI_Aux( int num_at, - int num_isotopic_atoms, - int nAllocMode, - int bOrigCoord ) +INChI_Aux *Alloc_INChI_Aux(int num_at, + int num_isotopic_atoms, + int nAllocMode, + int bOrigCoord) { - INChI_Aux *pINChI_Aux; - int bIsotopic = ( nAllocMode & REQ_MODE_ISO ); - int num_at_tg = num_at + num_at / 2; + INChI_Aux *pINChI_Aux; + int bIsotopic = (nAllocMode & REQ_MODE_ISO); + int num_at_tg = num_at + num_at / 2; /* int bTautomeric = (nAllocMode & REQ_MODE_TAUT); */ if (num_at <= 0 || - NULL == ( pINChI_Aux = (INChI_Aux *) inchi_calloc( 1, sizeof( INChI_Aux ) ) )) + NULL == (pINChI_Aux = (INChI_Aux *)inchi_calloc(1, sizeof(INChI_Aux)))) { return NULL; } - if (( pINChI_Aux->nOrigAtNosInCanonOrd = (AT_NUMB*) - inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nOrigAtNosInCanonOrd[0] ) ) ) && - ( pINChI_Aux->nOrigAtNosInCanonOrdInv = (AT_NUMB*) - inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nOrigAtNosInCanonOrd[0] ) ) ) && - ( pINChI_Aux->nConstitEquNumbers = (AT_NUMB*) - inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nConstitEquNumbers[0] ) ) )) + if ((pINChI_Aux->nOrigAtNosInCanonOrd = (AT_NUMB *) + inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nOrigAtNosInCanonOrd[0]))) && + (pINChI_Aux->nOrigAtNosInCanonOrdInv = (AT_NUMB *) + inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nOrigAtNosInCanonOrd[0]))) && + (pINChI_Aux->nConstitEquNumbers = (AT_NUMB *) + inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nConstitEquNumbers[0])))) { ; } @@ -4912,7 +7554,7 @@ INChI_Aux *Alloc_INChI_Aux( int num_at, } if (num_at > 1 && - ( pINChI_Aux->nConstitEquTGroupNumbers = (AT_NUMB*) inchi_calloc( (long long)num_at / 2 + 1, sizeof( pINChI_Aux->nConstitEquTGroupNumbers[0] ) ) )) /* djb-rwth: cast operator added */ + (pINChI_Aux->nConstitEquTGroupNumbers = (AT_NUMB *)inchi_calloc((long long)num_at / 2 + 1, sizeof(pINChI_Aux->nConstitEquTGroupNumbers[0])))) /* djb-rwth: cast operator added */ { ; } @@ -4926,24 +7568,24 @@ INChI_Aux *Alloc_INChI_Aux( int num_at, if (num_at > 0) { - pINChI_Aux->OrigInfo = (ORIG_INFO *) inchi_calloc( num_at, sizeof( pINChI_Aux->OrigInfo[0] ) ); + pINChI_Aux->OrigInfo = (ORIG_INFO *)inchi_calloc(num_at, sizeof(pINChI_Aux->OrigInfo[0])); if (!pINChI_Aux->OrigInfo) goto out_of_RAM; } if (bOrigCoord && num_at > 0) { - pINChI_Aux->szOrigCoord = (MOL_COORD *) inchi_calloc( num_at, sizeof( pINChI_Aux->szOrigCoord[0] ) ); + pINChI_Aux->szOrigCoord = (MOL_COORD *)inchi_calloc(num_at, sizeof(pINChI_Aux->szOrigCoord[0])); if (!pINChI_Aux->szOrigCoord) goto out_of_RAM; } if (bIsotopic) { - if ( /*num_isotopic_atoms &&*/ - ( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd = (AT_NUMB*) inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0] ) ) ) && - ( pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv = (AT_NUMB*) inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0] ) ) ) && - ( pINChI_Aux->nConstitEquIsotopicNumbers = (AT_NUMB*) inchi_calloc( num_at_tg, sizeof( pINChI_Aux->nConstitEquIsotopicNumbers[0] ) ) )) + if (/*num_isotopic_atoms &&*/ + (pINChI_Aux->nIsotopicOrigAtNosInCanonOrd = (AT_NUMB *)inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0]))) && + (pINChI_Aux->nIsotopicOrigAtNosInCanonOrdInv = (AT_NUMB *)inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nIsotopicOrigAtNosInCanonOrd[0]))) && + (pINChI_Aux->nConstitEquIsotopicNumbers = (AT_NUMB *)inchi_calloc(num_at_tg, sizeof(pINChI_Aux->nConstitEquIsotopicNumbers[0])))) { ; } @@ -4952,8 +7594,8 @@ INChI_Aux *Alloc_INChI_Aux( int num_at, goto out_of_RAM; } - if ( /*num_isotopic_atoms && num_at > 1 &&*/ - ( pINChI_Aux->nConstitEquIsotopicTGroupNumbers = (AT_NUMB*) inchi_calloc( (long long)num_at / 2 + 1, sizeof( pINChI_Aux->nConstitEquIsotopicTGroupNumbers[0] ) ) )) /* djb-rwth: cast operator added */ + if ( /*num_isotopic_atoms && num_at > 1 &&*/ + (pINChI_Aux->nConstitEquIsotopicTGroupNumbers = (AT_NUMB *)inchi_calloc((long long)num_at / 2 + 1, sizeof(pINChI_Aux->nConstitEquIsotopicTGroupNumbers[0])))) /* djb-rwth: cast operator added */ { ; } @@ -4965,12 +7607,11 @@ INChI_Aux *Alloc_INChI_Aux( int num_at, return pINChI_Aux; - out_of_RAM: if (pINChI_Aux) { - Free_INChI_Aux( &pINChI_Aux ); + Free_INChI_Aux(&pINChI_Aux); /* inchi_free(pINChI_Aux); */ @@ -4979,11 +7620,10 @@ INChI_Aux *Alloc_INChI_Aux( int num_at, return NULL; } - /**************************************************************************** Note that orig_num, curr_num are allocd by caller as (n+1)-long lists ****************************************************************************/ -void CompAtomData_GetNumMapping( COMP_ATOM_DATA *adata, int *orig_num, int *curr_num ) +void CompAtomData_GetNumMapping(COMP_ATOM_DATA *adata, int *orig_num, int *curr_num) { int i; if (!orig_num || !curr_num) @@ -4993,18 +7633,17 @@ void CompAtomData_GetNumMapping( COMP_ATOM_DATA *adata, int *orig_num, int *curr for (i = 0; i < adata->num_at; i++) { int orig = adata->at[i].orig_at_number; - orig_num[i] = orig; /* orig's are from 1 */ - curr_num[orig] = i; /* curr's are from 0 */ + orig_num[i] = orig; /* orig's are from 1 */ + curr_num[orig] = i; /* curr's are from 0 */ } } - /**************************************************************************** Allocate integer matrix [mxn] ****************************************************************************/ -int imat_new( int m, int n, int ***a ) +int imat_new(int m, int n, int ***a) { - int i; + int i; if (m == 0 || n == 0) { return 0; @@ -5014,15 +7653,15 @@ int imat_new( int m, int n, int ***a ) imat_free(m, *a); *a = NULL; } - *a = (int **) inchi_calloc( m, sizeof( int * ) ); + *a = (int **)inchi_calloc(m, sizeof(int *)); if (NULL == *a) { return 1; } for (i = 0; i < m; i++) { - ( *a )[i] = (int *) inchi_calloc( n, sizeof( int ) ); - if (NULL == ( *a )[i]) + (*a)[i] = (int *)inchi_calloc(n, sizeof(int)); + if (NULL == (*a)[i]) { return 1; } @@ -5033,7 +7672,7 @@ int imat_new( int m, int n, int ***a ) /**************************************************************************** Free integer matrix [mxn] ****************************************************************************/ -void imat_free( int m, int **a ) +void imat_free(int m, int **a) { int i; if (NULL != a) @@ -5042,32 +7681,30 @@ void imat_free( int m, int **a ) { if (NULL != a[i]) /* djb-rwth: ui_rr? -- false positive as this function just does the clean-up job */ { - inchi_free( a[i] ); + inchi_free(a[i]); } } - inchi_free( a ); + inchi_free(a); a = NULL; } return; } - /* Lt-wt subgraph */ - /**************************************************************************** Establish light-weight subgraph representing (part of) orig_inp_data ****************************************************************************/ -subgraf *subgraf_new( ORIG_ATOM_DATA *orig_inp_data, - int nnodes, - int *nodes ) +subgraf *subgraf_new(ORIG_ATOM_DATA *orig_inp_data, + int nnodes, + int *nodes) { int i, j, iat, nbr, jat, nj, degree, nat, err = 0; - subgraf *sg = (subgraf *) inchi_calloc( 1, sizeof( subgraf ) ); + subgraf *sg = (subgraf *)inchi_calloc(1, sizeof(subgraf)); if (!sg) { return NULL; @@ -5077,15 +7714,15 @@ subgraf *subgraf_new( ORIG_ATOM_DATA *orig_inp_data, /* orig2node is mapping of original at numbers --> subgraph node numbers */ err = 1; - if (!( sg->orig2node = (int *) inchi_calloc( (long long)nat + 1, sizeof( int ) ) )) /* djb-rwth: cast operator added */ + if (!(sg->orig2node = (int *)inchi_calloc((long long)nat + 1, sizeof(int)))) /* djb-rwth: cast operator added */ { goto exit_function; } - if (!( sg->nodes = (int *) inchi_calloc( nnodes, sizeof( int ) ) )) + if (!(sg->nodes = (int *)inchi_calloc(nnodes, sizeof(int)))) { goto exit_function; } - if (!( sg->degrees = (int *) inchi_calloc( nnodes, sizeof( int ) ) )) + if (!(sg->degrees = (int *)inchi_calloc(nnodes, sizeof(int)))) { goto exit_function; } @@ -5106,9 +7743,9 @@ subgraf *subgraf_new( ORIG_ATOM_DATA *orig_inp_data, sg->orig2node[sg->nodes[i]] = i; } - /* Create and fill subgraph adjacency matrix based on nodes/orig atom numbers + /* Create and fill subgraph adjacency matrix based on nodes/orig atom numbers and connections stored in orig_inp_data */ - sg->adj = (subgraf_edge **) inchi_calloc( nnodes, sizeof( subgraf_edge * ) ); + sg->adj = (subgraf_edge **)inchi_calloc(nnodes, sizeof(subgraf_edge *)); if (!sg->adj) { goto exit_function; @@ -5116,10 +7753,10 @@ subgraf *subgraf_new( ORIG_ATOM_DATA *orig_inp_data, for (i = 0; i < sg->nnodes; i++) { - iat = nodes[i] - 1; /* current atom number for this node */ + iat = nodes[i] - 1; /* current atom number for this node */ degree = orig_inp_data->at[iat].valence; nj = -1; - sg->adj[i] = (subgraf_edge *) inchi_calloc( degree, sizeof( subgraf_edge ) ); + sg->adj[i] = (subgraf_edge *)inchi_calloc(degree, sizeof(subgraf_edge)); if (!sg->adj[i]) { goto exit_function; @@ -5143,16 +7780,15 @@ subgraf *subgraf_new( ORIG_ATOM_DATA *orig_inp_data, exit_function: if (err) { - subgraf_free( sg ); + subgraf_free(sg); return NULL; /* djb-rwth: avoiding reading from freed memory */ } return sg; } - /****************************************************************************/ -void subgraf_free( subgraf *sg ) +void subgraf_free(subgraf *sg) { int i; if (!sg) @@ -5161,15 +7797,15 @@ void subgraf_free( subgraf *sg ) } if (sg->nodes) { - inchi_free( sg->nodes ); + inchi_free(sg->nodes); } if (sg->degrees) { - inchi_free( sg->degrees ); + inchi_free(sg->degrees); } if (sg->orig2node) { - inchi_free( sg->orig2node ); + inchi_free(sg->orig2node); } if (sg->adj) { @@ -5177,55 +7813,54 @@ void subgraf_free( subgraf *sg ) { if (sg->adj[i]) /* djb-rwth: ui_rr? -- false positive as this function just does the clean-up job */ { - inchi_free( sg->adj[i] ); + inchi_free(sg->adj[i]); } } - inchi_free( sg->adj ); + inchi_free(sg->adj); } - inchi_free( sg ); + inchi_free(sg); sg = NULL; return; } /****************************************************************************/ -void subgraf_debug_trace( subgraf *sg ) +void subgraf_debug_trace(subgraf *sg) { int p, q; - ITRACE_( "\n\n*********************************************************************\n* Subgraf:" ); - ITRACE_( "\n\tNodes: %-d ( ", sg->nnodes ); + ITRACE_("\n\n*********************************************************************\n* Subgraf:"); + ITRACE_("\n\tNodes: %-d ( ", sg->nnodes); for (p = 0; p < sg->nnodes; p++) { - ITRACE_( "%-d ", sg->nodes[p] ); + ITRACE_("%-d ", sg->nodes[p]); } - ITRACE_( ")\n\tAdj lists:\n" ); + ITRACE_(")\n\tAdj lists:\n"); for (p = 0; p < sg->nnodes; p++) { - ITRACE_( "\tNode #%-d (orig# %-d) ::: Neighbors (node#, orig#) : ", - p, sg->nodes[p] ); + ITRACE_("\tNode #%-d (orig# %-d) ::: Neighbors (node#, orig#) : ", + p, sg->nodes[p]); for (q = 0; q < sg->degrees[p]; q++) { int nbr = sg->adj[p][q].nbr; /* djb-rwth: ignoring LLVM warning: variable used */ - ITRACE_( "(%-d/%-d/%-d) ", nbr, sg->nodes[nbr] ); + ITRACE_("(%-d/%-d/%-d) ", nbr, sg->nodes[nbr]); } - ITRACE_( "\n" ); + ITRACE_("\n"); } - ITRACE_( "\n* End Subgraf\n*********************************************************************\n" ); + ITRACE_("\n* End Subgraf\n*********************************************************************\n"); return; } - /****************************************************************************/ -subgraf_pathfinder * subgraf_pathfinder_new( subgraf *sg, - ORIG_ATOM_DATA *orig_inp_data, - int start, - int end ) +subgraf_pathfinder *subgraf_pathfinder_new(subgraf *sg, + ORIG_ATOM_DATA *orig_inp_data, + int start, + int end) { subgraf_pathfinder *spf = NULL; - spf = (subgraf_pathfinder *) inchi_calloc( 1, sizeof( subgraf_pathfinder ) ); + spf = (subgraf_pathfinder *)inchi_calloc(1, sizeof(subgraf_pathfinder)); if (!spf) { goto exit_function; @@ -5237,10 +7872,10 @@ subgraf_pathfinder * subgraf_pathfinder_new( subgraf *sg, spf->nbonds = 0; spf->nseen = 0; - spf->seen = (int *) inchi_calloc( spf->sg->nnodes, sizeof( int ) ); + spf->seen = (int *)inchi_calloc(spf->sg->nnodes, sizeof(int)); if (!spf->seen) { - inchi_free( spf ); + inchi_free(spf); spf = NULL; } @@ -5249,7 +7884,7 @@ subgraf_pathfinder * subgraf_pathfinder_new( subgraf *sg, } /****************************************************************************/ -void subgraf_pathfinder_free( subgraf_pathfinder *spf ) +void subgraf_pathfinder_free(subgraf_pathfinder *spf) { if (!spf) { @@ -5257,27 +7892,26 @@ void subgraf_pathfinder_free( subgraf_pathfinder *spf ) } if (spf->seen) { - inchi_free( spf->seen ); + inchi_free(spf->seen); } - inchi_free( spf ); + inchi_free(spf); spf = NULL; return; } - /**************************************************************************** - Find path(s) from subgraf node spf->start to spf->end + Find path(s) from subgraf node spf->start to spf->end and fill bonds[nbonds] and atoms[natoms] Do not traverse through supplied forbidden edges (if not zero/NULL) ****************************************************************************/ -void subgraf_pathfinder_run( subgraf_pathfinder *spf, - int nforbidden, /* number of edges forbidden for traversal */ - int *forbidden, /* nodes of forbidden edges: [edge1node1,edge1node2, edge2node1, edge2node2, ... ] */ - int *nbonds, - int **bonds, /* collect subgraf bonds here */ - int *natoms, - int *atoms /* if not NULL, collect subgraf atoms here */ - ) +void subgraf_pathfinder_run(subgraf_pathfinder *spf, + int nforbidden, /* number of edges forbidden for traversal */ + int *forbidden, /* nodes of forbidden edges: [edge1node1,edge1node2, edge2node1, edge2node2, ... ] */ + int *nbonds, + int **bonds, /* collect subgraf bonds here */ + int *natoms, + int *atoms /* if not NULL, collect subgraf atoms here */ +) { int j, k, node, node0; int f, skip; @@ -5293,16 +7927,16 @@ void subgraf_pathfinder_run( subgraf_pathfinder *spf, for (j = 0; j < spf->sg->degrees[node0]; j++) { node = spf->sg->adj[node0][j].nbr; - if (is_in_the_ilist( spf->seen, node, spf->nseen )) + if (is_in_the_ilist(spf->seen, node, spf->nseen)) { continue; } if (nforbidden && forbidden) - { + { skip = 0; for (f = 0; f < nforbidden; f++) { - if (bIsSameBond(node0, node, forbidden[2 * f], forbidden[2 * f + 1]) ) + if (bIsSameBond(node0, node, forbidden[2 * f], forbidden[2 * f + 1])) { skip = 1; break; @@ -5317,36 +7951,36 @@ void subgraf_pathfinder_run( subgraf_pathfinder *spf, { spf->seen[spf->nseen++] = node; - ITRACE_( "\n\tFound path (in orig atom numbers):\t" ); + ITRACE_("\n\tFound path (in orig atom numbers):\t"); for (k = 0; k < spf->nseen; k++) { int orig_atnum = spf->sg->nodes[spf->seen[k]]; - ITRACE_( "%-d ", orig_atnum); + ITRACE_("%-d ", orig_atnum); if (atoms && !is_in_the_ilist(atoms, orig_atnum, *natoms)) { atoms[(*natoms)++] = orig_atnum; } } - ITRACE_( "\t( In node nums: " ); + ITRACE_("\t( In node nums: "); for (k = 1; k < spf->nseen; k++) { int at1 = spf->seen[k - 1]; int at2 = spf->seen[k]; - add_bond_if_unseen( spf, at1, at2, nbonds, bonds ); + add_bond_if_unseen(spf, at1, at2, nbonds, bonds); - ITRACE_( "%-d ", spf->seen[k] ); + ITRACE_("%-d ", spf->seen[k]); } - ITRACE_( ")" ); + ITRACE_(")"); spf->seen[spf->nseen - 1] = 0; - spf->nseen--; /* pop_back */ + spf->nseen--; /* pop_back */ break; } } for (j = 0; j < spf->sg->degrees[node0]; j++) { node = spf->sg->adj[node0][j].nbr; - if (node == spf->end || is_in_the_ilist( spf->seen, node, spf->nseen )) + if (node == spf->end || is_in_the_ilist(spf->seen, node, spf->nseen)) { continue; } @@ -5367,7 +8001,7 @@ void subgraf_pathfinder_run( subgraf_pathfinder *spf, } } spf->seen[spf->nseen++] = node; - subgraf_pathfinder_run( spf, 0, NULL, nbonds, bonds, natoms, atoms ); + subgraf_pathfinder_run(spf, 0, NULL, nbonds, bonds, natoms, atoms); spf->seen[spf->nseen - 1] = 0; spf->nseen--; } @@ -5375,20 +8009,19 @@ void subgraf_pathfinder_run( subgraf_pathfinder *spf, return; } - /****************************************************************************/ -void add_bond_if_unseen( subgraf_pathfinder *spf, - int node0, - int node, - int *nbonds, - int **bonds ) +void add_bond_if_unseen(subgraf_pathfinder *spf, + int node0, + int node, + int *nbonds, + int **bonds) { int seen, p, at1, at2; at1 = spf->sg->nodes[node0]; at2 = spf->sg->nodes[node]; #if 0 - if (at1 > at2) + if ( at1 > at2 ) { int tmp = at1; at1 = at2; @@ -5409,21 +8042,20 @@ void add_bond_if_unseen( subgraf_pathfinder *spf, { bonds[*nbonds][0] = at1; bonds[*nbonds][1] = at2; - ( *nbonds )++; + (*nbonds)++; } return; } - /**************************************************************************** At the first call, push start node to spf->start and set spf->nseen = 0 ****************************************************************************/ int subgraf_pathfinder_collect_all(subgraf_pathfinder *spf, - int nforbidden, /* number of edges forbidden for traversal */ - int *forbidden, /* nodes of forbidden edges: [edge1node1,edge1node2, edge2node1, edge2node2, ... ] */ - int *atnums /* 1-based origs# */ - ) + int nforbidden, /* number of edges forbidden for traversal */ + int *forbidden, /* nodes of forbidden edges: [edge1node1,edge1node2, edge2node1, edge2node2, ... ] */ + int *atnums /* 1-based origs# */ +) { int j, f, node, next_node, skip; @@ -5462,13 +8094,11 @@ int subgraf_pathfinder_collect_all(subgraf_pathfinder *spf, return spf->nseen; } - -#if ( FIX_ADJ_RAD == 1 ) - +#if (FIX_ADJ_RAD == 1) /****************************************************************************/ -int FixNextRadicals( int cur_at, inp_ATOM *at ); -int FixNextRadicals( int cur_at, inp_ATOM *at ) +int FixNextRadicals(int cur_at, inp_ATOM *at); +int FixNextRadicals(int cur_at, inp_ATOM *at) { int j, neigh, num_found = 0; @@ -5479,20 +8109,19 @@ int FixNextRadicals( int cur_at, inp_ATOM *at ) { at[neigh].radical = 0; num_found++; - num_found += FixNextRadicals( neigh, at ); + num_found += FixNextRadicals(neigh, at); } } return num_found; } - /****************************************************************************/ -int FixAdjacentRadicals( int num_inp_atoms, inp_ATOM *at ) +int FixAdjacentRadicals(int num_inp_atoms, inp_ATOM *at) { int i, j; char *bVisited = NULL; - int nNumFound = 0, neigh, cur_found; + int nNumFound = 0, neigh, cur_found; for (i = 0; i < num_inp_atoms; i++) { @@ -5511,7 +8140,7 @@ int FixAdjacentRadicals( int num_inp_atoms, inp_ATOM *at ) { nNumFound++; at[i].radical = 0; - nNumFound += FixNextRadicals( i, at ); + nNumFound += FixNextRadicals(i, at); } } } @@ -5530,12 +8159,12 @@ int FixAdjacentRadicals( int num_inp_atoms, inp_ATOM *at ) */ /****************************************************************************/ -void PrintFileName( const char *fmt, - FILE *out_file, - /* INCHI_IOSTREAM *out_file, */ - const char *szFname ) +void PrintFileName(const char *fmt, + FILE *out_file, + /* INCHI_IOSTREAM *out_file, */ + const char *szFname) { - inchi_print_nodisplay( out_file, fmt, szFname ); + inchi_print_nodisplay(out_file, fmt, szFname); } #endif diff --git a/INCHI-1-SRC/INCHI_BASE/src/strutil.h b/INCHI-1-SRC/INCHI_BASE/src/strutil.h index 14af75ba..a0ce7ce3 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/strutil.h +++ b/INCHI-1-SRC/INCHI_BASE/src/strutil.h @@ -45,6 +45,8 @@ #include "inpdef.h" #include "ichi.h" +#include "util.h" /* (@nnuk : Nauman Ullah Khan) :: utilizing defined macros */ +#include "incomdef.h" #ifndef COMPILE_ALL_CPP #ifdef __cplusplus @@ -53,10 +55,63 @@ extern "C" #endif #endif + /*(@nnuk : Nauman Ullah Khan) + * Metal definitions for molecular inorganics (MolInOrg) + */ +#define MolInOrg1 1 /* takes the lowest valence of an element */ +#define MolInOrg2 3 /* takes the two lowest valences of an element */ +#define MolInOrg3 7 /* takes the three lowest valences of an element */ +#define MolInOrg4 15 /* takes the four lowest valences of an element */ + /* forward declaration */ struct tagTautomerGroupsInfo; struct tagCANON_GLOBALS; + /*(@nnuk : Nauman Ullah Khan) + * CHEMICAL ELEMENTS & ATOMIC VALENCE MODEL FOR VARIOUS OXIDATION STATES + */ + typedef struct tagMolecularInorganicsArray + { + /* Element chemical symbol */ + const char* szElName; + /* Average atomic mass from the Periodic Chart of the Elements + (Fisher cat. no. 05-702-10) */ + int nAtMass; + /* (not used currently) Atomic mass of the most abundant isotope */ + int nNormAtMass; + /* (not used currently) Exact mw of the most abundant isotope (not used) */ + double dAtMass; + /* MolInOrg1, MolInOrg2, MolInOrg3 or MolInOrg4 */ + int nType; + /* (not used currently) Pauling electronegativity x 10; 0 means unknown */ + int nElNegPauling10; + /* InChI does not add implicit H to atoms that have non-zero bSkipAddingH */ + /* NB: was called bDoNotAddH, renamed to avoid confusion with other procedures */ + int bSkipAddingH; + S_CHAR cValence[NUM_ATOM_CHARGES][MAX_NUM_VALENCES]; + } MolecularInorganicsElData; + + /*(@nnuk : Nauman Ullah Khan) :: Structure to hold variables for the array of all chemical elements, further used by MolecularInorganics function*/ + typedef struct tagElementsMolecularInorganics + { + int atomic_number; + char symbol[3]; /* Fixed length for symbol, up to 2 characters + null terminator */ + + } ElementsMolecularInorganics; + + /* (@nnuk : Nauman Ullah Khan) :: Main function for molecular inorganics */ + int MolecularInorganicsPreprocessing(ORIG_ATOM_DATA* orig_at_data, INPUT_PARMS* ip); + /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, for getting the binary value of the electronegativity difference between any two elements */ + int shouldBondBeCut(int atom1, int atom2); + /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, for updating the neighbour's list in the main molecular inorganics function processing */ + void updateNeighborListMolecularInorganics(inp_ATOM* at, int atom_idx, int neighbor_idx); + /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, decides for the specific metal bonds to be kept or disconnected. */ + int MolecularInorganicsIsMetalToDisconnect(inp_ATOM* at, int atom_idx); + /* Function retrieves valence values for molecular inorganics functionality*/ + int getElValenceforMolecularInorganics(int nPeriodicNum, int charge, int val_num); + /* Function retrieves element type value for molecular inorganics functionality*/ + int getElTypeforMolecularInorganics(int nPeriodicNum); + /** * @brief Extract one (connected) component * @@ -293,7 +348,7 @@ extern "C" IDIF_SC_MISS_UNDF | IDIF_SC_MISS | IDIF_SB_PARITY | IDIF_SB_EXTRA_UNDF | \ IDIF_SB_EXTRA | IDIF_SB_MISS_UNDF | IDIF_SB_MISS) -/*************************************************************************************/ + /*************************************************************************************/ #define ICR_MAX_ENDP_IN1_ONLY 32 #define ICR_MAX_ENDP_IN2_ONLY 32 #define ICR_MAX_DIFF_FIXED_H 32 diff --git a/INCHI-1-SRC/INCHI_BASE/src/util.c b/INCHI-1-SRC/INCHI_BASE/src/util.c index 72a518bb..16e620fc 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/util.c +++ b/INCHI-1-SRC/INCHI_BASE/src/util.c @@ -63,213 +63,180 @@ #include "bcf_s.h" -#define MIN_ATOM_CHARGE (-2) -#define MAX_ATOM_CHARGE 2 -#define NEUTRAL_STATE (-MIN_ATOM_CHARGE) -#define NUM_ATOM_CHARGES (MAX_ATOM_CHARGE - MIN_ATOM_CHARGE + 1) -#define MAX_NUM_VALENCES 5 /* max. number + 1 to provide zero termination */ - - - -/* - Local -*/ /* CHEMICAL ELEMENTS & ATOMIC VALENCE MODEL FOR VARIOUS OXIDATION STATES */ -typedef struct tagElData -{ - /* Element chemical symbol */ - const char *szElName; - /* Average atomic mass from the Periodic Chart of the Elements - (Fisher cat. no. 05-702-10) */ - int nAtMass; - /* (not used currently) Atomic mass of the most abundant isotope */ - int nNormAtMass; - /* (not used currently) Exact mw of the most abundant isotope (not used) */ - double dAtMass; - /* METAL or METAL2 */ - int nType; - /* (not used currently) Pauling electronegativity x 10; 0 means unknown */ - int nElNegPauling10; - /* InChI does not add implicit H to atoms that have non-zero bSkipAddingH */ - /* NB: was called bDoNotAddH, renamed to avoid confusion with other procedures */ - int bSkipAddingH; - S_CHAR cValence[NUM_ATOM_CHARGES][MAX_NUM_VALENCES]; -} ELDATA; - - const ELDATA ElData[] = { -/* avg norm El No -------- Valence(s) of an ion or neutral atom -------------*/ -/* mw mass exact mw type neg H -2 -1 0 +1 +2 */ -{ "H", 1, 1, 1.007825035, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "D", 2, 2, 2.014101778, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "T", 3, 3, 3.016049268, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "He", 4, 4, 4.002600000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "Li", 7, 7, 7.016000000, METAL , 10, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Be", 9, 9, 9.012180000, METAL , 15, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "B", 11, 11, 11.009300000, 0 , 20, 0, {{3,}, {4,}, {3,}, {2,}, {1,} }}, -{ "C", 12, 12, 12.000000000, 0 , 25, 0, {{2,}, {3,}, {4,}, {3,}, {2,} }}, -{ "N", 14, 14, 14.003074000, 0 , 30, 0, {{1,}, {2,}, {3,5}, {4,}, {3,} }}, -{ "O", 16, 16, 15.994914630, 0 , 35, 0, {{0,}, {1,}, {2,}, {3,5,}, {4,} }}, -{ "F", 19, 19, 18.998403220, 0 , 40, 0, {{0,}, {0,}, {1,}, {2,}, {3,5} }}, -{ "Ne", 20, 20, 19.992440000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "Na", 23, 23, 22.989770000, METAL , 9, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Mg", 24, 24, 23.985000000, METAL , 12, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "Al", 27, 27, 26.981540000, METAL , 15, 0, {{3,5,}, {4,}, {3,}, {2,}, {1,} }}, -{ "Si", 28, 28, 27.976927100, 0 , 18, 0, {{2,}, {3,5}, {4,}, {3,}, {2,} }}, -{ "P", 31, 31, 30.973762000, 0 , 21, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {4,}, {3,} }}, -{ "S", 32, 32, 31.972070700, 0 , 25, 0, {{0,}, {1,3,5,7,}, {2,4,6}, {3,5,}, {4,} }}, -{ "Cl", 35, 35, 34.968852730, 0 , 30, 0, {{0,}, {0,}, {1,3,5,7}, {2,4,6}, {3,5,} }}, -{ "Ar", 40, 40, 39.962400000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "K", 39, 39, 38.963700000, METAL , 8, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Ca", 40, 40, 39.962600000, METAL , 10, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "Sc", 45, 45, 44.955910000, METAL , 13, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Ti", 48, 48, 47.947950000, METAL , 15, 1, {{0,}, {0,}, {3,4}, {0,}, {0,} }}, -{ "V", 51, 51, 50.943960000, METAL , 16, 1, {{0,}, {0,}, {2,3,4,5,}, {0,}, {0,} }}, -{ "Cr", 52, 52, 51.940500000, METAL , 16, 1, {{0,}, {0,}, {2,3,6,}, {0,}, {0,} }}, -{ "Mn", 55, 55, 54.938050000, METAL2, 15, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, -{ "Fe", 56, 56, 55.934900000, METAL2, 18, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, -{ "Co", 59, 59, 58.933200000, METAL2, 18, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Ni", 59, 58, 57.935300000, METAL2, 18, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Cu", 64, 63, 62.929600000, METAL , 19, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, -{ "Zn", 65, 64, 63.929147000, METAL , 16, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, -{ "Ga", 70, 69, 68.925600000, METAL , 18, 0, {{3,5,}, {4,}, {3,}, {0,}, {1,} }}, -{ "Ge", 73, 74, 73.921177400, 0 , 18, 0, {{2,4,6,}, {3,5,}, {4,}, {3,}, {0,} }}, -{ "As", 75, 75, 74.921594200, 0 , 20, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {4,}, {3,} }}, -{ "Se", 79, 80, 79.916519600, 0 , 24, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {4,} }}, -{ "Br", 80, 79, 78.918336100, 0 , 28, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6,}, {3,5,} }}, -{ "Kr", 84, 84, 83.911500000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "Rb", 85, 85, 84.911800000, METAL , 8, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Sr", 88, 88, 87.905600000, METAL , 10, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "Y", 89, 89, 88.905860000, METAL , 12, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Zr", 91, 90, 89.904700000, METAL , 14, 1, {{0,}, {0,}, {4,}, {0,}, {0,} }}, -{ "Nb", 93, 93, 92.906400000, METAL , 16, 1, {{0,}, {0,}, {3,5,}, {0,}, {0,} }}, -{ "Mo", 96, 98, 97.905400000, METAL , 18, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Tc", 98, 98, 97.907200000, METAL , 19, 1, {{0,}, {0,}, {7,}, {0,}, {0,} }}, -{ "Ru", 101, 102, 101.904300000, METAL , 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, -{ "Rh", 103, 103, 102.905500000, METAL , 22, 1, {{0,}, {0,}, {2,3,4,}, {0,}, {0,} }}, -{ "Pd", 106, 106, 105.903500000, METAL , 22, 1, {{0,}, {0,}, {2,4,}, {0,}, {0,} }}, -{ "Ag", 108, 107, 106.905100000, METAL , 19, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Cd", 112, 114, 113.903400000, METAL , 17, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, -{ "In", 115, 115, 114.903900000, METAL , 17, 0, {{3,5,}, {2,4,}, {3,}, {0,}, {1,} }}, -{ "Sn", 119, 120, 119.902200000, METAL2, 18, 0, {{2,4,6,}, {3,5}, {2,4,}, {3,}, {0,} }}, -{ "Sb", 122, 121, 120.903800000, METAL, 19, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,}, {3,} }}, -{ "Te", 128, 130, 129.906200000, 0 , 21, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,} }}, -{ "I", 127, 127, 126.904500000, 0 , 25, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6}, {3,5,} }}, -{ "Xe", 131, 132, 131.904100000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "Cs", 133, 133, 132.905430000, METAL , 7, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Ba", 137, 138, 137.905200000, METAL , 9, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "La", 139, 139, 138.906360000, METAL , 11, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Ce", 140, 140, 139.905400000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, -{ "Pr", 141, 141, 140.907660000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, -{ "Nd", 144, 142, 141.907719000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Pm", 145, 145, 144.912800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Sm", 150, 152, 151.919700000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Eu", 152, 153, 152.921200000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Gd", 157, 158, 157.924099000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Tb", 159, 159, 158.925350000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, -{ "Dy", 163, 164, 163.929200000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, /* mw rounding uncertain */ -{ "Ho", 165, 165, 164.930300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Er", 167, 166, 165.930300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Tm", 169, 169, 168.934230000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Yb", 173, 174, 173.938900000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, -{ "Lu", 175, 175, 174.940800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Hf", 178, 180, 179.946600000, METAL , 13, 1, {{0,}, {0,}, {4,}, {0,}, {0,} }}, -{ "Ta", 181, 181, 180.948010000, METAL , 15, 1, {{0,}, {0,}, {5,}, {0,}, {0,} }}, -{ "W", 184, 184, 183.951000000, METAL2, 17, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Re", 186, 187, 186.955800000, METAL2, 19, 1, {{0,}, {0,}, {2,4,6,7,}, {0,}, {0,} }}, -{ "Os", 190, 192, 191.961500000, METAL2, 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, -{ "Ir", 192, 193, 192.962900000, METAL2, 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, -{ "Pt", 195, 195, 194.964800000, METAL2, 22, 1, {{0,}, {0,}, {2,4,}, {0,}, {0,} }}, -{ "Au", 197, 197, 196.966560000, METAL , 24, 1, {{0,}, {0,}, {1,3,}, {0,}, {0,} }}, -{ "Hg", 201, 202, 201.970617000, METAL2, 19, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, -{ "Tl", 204, 205, 204.974400000, METAL2, 18, 0, {{3,5,}, {2,4,}, {1,3,}, {0,}, {0,} }}, -{ "Pb", 207, 208, 207.976627000, METAL2, 18, 0, {{2,4,6,}, {3,5}, {2,4,}, {3,}, {0,} }}, -{ "Bi", 209, 209, 208.980390000, METAL , 19, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,}, {3,} }}, -{ "Po", 209, 209, 208.982400000, METAL2, 20, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,} }}, -{ "At", 210, 210, 209.987100000, 0 , 22, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6}, {3,5,} }}, -{ "Rn", 222, 222, 222.017500000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, -{ "Fr", 223, 223, 223.019700000, METAL , 0, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Ra", 226, 226, 226.025410000, METAL , 0, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, -{ "Ac", 227, 227, 227.027750000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Th", 232, 232, 232.038050000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, -{ "Pa", 231, 231, 231.035880000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,}, {0,}, {0,} }}, -{ "U", 238, 238, 238.050790000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Np", 237, 237, 237.048170000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Pu", 244, 244, 244.064200000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Am", 243, 243, 243.061370000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, -{ "Cm", 247, 247, 247.070300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Bk", 247, 247, 247.070300000, METAL , 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, -{ "Cf", 251, 251, 251.079600000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Es", 252, 252, 252.082800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Fm", 257, 257, 257.095100000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Md", 258, 258, 258.098600000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "No", 259, 259, 259.100900000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Lr", 260, 260, 260.105400000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Rf", 261, 261, 261.108700000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, - -/* - The elements below were added after v. 1.03. - When available, the mass is given for isotope with the longest half-life. - Standard valences given here are just placeholders. - v. 1.04: added elements 105-112. - Ref.: M. E. WIESER AND T. B. COPLEN. - Atomic weights of the elements 2009 (IUPAC Technical Report). - Pure Appl. Chem., Vol. 83, No. 2, pp. 359-396, 2011. - v. 1.05: added elements 114 and 116; - updated data for elements 105-112. - Ref.: J. Meija, T.B. Coplen, M.Berglund et al. - Atomic weights of the elements 2013 (IUPAC Technical Report). - Pure Appl. Chem., Vol. 88, No. 3, pp. 265-291, 2016. - added elements 113, 115, 117, and 118, according to IUPAC provisional recommendations: - Ref.: L. Ohrstrom, J. Reedijk. - Names and Symbols of the Elements with Atomic Numbers 113, 115, 117 and 118. - Pure Appl. Chem., May 1, 2016, Manuscript ID PAC-REC-16-05-01 - http://iupac.org/cms/wp-content/uploads/2016/06/names-and-symbols-of-elements.pdf -*/ + /* avg norm El No -------- Valence(s) of an ion or neutral atom -------------*/ + /* mw mass exact mw type neg H -2 -1 0 +1 +2 */ + { "H", 1, 1, 1.007825035, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "D", 2, 2, 2.014101778, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "T", 3, 3, 3.016049268, 0 , 21, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "He", 4, 4, 4.002600000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "Li", 7, 7, 7.016000000, METAL , 10, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Be", 9, 9, 9.012180000, METAL , 15, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "B", 11, 11, 11.009300000, 0 , 20, 0, {{3,}, {4,}, {3,}, {2,}, {1,} }}, + { "C", 12, 12, 12.000000000, 0 , 25, 0, {{2,}, {3,}, {4,}, {3,}, {2,} }}, + { "N", 14, 14, 14.003074000, 0 , 30, 0, {{1,}, {2,}, {3,5}, {4,}, {3,} }}, + { "O", 16, 16, 15.994914630, 0 , 35, 0, {{0,}, {1,}, {2,}, {3,5,}, {4,} }}, + { "F", 19, 19, 18.998403220, 0 , 40, 0, {{0,}, {0,}, {1,}, {2,}, {3,5} }}, + { "Ne", 20, 20, 19.992440000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "Na", 23, 23, 22.989770000, METAL , 9, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Mg", 24, 24, 23.985000000, METAL , 12, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "Al", 27, 27, 26.981540000, METAL , 15, 0, {{3,5,}, {4,}, {3,}, {2,}, {1,} }}, + { "Si", 28, 28, 27.976927100, 0 , 18, 0, {{2,}, {3,5}, {4,}, {3,}, {2,} }}, + { "P", 31, 31, 30.973762000, 0 , 21, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {4,}, {3,} }}, + { "S", 32, 32, 31.972070700, 0 , 25, 0, {{0,}, {1,3,5,7,}, {2,4,6}, {3,5,}, {4,} }}, + { "Cl", 35, 35, 34.968852730, 0 , 30, 0, {{0,}, {0,}, {1,3,5,7}, {2,4,6}, {3,5,} }}, + { "Ar", 40, 40, 39.962400000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "K", 39, 39, 38.963700000, METAL , 8, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Ca", 40, 40, 39.962600000, METAL , 10, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "Sc", 45, 45, 44.955910000, METAL , 13, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Ti", 48, 48, 47.947950000, METAL , 15, 1, {{0,}, {0,}, {3,4}, {0,}, {0,} }}, + { "V", 51, 51, 50.943960000, METAL , 16, 1, {{0,}, {0,}, {2,3,4,5,}, {0,}, {0,} }}, + { "Cr", 52, 52, 51.940500000, METAL , 16, 1, {{0,}, {0,}, {2,3,6,}, {0,}, {0,} }}, + { "Mn", 55, 55, 54.938050000, METAL2, 15, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, + { "Fe", 56, 56, 55.934900000, METAL2, 18, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, + { "Co", 59, 59, 58.933200000, METAL2, 18, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Ni", 59, 58, 57.935300000, METAL2, 18, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Cu", 64, 63, 62.929600000, METAL , 19, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, + { "Zn", 65, 64, 63.929147000, METAL , 16, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, + { "Ga", 70, 69, 68.925600000, METAL , 18, 0, {{3,5,}, {4,}, {3,}, {0,}, {1,} }}, + { "Ge", 73, 74, 73.921177400, 0 , 18, 0, {{2,4,6,}, {3,5,}, {4,}, {3,}, {0,} }}, + { "As", 75, 75, 74.921594200, 0 , 20, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {4,}, {3,} }}, + { "Se", 79, 80, 79.916519600, 0 , 24, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {4,} }}, + { "Br", 80, 79, 78.918336100, 0 , 28, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6,}, {3,5,} }}, + { "Kr", 84, 84, 83.911500000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "Rb", 85, 85, 84.911800000, METAL , 8, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Sr", 88, 88, 87.905600000, METAL , 10, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "Y", 89, 89, 88.905860000, METAL , 12, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Zr", 91, 90, 89.904700000, METAL , 14, 1, {{0,}, {0,}, {4,}, {0,}, {0,} }}, + { "Nb", 93, 93, 92.906400000, METAL , 16, 1, {{0,}, {0,}, {3,5,}, {0,}, {0,} }}, + { "Mo", 96, 98, 97.905400000, METAL , 18, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Tc", 98, 98, 97.907200000, METAL , 19, 1, {{0,}, {0,}, {7,}, {0,}, {0,} }}, + { "Ru", 101, 102, 101.904300000, METAL , 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, + { "Rh", 103, 103, 102.905500000, METAL , 22, 1, {{0,}, {0,}, {2,3,4,}, {0,}, {0,} }}, + { "Pd", 106, 106, 105.903500000, METAL , 22, 1, {{0,}, {0,}, {2,4,}, {0,}, {0,} }}, + { "Ag", 108, 107, 106.905100000, METAL , 19, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Cd", 112, 114, 113.903400000, METAL , 17, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, + { "In", 115, 115, 114.903900000, METAL , 17, 0, {{3,5,}, {2,4,}, {3,}, {0,}, {1,} }}, + { "Sn", 119, 120, 119.902200000, METAL2, 18, 0, {{2,4,6,}, {3,5}, {2,4,}, {3,}, {0,} }}, + { "Sb", 122, 121, 120.903800000, METAL, 19, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,}, {3,} }}, + { "Te", 128, 130, 129.906200000, 0 , 21, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,} }}, + { "I", 127, 127, 126.904500000, 0 , 25, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6}, {3,5,} }}, + { "Xe", 131, 132, 131.904100000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "Cs", 133, 133, 132.905430000, METAL , 7, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Ba", 137, 138, 137.905200000, METAL , 9, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "La", 139, 139, 138.906360000, METAL , 11, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Ce", 140, 140, 139.905400000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, + { "Pr", 141, 141, 140.907660000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, + { "Nd", 144, 142, 141.907719000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Pm", 145, 145, 144.912800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Sm", 150, 152, 151.919700000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Eu", 152, 153, 152.921200000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Gd", 157, 158, 157.924099000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Tb", 159, 159, 158.925350000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, + { "Dy", 163, 164, 163.929200000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, /* mw rounding uncertain */ + { "Ho", 165, 165, 164.930300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Er", 167, 166, 165.930300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Tm", 169, 169, 168.934230000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Yb", 173, 174, 173.938900000, METAL2, 0, 1, {{0,}, {0,}, {2,3,}, {0,}, {0,} }}, + { "Lu", 175, 175, 174.940800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Hf", 178, 180, 179.946600000, METAL , 13, 1, {{0,}, {0,}, {4,}, {0,}, {0,} }}, + { "Ta", 181, 181, 180.948010000, METAL , 15, 1, {{0,}, {0,}, {5,}, {0,}, {0,} }}, + { "W", 184, 184, 183.951000000, METAL2, 17, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Re", 186, 187, 186.955800000, METAL2, 19, 1, {{0,}, {0,}, {2,4,6,7,}, {0,}, {0,} }}, + { "Os", 190, 192, 191.961500000, METAL2, 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, + { "Ir", 192, 193, 192.962900000, METAL2, 22, 1, {{0,}, {0,}, {2,3,4,6,}, {0,}, {0,} }}, + { "Pt", 195, 195, 194.964800000, METAL2, 22, 1, {{0,}, {0,}, {2,4,}, {0,}, {0,} }}, + { "Au", 197, 197, 196.966560000, METAL , 24, 1, {{0,}, {0,}, {1,3,}, {0,}, {0,} }}, + { "Hg", 201, 202, 201.970617000, METAL2, 19, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, + { "Tl", 204, 205, 204.974400000, METAL2, 18, 0, {{3,5,}, {2,4,}, {1,3,}, {0,}, {0,} }}, + { "Pb", 207, 208, 207.976627000, METAL2, 18, 0, {{2,4,6,}, {3,5}, {2,4,}, {3,}, {0,} }}, + { "Bi", 209, 209, 208.980390000, METAL , 19, 0, {{1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,}, {3,} }}, + { "Po", 209, 209, 208.982400000, METAL2, 20, 0, {{0,}, {1,3,5,7,}, {2,4,6,}, {3,5,}, {2,4,} }}, + { "At", 210, 210, 209.987100000, 0 , 22, 0, {{0,}, {0,}, {1,3,5,7,}, {2,4,6}, {3,5,} }}, + { "Rn", 222, 222, 222.017500000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + { "Fr", 223, 223, 223.019700000, METAL , 0, 0, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Ra", 226, 226, 226.025410000, METAL , 0, 0, {{0,}, {0,}, {2,}, {1,}, {0,} }}, + { "Ac", 227, 227, 227.027750000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Th", 232, 232, 232.038050000, METAL2, 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, + { "Pa", 231, 231, 231.035880000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,}, {0,}, {0,} }}, + { "U", 238, 238, 238.050790000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Np", 237, 237, 237.048170000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Pu", 244, 244, 244.064200000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Am", 243, 243, 243.061370000, METAL2, 0, 1, {{0,}, {0,}, {3,4,5,6,}, {0,}, {0,} }}, + { "Cm", 247, 247, 247.070300000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Bk", 247, 247, 247.070300000, METAL , 0, 1, {{0,}, {0,}, {3,4,}, {0,}, {0,} }}, + { "Cf", 251, 251, 251.079600000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Es", 252, 252, 252.082800000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Fm", 257, 257, 257.095100000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Md", 258, 258, 258.098600000, METAL , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "No", 259, 259, 259.100900000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Lr", 260, 260, 260.105400000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Rf", 261, 261, 261.108700000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 105 dubnium Db ? Like: Ta */ -{ "Db", 270, 270, 270.131000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 106 seaborgium Sg ? Like: W */ -{ "Sg", 269, 269, 269.129000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 107 bohrium Bh ? Like: Re */ -{ "Bh", 270, 270, 270.133000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 108 hassium Hs ? Like: Os */ -{ "Hs", 270, 270, 270.134000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 109 meitnerium Mt ? Like: Ir */ -{ "Mt", 278, 278, 278.156000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 110 darmstadtium Ds ? Like: Pt */ -{ "Ds", 281, 281, 281.165000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 111 roentgenium Rg ? Like: Au */ -{ "Rg", 281, 281, 281.166000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 112 copernicium Cn ? Like: Hg */ -{ "Cn", 285, 285, 285.177000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 113 nihonium Nh ? Like: ? */ -{ "Nh", 278, 278, 278.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 114 flerovium Fl ? Like: Pb */ -{ "Fl", 289, 289, 289.190000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 115 moscovium Mc ? Like: ? */ -{ "Mc", 289, 289, 289.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 116 livermorium Lv ? Like: Po */ -{ "Lv", 293, 293, 293.204000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 117 tennessine Ts ? Like: ? */ -{ "Ts", 297, 297, 297.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* 118 oganesson Og ? Like: ? */ -{ "Og", 294, 294, 294.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -/* End of added in v. 1.04 - 1.05 */ -{ "Zy", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Zz", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -#ifdef INCHI_ZFRAG -{ "Zu", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, -{ "Zv", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, -{ "Zw", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, -{ "Zx", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, -#endif + /* + The elements below were added after v. 1.03. + When available, the mass is given for isotope with the longest half-life. + Standard valences given here are just placeholders. + v. 1.04: added elements 105-112. + Ref.: M. E. WIESER AND T. B. COPLEN. + Atomic weights of the elements 2009 (IUPAC Technical Report). + Pure Appl. Chem., Vol. 83, No. 2, pp. 359-396, 2011. + v. 1.05: added elements 114 and 116; + updated data for elements 105-112. + Ref.: J. Meija, T.B. Coplen, M.Berglund et al. + Atomic weights of the elements 2013 (IUPAC Technical Report). + Pure Appl. Chem., Vol. 88, No. 3, pp. 265-291, 2016. + added elements 113, 115, 117, and 118, according to IUPAC provisional recommendations: + Ref.: L. Ohrstrom, J. Reedijk. + Names and Symbols of the Elements with Atomic Numbers 113, 115, 117 and 118. + Pure Appl. Chem., May 1, 2016, Manuscript ID PAC-REC-16-05-01 + http://iupac.org/cms/wp-content/uploads/2016/06/names-and-symbols-of-elements.pdf + */ -{ "", 0, 0, 0.000000000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, + /* 105 dubnium Db ? Like: Ta */ + { "Db", 270, 270, 270.131000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 106 seaborgium Sg ? Like: W */ + { "Sg", 269, 269, 269.129000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 107 bohrium Bh ? Like: Re */ + { "Bh", 270, 270, 270.133000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 108 hassium Hs ? Like: Os */ + { "Hs", 270, 270, 270.134000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 109 meitnerium Mt ? Like: Ir */ + { "Mt", 278, 278, 278.156000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 110 darmstadtium Ds ? Like: Pt */ + { "Ds", 281, 281, 281.165000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 111 roentgenium Rg ? Like: Au */ + { "Rg", 281, 281, 281.166000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 112 copernicium Cn ? Like: Hg */ + { "Cn", 285, 285, 285.177000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 113 nihonium Nh ? Like: ? */ + { "Nh", 278, 278, 278.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 114 flerovium Fl ? Like: Pb */ + { "Fl", 289, 289, 289.190000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 115 moscovium Mc ? Like: ? */ + { "Mc", 289, 289, 289.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 116 livermorium Lv ? Like: Po */ + { "Lv", 293, 293, 293.204000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 117 tennessine Ts ? Like: ? */ + { "Ts", 297, 297, 297.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* 118 oganesson Og ? Like: ? */ + { "Og", 294, 294, 294.000000000, METAL , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + /* End of added in v. 1.04 - 1.05 */ + { "Zy", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Zz", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + #ifdef INCHI_ZFRAG + { "Zu", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,}, {0,}, {0,} }}, + { "Zv", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {2,}, {0,}, {0,} }}, + { "Zw", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {3,}, {0,}, {0,} }}, + { "Zx", 0, 0, 0.000000000, 0 , 0, 1, {{0,}, {0,}, {1,2,}, {0,}, {0,} }}, + #endif + + { "", 0, 0, 0.000000000, 0 , 0, 0, {{0,}, {0,}, {0,}, {0,}, {0,} }}, }; @@ -277,6 +244,7 @@ const int ERR_ELEM = 255; const int nElDataLen = sizeof( ElData ) / sizeof( ElData[0] ) - 1; + /* MISC. CHEMICAL-STRUCTURE RELATED UTILITIES AND HELPERS */ @@ -290,12 +258,12 @@ int get_element_chemical_symbol( int nAtNum, char *szElement ) { nAtNum -= 1; - if (0 < nAtNum) + if ( 0 < nAtNum ) { nAtNum += 2; /* bypass D, T */ } - if (0 <= nAtNum && nAtNum < nElDataLen) + if ( 0 <= nAtNum && nAtNum < nElDataLen ) { /* valid element symbol found */ strcpy(szElement, ElData[nAtNum].szElName); @@ -318,12 +286,12 @@ int get_element_or_pseudoelement_symbol( int nAtNum, { nAtNum -= 1; - if (0 < nAtNum) + if ( 0 < nAtNum ) { nAtNum += 2; /* bypass D, T */ } - if (0 <= nAtNum && nAtNum < nElDataLen) + if ( 0 <= nAtNum && nAtNum < nElDataLen ) { /* valid element symbol found */ strcpy(szElement, ElData[nAtNum].szElName); @@ -347,7 +315,7 @@ int get_element_or_pseudoelement_symbol( int nAtNum, int el_number_in_internal_ref_table( const char* elname ) { int i; - const char *p; + const char* p; for (i = 0; ( p = ElData[i].szElName )[0] && strcmp( p, elname ); i++) { @@ -412,7 +380,7 @@ int get_periodic_table_number( const char* elname ) num = el_number_in_internal_ref_table( elname ); - if (num < ERR_ELEM) + if ( num < ERR_ELEM ) { /* account for D,T in internal table (but not Mendeleev's table) */ num = inchi_max( 1, num - 1 ); @@ -438,7 +406,7 @@ int if_skip_add_H( int nPeriodicNum ) ****************************************************************************/ int get_el_valence( int nPeriodicNum, int charge, int val_num ) { - if (charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE || val_num >= MAX_NUM_VALENCES) + if ( charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE || val_num >= MAX_NUM_VALENCES ) { return 0; } @@ -460,14 +428,14 @@ int get_unusual_el_valence( int nPeriodicNum, { int i, num_found, chem_valence, rad_adj, known_chem_valence, exact_found; - if (!num_bonds && !num_H) + if ( !num_bonds && !num_H ) { return 0; } - if (charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE) + if ( charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE ) { - if (bonds_valence == num_bonds) + if ( bonds_valence == num_bonds ) { return 0; /* all single bonds */ } @@ -485,22 +453,22 @@ int get_unusual_el_valence( int nPeriodicNum, exact_found = 0; /* Take into account a radical */ - if (radical == RADICAL_DOUBLET) + if ( radical == RADICAL_DOUBLET ) { rad_adj = 1; } - else if (radical == RADICAL_TRIPLET) + else if ( radical == RADICAL_TRIPLET ) { rad_adj = 2; } - for (i = 0; i < MAX_NUM_VALENCES; i++) + for ( i = 0; i < MAX_NUM_VALENCES; i++ ) { if (0 < ( known_chem_valence = get_el_valence( nPeriodicNum, charge, i ) - rad_adj ) && num_bonds <= known_chem_valence && known_chem_valence <= chem_valence) { num_found++; - if (known_chem_valence == chem_valence) + if ( known_chem_valence == chem_valence ) { exact_found = 1; break; @@ -561,7 +529,7 @@ int needed_unusual_el_valence( int nPeriodicNum, if_skip_add_H( nPeriodicNum ) || bonds_valence != actual_bonds_valence || num_H_expected != num_H) { - if (!num_H && !num_H_expected && bonds_valence == actual_bonds_valence) + if ( !num_H && !num_H_expected && bonds_valence == actual_bonds_valence ) { return 0; /* no H */ } @@ -569,11 +537,11 @@ int needed_unusual_el_valence( int nPeriodicNum, } /* take into account radical */ - if (radical == RADICAL_DOUBLET) + if ( radical == RADICAL_DOUBLET ) { rad_adj = 1; } - else if (radical == RADICAL_TRIPLET) + else if ( radical == RADICAL_TRIPLET ) { rad_adj = 2; } @@ -586,19 +554,19 @@ int needed_unusual_el_valence( int nPeriodicNum, num_found = 0; exact_found = 0; - for (i = 0; i < MAX_NUM_VALENCES; i++) + for ( i = 0; i < MAX_NUM_VALENCES; i++ ) { if (0 < ( known_chem_valence = get_el_valence( nPeriodicNum, charge, i ) ) && bonds_valence <= ( known_chem_valence -= rad_adj )) { /* found known valence that fits without H */ num_found_known++; - if (known_chem_valence <= chem_valence) + if ( known_chem_valence <= chem_valence ) { /* known valence is large enough to accommodate (implicit) H */ num_found++; } - if (known_chem_valence == chem_valence) + if ( known_chem_valence == chem_valence ) { exact_found = 1; break; @@ -626,14 +594,14 @@ int detect_unusual_el_valence( int nPeriodicNum, { int i, chem_valence, rad_adj, known_chem_valence; - if (!num_bonds && !num_H) + if ( !num_bonds && !num_H ) { return 0; } - if (charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE) + if ( charge < MIN_ATOM_CHARGE || charge > MAX_ATOM_CHARGE ) { - if (bonds_valence == num_bonds) + if ( bonds_valence == num_bonds ) { return 0; /* all single bonds */ } @@ -649,20 +617,20 @@ int detect_unusual_el_valence( int nPeriodicNum, rad_adj = 0; /* take into account radical */ - if (radical == RADICAL_DOUBLET) + if ( radical == RADICAL_DOUBLET ) { rad_adj = 1; } - else if (radical == RADICAL_TRIPLET || radical == RADICAL_SINGLET) + else if ( radical == RADICAL_TRIPLET || radical == RADICAL_SINGLET ) { rad_adj = 2; } - for (i = 0; i < MAX_NUM_VALENCES; i++) + for ( i = 0; i < MAX_NUM_VALENCES; i++ ) { if (0 < ( known_chem_valence = get_el_valence( nPeriodicNum, charge, i ) - rad_adj )) { - if (known_chem_valence == chem_valence) + if ( known_chem_valence == chem_valence ) { return 0; } @@ -705,9 +673,9 @@ int extract_charges_and_radicals( char *elname, int *pnRadical, int *pnCharge ) p = elname; /* extract radicals & charges */ - while ((q = strpbrk(p, "+-^"))) /* djb-rwth: addressing LLVM warning */ + while ( (q = strpbrk(p, "+-^")) ) /* djb-rwth: addressing LLVM warning */ { - switch (*q) + switch ( *q ) { case '+': case '-': @@ -774,7 +742,7 @@ int extract_charges_and_radicals( char *elname, int *pnRadical, int *pnCharge ) int extract_H_atoms( char *elname, S_CHAR num_iso_H[] ) { int i, len, c, k, num_H, val; - char *q; + char* q; char elname1 = '\0'; i = 0; @@ -782,14 +750,14 @@ int extract_H_atoms( char *elname, S_CHAR num_iso_H[] ) len = (int) strlen( elname ); c = UCINT elname[0]; - if (len > 1) + if ( len > 1 ) { elname1 = elname[1]; } - while (i < len) + while ( i < len ) { - switch (c) + switch ( c ) { case 'H': k = 0; @@ -820,7 +788,7 @@ int extract_H_atoms( char *elname, S_CHAR num_iso_H[] ) { val = 1; } - if (k) + if ( k ) { num_iso_H[k] += val; } @@ -845,7 +813,7 @@ int extract_H_atoms( char *elname, S_CHAR num_iso_H[] ) len = (int) strlen( elname ); if (len == 2) { - if (elname[1] != elname1) + if ( elname[1] != elname1 ) /* Error, incorrect 2nd char of elname appears after 'subtracting' {H,D,T} */ /* See a bug reported to inchi-discuss by A. Dalke for alias atom "pH4d" */ /*^^^ 2017-01-06 */ @@ -873,19 +841,19 @@ int get_num_H( const char* elname, int val, i, el_number, num_H = 0, num_iso_H; static int intl_el_number_N = 0, intl_el_number_S=0, intl_el_number_O=0, intl_el_number_C=0; - if (!intl_el_number_N) + if ( !intl_el_number_N ) { intl_el_number_N = el_number_in_internal_ref_table( "N" ); } - if (!intl_el_number_S) + if ( !intl_el_number_S ) { intl_el_number_S = el_number_in_internal_ref_table( "S" ); } - if (!intl_el_number_O) + if ( !intl_el_number_O ) { intl_el_number_O = el_number_in_internal_ref_table( "O" ); } - if (!intl_el_number_C) + if ( !intl_el_number_C ) { intl_el_number_C = el_number_in_internal_ref_table( "C" ); } @@ -894,7 +862,7 @@ int get_num_H( const char* elname, /* atom_input_valence (cValence) cannot be specified in case of */ /* aliased MOLFile atom with known inp_num_H or inp_num_iso_H[] */ - if (bAliased) + if ( bAliased ) { num_H = inp_num_H; } @@ -902,7 +870,7 @@ int get_num_H( const char* elname, { num_H = inchi_max( 0, atom_input_valence - chem_bonds_valence ); } - else if (atom_input_valence == 15 && !chem_bonds_valence) + else if ( atom_input_valence == 15 && !chem_bonds_valence ) { num_H = 0; } @@ -912,9 +880,9 @@ int get_num_H( const char* elname, !ElData[el_number].bSkipAddingH && !bDoNotAddH) { /* add hydrogen atoms according to standard element valence */ - if (radical && radical != RADICAL_SINGLET) + if ( radical && radical != RADICAL_SINGLET ) { - if ((val = ElData[el_number].cValence[NEUTRAL_STATE + charge][0])) /* djb-rwth: addressing LLVM warning */ + if ( (val = ElData[el_number].cValence[NEUTRAL_STATE + charge][0]) ) /* djb-rwth: addressing LLVM warning */ { val -= ( radical == RADICAL_DOUBLET ) ? 1 : ( radical == RADICAL_SINGLET || radical == RADICAL_TRIPLET ) ? 2 : val; @@ -934,7 +902,7 @@ int get_num_H( const char* elname, } /* special case: do not add H to N(IV), S(III), S+(II), S-(II) */ /* S ions added 2004-05-10 */ - if (el_number == intl_el_number_N && !charge && !radical && val == 5) + if ( el_number == intl_el_number_N && !charge && !radical && val == 5 ) { val = 3; } @@ -944,11 +912,11 @@ int get_num_H( const char* elname, val = 2; } */ - else if (el_number == intl_el_number_S && !charge && !radical && val == 4 && chem_bonds_valence == 3) + else if ( el_number == intl_el_number_S && !charge && !radical && val == 4 && chem_bonds_valence == 3 ) { val = 3; } - else if (bHasMetalNeighbor && el_number != intl_el_number_C && val > 0) + else if ( bHasMetalNeighbor && el_number != intl_el_number_C && val > 0 ) { val--; } @@ -965,18 +933,18 @@ int get_num_H( const char* elname, } num_iso_H = 0; - if (inp_num_iso_H) + if ( inp_num_iso_H ) { - for (i = 0; i < NUM_H_ISOTOPES; i++) + for ( i = 0; i < NUM_H_ISOTOPES; i++ ) { num_iso_H += inp_num_iso_H[i]; } } /* should not happen because atom here is not aliased */ - if (num_iso_H) + if ( num_iso_H ) { - if (num_H >= num_iso_H) + if ( num_H >= num_iso_H ) { num_H -= num_iso_H; } @@ -988,7 +956,7 @@ int get_num_H( const char* elname, } /* should not happen because atom here is not aliased */ - if (inp_num_H > num_H) + if ( inp_num_H > num_H ) { num_H = inp_num_H; /* as requested in the alias */ /* num_H = inp_num_H + (inp_num_H - num_H)%2; */ /* keep unchanged parity of the number of non-isotopic H atoms */ @@ -1008,12 +976,12 @@ int get_atomic_mass_from_elnum( int nAtNum ) { nAtNum -= 1; - if (0 < nAtNum) + if ( 0 < nAtNum ) { nAtNum += 2; /* bypass D, T */ } - if (0 <= nAtNum && nAtNum < nElDataLen) + if ( 0 <= nAtNum && nAtNum < nElDataLen ) { return (int) ElData[nAtNum].nAtMass; } @@ -1058,7 +1026,7 @@ int get_atomic_mass( const char *elname ) ****************************************************************************/ AT_NUMB *is_in_the_list( AT_NUMB *pathAtom, AT_NUMB nNextAtom, int nPathLen ) { - for (; nPathLen && *pathAtom != nNextAtom; nPathLen--, pathAtom++) + for ( ; nPathLen && *pathAtom != nNextAtom; nPathLen--, pathAtom++ ) { ; } @@ -1071,7 +1039,7 @@ AT_NUMB *is_in_the_list( AT_NUMB *pathAtom, AT_NUMB nNextAtom, int nPathLen ) ****************************************************************************/ int *is_in_the_ilist( int *pathAtom, int nNextAtom, int nPathLen ) { - for (; nPathLen && *pathAtom != nNextAtom; nPathLen--, pathAtom++) + for ( ; nPathLen && *pathAtom != nNextAtom; nPathLen--, pathAtom++ ) { ; } @@ -1085,7 +1053,7 @@ int *is_in_the_ilist( int *pathAtom, int nNextAtom, int nPathLen ) int is_ilist_inside( int *ilist, int nlist, int *ilist2, int nlist2 ) { int k; - for (k = 0; k < nlist; k++) + for ( k = 0; k < nlist; k++ ) { if (!is_in_the_ilist( ilist2, ilist[k], nlist2 )) { @@ -1102,7 +1070,7 @@ int nBondsValToMetal( inp_ATOM* at, int iat ) int i, bond_type, nVal2Metal = 0; /* djb-rwth: removing redundant variables */ inp_ATOM* a = at + iat; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { /* djb-rwth: removing redundant code */ @@ -1110,7 +1078,7 @@ int nBondsValToMetal( inp_ATOM* at, int iat ) { bond_type = a->bond_type[i]; - if (bond_type <= BOND_TYPE_TRIPLE) + if ( bond_type <= BOND_TYPE_TRIPLE ) { nVal2Metal += bond_type; } @@ -1179,7 +1147,7 @@ int has_other_ion_neigh( inp_ATOM *at, int charge = at[iat_ion_neigh].charge; int i, neigh; - for (i = 0; i < at[iat].valence; i++) + for ( i = 0; i < at[iat].valence; i++ ) { neigh = at[iat].neighbor[i]; @@ -1211,13 +1179,13 @@ int has_other_ion_in_sphere_2( inp_ATOM *at, int iat, dist = 1; /* use at->cFlags as an indicator */ - while (dist <= 2) + while ( dist <= 2 ) { - for (lenq2 = lenq; iq < lenq2; iq++) + for ( lenq2 = lenq; iq < lenq2; iq++ ) { i = q[iq]; - for (j = 0; j < at[i].valence; j++) + for ( j = 0; j < at[i].valence; j++ ) { neigh = at[i].neighbor[j]; @@ -1239,7 +1207,7 @@ int has_other_ion_in_sphere_2( inp_ATOM *at, int iat, dist++; } - for (iq = 0; iq < lenq; iq++) + for ( iq = 0; iq < lenq; iq++ ) { i = q[iq]; at[i].cFlags = 0; @@ -1258,12 +1226,12 @@ int nNoMetalNumBonds( inp_ATOM *at, int at_no ) int num_H = NUMH( a, 0 ); int std_chem_bonds_valence = get_el_valence( a->el_number, a->charge, 0 ); - if (a->chem_bonds_valence + num_H > std_chem_bonds_valence) + if ( a->chem_bonds_valence + num_H > std_chem_bonds_valence ) { int valence_to_metal = 0; int num_bonds_to_metal = 0; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { if (is_el_a_metal( at[(int) a->neighbor[i]].el_number )) { @@ -1276,7 +1244,7 @@ int nNoMetalNumBonds( inp_ATOM *at, int at_no ) } } - if (a->chem_bonds_valence + num_H - valence_to_metal == std_chem_bonds_valence) + if ( a->chem_bonds_valence + num_H - valence_to_metal == std_chem_bonds_valence ) { /* removing bonds to metal produces standard valence */ return a->valence - num_bonds_to_metal; @@ -1291,7 +1259,7 @@ int nNoMetalNumBonds( inp_ATOM *at, int at_no ) { int valence_to_metal = 0; int num_bonds_to_metal = 0; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { if (is_el_a_metal( at[(int) a->neighbor[i]].el_number )) { @@ -1303,7 +1271,7 @@ int nNoMetalNumBonds( inp_ATOM *at, int at_no ) valence_to_metal += ( a->bond_type[i] & BOND_TYPE_MASK ); } } - if (1 == valence_to_metal) + if ( 1 == valence_to_metal ) { /* removing bonds to metal produces standard valence */ return a->valence - num_bonds_to_metal; @@ -1325,12 +1293,12 @@ int nNoMetalBondsValence( inp_ATOM *at, int at_no ) int num_H = NUMH( a, 0 ); int std_chem_bonds_valence = get_el_valence( a->el_number, a->charge, 0 ); - if (a->chem_bonds_valence + num_H > std_chem_bonds_valence) + if ( a->chem_bonds_valence + num_H > std_chem_bonds_valence ) { int valence_to_metal = 0; /*int num_bonds_to_metal = 0;*/ - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { if (is_el_a_metal( at[(int) a->neighbor[i]].el_number )) { @@ -1343,7 +1311,7 @@ int nNoMetalBondsValence( inp_ATOM *at, int at_no ) } } - if (a->chem_bonds_valence + num_H - valence_to_metal == std_chem_bonds_valence) + if ( a->chem_bonds_valence + num_H - valence_to_metal == std_chem_bonds_valence ) { /* removing bonds to metal produces standard valence */ return a->chem_bonds_valence - valence_to_metal; @@ -1358,7 +1326,7 @@ int nNoMetalBondsValence( inp_ATOM *at, int at_no ) int valence_to_metal = 0; /* int num_bonds_to_metal = 0;*/ - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { if (is_el_a_metal( at[(int) a->neighbor[i]].el_number )) { @@ -1387,9 +1355,9 @@ int nNoMetalNeighIndex( inp_ATOM *at, int at_no ) { int i; - inp_ATOM *a = at + at_no; + inp_ATOM* a = at + at_no; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { if (!is_el_a_metal( at[(int) a->neighbor[i]].el_number )) { @@ -1406,9 +1374,9 @@ int nNoMetalOtherNeighIndex( inp_ATOM *at, int at_no, int cur_neigh ) { int i, neigh; - inp_ATOM *a = at + at_no; + inp_ATOM* a = at + at_no; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { neigh = (int) a->neighbor[i]; @@ -1430,9 +1398,9 @@ int nNoMetalOtherNeighIndex2( inp_ATOM *at, { int i, neigh; - inp_ATOM *a = at + at_no; + inp_ATOM* a = at + at_no; - for (i = 0; i < a->valence; i++) + for ( i = 0; i < a->valence; i++ ) { neigh = (int) a->neighbor[i]; @@ -1462,7 +1430,7 @@ int MakeRemovedProtonsString( int nNumRemovedProtons, len = 0; - if (nNumRemovedProtons) + if ( nNumRemovedProtons ) { len = sprintf(szRemovedProtons, "Proton balance: %c %d H+", nNumRemovedProtons >= 0 ? '+' : '-', abs(nNumRemovedProtons)); @@ -1471,13 +1439,13 @@ int MakeRemovedProtonsString( int nNumRemovedProtons, if (bIsotopic && ( nNumRemovedProtonsIsotopic || nNumExchgIsotopicH )) { - for (i = 0, j = 0; i < NUM_H_ISOTOPES; i++) + for ( i = 0, j = 0; i < NUM_H_ISOTOPES; i++ ) { num = ( nNumExchgIsotopicH ? nNumExchgIsotopicH[i] : 0 ) + ( nNumRemovedProtonsIsotopic ? nNumRemovedProtonsIsotopic[i] : 0 ); - if (num) + if ( num ) { len += sprintf(szRemovedProtons + len, "%s %d^%dH", j ? ", " : " [ removed ", num, i + 1); @@ -1485,17 +1453,17 @@ int MakeRemovedProtonsString( int nNumRemovedProtons, } } - if (j) + if ( j ) { len += sprintf(szRemovedProtons + len, " ]"); - if (num_removed_iso_H) + if ( num_removed_iso_H ) { *num_removed_iso_H = j; } } } - if (!len) + if ( !len ) { szRemovedProtons[0] = '\0'; } @@ -1569,7 +1537,7 @@ void *inchi_calloc( size_t c, size_t n ) /****************************************************************************/ void inchi_free( void *p ) { - if (p) + if ( p ) { inchi_free( p ); /*added check if zero*/ } @@ -1592,7 +1560,7 @@ int normalize_string( char* name ) len = (int) strlen( name ); - for (i = 0, n = 0; i < len; i++) + for ( i = 0, n = 0; i < len; i++ ) { if (isspace( UCINT name[i] ) /*|| !isprint( UCINT name[i] )*/) { @@ -1601,7 +1569,7 @@ int normalize_string( char* name ) } else { - if (n > 0) + if ( n > 0 ) { memmove((void*)&name[i - n], (void*)&name[i], (long long)len - (long long)i + 1); /* djb-rwth: cast operators added */ i -= n; @@ -1610,11 +1578,11 @@ int normalize_string( char* name ) n = -1; } } - if (n == len) /* empty line */ + if ( n == len ) /* empty line */ { name[len = 0] = '\0'; } - else if (++n && n <= len) + else if ( ++n && n <= len ) { len -= n; name[len] = '\0'; @@ -1631,12 +1599,12 @@ int dotify_non_printable_chars( char *line ) { int i, c, num = 0; - if (line) + if ( line ) { - for (i = 0; (c = UCINT line[i]); i++) /* djb-rwth: addressing LLVM warning */ + for ( i = 0; (c = UCINT line[i]); i++ ) /* djb-rwth: addressing LLVM warning */ { /* assuming ASCII charset */ - if (c < ' ' || c >= 0x7F) + if ( c < ' ' || c >= 0x7F ) { line[i] = '.'; num++; @@ -1658,9 +1626,9 @@ int dotify_non_printable_chars( char *line ) int read_upto_delim( char **pstring, char *field, int maxlen, char* delims ) { int i, n; - char *p = *pstring; + char* p = *pstring; - if (!p) + if ( !p ) { return -1; } @@ -1679,7 +1647,7 @@ int read_upto_delim( char **pstring, char *field, int maxlen, char* delims ) n++; } - if (n + 1 > maxlen) + if ( n + 1 > maxlen ) { return -1; } @@ -1687,7 +1655,7 @@ int read_upto_delim( char **pstring, char *field, int maxlen, char* delims ) mystrncpy( field, p, n + 1 ); field[n + 1] = '\0'; - if (!p[n]) + if ( !p[n] ) { /* reached EOL */ *pstring = NULL; @@ -1710,9 +1678,9 @@ int read_upto_delim( char **pstring, char *field, int maxlen, char* delims ) int is_matching_any_delim( char c, char* delims ) { int ic = UCINT c; - while (*delims) + while ( *delims ) { - if (ic == *delims) + if ( ic == *delims ) { return 1; } @@ -1743,7 +1711,7 @@ void remove_one_lf( char* p ) if (p && 0 < ( len = strlen( p ) ) && p[len - 1] == '\n') { p[len - 1] = '\0'; - if (len >= 2 && p[len - 2] == '\r') + if ( len >= 2 && p[len - 2] == '\r' ) { p[len - 2] = '\0'; } @@ -1762,7 +1730,7 @@ int mystrncpy( char *target, const char *source, unsigned maxlen ) const char *p; unsigned len, source_len; - if (target == NULL || maxlen == 0 || source == NULL) + if ( target == NULL || maxlen == 0 || source == NULL ) { return 0; } @@ -1787,7 +1755,7 @@ int mystrncpy( char *target, const char *source, unsigned maxlen ) len = maxlen - 1; } - if (len) + if ( len ) { memmove(target, source, len); } @@ -1811,7 +1779,7 @@ char* lrtrim( char *p, int* nLen ) { ; } - if (i) + if ( i ) { len -= i; /* djb-rwth: variable has to be decreased before memmove */ (memmove)(p, p + i, ((long long)len + 1)); /* djb-rwth: now cast operator can be added */ @@ -1824,7 +1792,7 @@ char* lrtrim( char *p, int* nLen ) p[len] = '\0'; } - if (nLen) + if ( nLen ) { *nLen = len; } @@ -1867,7 +1835,7 @@ void extract_inchi_substring( char ** buf, const char *str, size_t slen ) bufp = *buf; *buf = NULL; - if (str == NULL) + if ( str == NULL ) { return; } @@ -1880,7 +1848,7 @@ void extract_inchi_substring( char ** buf, const char *str, size_t slen ) if (NULL == p) return; - for (i = 0; i < slen; i++) + for ( i = 0; i < slen; i++ ) { pp = p[i]; @@ -1910,7 +1878,7 @@ void extract_inchi_substring( char ** buf, const char *str, size_t slen ) *buf = (char*) inchi_calloc( i + 1, sizeof( char ) ); memcpy(*buf, p, i); - if (*buf) + if ( *buf ) (*buf)[i] = '\0'; return; @@ -1928,7 +1896,7 @@ void extract_auxinfo_substring( char ** buf, const char *str, size_t slen ) bufp = *buf; *buf = NULL; - if (str == NULL) + if ( str == NULL ) { return; } @@ -1943,7 +1911,7 @@ void extract_auxinfo_substring( char ** buf, const char *str, size_t slen ) return; } - for (i = 0; i < slen; i++) + for ( i = 0; i < slen; i++ ) { pp = p[i]; if (isspace( UCINT pp )) break; @@ -1951,7 +1919,7 @@ void extract_auxinfo_substring( char ** buf, const char *str, size_t slen ) *buf = (char*) inchi_calloc( i + 1, sizeof( char ) ); memcpy(*buf, p, i); - if (*buf) + if ( *buf ) (*buf)[i] = '\0'; return; @@ -1994,7 +1962,7 @@ int inchi_memicmp( const void * p1, const void * p2, size_t length ) /****************************************************************************/ int inchi_stricmp( const char *s1, const char *s2 ) { - while (*s1) + while ( *s1 ) { if (*s1 == *s2 || __MYTOLOWER( (int) *s1 ) == __MYTOLOWER( (int) *s2 )) @@ -2009,7 +1977,7 @@ int inchi_stricmp( const char *s1, const char *s2 ) } } - if (*s2) + if ( *s2 ) { return -1; } @@ -2021,8 +1989,8 @@ int inchi_stricmp( const char *s1, const char *s2 ) /****************************************************************************/ char *inchi__strnset( char *s, int val, size_t length ) { - char *ps = s; - while (length-- && *ps) + char* ps = s; + while ( length-- && *ps ) { *ps++ = (char) val; } @@ -2034,8 +2002,8 @@ char *inchi__strnset( char *s, int val, size_t length ) /****************************************************************************/ char *inchi__strdup( const char *string ) { - char *p = NULL; - if (string) + char* p = NULL; + if ( string ) { size_t length = strlen( string ); p = (char *) inchi_malloc( length + 1 ); diff --git a/INCHI-1-SRC/INCHI_BASE/src/util.h b/INCHI-1-SRC/INCHI_BASE/src/util.h index c91dc796..143e1c5f 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/util.h +++ b/INCHI-1-SRC/INCHI_BASE/src/util.h @@ -603,6 +603,36 @@ int get_endpoint_valence(U_CHAR el_number); int get_endpoint_valence_KET(U_CHAR el_number); #endif +#define MIN_ATOM_CHARGE (-2) +#define MAX_ATOM_CHARGE 2 +#define NEUTRAL_STATE (-MIN_ATOM_CHARGE) +#define NUM_ATOM_CHARGES (MAX_ATOM_CHARGE - MIN_ATOM_CHARGE + 1) +#define MAX_NUM_VALENCES 5 /* max. number + 1 to provide zero termination */ + +/* CHEMICAL ELEMENTS & ATOMIC VALENCE MODEL + FOR VARIOUS OXIDATION STATES +*/ +typedef struct tagElData +{ + /* Element chemical symbol */ + const char* szElName; + /* Average atomic mass from the Periodic Chart of the Elements + (Fisher cat. no. 05-702-10) */ + int nAtMass; + /* (not used currently) Atomic mass of the most abundant isotope */ + int nNormAtMass; + /* (not used currently) Exact mw of the most abundant isotope (not used) */ + double dAtMass; + /* METAL or METAL2 */ + int nType; + /* (not used currently) Pauling electronegativity x 10; 0 means unknown */ + int nElNegPauling10; + /* InChI does not add implicit H to atoms that have non-zero bSkipAddingH */ + /* NB: was called bDoNotAddH, renamed to avoid confusion with other procedures */ + int bSkipAddingH; + S_CHAR cValence[NUM_ATOM_CHARGES][MAX_NUM_VALENCES]; +} ELDATA; + /* Forward declaration */ struct tagCANON_GLOBALS; diff --git a/INCHI-1-TEST/tests/test_unit/test_strutil.cpp b/INCHI-1-TEST/tests/test_unit/test_strutil.cpp index d154fa4b..c6298fc4 100644 --- a/INCHI-1-TEST/tests/test_unit/test_strutil.cpp +++ b/INCHI-1-TEST/tests/test_unit/test_strutil.cpp @@ -44,6 +44,131 @@ TEST(strutil_testing, test_SetConnectedComponentNumber) FreeInpAtom(&new_mol); } +/* (NaumanUllahKhan :: @nnuk) + * Test to validate the disconnection of bond(s) + * between a Metal and a Non-Metal atom. + */ +TEST(strutil_testing, test1_MolecularInorganicsPreprocessing) +{ + INPUT_PARMS ip; + memset(&ip, 0, sizeof(ip)); + ip.bMolecularInorganics = true; + ip.bMolecularInorganicsReconnectedInChI = false; + + ORIG_ATOM_DATA orig_at_data; + memset(&orig_at_data, 0, sizeof(orig_at_data)); + + inp_ATOM atoms[3]; + AT_NUMB nOldCompNumber[3] = {0}; + + /* Initialize all atoms */ + for (int i = 0; i < 3; i++) + { + memset(&atoms[i], 0, sizeof(inp_ATOM)); + atoms[i].num_iso_H[0] = 0; + atoms[i].num_iso_H[1] = 0; + atoms[i].num_iso_H[2] = 0; + atoms[i].num_H = 0; + atoms[i].charge = 0; + atoms[i].chem_bonds_valence = 0; + atoms[i].valence = 0; + atoms[i].el_number = 0; + atoms[i].orig_at_number = i + 1; + } + + /* Central Metal atom (Iron) */ + atoms[0].el_number = 26; + atoms[0].valence = 2; + atoms[0].chem_bonds_valence = 2; + strcpy(atoms[0].elname, "Fe"); + atoms[0].neighbor[0] = 1; + atoms[0].neighbor[1] = 2; + atoms[0].bond_type[0] = 1; + atoms[0].bond_type[1] = 1; + + /* Non-Metal atom (Fluorine) */ + atoms[1].el_number = 9; + atoms[1].valence = 1; + atoms[1].chem_bonds_valence = 1; + strcpy(atoms[1].elname, "F"); + atoms[1].neighbor[0] = 0; + atoms[1].bond_type[0] = 1; + + /* Non-Metal atom (Fluorine) */ + atoms[2].el_number = 9; + atoms[2].valence = 1; + atoms[2].chem_bonds_valence = 1; + strcpy(atoms[2].elname, "F"); + atoms[2].neighbor[0] = 0; + atoms[2].bond_type[0] = 1; + + orig_at_data.at = atoms; + orig_at_data.num_inp_atoms = 3; + orig_at_data.nOldCompNumber = nOldCompNumber; + + int result = MolecularInorganicsPreprocessing(&orig_at_data, &ip); + + /* Should disconnect both F bonds to Fe */ + EXPECT_EQ(result, 2); + EXPECT_FALSE(ip.bMolecularInorganicsReconnectedInChI); + + /* Charges: Fe -> +2, both F -> -1 */ + EXPECT_EQ(atoms[0].charge, 2); + EXPECT_EQ(atoms[1].charge, -1); + EXPECT_EQ(atoms[2].charge, -1); +} + +/* (NaumanUllahKhan :: @nnuk) + * Test to check if the functionality fails correctly for Fe-Cl bond. + */ +TEST(strutil_testing, test2_MolecularInorganicsPreprocessing) +{ + INPUT_PARMS ip; + memset(&ip, 0, sizeof(ip)); + ip.bMolecularInorganics = false; /* KEY: Functionality disabled */ + + ORIG_ATOM_DATA orig_at_data; + memset(&orig_at_data, 0, sizeof(orig_at_data)); + + /* Create valid structure that WOULD disconnect if enabled */ + inp_ATOM atoms[2]; + AT_NUMB nOldCompNumber[2] = {0}; + + for (int i = 0; i < 2; i++) + { + memset(&atoms[i], 0, sizeof(inp_ATOM)); + atoms[i].orig_at_number = i + 1; + } + + /* Iron-Chlorine bond that SHOULD connect... but won't because function is disabled */ + atoms[0].el_number = 26; + atoms[0].valence = 1; + atoms[0].chem_bonds_valence = 1; + strcpy(atoms[0].elname, "Fe"); + atoms[0].neighbor[0] = 1; + atoms[0].bond_type[0] = 1; + + atoms[1].el_number = 17; + atoms[1].valence = 1; + atoms[1].chem_bonds_valence = 1; + strcpy(atoms[1].elname, "Cl"); + atoms[1].neighbor[0] = 0; + atoms[1].bond_type[0] = 1; + + orig_at_data.at = atoms; + orig_at_data.num_inp_atoms = 2; + orig_at_data.nOldCompNumber = nOldCompNumber; + + int result = MolecularInorganicsPreprocessing(&orig_at_data, &ip); + + /* Should return -1 that failure detection works */ + EXPECT_EQ(result, -1); + + EXPECT_EQ(atoms[0].charge, 0); + EXPECT_EQ(atoms[1].charge, 0); + EXPECT_FALSE(ip.bMolecularInorganicsReconnectedInChI); +} + TEST(strutil_testing, test_UnMarkRingSystemsInp) {