InChI
 
Loading...
Searching...
No Matches
strutil.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2024 IUPAC and InChI Trust
4 */
5
6#ifndef _STRUTIL_H_
7#define _STRUTIL_H_
8
9/* Mol structure utlities */
10
11#include "inpdef.h"
12#include "ichi.h"
13#include "util.h" /* (@nnuk : Nauman Ullah Khan) :: utilizing defined macros */
14#include "incomdef.h"
15
16#ifndef COMPILE_ALL_CPP
17#ifdef __cplusplus
18extern "C"
19{
20#endif
21#endif
22
23 /*(@nnuk : Nauman Ullah Khan)
24 * Metal definitions for molecular inorganics (MolInOrg)
25 */
26#define MolInOrg1 1 /* takes the lowest valence of an element */
27#define MolInOrg2 3 /* takes the two lowest valences of an element */
28#define MolInOrg3 7 /* takes the three lowest valences of an element */
29#define MolInOrg4 15 /* takes the four lowest valences of an element */
30
31 /* forward declaration */
33 struct tagCANON_GLOBALS;
34
35 /*(@nnuk : Nauman Ullah Khan)
36 * CHEMICAL ELEMENTS & ATOMIC VALENCE MODEL FOR VARIOUS OXIDATION STATES
37 */
39 {
40 /* Element chemical symbol */
41 const char* szElName;
42 /* Average atomic mass from the Periodic Chart of the Elements
43 (Fisher cat. no. 05-702-10) */
45 /* (not used currently) Atomic mass of the most abundant isotope */
47 /* (not used currently) Exact mw of the most abundant isotope (not used) */
48 double dAtMass;
49 /* MolInOrg1, MolInOrg2, MolInOrg3 or MolInOrg4 */
50 int nType;
51 /* (not used currently) Pauling electronegativity x 10; 0 means unknown */
53 /* InChI does not add implicit H to atoms that have non-zero bSkipAddingH */
54 /* NB: was called bDoNotAddH, renamed to avoid confusion with other procedures */
58
59 /*(@nnuk : Nauman Ullah Khan) :: Structure to hold variables for the array of all chemical elements, further used by MolecularInorganics function*/
61 {
63 char symbol[3]; /* Fixed length for symbol, up to 2 characters + null terminator */
64
66
67 /* (@nnuk : Nauman Ullah Khan) :: Main function for molecular inorganics */
69 /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, for getting the binary value of the electronegativity difference between any two elements */
70 int shouldBondBeCut(int atom1, int atom2);
71 /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, for updating the neighbour's list in the main molecular inorganics function processing */
72 void updateNeighborListMolecularInorganics(inp_ATOM* at, int atom_idx, int neighbor_idx);
73 /* (@nnuk : Nauman Ullah Khan) :: Function related to molecular inorganics, decides for the specific metal bonds to be kept or disconnected. */
75 /* Function retrieves valence values for molecular inorganics functionality*/
76 int getElValenceforMolecularInorganics(int nPeriodicNum, int charge, int val_num);
77 /* Function retrieves element type value for molecular inorganics functionality*/
78 int getElTypeforMolecularInorganics(int nPeriodicNum);
79
88 int set_EnhancedStereo_t_m_layers(const ORIG_ATOM_DATA *orig_inp_data,
89 const INChI *inchi,
90 const INChI_Aux *aux);
91
100 int orig_atom_num);
101
110 int get_parity_idx_from_canonical_atom_number( int canon_atom_num,
111 const AT_NUMB *nNumber,
112 int nof_atoms);
113
125 int invert_parities(const INChI *inchi,
126 const INChI_Aux *aux,
127 int **list_atoms,
128 int nof_lists,
129 int is_absolute);
130
140 int ExtractConnectedComponent(inp_ATOM *at, int num_at,
141 int component_number,
142 inp_ATOM *component_at);
151 int SetConnectedComponentNumber(inp_ATOM *at, int num_at, int component_number);
152
163 INChI *Alloc_INChI(inp_ATOM *at, int num_at, int *found_num_bonds,
164 int *found_num_isotopic, int nAllocMode);
165
172 int Free_INChI(INChI **ppINChI);
173
180 int Free_INChI_Members(INChI *pINChI);
181
188 int Free_INChI_Stereo(INChI_Stereo *pINChI_Stereo);
189
199 INChI_Aux *Alloc_INChI_Aux(int num_at, int num_isotopic_atoms,
200 int nAllocMode, int bOrigData);
201
208 int Free_INChI_Aux(INChI_Aux **ppINChI_Aux);
209
231 int Create_INChI(struct tagCANON_GLOBALS *pCG,
232 struct tagINCHI_CLOCK *ic,
233 INPUT_PARMS *ip,
234 INChI **ppINChI,
235 INChI_Aux **ppINChI_Aux,
236 ORIG_ATOM_DATA *orig_inp_data,
237 inp_ATOM *inp_at,
238 INP_ATOM_DATA *inp_norm_data[2],
239 int num_inp_at,
240 const unsigned char* keep_explicit_HDT,
241 INCHI_MODE nUserMode,
242 INCHI_MODE *pbTautFlags,
243 INCHI_MODE *pbTautFlagsDone,
244 struct tagInchiTime *ulMaxTime,
245 struct tagTautomerGroupsInfo *ti_out,
246 char *pStrErrStruct);
247
267 inp_ATOM *norm_at,
268 INF_ATOM_DATA *inf_norm_at_data,
269 int init_num_at,
270 int num_removed_H,
271 int bAdd_DT_to_num_H,
272 int nNumRemovedProtons,
273 NUM_H *nNumRemovedProtonsIsotopic,
274 int bIsotopic,
275 INChI *pINChI,
276 INChI_Aux *pINChI_Aux,
277 int bAbcNumbers,
278 INCHI_MODE nMode);
279
295 COMP_ATOM_DATA *composite_norm_data,
296 INF_ATOM_DATA *inf_norm_at_data,
297 int bIsotopic,
298 int bTautomeric,
299 PINChI2 *pINChI2,
300 PINChI_Aux2 *pINChI_Aux2,
301 int bAbcNumbers,
302 INCHI_MODE nMode);
303
304#if (FIX_DALKE_BUGS == 1)
311 char *AllocateAndFillHillFormula(INChI *pINChI);
312#endif
313
314 typedef enum tagInchiDiffBits
315 {
316 IDIF_PROBLEM = 0x00000001, /* severe: at least one InChI does not exist */
317 IDIF_NUM_AT = 0x00000001, /* severe: different number of atoms in the skeleton */
318 IDIF_ATOMS = 0x00000001, /* severe: diiferent types of skeleton atoms */
319 IDIF_NUM_EL = 0x00000001, /* severe: formulas differ in another element */
320 IDIF_CON_LEN = 0x00000001, /* severe: different connection table lengths */
321 IDIF_CON_TBL = 0x00000001, /* severe: different connection tables */
322 IDIF_POSITION_H = 0x00000002, /* difference in non-taut (Mobile-H) or all H (Fixed-H) location/number */
323 IDIF_MORE_FH = 0x00000004, /* extra fixed H */
324 IDIF_LESS_FH = 0x00000008, /* missing fixed H */
325 IDIF_MORE_H = 0x00000010, /* formulas differ in number of H */
326 IDIF_LESS_H = 0x00000020, /* formulas differ in number of H */
327 /*IDIF_TAUT_LEN = 0x00000008,*/ /* different lengths of tautomer lists */
328 IDIF_NO_TAUT = 0x00000040, /* restored structure has no taut groups while the original InChI has some */
329 IDIF_WRONG_TAUT = 0x00000080, /* restored has tautomerism while the original does not have it */
330 IDIF_SINGLE_TG = 0x00000100, /* restored has 1 taut. group while the original InChI has multiple tg */
331 IDIF_MULTIPLE_TG = 0x00000200, /* restored has multiple tg while the original InChI has only one tg */
332 IDIF_NUM_TG = 0x00000400, /* different number of tautomeric groups */
333 /*IDIF_LESS_TG_ENDP = 0x00000200,*/ /* restores structure has less taut. endpoints */
334 /*IDIF_MORE_TG_ENDP = 0x00000400,*/ /* restores structure has more taut. endpoints */
335 IDIF_EXTRA_TG_ENDP = 0x00000800, /* extra tautomeric endpoint(s) in restored structure */
336 IDIF_MISS_TG_ENDP = 0x00001000, /* one or more tg endpoint is not in the restored structure */
337 IDIF_DIFF_TG_ENDP = 0x00002000, /* lists of tg endpoints are different */
338 IDIF_TG = 0x00004000, /* different tautomeric groups */
339 IDIF_NUM_ISO_AT = 0x00008000, /* ?severe: restored struct. has different number of isotopic atoms */
340 IDIF_ISO_AT = 0x00010000, /* ?severe: restored struct. has different locations/isotopes of isotopic atoms */
341 IDIF_CHARGE = 0x00020000, /* restored structure has different charge */
342 IDIF_REM_PROT = 0x00040000, /* proton(s) removed/added from the restored structure */
343 IDIF_REM_ISO_H = 0x00080000, /* isotopic H removed */
344 IDIF_SC_INV = 0x00100000, /* restores structure has different inversion stereocenter mark */
345 IDIF_SC_PARITY = 0x00200000, /* restored structure has stereoatoms or allenes with different parity */
346 IDIF_SC_EXTRA_UNDF = 0x00400000, /* restored structure has extra undefined stereocenter(s) */
347 IDIF_SC_EXTRA = 0x00800000, /* restored structure has extra stereocenter(s) */
348 IDIF_SC_MISS_UNDF = 0x01000000, /* restored structure has not some undefined stereocenter(s) */
349 IDIF_SC_MISS = 0x02000000, /* restored structure has not some stereocenters that are not undefined */
350 IDIF_SB_PARITY = 0x04000000, /* restored structure has stereobonds or cumulenes with different parity */
351 IDIF_SB_EXTRA_UNDF = 0x08000000, /* restored structure has extra undefined stereobond(s) */
352 IDIF_SB_EXTRA = 0x10000000, /* restored structure has extra stereobond(s) */
353 IDIF_SB_MISS_UNDF = 0x20000000, /* restored structure has not some undefined stereocenters */
354 IDIF_SB_MISS = 0x40000000 /* restored structure has not some stereobonds that are not undefined */
356
357#define IDIFF_SB (IDIF_SB_PARITY | IDIF_SB_EXTRA_UNDF | IDIF_SB_EXTRA | IDIF_SB_MISS_UNDF | IDIF_SB_MISS)
358#define IDIFF_SC (IDIF_SC_PARITY | IDIF_SC_EXTRA_UNDF | IDIF_SC_EXTRA | IDIF_SC_MISS_UNDF | IDIF_SC_MISS)
359
360#define IDIFF_CONSTIT (IDIF_POSITION_H | IDIF_MORE_FH | IDIF_LESS_FH | IDIF_MORE_H | IDIF_LESS_H | \
361 IDIF_NO_TAUT | IDIF_WRONG_TAUT | IDIF_SINGLE_TG | IDIF_MULTIPLE_TG | \
362 IDIF_NUM_TG | IDIF_EXTRA_TG_ENDP | IDIF_MISS_TG_ENDP | IDIF_TG | \
363 IDIF_NUM_ISO_AT | IDIF_ISO_AT | IDIF_CHARGE | IDIF_REM_PROT | IDIF_REM_ISO_H | \
364 IDIF_DIFF_TG_ENDP)
365#define IDIFF_STEREO (IDIF_SC_INV | IDIF_SC_PARITY | IDIF_SC_EXTRA_UNDF | IDIF_SC_EXTRA | \
366 IDIF_SC_MISS_UNDF | IDIF_SC_MISS | IDIF_SB_PARITY | IDIF_SB_EXTRA_UNDF | \
367 IDIF_SB_EXTRA | IDIF_SB_MISS_UNDF | IDIF_SB_MISS)
368
369 /*************************************************************************************/
370#define ICR_MAX_ENDP_IN1_ONLY 32
371#define ICR_MAX_ENDP_IN2_ONLY 32
372#define ICR_MAX_DIFF_FIXED_H 32
373#define ICR_MAX_SB_IN1_ONLY 32
374#define ICR_MAX_SB_IN2_ONLY 32
375#define ICR_MAX_SC_IN1_ONLY 32
376#define ICR_MAX_SC_IN2_ONLY 32
377#define ICR_MAX_SB_UNDF 32
378#define ICR_MAX_SC_UNDF 32
379
381 {
383
390
391 /* 1 => InChI from reversed struct. 2 => input InChI */
392
393 AT_NUMB endp_in1_only[ICR_MAX_ENDP_IN1_ONLY]; /* endpoint canonical number = index+1 */
395
396 AT_NUMB endp_in2_only[ICR_MAX_ENDP_IN2_ONLY]; /* endpoint canonical number = index+1 */
398
402
406
410
415
420
425
430 } ICR; /* tagInChICompareResults */
431
443 INCHI_MODE CompareReversedINChI2(INChI *i1 /* InChI from reversed struct */,
444 INChI *i2 /* input InChI */,
445 INChI_Aux *a1, INChI_Aux *a2,
446 ICR *picr, int *err);
447
458 int CompareIcr(ICR *picr1, ICR *picr2, INCHI_MODE *pin1, INCHI_MODE *pin2, INCHI_MODE mask);
459
469 int CompareReversedINChI(INChI *i1, INChI *i2, INChI_Aux *a1, INChI_Aux *a2);
470
471 // Where is this function?
472 const char *CompareReversedInchiMsg(int code);
473
474#define EQL_EXISTS 1
475#define EQL_SP3 2
476#define EQL_SP3_INV 4
477#define EQL_SP2 8
478
489 int Eql_INChI_Stereo(INChI_Stereo *s1, int eql1, INChI_Stereo *s2, int eql2, int bRelRac);
490
498 int Eql_INChI_Isotopic(INChI *i1, INChI *i2);
499
500#define EQL_EQU 0
501#define EQL_EQU_TG 1
502#define EQL_EQU_ISO 2
503
513 int Eql_INChI_Aux_Equ(INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2);
514
515#define EQL_NUM 0
516#define EQL_NUM_INV 1
517#define EQL_NUM_ISO 2
518
528 int Eql_INChI_Aux_Num(INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2);
529
537 int bHasEquString(AT_NUMB *LinearCT, int nLenCT);
538
546 int CompINChINonTaut2(const void *p1, const void *p2);
547
555 int CompINChITaut2(const void *p1, const void *p2);
556
566 int CompINChI2(const INCHI_SORT *p1, const INCHI_SORT *p2, int bTaut, int bCompareIsotopic);
567
576 int CompINChITautVsNonTaut(const INCHI_SORT *p1, const INCHI_SORT *p2, int bCompareIsotopic);
577
579 { /* r = repetitive, n = non-repetitive */
580 DIFS_f_FORMULA, /* 0 r; fixed-H <-> mobile-H */
581 DIFS_c_CONNECT, /* 1 n; connection table; mobile-H only */
582 DIFS_h_H_ATOMS, /* 2 n; hydrogen atoms: mobile-H and Fixed-H; have different meanings */
583 DIFS_q_CHARGE, /* 3 r; charge; fixed-H <-> mobile-H */
584 DIFS_p_PROTONS, /* 4 n; protons; mobile-H only */
585 DIFS_b_SBONDS, /* 5 r: stereobonds: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
586 DIFS_t_SATOMS, /* 6 r: stereoatoms: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
587 DIFS_m_SP3INV, /* 7 r: stereo-abs-inv: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
588 DIFS_s_STYPE, /* 8 r: stereo-type: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
589 DIFS_i_IATOMS, /* 9 r: isotopic atoms: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
590 DIFS_o_TRANSP, /* 10 n: Fixed-H transposition */
591 DIFS_idf_LENGTH, /* 11 length of the array relevant to the INChI Identifier */
592 /* later elements referring to AuxInfo may be added */
593 DIFS_LENGTH = DIFS_idf_LENGTH /* length of the array */
595
597 {
598 DIFL_M, /* 0 main layer */
599 DIFL_MI, /* 1 main isotopic */
600 DIFL_F, /* 2 fixed-H */
601 DIFL_FI, /* 3 fixed-H isotopic */
602 DIFL_LENGTH /* number of layers */
604
605 /* Value meaning */
606 typedef enum tagMarkDiff
607 {
608 DIFV_BOTH_EMPTY = 0, /* both this and the component in the preceding namesake segment are empty */
609 DIFV_EQL2PRECED = 1, /* equal to the component in the preceding namesake segment */
610 DIFV_NEQ2PRECED = 2, /* different from the component in the preceding namesake segment */
611 DIFV_IS_EMPTY = 4, /* is empty while the preceding namesake segment is not empty */
612 DIFV_FI_EQ_MI = 8, /* FI stereo component is equal to the component in the MI namesake segment */
613 /* while M and F components are empty */
614 /* decision_F = bitmask: bits that should not be present */
615 /* decision_T = bitmask: at least one of the bits should be present */
616 /* decision = true if( !( BITS & decision_F ) && ( BITS & decision_F ) ) */
617 DIFV_OUTPUT_EMPTY_T = (DIFV_IS_EMPTY), /* bits present for empty segment output */
619
620 DIFV_OUTPUT_OMIT_F = (DIFV_NEQ2PRECED | DIFV_IS_EMPTY), /* bits NOT present for omitting */
621
624
626 {
628 INCHI_SEGM_FILL = 1, /* the value is used in str_LineEnd() */
629 INCHI_SEGM_EMPTY = 2 /* the value is used in str_LineEnd() */
631
641 int CompINChILayers(const INCHI_SORT *p1, const INCHI_SORT *p2,
642 char sDifSegs[][DIFS_LENGTH], int bFixTranspChargeBug);
643
650 int MarkUnusedAndEmptyLayers(char sDifSegs[][DIFS_LENGTH]);
651
658 int INChI_SegmentAction(char cDifSegs);
659
660#define FLAG_SORT_PRINT_TRANSPOS_BAS 1 /* transposition in the main InChI layer */
661#define FLAG_SORT_PRINT_TRANSPOS_REC 2 /* transposition in the reconnected InChI layer */
662#define FLAG_SORT_PRINT_NO_NFIX_H_BAS 4 /* no fixed H non-isotopic in the main InChI layer */
663#define FLAG_SORT_PRINT_NO_NFIX_H_REC 8 /* no fixed H non-isotopic in the reconnected InChI layer */
664#define FLAG_SORT_PRINT_NO_IFIX_H_BAS 16 /* no fixed H isotopic in the main InChI layer */
665#define FLAG_SORT_PRINT_NO_IFIX_H_REC 32 /* no fixed H isotopic in the the reconnected InChI layer */
666#define FLAG_SORT_PRINT_ReChI_PREFIX 64 /* Output ReChI instead of InChI */
667
668 struct tagCANON_GLOBALS;
669
693 int OutputINChI1(struct tagCANON_GLOBALS *pCG,
694 INCHI_IOS_STRING *strbuf,
695 INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM],
696 int iINChI,
697 ORIG_ATOM_DATA *orig_inp_data,
698 ORIG_STRUCT *pOrigStruct,
699 INPUT_PARMS *ip,
700 int bDisconnectedCoord,
701 int bOutputType,
702 int bINChIOutputOptions,
703 int num_components2[],
704 int num_non_taut2[],
705 int num_taut2[],
706 INCHI_IOSTREAM *out_file,
707 INCHI_IOSTREAM *log_file,
708 int num_input_struct,
709 int *pSortPrintINChIFlags,
710 unsigned char save_opt_bits);
711
712 int OutputINChI2(struct tagCANON_GLOBALS *pCG,
713 INCHI_IOS_STRING *strbuf,
714 INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM],
715 int INCHI_basic_or_INCHI_reconnected,
716 ORIG_ATOM_DATA *orig_inp_data,
717 ORIG_STRUCT *pOrigStruct,
718 INPUT_PARMS *ip,
719 int bDisconnectedCoord,
720 int bOutputType,
721 int bINChIOutputOptions,
722 int num_components2[],
723 int num_non_taut2[],
724 int num_taut2[],
725 INCHI_IOSTREAM *out_file,
726 INCHI_IOSTREAM *log_file,
727 int num_input_struct,
728 int *pSortPrintINChIFlags,
729 unsigned char save_opt_bits);
730
744 INCHI_SORT *pINChISort[TAUT_NUM],
745 int *num_components,
746 ORIG_ATOM_DATA *orig_inp_data,
747 ORIG_ATOM_DATA *prep_inp_data,
748 COMP_ATOM_DATA composite_norm_data[TAUT_NUM + 1],
749 int bCompareComponents); /* djb-rwth: matching composite_norm_data bounds */
750
760 char *pErrorText,
761 int bError);
762
772 int GetInpStructErrorType(INPUT_PARMS *ip, int err, char *pStrErrStruct, int num_inp_atoms);
773
786 INCHI_IOSTREAM *log_file,
787 char *pStrErrStruct,
788 int nErrorType,
789 long num_inp,
790 INPUT_PARMS *ip);
791
799 int bNumHeterAtomHasIsotopicH(inp_ATOM *atom, int num_atoms);
800
801 // does this function exist?
802 int WriteToSDfile(const INP_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment,
803 const char *szLabel, const char *szValue);
804
812 int bIsMetalSalt(inp_ATOM *at, int i);
813
823 int bIsSameBond(int a1, int a2, int b1, int b2);
824
825 extern const char gsMissing[];
826 extern const char gsEmpty[];
827 extern const char gsSpace[];
828 extern const char gsEqual[];
829
830#define SDF_LBL_VAL(L, V) ((L) && (L)[0]) ? gsSpace : gsEmpty, ((L) && (L)[0]) ? L : gsEmpty, ((L) && (L)[0]) ? (((V) && (V)[0]) ? gsEqual : gsSpace) : gsEmpty, ((V) && (V)[0]) ? V : ((L) && (L)[0]) ? gsMissing \
831 : gsEmpty
832
833 /* Handle integer matrix [mxn] */
842 int imat_new(int m, int n, int ***a);
843
850 void imat_free(int m, int **a);
851
852 /* Light-weight {nodes, connections} subgraph of molecule, subgraf
853 refers to parent structure via orig atom numbers stored internally
854 nodes and edges: are living in 0-based node numbers domain
855 atoms and bonds: are living in 1-based orig atom numbers domain
856 */
857
858 /* subgraf_edge is node connections element */
859 typedef struct subgraf_edge
860 {
861 int nbr; /* node neighbor */
862 int etype; /* edge type echoing corresponding bond type */
864 /* subgraf is set of nodes and their connections */
865 typedef struct subgraf
866 {
867 int nnodes; /* number of nodes (atoms) */
868 int *nodes; /* nodes[i] is 1-based orig atom number of node #i */
869 /* (i = 0 to nnodes) */
870 int *degrees; /* degrees of nodes */
871 int *orig2node; /* orig2node[k] is 0-based node number for orig #k */
872 subgraf_edge **adj; /* node connections representing adjacency relation */
873 /* adj[i] is vector[0-degree] of edges at node #i */
875 /* helper structure for finding paths in subgraf*/
876 typedef struct subgraf_pathfinder
877 {
878 subgraf *sg; /* base subgraf */
879 int start; /* start node of path, 0-based */
880 int end; /* end node of path */
881 int maxbonds; /* max number of bonds in path */
882 int nbonds; /* actual number of bonds in path */
883 int nseen; /* number of nodes of found path(s) */
884 int *seen; /* nodes of found path(s) */
886
895 subgraf *subgraf_new(ORIG_ATOM_DATA *orig_inp_data,
896 int nnodes,
897 int *nodes);
898
905 void subgraf_free(subgraf *sg);
912
923 ORIG_ATOM_DATA *orig_inp_data,
924 int start,
925 int end);
926
934
947 int nforbidden,
948 int *forbidden_orig,
949 int *nbonds, int **bonds,
950 int *natoms, int *atoms);
951
962 int nforbidden,
963 int *forbidden,
964 int *atnums);
965
966 void CompAtomData_GetNumMapping(COMP_ATOM_DATA *adata, int *orig_num, int *curr_num);
967
968#ifndef COMPILE_ALL_CPP
969#ifdef __cplusplus
970}
971#endif
972#endif
973
974#endif /* _STRUTIL_H_ */
INChI * PINChI2[TAUT_NUM]
Definition ichi.h:224
INChI_Aux * PINChI_Aux2[TAUT_NUM]
Definition ichi.h:267
#define NUM_ATOM_CHARGES
#define MAX_NUM_VALENCES
unsigned short AT_NUMB
Definition ichisize.h:10
signed short NUM_H
Definition ichisize.h:14
unsigned long INCHI_MODE
Definition ichisize.h:25
signed char S_CHAR
Definition inchi_api.h:78
#define TAUT_NUM
Definition mode.h:560
Definition strutil.h:860
int etype
Definition strutil.h:862
int nbr
Definition strutil.h:861
Definition strutil.h:877
int * seen
Definition strutil.h:884
int nseen
Definition strutil.h:883
int end
Definition strutil.h:880
subgraf * sg
Definition strutil.h:878
int start
Definition strutil.h:879
int nbonds
Definition strutil.h:882
int maxbonds
Definition strutil.h:881
Definition strutil.h:866
int * nodes
Definition strutil.h:868
int * degrees
Definition strutil.h:870
int * orig2node
Definition strutil.h:871
subgraf_edge ** adj
Definition strutil.h:872
int nnodes
Definition strutil.h:867
Definition ichicant.h:303
Structure describing composite atom data for InChI generation.
Definition inpdef.h:614
Definition strutil.h:61
int atomic_number
Definition strutil.h:62
char symbol[3]
Definition strutil.h:63
Definition ichitime.h:50
Definition ichi.h:232
Definition ichi.h:87
Definition ichi.h:174
Definition ichi.h:270
Definition strutil.h:381
int num_fixed_H2_more
Definition strutil.h:409
AT_NUMB sc_in2_only[ICR_MAX_SC_IN2_ONLY]
Definition strutil.h:413
int num_sb_in2_only
Definition strutil.h:419
AT_NUMB fixed_H_at1_more[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:403
int num_sc_in1_only
Definition strutil.h:412
int tot_num_H2
Definition strutil.h:385
AT_NUMB sc_undef_in2_only[ICR_MAX_SB_UNDF]
Definition strutil.h:428
AT_NUMB sb_undef_in1_only[ICR_MAX_SC_UNDF]
Definition strutil.h:421
int num_endp_in2_only
Definition strutil.h:397
int tot_num_H1
Definition strutil.h:384
S_CHAR fixed_H_nH2_more[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:408
int num_sc_in2_only
Definition strutil.h:414
int num_sb_undef_in2_only
Definition strutil.h:424
INCHI_MODE flags
Definition strutil.h:382
int num_sb_undef_in1_only
Definition strutil.h:422
int num_sb_in1_only
Definition strutil.h:417
AT_NUMB sb_undef_in2_only[ICR_MAX_SC_UNDF]
Definition strutil.h:423
AT_NUMB diff_pos_H_at[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:399
int num_diff_pos_H
Definition strutil.h:401
AT_NUMB sb_in2_only[ICR_MAX_SB_IN2_ONLY]
Definition strutil.h:418
int num_fixed_H1_more
Definition strutil.h:405
AT_NUMB sc_in1_only[ICR_MAX_SC_IN1_ONLY]
Definition strutil.h:411
int num_sc_undef_in2_only
Definition strutil.h:429
AT_NUMB fixed_H_at2_more[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:407
AT_NUMB endp_in1_only[ICR_MAX_ENDP_IN1_ONLY]
Definition strutil.h:393
AT_NUMB sb_in1_only[ICR_MAX_SB_IN1_ONLY]
Definition strutil.h:416
int num_taut_M2
Definition strutil.h:389
int num_endp_in1_only
Definition strutil.h:394
int num_taut_M1
Definition strutil.h:388
int num_sc_undef_in1_only
Definition strutil.h:427
AT_NUMB sc_undef_in1_only[ICR_MAX_SB_UNDF]
Definition strutil.h:426
AT_NUMB endp_in2_only[ICR_MAX_ENDP_IN2_ONLY]
Definition strutil.h:396
int num_taut_H1
Definition strutil.h:386
int num_taut_H2
Definition strutil.h:387
S_CHAR fixed_H_nH1_more[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:404
S_CHAR diff_pos_H_nH[ICR_MAX_DIFF_FIXED_H]
Definition strutil.h:400
Definition ichitime.h:34
Structure describing information about atoms for InChI generation.
Definition inpdef.h:518
Structure describing input atom data for InChI generation.
Definition inpdef.h:554
Structure describing an input atom.
Definition inpdef.h:107
Definition ichidrp.h:85
Definition strutil.h:39
int nType
Definition strutil.h:50
int nNormAtMass
Definition strutil.h:46
const char * szElName
Definition strutil.h:41
int nElNegPauling10
Definition strutil.h:52
double dAtMass
Definition strutil.h:48
int nAtMass
Definition strutil.h:44
S_CHAR cValence[NUM_ATOM_CHARGES][MAX_NUM_VALENCES]
Definition strutil.h:56
int bSkipAddingH
Definition strutil.h:55
Structure describing original atom data.
Definition inpdef.h:398
Structure describing the original structure.
Definition inpdef.h:443
Definition mode.h:999
Definition mode.h:985
Definition ichitaut.h:187
int OutputINChI2(struct tagCANON_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)
Definition ichiprt1.c:924
#define ICR_MAX_SC_IN2_ONLY
Definition strutil.h:376
int imat_new(int m, int n, int ***a)
Allocate integer matrix.
Definition strutil.c:5882
struct tagInChICompareResults ICR
int CompINChITaut2(const void *p1, const void *p2)
Compare function for qsort (tautomeric structures)
Definition ichimake.c:2028
int GetInpStructErrorType(INPUT_PARMS *ip, int err, char *pStrErrStruct, int num_inp_atoms)
Get the input struct error type.
Definition ichimake.c:2444
const char gsMissing[]
Definition runichi.c:172
void updateNeighborListMolecularInorganics(inp_ATOM *at, int atom_idx, int neighbor_idx)
Definition strutil.c:4167
enum tagMarkDiff DIF_VALUES
int Free_INChI_Stereo(INChI_Stereo *pINChI_Stereo)
Free INChI_Stereo data structure.
Definition strutil.c:5497
struct tagElementsMolecularInorganics ElementsMolecularInorganics
tagDiffINChISegments
Definition strutil.h:579
@ DIFS_t_SATOMS
Definition strutil.h:586
@ DIFS_idf_LENGTH
Definition strutil.h:591
@ DIFS_m_SP3INV
Definition strutil.h:587
@ DIFS_h_H_ATOMS
Definition strutil.h:582
@ DIFS_f_FORMULA
Definition strutil.h:580
@ DIFS_q_CHARGE
Definition strutil.h:583
@ DIFS_p_PROTONS
Definition strutil.h:584
@ DIFS_b_SBONDS
Definition strutil.h:585
@ DIFS_o_TRANSP
Definition strutil.h:590
@ DIFS_i_IATOMS
Definition strutil.h:589
@ DIFS_s_STYPE
Definition strutil.h:588
@ DIFS_LENGTH
Definition strutil.h:593
@ DIFS_c_CONNECT
Definition strutil.h:581
enum tagDiffINChISegments DIF_SEGMENTS
int shouldBondBeCut(int atom1, int atom2)
Definition strutil.c:4136
int Free_INChI_Aux(INChI_Aux **ppINChI_Aux)
Free INChI_Aux data structure.
Definition strutil.c:5724
void imat_free(int m, int **a)
Free integer matrix.
Definition strutil.c:5913
int Eql_INChI_Isotopic(INChI *i1, INChI *i2)
Compares isotopic information of two InChIs.
Definition ichiprt2.c:168
int get_canonical_atom_number(const INChI_Aux *aux, int orig_atom_num)
Get the canonical atom number object.
Definition strutil.c:4979
int subgraf_pathfinder_collect_all(subgraf_pathfinder *spf, int nforbidden, int *forbidden, int *atnums)
Collects atom numbers along path.
Definition strutil.c:6292
int FillOutInfAtom(struct tagCANON_GLOBALS *pCG, inp_ATOM *norm_at, INF_ATOM_DATA *inf_norm_at_data, int init_num_at, int num_removed_H, int bAdd_DT_to_num_H, int nNumRemovedProtons, NUM_H *nNumRemovedProtonsIsotopic, int bIsotopic, INChI *pINChI, INChI_Aux *pINChI_Aux, int bAbcNumbers, INCHI_MODE nMode)
Fill out.
subgraf * subgraf_new(ORIG_ATOM_DATA *orig_inp_data, int nnodes, int *nodes)
Create graph from atom data.
Definition strutil.c:5939
#define ICR_MAX_SC_IN1_ONLY
Definition strutil.h:375
const char * CompareReversedInchiMsg(int code)
int Free_INChI(INChI **ppINChI)
Free INChI data structure.
Definition strutil.c:5559
int CompINChI2(const INCHI_SORT *p1, const INCHI_SORT *p2, int bTaut, int bCompareIsotopic)
Compares two INChI data structures (qsort)
Definition ichimake.c:1676
enum tagINChISegmAction INCHI_SEGM_ACTION
int set_EnhancedStereo_t_m_layers(const ORIG_ATOM_DATA *orig_inp_data, const INChI *inchi, const INChI_Aux *aux)
Set the enhanced stereochemistry for t- and m-layers.
Definition strutil.c:5121
#define ICR_MAX_SB_UNDF
Definition strutil.h:377
int ProcessStructError(INCHI_IOSTREAM *out_file, INCHI_IOSTREAM *log_file, char *pStrErrStruct, int nErrorType, long num_inp, INPUT_PARMS *ip)
Definition ichimake.c:2475
INCHI_MODE CompareReversedINChI2(INChI *i1, INChI *i2, INChI_Aux *a1, INChI_Aux *a2, ICR *picr, int *err)
Compares two InChIs (2)
Definition ichimake.c:3226
tagMarkDiff
Definition strutil.h:607
@ DIFV_OUTPUT_OMIT_F
Definition strutil.h:620
@ DIFV_OUTPUT_FILL_T
Definition strutil.h:622
@ DIFV_NEQ2PRECED
Definition strutil.h:610
@ DIFV_OUTPUT_EMPTY_T
Definition strutil.h:617
@ DIFV_BOTH_EMPTY
Definition strutil.h:608
@ DIFV_EQL2PRECED
Definition strutil.h:609
@ DIFV_OUTPUT_EMPTY_F
Definition strutil.h:618
@ DIFV_FI_EQ_MI
Definition strutil.h:612
@ DIFV_IS_EMPTY
Definition strutil.h:611
void subgraf_free(subgraf *sg)
Free graph data structure.
Definition strutil.c:6029
#define ICR_MAX_ENDP_IN1_ONLY
Definition strutil.h:370
#define ICR_MAX_SB_IN2_ONLY
Definition strutil.h:374
void subgraf_pathfinder_run(subgraf_pathfinder *spf, int nforbidden, int *forbidden_orig, int *nbonds, int **bonds, int *natoms, int *atoms)
Find path(s) from subgraf node spf->start to spf->end and fill bonds[nbonds] and atoms[natoms]....
Definition strutil.c:6145
const char gsEmpty[]
Definition runichi.c:173
int bHasEquString(AT_NUMB *LinearCT, int nLenCT)
Checks if a given array of equivalence numbers (LinearCT) contains any repetitions.
Definition ichiprt2.c:363
int CompareReversedINChI(INChI *i1, INChI *i2, INChI_Aux *a1, INChI_Aux *a2)
Compares two InChIs (1)
Definition ichimake.c:2900
int MolecularInorganicsIsMetalToDisconnect(inp_ATOM *at, int atom_idx)
Definition strutil.c:4092
int INChI_SegmentAction(char cDifSegs)
Action to take per segment (?)
Definition ichimake.c:1450
int bIsSameBond(int a1, int a2, int b1, int b2)
Check if two bonds are the same.
Definition runichi2.c:1387
int Eql_INChI_Aux_Num(INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2)
Compares two InChI AuxInfo objects in terms of numbering.
Definition ichiprt2.c:270
subgraf_pathfinder * subgraf_pathfinder_new(subgraf *sg, ORIG_ATOM_DATA *orig_inp_data, int start, int end)
Allocate new graph pathfinder data structure.
Definition strutil.c:6094
void CompAtomData_GetNumMapping(COMP_ATOM_DATA *adata, int *orig_num, int *curr_num)
Definition strutil.c:5864
void subgraf_debug_trace(subgraf *sg)
Debug graph data structure.
Definition strutil.c:6066
#define ICR_MAX_DIFF_FIXED_H
Definition strutil.h:372
int MolecularInorganicsPreprocessing(ORIG_ATOM_DATA *orig_at_data, INPUT_PARMS *ip)
Definition strutil.c:4392
int CompINChITautVsNonTaut(const INCHI_SORT *p1, const INCHI_SORT *p2, int bCompareIsotopic)
Compare tautomeric vs non-tautomeric information.
Definition ichimake.c:306
int MarkUnusedAndEmptyLayers(char sDifSegs[][DIFS_LENGTH])
Mark unused and empty layers.
Definition ichimake.c:1489
int bIsMetalSalt(inp_ATOM *at, int i)
Check if atom is a metal salt.
Definition strutil.c:2477
int bNumHeterAtomHasIsotopicH(inp_ATOM *atom, int num_atoms)
Check if hetero atoms has isotopic hydrogens.
Definition strutil.c:4835
int CompINChILayers(const INCHI_SORT *p1, const INCHI_SORT *p2, char sDifSegs[][DIFS_LENGTH], int bFixTranspChargeBug)
Compare InChI layers.
Definition ichimake.c:609
int invert_parities(const INChI *inchi, const INChI_Aux *aux, int **list_atoms, int nof_lists, int is_absolute)
Invert the parities for enhanced stereochemistry t- and m-layers.
Definition strutil.c:5036
const char gsEqual[]
Definition runichi.c:175
enum tagInchiDiffBits IDIF
INChI_Aux * Alloc_INChI_Aux(int num_at, int num_isotopic_atoms, int nAllocMode, int bOrigData)
Allocate AuxInfo data structure.
Definition strutil.c:5764
int getElTypeforMolecularInorganics(int nPeriodicNum)
Definition strutil.c:4082
enum tagDiffINChILayers DIF_LAYERS
int ExtractConnectedComponent(inp_ATOM *at, int num_at, int component_number, inp_ATOM *component_at)
Extract one (connected) component.
Definition strutil.c:5446
int SaveEquComponentsInfoAndSortOrder(int iINChI, INCHI_SORT *pINChISort[TAUT_NUM], int *num_components, ORIG_ATOM_DATA *orig_inp_data, ORIG_ATOM_DATA *prep_inp_data, COMP_ATOM_DATA composite_norm_data[TAUT_NUM+1], int bCompareComponents)
Save equivalent components information and sort order (not used ?)
#define ICR_MAX_ENDP_IN2_ONLY
Definition strutil.h:371
tagDiffINChILayers
Definition strutil.h:597
@ DIFL_LENGTH
Definition strutil.h:602
@ DIFL_FI
Definition strutil.h:601
@ DIFL_M
Definition strutil.h:598
@ DIFL_MI
Definition strutil.h:599
@ DIFL_F
Definition strutil.h:600
INChI * Alloc_INChI(inp_ATOM *at, int num_at, int *found_num_bonds, int *found_num_isotopic, int nAllocMode)
Allocate INChI data structure.
Definition strutil.c:5604
tagINChISegmAction
Definition strutil.h:626
@ INCHI_SEGM_OMIT
Definition strutil.h:627
@ INCHI_SEGM_FILL
Definition strutil.h:628
@ INCHI_SEGM_EMPTY
Definition strutil.h:629
struct tagMolecularInorganicsArray MolecularInorganicsElData
int SetConnectedComponentNumber(inp_ATOM *at, int num_at, int component_number)
Set the Connected Component Number object.
Definition strutil.c:5485
const char gsSpace[]
Definition runichi.c:174
int CompareIcr(ICR *picr1, ICR *picr2, INCHI_MODE *pin1, INCHI_MODE *pin2, INCHI_MODE mask)
Compares results from InChI comparison.
Definition ichimake.c:3153
int Eql_INChI_Aux_Equ(INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2)
Compares two InChI AuxInfo objects.
Definition ichiprt2.c:192
int FillOutCompositeCanonInfAtom(struct tagCANON_GLOBALS *pCG, COMP_ATOM_DATA *composite_norm_data, INF_ATOM_DATA *inf_norm_at_data, int bIsotopic, int bTautomeric, PINChI2 *pINChI2, PINChI_Aux2 *pINChI_Aux2, int bAbcNumbers, INCHI_MODE nMode)
Fill out composite canonical info atom data structure.
#define ICR_MAX_SC_UNDF
Definition strutil.h:378
int OutputINChIPlainError(INCHI_IOSTREAM *out_file, char *pErrorText, int bError)
Print error message (plain text)
Definition ichiprt1.c:474
int get_parity_idx_from_canonical_atom_number(int canon_atom_num, const AT_NUMB *nNumber, int nof_atoms)
Get the parity index from canonical atom number.
Definition strutil.c:5006
void subgraf_pathfinder_free(subgraf_pathfinder *spf)
Frees subgraph pathfinder data structure.
Definition strutil.c:6125
tagInchiDiffBits
Definition strutil.h:315
@ IDIF_SC_EXTRA_UNDF
Definition strutil.h:346
@ IDIF_MULTIPLE_TG
Definition strutil.h:331
@ IDIF_CON_TBL
Definition strutil.h:321
@ IDIF_REM_ISO_H
Definition strutil.h:343
@ IDIF_SB_MISS_UNDF
Definition strutil.h:353
@ IDIF_NUM_ISO_AT
Definition strutil.h:339
@ IDIF_REM_PROT
Definition strutil.h:342
@ IDIF_POSITION_H
Definition strutil.h:322
@ IDIF_SB_MISS
Definition strutil.h:354
@ IDIF_MISS_TG_ENDP
Definition strutil.h:336
@ IDIF_TG
Definition strutil.h:338
@ IDIF_SC_INV
Definition strutil.h:344
@ IDIF_SC_PARITY
Definition strutil.h:345
@ IDIF_SINGLE_TG
Definition strutil.h:330
@ IDIF_SB_EXTRA
Definition strutil.h:352
@ IDIF_MORE_FH
Definition strutil.h:323
@ IDIF_NUM_EL
Definition strutil.h:319
@ IDIF_ISO_AT
Definition strutil.h:340
@ IDIF_NUM_AT
Definition strutil.h:317
@ IDIF_CON_LEN
Definition strutil.h:320
@ IDIF_EXTRA_TG_ENDP
Definition strutil.h:335
@ IDIF_SB_EXTRA_UNDF
Definition strutil.h:351
@ IDIF_LESS_H
Definition strutil.h:326
@ IDIF_ATOMS
Definition strutil.h:318
@ IDIF_DIFF_TG_ENDP
Definition strutil.h:337
@ IDIF_SC_MISS
Definition strutil.h:349
@ IDIF_CHARGE
Definition strutil.h:341
@ IDIF_SC_EXTRA
Definition strutil.h:347
@ IDIF_LESS_FH
Definition strutil.h:324
@ IDIF_PROBLEM
Definition strutil.h:316
@ IDIF_NO_TAUT
Definition strutil.h:328
@ IDIF_WRONG_TAUT
Definition strutil.h:329
@ IDIF_SB_PARITY
Definition strutil.h:350
@ IDIF_NUM_TG
Definition strutil.h:332
@ IDIF_MORE_H
Definition strutil.h:325
@ IDIF_SC_MISS_UNDF
Definition strutil.h:348
int getElValenceforMolecularInorganics(int nPeriodicNum, int charge, int val_num)
Definition strutil.c:4068
int WriteToSDfile(const INP_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, const char *szLabel, const char *szValue)
int Create_INChI(struct tagCANON_GLOBALS *pCG, struct tagINCHI_CLOCK *ic, INPUT_PARMS *ip, INChI **ppINChI, INChI_Aux **ppINChI_Aux, ORIG_ATOM_DATA *orig_inp_data, inp_ATOM *inp_at, INP_ATOM_DATA *inp_norm_data[2], int num_inp_at, const unsigned char *keep_explicit_HDT, INCHI_MODE nUserMode, INCHI_MODE *pbTautFlags, INCHI_MODE *pbTautFlagsDone, struct tagInchiTime *ulMaxTime, struct tagTautomerGroupsInfo *ti_out, char *pStrErrStruct)
Create INChI.
Definition ichimake.c:3671
int OutputINChI1(struct tagCANON_GLOBALS *pCG, INCHI_IOS_STRING *strbuf, INCHI_SORT *pINChISortTautAndNonTaut2[][TAUT_NUM], int iINChI, 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)
Main actual worker which serializes InChI to string (called from OutputINChI2( ......
Definition ichiprt1.c:1016
int CompINChINonTaut2(const void *p1, const void *p2)
Compare function for qsort (normal structure)
Definition ichimake.c:2006
int Free_INChI_Members(INChI *pINChI)
Free INChI members.
Definition strutil.c:5581
#define ICR_MAX_SB_IN1_ONLY
Definition strutil.h:373
char * AllocateAndFillHillFormula(INChI *pINChI)
Allocate and fill hill formula.
Definition ichimak2.c:367
int Eql_INChI_Stereo(INChI_Stereo *s1, int eql1, INChI_Stereo *s2, int eql2, int bRelRac)
Compares stereo information of two structures.
Definition ichiprt2.c:19