rino 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README +44 -0
  2. data/Rakefile +123 -0
  3. data/ext/extconf.rb +26 -0
  4. data/ext/ruby_inchi_main.so +0 -0
  5. data/ext/src/aux2atom.h +2786 -0
  6. data/ext/src/comdef.h +148 -0
  7. data/ext/src/e_0dstereo.c +3014 -0
  8. data/ext/src/e_0dstereo.h +31 -0
  9. data/ext/src/e_comdef.h +57 -0
  10. data/ext/src/e_ctl_data.h +147 -0
  11. data/ext/src/e_ichi_io.c +498 -0
  12. data/ext/src/e_ichi_io.h +40 -0
  13. data/ext/src/e_ichi_parms.c +37 -0
  14. data/ext/src/e_ichi_parms.h +41 -0
  15. data/ext/src/e_ichicomp.h +50 -0
  16. data/ext/src/e_ichierr.h +40 -0
  17. data/ext/src/e_ichimain.c +593 -0
  18. data/ext/src/e_ichisize.h +43 -0
  19. data/ext/src/e_inchi_atom.c +75 -0
  20. data/ext/src/e_inchi_atom.h +33 -0
  21. data/ext/src/e_inpdef.h +41 -0
  22. data/ext/src/e_mode.h +706 -0
  23. data/ext/src/e_mol2atom.c +649 -0
  24. data/ext/src/e_readinch.c +58 -0
  25. data/ext/src/e_readmol.c +54 -0
  26. data/ext/src/e_readmol.h +180 -0
  27. data/ext/src/e_readstru.c +251 -0
  28. data/ext/src/e_readstru.h +33 -0
  29. data/ext/src/e_util.c +284 -0
  30. data/ext/src/e_util.h +61 -0
  31. data/ext/src/extr_ct.h +251 -0
  32. data/ext/src/ichi.h +206 -0
  33. data/ext/src/ichi_bns.c +7999 -0
  34. data/ext/src/ichi_bns.h +231 -0
  35. data/ext/src/ichican2.c +5000 -0
  36. data/ext/src/ichicano.c +2195 -0
  37. data/ext/src/ichicano.h +49 -0
  38. data/ext/src/ichicans.c +1625 -0
  39. data/ext/src/ichicant.h +379 -0
  40. data/ext/src/ichicomn.h +260 -0
  41. data/ext/src/ichicomp.h +50 -0
  42. data/ext/src/ichidrp.h +119 -0
  43. data/ext/src/ichierr.h +124 -0
  44. data/ext/src/ichiisot.c +101 -0
  45. data/ext/src/ichilnct.c +286 -0
  46. data/ext/src/ichimain.h +132 -0
  47. data/ext/src/ichimak2.c +1189 -0
  48. data/ext/src/ichimake.c +3812 -0
  49. data/ext/src/ichimake.h +205 -0
  50. data/ext/src/ichimap1.c +851 -0
  51. data/ext/src/ichimap2.c +2856 -0
  52. data/ext/src/ichimap4.c +1609 -0
  53. data/ext/src/ichinorm.c +741 -0
  54. data/ext/src/ichinorm.h +67 -0
  55. data/ext/src/ichiparm.c +45 -0
  56. data/ext/src/ichiparm.h +1441 -0
  57. data/ext/src/ichiprt1.c +3612 -0
  58. data/ext/src/ichiprt2.c +1511 -0
  59. data/ext/src/ichiprt3.c +3011 -0
  60. data/ext/src/ichiqueu.c +1003 -0
  61. data/ext/src/ichiring.c +326 -0
  62. data/ext/src/ichiring.h +49 -0
  63. data/ext/src/ichisize.h +35 -0
  64. data/ext/src/ichisort.c +539 -0
  65. data/ext/src/ichister.c +3538 -0
  66. data/ext/src/ichister.h +35 -0
  67. data/ext/src/ichitaut.c +3843 -0
  68. data/ext/src/ichitaut.h +387 -0
  69. data/ext/src/ichitime.h +74 -0
  70. data/ext/src/inchi_api.h +670 -0
  71. data/ext/src/inchi_dll.c +1480 -0
  72. data/ext/src/inchi_dll.h +34 -0
  73. data/ext/src/inchi_dll_main.c +23 -0
  74. data/ext/src/inchi_dll_main.h +31 -0
  75. data/ext/src/inpdef.h +328 -0
  76. data/ext/src/lreadmol.h +1246 -0
  77. data/ext/src/mode.h +706 -0
  78. data/ext/src/ruby_inchi_main.c +558 -0
  79. data/ext/src/runichi.c +4179 -0
  80. data/ext/src/strutil.c +3861 -0
  81. data/ext/src/strutil.h +182 -0
  82. data/ext/src/util.c +1130 -0
  83. data/ext/src/util.h +85 -0
  84. data/lib/clean_tempfile.rb +220 -0
  85. data/lib/rino.rb +111 -0
  86. data/test/test.rb +386 -0
  87. metadata +130 -0
