rino 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/ext/extconf.rb +1 -24
- data/ext/libinchi.so +0 -0
- data/ext/src/aux2atom.h +120 -39
- data/ext/src/comdef.h +3 -3
- data/ext/src/dispstru.c +2547 -0
- data/ext/src/dispstru.h +73 -0
- data/ext/src/extr_ct.h +5 -2
- data/ext/src/ichi.h +27 -11
- data/ext/src/ichi_bns.c +1800 -254
- data/ext/src/ichi_bns.h +205 -4
- data/ext/src/ichican2.c +197 -86
- data/ext/src/ichicano.c +8 -13
- data/ext/src/ichicano.h +2 -2
- data/ext/src/ichicans.c +11 -6
- data/ext/src/ichicant.h +2 -2
- data/ext/src/ichicomn.h +2 -2
- data/ext/src/ichicomp.h +19 -4
- data/ext/src/ichidrp.h +9 -5
- data/ext/src/ichierr.h +5 -3
- data/ext/src/ichiisot.c +2 -2
- data/ext/src/ichimain.c +461 -0
- data/ext/src/ichimain.h +23 -15
- data/ext/src/ichimak2.c +6 -6
- data/ext/src/ichimake.c +843 -42
- data/ext/src/ichimake.h +4 -2
- data/ext/src/ichimap1.c +5 -5
- data/ext/src/ichimap2.c +2 -2
- data/ext/src/ichimap4.c +34 -21
- data/ext/src/ichinorm.c +11 -5
- data/ext/src/ichinorm.h +3 -2
- data/ext/src/ichiparm.c +2 -2
- data/ext/src/ichiparm.h +232 -30
- data/ext/src/ichiprt1.c +35 -11
- data/ext/src/ichiprt2.c +78 -7
- data/ext/src/ichiprt3.c +300 -120
- data/ext/src/ichiqueu.c +17 -2
- data/ext/src/ichiread.c +6932 -0
- data/ext/src/ichiring.c +3 -2
- data/ext/src/ichiring.h +2 -2
- data/ext/src/ichirvr1.c +4891 -0
- data/ext/src/ichirvr2.c +6344 -0
- data/ext/src/ichirvr3.c +5499 -0
- data/ext/src/ichirvr4.c +3177 -0
- data/ext/src/ichirvr5.c +1166 -0
- data/ext/src/ichirvr6.c +1287 -0
- data/ext/src/ichirvr7.c +2319 -0
- data/ext/src/ichirvrs.h +882 -0
- data/ext/src/ichisize.h +2 -2
- data/ext/src/ichisort.c +5 -5
- data/ext/src/ichister.c +281 -86
- data/ext/src/ichister.h +9 -3
- data/ext/src/ichitaut.c +208 -9
- data/ext/src/ichitaut.h +13 -11
- data/ext/src/ichitime.h +16 -2
- data/ext/src/inchicmp.h +107 -0
- data/ext/src/inpdef.h +6 -3
- data/ext/src/libinchi_wrap.c +912 -0
- data/ext/src/lreadmol.h +34 -31
- data/ext/src/mode.h +244 -7
- data/ext/src/mol2atom.c +1060 -0
- data/ext/src/mol2atom.h +31 -0
- data/ext/src/readinch.c +239 -0
- data/ext/src/readmol.c +28 -0
- data/ext/src/{e_readmol.h → readmol.h} +7 -9
- data/ext/src/runichi.c +251 -177
- data/ext/src/strutil.c +444 -238
- data/ext/src/strutil.h +150 -11
- data/ext/src/util.c +176 -118
- data/ext/src/util.h +15 -3
- data/lib/rino.rb +71 -3
- data/test/test.rb +33 -4
- metadata +22 -34
- data/ext/ruby_inchi_main.so +0 -0
- data/ext/src/e_0dstereo.c +0 -3014
- data/ext/src/e_0dstereo.h +0 -31
- data/ext/src/e_comdef.h +0 -57
- data/ext/src/e_ctl_data.h +0 -147
- data/ext/src/e_ichi_io.c +0 -498
- data/ext/src/e_ichi_io.h +0 -40
- data/ext/src/e_ichi_parms.c +0 -37
- data/ext/src/e_ichi_parms.h +0 -41
- data/ext/src/e_ichicomp.h +0 -50
- data/ext/src/e_ichierr.h +0 -40
- data/ext/src/e_ichimain.c +0 -593
- data/ext/src/e_ichisize.h +0 -43
- data/ext/src/e_inchi_atom.c +0 -75
- data/ext/src/e_inchi_atom.h +0 -33
- data/ext/src/e_inpdef.h +0 -41
- data/ext/src/e_mode.h +0 -706
- data/ext/src/e_mol2atom.c +0 -649
- data/ext/src/e_readinch.c +0 -58
- data/ext/src/e_readmol.c +0 -54
- data/ext/src/e_readstru.c +0 -251
- data/ext/src/e_readstru.h +0 -33
- data/ext/src/e_util.c +0 -284
- data/ext/src/e_util.h +0 -61
- data/ext/src/ichilnct.c +0 -286
- data/ext/src/inchi_api.h +0 -670
- data/ext/src/inchi_dll.c +0 -1480
- data/ext/src/inchi_dll.h +0 -34
- data/ext/src/inchi_dll_main.c +0 -23
- data/ext/src/inchi_dll_main.h +0 -31
- data/ext/src/ruby_inchi_main.c +0 -558
data/ext/src/e_readinch.c
DELETED
@@ -1,58 +0,0 @@
|
|
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
|
-
|
data/ext/src/e_readmol.c
DELETED
@@ -1,54 +0,0 @@
|
|
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
|
-
|
data/ext/src/e_readstru.c
DELETED
@@ -1,251 +0,0 @@
|
|
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
|
-
}
|
data/ext/src/e_readstru.h
DELETED
@@ -1,33 +0,0 @@
|
|
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__ */
|
data/ext/src/e_util.c
DELETED
@@ -1,284 +0,0 @@
|
|
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 <string.h>
|
12
|
-
#include <stdlib.h>
|
13
|
-
#include <ctype.h>
|
14
|
-
#include <stdarg.h>
|
15
|
-
|
16
|
-
#include "e_mode.h"
|
17
|
-
#include "inchi_api.h"
|
18
|
-
#include "e_ichisize.h"
|
19
|
-
#include "e_comdef.h"
|
20
|
-
#include "e_util.h"
|
21
|
-
#include "e_ichicomp.h"
|
22
|
-
|
23
|
-
#define extract_ChargeRadical e_extract_ChargeRadical
|
24
|
-
#define normalize_name e_normalize_name
|
25
|
-
/******************************************************************************************************/
|
26
|
-
int extract_ChargeRadical( char *elname, int *pnRadical, int *pnCharge )
|
27
|
-
{
|
28
|
-
char *q, *r, *p;
|
29
|
-
int nCharge=0, nRad = 0, charge_len = 0, k, nVal, nSign, nLastSign=1, len;
|
30
|
-
|
31
|
-
p = elname;
|
32
|
-
|
33
|
-
/* extract radicals & charges */
|
34
|
-
while ( q = strpbrk( p, "+-^" ) ) {
|
35
|
-
switch ( *q ) {
|
36
|
-
case '+':
|
37
|
-
case '-':
|
38
|
-
for ( k = 0, nVal=0; (nSign = ('+' == q[k])) || (nSign = -('-' == q[k])); k++ ) {
|
39
|
-
nVal += (nLastSign = nSign);
|
40
|
-
charge_len ++;
|
41
|
-
}
|
42
|
-
if ( nSign = (int)strtol( q+k, &r, 10 ) ) { /* fixed 12-5-2001 */
|
43
|
-
nVal += nLastSign * (nSign-1);
|
44
|
-
}
|
45
|
-
charge_len = r - q;
|
46
|
-
nCharge += nVal;
|
47
|
-
break;
|
48
|
-
/* case '.': */ /* singlet '.' may be confused with '.' in formulas like CaO.H2O */
|
49
|
-
case '^':
|
50
|
-
nRad = 1; /* doublet here is 1. See below */
|
51
|
-
charge_len = 1;
|
52
|
-
for ( k = 1; q[0] == q[k]; k++ ) {
|
53
|
-
nRad ++;
|
54
|
-
charge_len ++;
|
55
|
-
}
|
56
|
-
break;
|
57
|
-
}
|
58
|
-
memmove( q, q+charge_len, strlen(q+charge_len)+1 );
|
59
|
-
}
|
60
|
-
len = strlen(p);
|
61
|
-
/* radical */
|
62
|
-
if ( (q = strrchr( p, ':' )) && !q[1]) {
|
63
|
-
nRad = RADICAL_SINGLET;
|
64
|
-
q[0] = '\0';
|
65
|
-
len --;
|
66
|
-
} else {
|
67
|
-
while( (q = strrchr( p, '.' )) && !q[1] ) {
|
68
|
-
nRad ++;
|
69
|
-
q[0] = '\0';
|
70
|
-
len --;
|
71
|
-
}
|
72
|
-
|
73
|
-
nRad = nRad == 1? RADICAL_DOUBLET :
|
74
|
-
nRad == 2? RADICAL_TRIPLET : 0;
|
75
|
-
}
|
76
|
-
*pnRadical = nRad;
|
77
|
-
*pnCharge = nCharge;
|
78
|
-
return ( nRad || nCharge );
|
79
|
-
|
80
|
-
}
|
81
|
-
/*****************************************************************/
|
82
|
-
int normalize_name( char* name )
|
83
|
-
{
|
84
|
-
/* remove leading & trailing spaces; replace consecutive spaces with a single space */
|
85
|
-
/* Treat non-printable characters (Greeks) as spaces. 11-23-99 DCh. */
|
86
|
-
int i, len, n;
|
87
|
-
len = (int)strlen(name);
|
88
|
-
for ( i = 0, n = 0; i < len; i++ ) {
|
89
|
-
if ( isspace( UCINT name[i] ) /*|| !isprint( UCINT name[i] )*/ ) {
|
90
|
-
name[i] = ' '; /* exterminate tabs !!! */
|
91
|
-
n++;
|
92
|
-
} else {
|
93
|
-
if ( n > 0 ) {
|
94
|
-
memmove( (void*) &name[i-n], (void*) &name[i], len-i+1 );
|
95
|
-
i -= n;
|
96
|
-
len -= n;
|
97
|
-
}
|
98
|
-
n = -1;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
if ( n == len ) /* empty line */
|
102
|
-
name[len=0] = '\0';
|
103
|
-
else
|
104
|
-
if ( ++n && n <= len ) {
|
105
|
-
len -= n;
|
106
|
-
name[len] = '\0';
|
107
|
-
}
|
108
|
-
return len;
|
109
|
-
}
|
110
|
-
/************************************************/
|
111
|
-
#ifndef e_inchi_malloc
|
112
|
-
void *e_inchi_malloc(size_t c)
|
113
|
-
{
|
114
|
-
return malloc(c);
|
115
|
-
}
|
116
|
-
#endif
|
117
|
-
#ifndef e_inchi_calloc
|
118
|
-
void *e_inchi_calloc(size_t c, size_t n)
|
119
|
-
{
|
120
|
-
return calloc(c,n);
|
121
|
-
}
|
122
|
-
#endif
|
123
|
-
#ifndef e_inchi_free
|
124
|
-
void e_inchi_free(void *p)
|
125
|
-
{
|
126
|
-
if(p) {
|
127
|
-
free(p); /*added check if zero*/
|
128
|
-
}
|
129
|
-
}
|
130
|
-
#endif
|
131
|
-
|
132
|
-
|
133
|
-
/***************************************************************************/
|
134
|
-
/* Copies up to maxlen characters INCLUDING end null from source to target */
|
135
|
-
/* Fills out the rest of the target with null bytes */
|
136
|
-
int e_mystrncpy(char *target,const char *source,unsigned maxlen)
|
137
|
-
{ /* protected from non-zero-terminated source and overlapped target/source. 7-9-99 DCh. */
|
138
|
-
const char *p;
|
139
|
-
unsigned len;
|
140
|
-
|
141
|
-
if (target==NULL || maxlen == 0 || source == NULL)
|
142
|
-
return 0;
|
143
|
-
if ( p = (const char*)memchr(source, 0, maxlen) ) {
|
144
|
-
len = p-source; /* maxlen does not include the found zero termination */
|
145
|
-
} else {
|
146
|
-
len = maxlen-1; /* reduced length does not include one more byte for zero termination */
|
147
|
-
}
|
148
|
-
if ( len )
|
149
|
-
memmove( target, source, len );
|
150
|
-
/* target[len] = '\0'; */
|
151
|
-
memset( target+len, 0, maxlen-len); /* zero termination */
|
152
|
-
return 1;
|
153
|
-
}
|
154
|
-
/************************************************************************/
|
155
|
-
/* Remove leading and trailing white spaces */
|
156
|
-
char* e_LtrimRtrim( char *p, int* nLen )
|
157
|
-
{
|
158
|
-
int i, len=0;
|
159
|
-
if ( p && (len = strlen( p )) ) {
|
160
|
-
for ( i = 0; i < len && __isascii( p[i] ) && isspace( p[i] ); i++ )
|
161
|
-
;
|
162
|
-
if ( i )
|
163
|
-
(memmove)( p, p+i, (len -= i)+1 );
|
164
|
-
for ( ; 0 < len && __isascii( p[len-1] ) && isspace( p[len-1] ); len-- )
|
165
|
-
;
|
166
|
-
p[len] = '\0';
|
167
|
-
}
|
168
|
-
if ( nLen )
|
169
|
-
*nLen = len;
|
170
|
-
return p;
|
171
|
-
}
|
172
|
-
|
173
|
-
/*************************************************************************/
|
174
|
-
void e_remove_trailing_spaces( char* p )
|
175
|
-
{
|
176
|
-
int len;
|
177
|
-
for( len = (int)strlen( p ) - 1; len >= 0 && isspace( UCINT p[len] ); len-- )
|
178
|
-
;
|
179
|
-
p[++len] = '\0';
|
180
|
-
}
|
181
|
-
/*************************************************************************/
|
182
|
-
void e_remove_one_lf( char* p)
|
183
|
-
{
|
184
|
-
size_t len;
|
185
|
-
if ( p && 0 < (len = strlen(p)) && p[len-1] == '\n' ){
|
186
|
-
p[len-1] = '\0';
|
187
|
-
if ( len >= 2 && p[len-2] == '\r' )
|
188
|
-
p[len-2] = '\0';
|
189
|
-
}
|
190
|
-
}
|
191
|
-
/*************************************************************************/
|
192
|
-
S_SHORT *e_is_in_the_slist( S_SHORT *pathAtom, S_SHORT nNextAtom, int nPathLen )
|
193
|
-
{
|
194
|
-
for ( ; nPathLen && *pathAtom != nNextAtom; nPathLen--, pathAtom++ )
|
195
|
-
;
|
196
|
-
return nPathLen? pathAtom : NULL;
|
197
|
-
}
|
198
|
-
/************************************************/
|
199
|
-
int e_is_element_a_metal( char szEl[] )
|
200
|
-
{
|
201
|
-
static char szMetals[] = "K;V;Y;W;U;"
|
202
|
-
"Li;Be;Na;Mg;Al;Ca;Sc;Ti;Cr;Mn;Fe;Co;Ni;Cu;Zn;Ga;Rb;Sr;Zr;"
|
203
|
-
"Nb;Mo;Tc;Ru;Rh;Pd;Ag;Cd;In;Sn;Sb;Cs;Ba;La;Ce;Pr;Nd;Pm;Sm;"
|
204
|
-
"Eu;Gd;Tb;Dy;Ho;Er;Tm;Yb;Lu;Hf;Ta;Re;Os;Ir;Pt;Au;Hg;Tl;Pb;"
|
205
|
-
"Bi;Po;Fr;Ra;Ac;Th;Pa;Np;Pu;Am;Cm;Bk;Cf;Es;Fm;Md;No;Lr;Rf;";
|
206
|
-
int len = strlen(szEl);
|
207
|
-
char *p;
|
208
|
-
|
209
|
-
if ( 0 < len && len <= 2 &&
|
210
|
-
isalpha( UCINT szEl[0] ) && isupper( szEl[0] ) &&
|
211
|
-
(p = strstr(szMetals, szEl) ) && p[len] == ';' ) {
|
212
|
-
|
213
|
-
return 1; /*return AtType_Metal;*/
|
214
|
-
}
|
215
|
-
return 0;
|
216
|
-
}
|
217
|
-
|
218
|
-
#ifdef INCHI_ANSI_ONLY
|
219
|
-
/*************************************************************************/
|
220
|
-
/************* non-ANSI functions ****************/
|
221
|
-
/*************************************************************************/
|
222
|
-
#define __MYTOLOWER(c) ( ((c) >= 'A') && ((c) <= 'Z') ? ((c) - 'A' + 'a') : (c) )
|
223
|
-
|
224
|
-
#if ( !defined(_MSC_VER) || defined(__STDC__) && __STDC__ == 1 )
|
225
|
-
/* support (VC++ Language extensions) = OFF && defined(INCHI_ANSI_ONLY) */
|
226
|
-
#ifdef INCHI_LINK_AS_DLL
|
227
|
-
/* the following code is enabled if linked as dll (ANSI C) */
|
228
|
-
/* because the InChI library dll does not export it */
|
229
|
-
int memicmp ( const void * p1, const void * p2, size_t length )
|
230
|
-
{
|
231
|
-
const U_CHAR *s1 = (const U_CHAR*)p1;
|
232
|
-
const U_CHAR *s2 = (const U_CHAR*)p2;
|
233
|
-
while ( length-- ) {
|
234
|
-
if ( *s1 == *s2 ||
|
235
|
-
__MYTOLOWER( (int)*s1 ) == __MYTOLOWER( (int)*s2 )) {
|
236
|
-
s1 ++;
|
237
|
-
s2 ++;
|
238
|
-
} else {
|
239
|
-
return __MYTOLOWER( (int)*s1 ) - __MYTOLOWER( (int)*s2 );
|
240
|
-
}
|
241
|
-
}
|
242
|
-
return 0;
|
243
|
-
}
|
244
|
-
/*************************************************************************/
|
245
|
-
int stricmp( const char *s1, const char *s2 )
|
246
|
-
{
|
247
|
-
while ( *s1 ) {
|
248
|
-
if ( *s1 == *s2 ||
|
249
|
-
__MYTOLOWER( (int)*s1 ) == __MYTOLOWER( (int)*s2 )) {
|
250
|
-
s1 ++;
|
251
|
-
s2 ++;
|
252
|
-
} else {
|
253
|
-
return __MYTOLOWER( (int)*s1 ) - __MYTOLOWER( (int)*s2 );
|
254
|
-
}
|
255
|
-
}
|
256
|
-
if ( *s2 )
|
257
|
-
return -1;
|
258
|
-
return 0;
|
259
|
-
}
|
260
|
-
/*************************************************************************/
|
261
|
-
char *_strnset( char *s, int val, size_t length )
|
262
|
-
{
|
263
|
-
char *ps = s;
|
264
|
-
while (length-- && *ps)
|
265
|
-
*ps++ = (char)val;
|
266
|
-
return s;
|
267
|
-
}
|
268
|
-
/*************************************************************************/
|
269
|
-
char *_strdup( const char *string )
|
270
|
-
{
|
271
|
-
char *p = NULL;
|
272
|
-
if ( string ) {
|
273
|
-
size_t length = strlen( string );
|
274
|
-
p = e_inchi_malloc( length + 1 );
|
275
|
-
if ( p ) {
|
276
|
-
strcpy( p, string );
|
277
|
-
}
|
278
|
-
}
|
279
|
-
return p;
|
280
|
-
}
|
281
|
-
#endif /* INCHI_LINK_AS_DLL */
|
282
|
-
#endif /* !defined(_MSC_VER) || defined(__STDC__) && __STDC__ == 1 */
|
283
|
-
#endif /* INCHI_ANSI_ONLY */
|
284
|
-
|