@@ -0,0 +1,58 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+ #include <limits.h>
13
+ #include <math.h>
14
+ #include <float.h>
15
+ #include <string.h>
16
+ #include <ctype.h>
17
+
18
+ /* for use in the main program */
19
+
20
+
21
+ #include "e_mode.h"
22
+ #include "inchi_api.h"
23
+ #include "e_ctl_data.h"
24
+ #include "e_inchi_atom.h"
25
+ #include "e_ichi_io.h"
26
+
27
+ #include "e_ichisize.h"
28
+ #include "e_comdef.h"
29
+ #include "e_util.h"
30
+ #include "e_ichierr.h"
31
+ #include "e_ichicomp.h"
32
+ #include "e_readstru.h"
33
+ #include "e_inpdef.h"
34
+
35
+ /* rename to avoid duplicated entry points */
36
+
37
+ #define mystrncpy e_mystrncpy
38
+ #define LtrimRtrim e_LtrimRtrim
39
+ #define FreeInchi_Atom e_FreeInchi_Atom
40
+ #define FreeInchi_Stereo0D e_FreeInchi_Stereo0D
41
+ #define CreateInchi_Atom e_CreateInchi_Atom
42
+ #define CreateInchi_Stereo0D e_CreateInchi_Stereo0D
43
+ #define FreeInchi_Input e_FreeInchi_Input
44
+ #define AddMOLfileError e_AddMOLfileError
45
+ #define my_fgets e_my_fgets
46
+ #define my_fgetsTab e_my_fgetsTab
47
+ #define my_fgetsTab1 e_my_fgetsTab1
48
+ #define is_in_the_slist e_is_in_the_slist
49
+ #define is_element_a_metal e_is_element_a_metal
50
+ #define INChIToInchi_Atom e_INChIToInchi_Atom
51
+ #define INChIToInchi_Input e_INChIToInchi_Input
52
+
53
+ #define IGNORE_HEADERS
54
+ #define STATIC
55
+
56
+ /* This contains executable code. Included in lReadAux.c, e_ReadINCH.c, ReadINCH.c, */
57
+ #include "aux2atom.h"
58
+
@@ -0,0 +1,54 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+ #include <limits.h>
13
+ #include <math.h>
14
+ #include <float.h>
15
+ #include <string.h>
16
+ #include <ctype.h>
17
+
18
+ #include "e_mode.h"
19
+ #include "inchi_api.h"
20
+ #include "e_ctl_data.h"
21
+
22
+ #include "e_ichisize.h"
23
+ #include "e_comdef.h"
24
+ #include "e_util.h"
25
+ #include "e_readmol.h"
26
+ #include "e_ichicomp.h"
27
+ #include "e_ichi_io.h"
28
+ #include "e_readstru.h"
29
+ #include "e_inpdef.h"
30
+
31
+ #define AddMOLfileError e_AddMOLfileError
32
+ #define remove_one_lf e_remove_one_lf
33
+ #define RemoveNonPrintable e_RemoveNonPrintable
34
+ #define mystrncpy e_mystrncpy
35
+ #define read_mol_file e_read_mol_file
36
+ #define bypass_sdf_data_items e_bypass_sdf_data_items
37
+ #define extract_ChargeRadical e_extract_ChargeRadical
38
+ #define delete_mol_data e_delete_mol_data
39
+ #define remove_trailing_spaces e_remove_trailing_spaces
40
+ #define normalize_name e_normalize_name
41
+ #define read_sdfile_segment e_read_sdfile_segment
42
+ #define CopyMOLfile e_CopyMOLfile
43
+ #define LtrimRtrim e_LtrimRtrim
44
+
45
+ #ifndef inchi_calloc
46
+ #define inchi_calloc e_inchi_calloc
47
+ #endif
48
+
49
+ #ifndef inchi_free
50
+ #define inchi_free e_inchi_free
51
+ #endif
52
+
53
+ #include "lreadmol.h"
54
+
@@ -0,0 +1,180 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __READMOL_H__
11
+ #define __READMOL_H__
12
+
13
+ /*************** read MOL file V2000.************************/
14
+ /* ref: A.Dalby et al, "Description of Several Chemical Structure
15
+ * File Formats Used by Computer Programs Developed at Molecular
16
+ * Design Limited", J. Chem. Inf. Comput. Sci., 1992, 32, 244-255.
17
+ */
18
+
19
+ /*
20
+ #define MOLFILEINPLINELEN 84 // add cr, lf, double zero termination
21
+ #ifndef MOLFILEMAXLINELEN
22
+ #define MOLFILEMAXLINELEN 80
23
+ #endif
24
+ */
25
+
26
+ #define MOLFILEINPLINELEN 204 /* add cr, lf, double zero termination */
27
+ #ifndef MOLFILEMAXLINELEN
28
+ #define MOLFILEMAXLINELEN 200
29
+ #endif
30
+
31
+
32
+ #define MOL_PRESENT 1
33
+ #define MOL_ABSENT 0
34
+
35
+ /* configuration */
36
+ #define MOL_QUERY MOL_ABSENT
37
+ #define MOL_CPSS MOL_ABSENT
38
+ #define MOL_REACT MOL_ABSENT
39
+
40
+ #define MOL_STRING_DATA 'S'
41
+ #define MOL_CHAR_INT_DATA 'C'
42
+ #define MOL_SHORT_INT_DATA 'N'
43
+ #define MOL_LONG_INT_DATA 'L'
44
+ #define MOL_DOUBLE_DATA 'D'
45
+ #define MOL_FLOAT_DATA 'F'
46
+ #define MOL_JUMP_TO_RIGHT 'J'
47
+ #define MOL_MAX_VALUE_LEN 32 /* max length of string containing a numerical value */
48
+
49
+
50
+ #define SDF_END_OF_DATA "$$$$"
51
+
52
+ /****************************************************************************/
53
+ typedef struct tagMOL_HEADER_BLOCK {
54
+ /* Line #1 */
55
+ char szMoleculeName[MOLFILEMAXLINELEN+1]; /* up to 80 characters */
56
+ /* Line #2: optional */
57
+ char szMoleculeLine2[MOLFILEMAXLINELEN+1]; /* the whole line2 -- up to 80 characters */
58
+ char szUserInitials[3]; /* 2 bytes; char */
59
+ char szProgramName[9]; /* 8 bytes; char */
60
+ char cMonth; /* 2 bytes; integral */
61
+ char cDay; /* 2 bytes; integral */
62
+ char cYear; /* 2 bytes; integral */
63
+ char cHour; /* 2 bytes; integral */
64
+ char cMinute; /* 2 bytes; integral */
65
+ char szDimCode[3]; /* 2 bytes: dimensional code; char */
66
+ short nScalingFactor1; /* 2 bytes; I2 */
67
+ double dScalingFactor2; /* 10 bytes, F10.5 */
68
+ double dEnergy; /* 10 bytes, F10.5 */
69
+ long lInternalRegistryNumber;/* 6 bytes, integral */
70
+ /* Line #3: comment */
71
+ char szComment[81];
72
+ }MOL_HEADER_BLOCK;
73
+
74
+ /****************************************************************************/
75
+ typedef struct tagMOL_ATOM {
76
+ double fX; /* F10.5; Generic */
77
+ double fY; /* F10.5; Generic */
78
+ double fZ; /* F10.5; Generic */
79
+ char szAtomSymbol[6]; /* aaa; Generic */ /* changed from 4 to 6 to match STDATA */
80
+ S_SHORT cMassDifference; /* dd; (M_ISO) Generic: -3..+4 otherwise 0 or 127=most abund. isotope */
81
+ S_CHAR cCharge; /* ccc; (M CHG), Generic: 1=+3,2=+2,3=+1,4=doublet,5=-1,6=-2,7=-3 */
82
+ char cRadical; /* (M RAD) */
83
+ char cStereoParity; /* sss; Generic */
84
+ #if ( MOL_QUERY == MOL_PRESENT )
85
+ char cH_countPlus1; /* hhh; Query; Hn means >= n H; H0 means no H */
86
+ char cStereoCare; /* bbb; Query: 0=ignore; 1=must match */
87
+ #endif
88
+ char cValence; /* vvv: 0=no marking; (1..14)=(1..14); 15=zero valence */
89
+ /* number of bonds including bonds to implies H's */
90
+ #if ( MOL_CPSS == MOL_PRESENT )
91
+ char cH0_designator; /* HHH: CPSS */
92
+ char cReactionComponentType; /* rrr: CPSS: 1=reactant, 2=product, 3=intermediate */
93
+ char cReactionComponentNumber; /* iii: CPSS: 0 to (n-1) */
94
+ #endif
95
+
96
+ #if ( MOL_REACT == MOL_PRESENT )
97
+ short nAtomAtomMappingNumber; /* mmm: Reaction: 1..255 */
98
+ char cInversionRetentionFlag; /* nnn: 1=inverted,2=retained config.; 0=property not applied */
99
+ #endif
100
+ #if ( MOL_REACT == MOL_PRESENT || MOL_QUERY == MOL_PRESENT )
101
+ char cExactChargeFlag; /* eee: 1=charge on atom must match exactly, 0=property not applied */
102
+ #endif
103
+ char cMyNumImpH; /* number of implicit H calculated for adding H to strings in STDATA */
104
+ char cDisplayAtom; /* Do not hide element's name ( applies to C 7-25-98 DCh */
105
+ char cAtomAliasedFlag; /* Do not remove charge/radical/isotope if it is in the alias. 9-3-99 DCh */
106
+ } MOL_ATOM;
107
+
108
+ /****************************************************************************/
109
+ typedef struct tagMOL_BONDS {
110
+ short nAtomNo1; /* 111: First atom number: Generic */
111
+ short nAtomNo2; /* 222: Second atom number: Generic */
112
+ char cBondType; /* ttt: 1,2,3=single, double, triple; 4=aromatic; 5=single or double */
113
+ /* 6=single or aromatic, 7=double or aromatic, 8=any. */
114
+ /* values 4-8 are for SSS queries only */
115
+ char cBondStereo; /* sss: Single bonds: 0=not stereo, 1=up, 4=either, 6=down */
116
+ /* Double bonds: 0=use x,y,z to determine cis/trans */
117
+ /* 3=cis or trans (either) */
118
+ /* xxx: not used */
119
+ #if ( MOL_QUERY == MOL_PRESENT )
120
+ char cBondTopology; /* rrr: 0=either, 1=ring, 2=chain: SSS queries only */
121
+ #endif
122
+ #if ( MOL_REACT == MOL_PRESENT )
123
+ char cReactingCenterStatus; /* ccc: 0=unmarked, 1=a center, -1=not a center; Additional: */
124
+ /* 2=no charge,4=bond made/broken,8=bond order changes */
125
+ /* 12=4+8; 5=4+1, 9=8+1, 13=12+1 are also possible */
126
+ #endif
127
+ } MOL_BONDS;
128
+ /****************************************************************************/
129
+ typedef struct tagMOL_CTAB {
130
+ /* Line #1: Counts line */
131
+ short nNumberOfAtoms; /* aaa; <= 999; Generic */
132
+ short nNumberOfBonds; /* bbb; <= 999; Generic */
133
+ #if ( MOL_QUERY == MOL_PRESENT )
134
+ short nNumberOfAtomsLists; /* lll; <= 30; Query */
135
+ #endif
136
+ /* fff; Obsolete */
137
+ char cChiralFlag; /* ccc; 0 or 1; Generic */
138
+ short nNumberOfStextEntries; /* sss; CPSS */
139
+ #if ( MOL_CPSS == MOL_PRESENT )
140
+ short nNumberOfReactionComponentsPlus1; /* xxx; CPSS */
141
+ short nNumberOfReactants; /* rrr; CPSS */
142
+ short nNumberOfProducts; /* ppp; CPSS */
143
+ short nNumberOfIntermediates; /* iii; CPSS */
144
+ #endif
145
+ short nNumberOfPropertyLines; /* mmm; Generic */
146
+ char csCurrentCtabVersion[7]; /* vvvvvv; Generic; 'V2000' */
147
+ /* The Atom Block */
148
+ MOL_ATOM *MolAtom;
149
+ MOL_BONDS *MolBond;
150
+ MOL_COORD *szCoord;
151
+ } MOL_CTAB;
152
+
153
+ typedef struct tagMOL_DATA {
154
+ MOL_HEADER_BLOCK hdr;
155
+ MOL_CTAB ctab;
156
+ } MOL_DATA;
157
+
158
+ #ifndef INCHI_ALL_CPP
159
+ #ifdef __cplusplus
160
+ extern "C" {
161
+ #endif
162
+ #endif
163
+
164
+
165
+ MOL_DATA* e_delete_mol_data( MOL_DATA* mol_data );
166
+
167
+ MOL_DATA* e_read_sdfile_segment(FILE* inp, MOL_HEADER_BLOCK *OnlyHeaderBlock, MOL_CTAB *OnlyCtab,
168
+ int bGetOrigCoord,
169
+ char *pname, int lname,
170
+ long *Id, const char *pSdfLabel, char *pSdfValue,
171
+ int *err, char *pStrErr );
172
+
173
+
174
+ #ifndef INCHI_ALL_CPP
175
+ #ifdef __cplusplus
176
+ }
177
+ #endif
178
+ #endif
179
+
180
+ #endif /*__READMOL_H__*/
@@ -0,0 +1,251 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+
13
+ #include <string.h>
14
+ #include <ctype.h>
15
+ #include <stdarg.h>
16
+ #include <errno.h>
17
+ #include <limits.h>
18
+ #include <float.h>
19
+
20
+ #include "e_mode.h"
21
+ #include "ichitime.h"
22
+ #include "inchi_api.h"
23
+ #include "e_ctl_data.h"
24
+ #include "e_readstru.h"
25
+ #include "e_ichi_io.h"
26
+ #include "e_util.h"
27
+ #include "e_ichierr.h"
28
+ #include "e_inpdef.h"
29
+
30
+ int e_TreatReadTheStructureErrors( STRUCT_DATA *sd, INPUT_PARMS *ip,
31
+ FILE *inp_file, FILE *log_file, FILE *output_file, FILE *prb_file,
32
+ inchi_Input *pInp, int *num_inp );
33
+ int e_GetInpStructErrorType( INPUT_PARMS *ip, int err, char *pStrErrStruct, int num_inp_atoms );
34
+
35
+ /*********************************************************************************************************/
36
+ int e_ReadStructure( STRUCT_DATA *sd, INPUT_PARMS *ip,
37
+ FILE *inp_file, FILE *log_file, FILE *output_file, FILE *prb_file,
38
+ inchi_Input *pInp, int num_inp, /* for CML:*/ int inp_index, int *out_index )
39
+ {
40
+ inchiTime ulTStart;
41
+ int nRet = 0, nRet2 = 0;
42
+ int bGetOrigCoord = 0;
43
+ INCHI_MODE InpAtomFlags = 0;
44
+
45
+ memset( sd, 0, sizeof(*sd) );
46
+ switch ( ip->nInputType ) {
47
+ case INPUT_MOLFILE:
48
+ case INPUT_SDFILE:
49
+ if ( pInp ) {
50
+ if ( ip->pSdfValue && ip->pSdfValue[0] ) {
51
+ /* Added 07-29-2003 to avoid inheriting exact value from prev. structure
52
+ and to make reference to a (bad) structure with unknown ID Value */
53
+ char *p, *q; /* q shadows prev declaration of const char *q */
54
+ int n;
55
+ if ( (p = strrchr( ip->pSdfValue, '+' )) &&
56
+ '[' == *(p-1) && 0 < (n=strtol(p+1,&q,10)) && q[0] && ']'==q[0] && !q[1] ) {
57
+ sprintf( p+1, "%d]", n+1 );
58
+ } else {
59
+ strcat( ip->pSdfValue, " [+1]" );
60
+ }
61
+ }
62
+ e_InchiTimeGet( &ulTStart );
63
+ sd->fPtrStart = (inp_file == stdin)? -1 : ftell( inp_file );
64
+ /* read the original structure */
65
+ nRet2 = e_MolfileToInchi_Input( inp_file, pInp, ip->bMergeAllInputStructures,
66
+ ip->bDoNotAddH, ip->bAllowEmptyStructure,
67
+ ip->pSdfLabel, ip->pSdfValue, &ip->lSdfId, &ip->lMolfileNumber,
68
+ &InpAtomFlags, &sd->nStructReadError, sd->pStrErrStruct );
69
+
70
+ sd->bChiralFlag |= InpAtomFlags;
71
+ if ( !ip->bGetSdfileId || ip->lSdfId == 999999) ip->lSdfId = 0;
72
+ if ( !ip->bGetMolfileNumber || ip->lMolfileNumber < 0 ) ip->lMolfileNumber = 0;
73
+ sd->fPtrEnd = (inp_file == stdin)? -1 : ftell( inp_file );
74
+ sd->ulStructTime += e_InchiTimeElapsed( &ulTStart );
75
+ } else {
76
+ /* read the next original structure */
77
+ int nStructReadError=0;
78
+ if ( !ip->bMergeAllInputStructures ) {
79
+ nRet2 = e_MolfileToInchi_Input( inp_file, NULL, 0, 0, 0,
80
+ NULL, NULL, NULL, NULL, NULL, &nStructReadError, NULL );
81
+ if ( nRet2 <= 0 && 10 < nStructReadError && nStructReadError < 20 ) {
82
+ return _IS_EOF;
83
+ }
84
+ } else {
85
+ return _IS_EOF;
86
+ }
87
+ }
88
+ break;
89
+ case INPUT_INCHI_XML:
90
+ case INPUT_INCHI_PLAIN:
91
+ if ( pInp ) {
92
+ if ( ip->pSdfValue && ip->pSdfValue[0] ) {
93
+ /* Added 07-29-2003 to avoid inheriting exact value from prev. structure
94
+ and to make reference to a (bad) structure with unknown ID Value */
95
+ char *p, *q;
96
+ int n;
97
+ if ( (p = strrchr( ip->pSdfValue, '+' )) &&
98
+ '[' == *(p-1) && 0 < (n=strtol(p+1,&q,10)) && q[0] && ']'==q[0] && !q[1] ) {
99
+ sprintf( p+1, "%d]", n+1 );
100
+ } else {
101
+ strcat( ip->pSdfValue, " [+1]" );
102
+ }
103
+ }
104
+ e_InchiTimeGet( &ulTStart );
105
+ sd->fPtrStart = (inp_file == stdin)? -1 : ftell( inp_file );
106
+ /* read the original structure */
107
+ nRet2 = e_INChIToInchi_Input( inp_file, pInp, ip->bMergeAllInputStructures, ip->bDoNotAddH,
108
+ ip->nInputType, ip->pSdfLabel, ip->pSdfValue, &ip->lMolfileNumber,
109
+ &InpAtomFlags, &sd->nStructReadError, sd->pStrErrStruct );
110
+ /*if ( !ip->bGetSdfileId || ip->lSdfId == 999999) ip->lSdfId = 0;*/
111
+ sd->bChiralFlag |= InpAtomFlags;
112
+ sd->fPtrEnd = (inp_file == stdin)? -1 : ftell( inp_file );
113
+ sd->ulStructTime += e_InchiTimeElapsed( &ulTStart );
114
+ } else {
115
+ /* read the next original structure */
116
+ int nStructReadError=0;
117
+ if ( !ip->bMergeAllInputStructures ) {
118
+ nRet2 = e_INChIToInchi_Input( inp_file, NULL, 0, 0,
119
+ ip->nInputType, NULL, NULL, NULL, NULL, &nStructReadError, NULL );
120
+ if ( nRet2 <= 0 && 10 < nStructReadError && nStructReadError < 20 ) {
121
+ return _IS_EOF;
122
+ }
123
+ } else {
124
+ return _IS_EOF;
125
+ }
126
+ }
127
+ break;
128
+
129
+ #if( ADD_CMLPP == 1 )
130
+ /* BILLY 8/6/04 */
131
+ case INPUT_CMLFILE:
132
+ if ( pInp ) {
133
+
134
+ e_InchiTimeGet( &ulTStart );
135
+ /*
136
+ if ( inp_index >= 0 ) {
137
+ sd->fPtrStart = inp_index;
138
+ } else {
139
+ sd->fPtrStart = GetCmlStructIndex();
140
+ }
141
+ */
142
+ sd->fPtrStart = -1; /* disable "e_CopyMOLfile() for CML input files */
143
+ sd->fPtrEnd = -1;
144
+ /* read the original structure */
145
+ nRet = CmlfileToOrigAtom( inp_file, pInp, ip->bMergeAllInputStructures,
146
+ bGetOrigCoord, ip->bDoNotAddH, inp_index, out_index,
147
+ ip->pSdfLabel, ip->pSdfValue, &ip->lSdfId,
148
+ &sd->nStructReadError, sd->pStrErrStruct );
149
+
150
+
151
+ sd->ulStructTime += e_InchiTimeElapsed( &ulTStart );
152
+ #if( bRELEASE_VERSION == 0 )
153
+ sd->bExtract |= pInp->bExtract;
154
+ #endif
155
+ } else {
156
+ /* read the next original structure */
157
+ int nStructReadError=0;
158
+ if ( !ip->bMergeAllInputStructures ) {
159
+ nRet2 = CmlfileToOrigAtom( inp_file, NULL, 0, 0, 0, inp_index, out_index,
160
+ NULL, NULL, NULL, &nStructReadError, NULL );
161
+
162
+ if ( nRet2 <= 0 && 10 < nStructReadError && nStructReadError < 20 ) {
163
+ return _IS_EOF;
164
+ }
165
+ } else {
166
+ return _IS_EOF;
167
+ }
168
+ }
169
+ break;
170
+ #endif
171
+
172
+ default:
173
+ nRet = _IS_FATAL; /* wrong file type */
174
+ }
175
+ nRet2 = e_TreatReadTheStructureErrors( sd, ip, inp_file, log_file, output_file, prb_file,
176
+ pInp, &num_inp );
177
+ if ( (!nRet || nRet == _IS_WARNING) && nRet2 )
178
+ nRet = nRet2;
179
+
180
+ return nRet;
181
+ }
182
+ /*****************************************************************************************************/
183
+ int e_TreatReadTheStructureErrors( STRUCT_DATA *sd, INPUT_PARMS *ip,
184
+ FILE *inp_file, FILE *log_file, FILE *output_file, FILE *prb_file,
185
+ inchi_Input *pInp, int *num_inp )
186
+ {
187
+ int nRet = _IS_OKAY;
188
+ /* End of file */
189
+ if ( 10 < sd->nStructReadError && sd->nStructReadError < 20 ) {
190
+ nRet = _IS_EOF;
191
+ goto exit_function; /* end of file */
192
+ }
193
+ /* Skipping the structures */
194
+ if ( *num_inp < ip->first_struct_number ) {
195
+ if ( log_file != stderr ) {
196
+ //e_my_fprintf( stderr, "\rSkipping structure #%d.%s%s%s%s...\r", *num_inp, SDF_LBL_VAL(ip->pSdfLabel,ip->pSdfValue));
197
+ }
198
+ nRet = sd->nErrorType = _IS_SKIP;
199
+ goto exit_function;
200
+ }
201
+
202
+ sd->nErrorType = e_GetInpStructErrorType( ip, sd->nStructReadError, sd->pStrErrStruct, pInp->num_atoms );
203
+
204
+ /* Fatal error */
205
+ if ( sd->nErrorType == _IS_FATAL ) {
206
+ e_my_fprintf( log_file, "Fatal Error %d (aborted; %s) inp structure #%d.%s%s%s%s\n",
207
+ sd->nStructReadError, sd->pStrErrStruct, *num_inp, SDF_LBL_VAL(ip->pSdfLabel,ip->pSdfValue) );
208
+ #if( bRELEASE_VERSION == 1 || EXTR_FLAGS == 0 )
209
+ if ( prb_file && 0L <= sd->fPtrStart && sd->fPtrStart < sd->fPtrEnd && !ip->bSaveAllGoodStructsAsProblem ) {
210
+ e_CopyMOLfile(inp_file, sd->fPtrStart, sd->fPtrEnd, prb_file, *num_inp);
211
+ }
212
+ #endif
213
+ /* goto exit_function; */
214
+ }
215
+ /* Non-fatal errors: do not produce INChI */
216
+ if ( sd->nErrorType == _IS_ERROR ) { /* 70 => too many atoms */
217
+ e_my_fprintf( log_file, "Error %d (no INChI; %s) inp structure #%d.%s%s%s%s\n",
218
+ sd->nStructReadError, sd->pStrErrStruct, *num_inp, SDF_LBL_VAL(ip->pSdfLabel,ip->pSdfValue) );
219
+ #if( bRELEASE_VERSION == 1 || EXTR_FLAGS == 0 )
220
+ if ( prb_file && 0L <= sd->fPtrStart && sd->fPtrStart < sd->fPtrEnd && !ip->bSaveAllGoodStructsAsProblem) {
221
+ e_CopyMOLfile(inp_file, sd->fPtrStart, sd->fPtrEnd, prb_file, *num_inp);
222
+ }
223
+ #endif
224
+ }
225
+ /* Warnings: try to produce INChI */
226
+ if ( sd->nErrorType == _IS_WARNING ) {
227
+ e_my_fprintf( log_file, "Warning: (%s) inp structure #%d.%s%s%s%s\n",
228
+ sd->pStrErrStruct, *num_inp, SDF_LBL_VAL(ip->pSdfLabel,ip->pSdfValue) );
229
+ }
230
+ exit_function:
231
+ if ( nRet <= _IS_OKAY && sd->nErrorType > 0 ) {
232
+ nRet = sd->nErrorType;
233
+ }
234
+ return nRet;
235
+ }
236
+ /**********************************************************************************************/
237
+ int e_GetInpStructErrorType( INPUT_PARMS *ip, int err, char *pStrErrStruct, int num_inp_atoms )
238
+ {
239
+ if ( err && err == 9 )
240
+ return _IS_ERROR; /* sdfile bypassed to $$$$ */
241
+ if ( err && err < 30 )
242
+ return _IS_FATAL;
243
+ if ( num_inp_atoms <= 0 || err ) {
244
+ if ( 98 == err && 0 == num_inp_atoms && ip->bAllowEmptyStructure )
245
+ return _IS_OKAY /* _IS_WARNING*/; /* the warning will be issued by the dll */
246
+ return _IS_ERROR;
247
+ }
248
+ if ( pStrErrStruct[0] )
249
+ return _IS_WARNING;
250
+ return _IS_OKAY;
251
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __READSTRU_H__
11
+ #define __READSTRU_H__
12
+
13
+
14
+ #ifndef INCHI_ALL_CPP
15
+ #ifdef __cplusplus
16
+ extern "C" {
17
+ #endif
18
+ #endif
19
+
20
+
21
+
22
+ int e_ReadStructure( STRUCT_DATA *sd, INPUT_PARMS *ip, FILE *inp_file, FILE *log_file, FILE *output_file, FILE *prb_file,
23
+ inchi_Input *pInp, int num_inp, /* for CML:*/ int inp_index, int *out_index );
24
+
25
+
26
+ #ifndef INCHI_ALL_CPP
27
+ #ifdef __cplusplus
28
+ }
29
+ #endif
30
+ #endif
31
+
32
+
33
+ #endif /* __READSTRU_H__ */