rino 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +44 -0
- data/Rakefile +123 -0
- data/ext/extconf.rb +26 -0
- data/ext/ruby_inchi_main.so +0 -0
- data/ext/src/aux2atom.h +2786 -0
- data/ext/src/comdef.h +148 -0
- data/ext/src/e_0dstereo.c +3014 -0
- data/ext/src/e_0dstereo.h +31 -0
- data/ext/src/e_comdef.h +57 -0
- data/ext/src/e_ctl_data.h +147 -0
- data/ext/src/e_ichi_io.c +498 -0
- data/ext/src/e_ichi_io.h +40 -0
- data/ext/src/e_ichi_parms.c +37 -0
- data/ext/src/e_ichi_parms.h +41 -0
- data/ext/src/e_ichicomp.h +50 -0
- data/ext/src/e_ichierr.h +40 -0
- data/ext/src/e_ichimain.c +593 -0
- data/ext/src/e_ichisize.h +43 -0
- data/ext/src/e_inchi_atom.c +75 -0
- data/ext/src/e_inchi_atom.h +33 -0
- data/ext/src/e_inpdef.h +41 -0
- data/ext/src/e_mode.h +706 -0
- data/ext/src/e_mol2atom.c +649 -0
- data/ext/src/e_readinch.c +58 -0
- data/ext/src/e_readmol.c +54 -0
- data/ext/src/e_readmol.h +180 -0
- data/ext/src/e_readstru.c +251 -0
- data/ext/src/e_readstru.h +33 -0
- data/ext/src/e_util.c +284 -0
- data/ext/src/e_util.h +61 -0
- data/ext/src/extr_ct.h +251 -0
- data/ext/src/ichi.h +206 -0
- data/ext/src/ichi_bns.c +7999 -0
- data/ext/src/ichi_bns.h +231 -0
- data/ext/src/ichican2.c +5000 -0
- data/ext/src/ichicano.c +2195 -0
- data/ext/src/ichicano.h +49 -0
- data/ext/src/ichicans.c +1625 -0
- data/ext/src/ichicant.h +379 -0
- data/ext/src/ichicomn.h +260 -0
- data/ext/src/ichicomp.h +50 -0
- data/ext/src/ichidrp.h +119 -0
- data/ext/src/ichierr.h +124 -0
- data/ext/src/ichiisot.c +101 -0
- data/ext/src/ichilnct.c +286 -0
- data/ext/src/ichimain.h +132 -0
- data/ext/src/ichimak2.c +1189 -0
- data/ext/src/ichimake.c +3812 -0
- data/ext/src/ichimake.h +205 -0
- data/ext/src/ichimap1.c +851 -0
- data/ext/src/ichimap2.c +2856 -0
- data/ext/src/ichimap4.c +1609 -0
- data/ext/src/ichinorm.c +741 -0
- data/ext/src/ichinorm.h +67 -0
- data/ext/src/ichiparm.c +45 -0
- data/ext/src/ichiparm.h +1441 -0
- data/ext/src/ichiprt1.c +3612 -0
- data/ext/src/ichiprt2.c +1511 -0
- data/ext/src/ichiprt3.c +3011 -0
- data/ext/src/ichiqueu.c +1003 -0
- data/ext/src/ichiring.c +326 -0
- data/ext/src/ichiring.h +49 -0
- data/ext/src/ichisize.h +35 -0
- data/ext/src/ichisort.c +539 -0
- data/ext/src/ichister.c +3538 -0
- data/ext/src/ichister.h +35 -0
- data/ext/src/ichitaut.c +3843 -0
- data/ext/src/ichitaut.h +387 -0
- data/ext/src/ichitime.h +74 -0
- data/ext/src/inchi_api.h +670 -0
- data/ext/src/inchi_dll.c +1480 -0
- data/ext/src/inchi_dll.h +34 -0
- data/ext/src/inchi_dll_main.c +23 -0
- data/ext/src/inchi_dll_main.h +31 -0
- data/ext/src/inpdef.h +328 -0
- data/ext/src/lreadmol.h +1246 -0
- data/ext/src/mode.h +706 -0
- data/ext/src/ruby_inchi_main.c +558 -0
- data/ext/src/runichi.c +4179 -0
- data/ext/src/strutil.c +3861 -0
- data/ext/src/strutil.h +182 -0
- data/ext/src/util.c +1130 -0
- data/ext/src/util.h +85 -0
- data/lib/clean_tempfile.rb +220 -0
- data/lib/rino.rb +111 -0
- data/test/test.rb +386 -0
- metadata +130 -0
data/ext/src/e_util.c
ADDED
@@ -0,0 +1,284 @@
|
|
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
|
+
|
data/ext/src/e_util.h
ADDED
@@ -0,0 +1,61 @@
|
|
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 __UTIL_H__
|
11
|
+
#define __UTIL_H__
|
12
|
+
|
13
|
+
/* BILLY 8/6/04 */
|
14
|
+
#ifndef INCHI_ALL_CPP
|
15
|
+
#ifdef __cplusplus
|
16
|
+
extern "C" {
|
17
|
+
#endif
|
18
|
+
#endif
|
19
|
+
|
20
|
+
int e_extract_ChargeRadical( char *elname, int *pnRadical, int *pnCharge );
|
21
|
+
int e_normalize_name( char* name );
|
22
|
+
|
23
|
+
int e_mystrncpy(char *target,const char *source,unsigned maxlen);
|
24
|
+
char *e_LtrimRtrim( char *p, int* nLen );
|
25
|
+
void e_remove_trailing_spaces( char* p );
|
26
|
+
void e_remove_one_lf( char* p);
|
27
|
+
int e_is_element_a_metal( char szEl[] );
|
28
|
+
|
29
|
+
AT_NUMB *e_is_in_the_list( AT_NUMB *pathAtom, AT_NUMB nNextAtom, int nPathLen );
|
30
|
+
S_SHORT *e_is_in_the_slist( S_SHORT *pathAtom, S_SHORT nNextAtom, int nPathLen );
|
31
|
+
void e_SplitTime( unsigned long ulTotalTime, int *hours, int *minutes, int *seconds, int *mseconds );
|
32
|
+
|
33
|
+
/* allocator */
|
34
|
+
#ifndef e_inchi_malloc
|
35
|
+
void *e_inchi_malloc(size_t c);
|
36
|
+
#endif
|
37
|
+
#ifndef e_inchi_calloc
|
38
|
+
void *e_inchi_calloc(size_t c, size_t n);
|
39
|
+
#endif
|
40
|
+
#ifndef e_inchi_free
|
41
|
+
void e_inchi_free(void *p);
|
42
|
+
#endif
|
43
|
+
|
44
|
+
|
45
|
+
extern char e_gsMissing[];
|
46
|
+
extern char e_gsEmpty[];
|
47
|
+
extern char e_gsSpace[];
|
48
|
+
extern char e_gsEqual[];
|
49
|
+
/* format string for SDF_LBL_VAL(L,V): %s%s%s%s (four strings) */
|
50
|
+
#define SDF_LBL_VAL(L,V) ((L)&&(L)[0])?e_gsSpace:e_gsEmpty, ((L)&&(L)[0])?L:e_gsEmpty, ((L)&&(L)[0])? (((V)&&(V)[0])?e_gsEqual:e_gsSpace):e_gsEmpty, ((V)&&(V)[0])?V:((L)&&(L)[0])?e_gsMissing:e_gsEmpty
|
51
|
+
|
52
|
+
|
53
|
+
/* BILLY 8/6/04 */
|
54
|
+
#ifndef INCHI_ALL_CPP
|
55
|
+
#ifdef __cplusplus
|
56
|
+
}
|
57
|
+
#endif
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#endif /* __UTIL_H__*/
|
61
|
+
|
data/ext/src/extr_ct.h
ADDED
@@ -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
|
+
#ifndef __EXTR_CT_H__
|
11
|
+
#define __EXTR_CT_H__
|
12
|
+
|
13
|
+
#include "mode.h"
|
14
|
+
#include "ichisize.h"
|
15
|
+
|
16
|
+
struct AtData {
|
17
|
+
char element[3];
|
18
|
+
int maxvalence;
|
19
|
+
};
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
#define NUM_CHEM_ELEMENTS 127 /* well above number of known chem. elements */
|
24
|
+
|
25
|
+
|
26
|
+
#define AT_ISO_SORT_KEY_MULT 32 /* up to 32 identical hydrogen isotopes */
|
27
|
+
/* (similar to T_GROUP_ISOWT_MULT) */
|
28
|
+
/* changed from 16 9-12-2003 */
|
29
|
+
typedef long AT_ISO_SORT_KEY; /* signed, should hold up to 4096*max_iso_diff */
|
30
|
+
/* (similar to T_GROUP_ISOWT) */
|
31
|
+
/*
|
32
|
+
= num_1H + AT_ISO_SORT_KEY_MULT*(num_D + AT_ISO_SORT_KEY_MULT*(num_T+AT_ISO_SORT_KEY_MULT*iso_atw_diff))
|
33
|
+
*/
|
34
|
+
|
35
|
+
/* typedef signed char AT_ISOTOPIC; */ /* + or - */
|
36
|
+
typedef struct tagStereoCarb {
|
37
|
+
AT_NUMB at_num;
|
38
|
+
U_CHAR parity;
|
39
|
+
} AT_STEREO_CARB;
|
40
|
+
typedef struct tagStereoDble {
|
41
|
+
AT_NUMB at_num1;
|
42
|
+
AT_NUMB at_num2;
|
43
|
+
U_CHAR parity;
|
44
|
+
} AT_STEREO_DBLE;
|
45
|
+
|
46
|
+
typedef struct tagIsotopicAtom {
|
47
|
+
AT_NUMB at_num;
|
48
|
+
NUM_H num_1H;
|
49
|
+
NUM_H num_D;
|
50
|
+
NUM_H num_T;
|
51
|
+
NUM_H iso_atw_diff;
|
52
|
+
} AT_ISOTOPIC;
|
53
|
+
|
54
|
+
typedef AT_NUMB AT_STEREO;
|
55
|
+
|
56
|
+
#define BYTE_BITS 8 /* number of bits in one byte */
|
57
|
+
|
58
|
+
#define BOND_MASK 0xf /* 4 bits */
|
59
|
+
#define BOND_BITS 4 /* 3 or 4 does not matter; 2 is too small for BOND_TAUTOM */
|
60
|
+
#define BOND_ADD (BOND_BITS==2?-1:0) /* subtract 1 from bonds stored in CT */
|
61
|
+
|
62
|
+
|
63
|
+
typedef struct tagAtom {
|
64
|
+
char elname[ATOM_EL_LEN];
|
65
|
+
AT_NUMB neighbor[MAXVAL]; /* changed to unsigned 2-2-95. D.Ch. */
|
66
|
+
AT_NUMB init_rank; /* also used in remove_terminal_HDT() to save orig. at. number */
|
67
|
+
AT_NUMB orig_at_number;
|
68
|
+
AT_NUMB orig_compt_at_numb;
|
69
|
+
/* low 3 bits=bond type;
|
70
|
+
high 5 bits (in case of cut-vertex atom) = an attached part number
|
71
|
+
*/
|
72
|
+
U_CHAR bond_type[MAXVAL];
|
73
|
+
U_CHAR el_number; /* periodic table number = charge of the nucleus = number of the protons */
|
74
|
+
/* U_CHAR hill_type; */ /* number in psudo hill order */
|
75
|
+
S_CHAR valence;
|
76
|
+
S_CHAR chem_bonds_valence; /* 8-24-00 to treat tautomer centerpoints, etc. */
|
77
|
+
S_CHAR num_H; /* first not including D, T; add_DT_to_num_H() includes. */
|
78
|
+
S_CHAR num_iso_H[NUM_H_ISOTOPES]; /* num 1H, 2H(D), 3H(T) */
|
79
|
+
S_CHAR cFlags;
|
80
|
+
S_CHAR iso_atw_diff; /* abs(iso_atw_diff) < 127 or 31 - ??? */
|
81
|
+
AT_ISO_SORT_KEY iso_sort_key; /* = num_1H + AT_ISO_SORT_KEY_MULT^1*num_D
|
82
|
+
+ AT_ISO_SORT_KEY_MULT^2*num_T
|
83
|
+
+ AT_ISO_SORT_KEY_MULT^3*iso_atw_diff
|
84
|
+
*/
|
85
|
+
S_CHAR charge;
|
86
|
+
S_CHAR radical; /* 1=>doublet(.), 2=> triplet as singlet (:) ???? why are they same ???? */
|
87
|
+
S_CHAR marked;
|
88
|
+
|
89
|
+
AT_NUMB endpoint; /* tautomer analysis. If != 0 then the hydrogens & (-)charge are in the tautomer group. */
|
90
|
+
|
91
|
+
/*
|
92
|
+
Pairs stereo_bond_neighbor[] and stereo_bond_neighbor2[], etc
|
93
|
+
initially refer to non-isotopic and isotopic cases, respectively.
|
94
|
+
To use same stereo processing code these arrays are swapped when
|
95
|
+
switching from non-isotopic to isotopic processing and back.
|
96
|
+
*/
|
97
|
+
AT_NUMB stereo_bond_neighbor[MAX_NUM_STEREO_BONDS]; /* Original number of an opposite atom */
|
98
|
+
AT_NUMB stereo_bond_neighbor2[MAX_NUM_STEREO_BONDS]; /* (stereo bond neighbor) +1; */
|
99
|
+
S_CHAR stereo_bond_ord[MAX_NUM_STEREO_BONDS]; /* Ordering number of a bond/neighbor in the direction to the */
|
100
|
+
S_CHAR stereo_bond_ord2[MAX_NUM_STEREO_BONDS]; /* stereo bond opposite atom (important for cumulenes); */
|
101
|
+
S_CHAR stereo_bond_z_prod[MAX_NUM_STEREO_BONDS]; /* Relative atom-neighbors */
|
102
|
+
S_CHAR stereo_bond_z_prod2[MAX_NUM_STEREO_BONDS]; /* double bond planes orientation; */
|
103
|
+
S_CHAR stereo_bond_parity[MAX_NUM_STEREO_BONDS]; /* parity + MULT_STEREOBOND*chain_length, */
|
104
|
+
S_CHAR stereo_bond_parity2[MAX_NUM_STEREO_BONDS]; /* where: */
|
105
|
+
/*
|
106
|
+
parity (Mask 0x07=BITS_PARITY):
|
107
|
+
|
108
|
+
0 = AB_PARITY_NONE = not a stereo bond
|
109
|
+
1/2 = AB_PARITY_ODD/EVEN = bond parity defined from initial ranks
|
110
|
+
3 = AB_PARITY_UNKN = geometry is unknown to the user
|
111
|
+
4 = AB_PARITY_UNDF = not enough geometry info to find the parity
|
112
|
+
6 = AB_PARITY_CALC = calculate later from the neighbor ranks; some ot them can be
|
113
|
+
replaced with AB_PARITY_ODD/EVEN after equivalence ranks have been determined
|
114
|
+
|
115
|
+
length (Mask 0x38=MASK_CUMULENE_LEN, length=stereo_bond_parity[i]/MULT_STEREOBOND):
|
116
|
+
|
117
|
+
0 => double or alternating stereogenic bond
|
118
|
+
1 => cumulene with 2 double bonds (stereogenic center)
|
119
|
+
2 => cumulene with 3 double bonds (stereogenic bond)
|
120
|
+
length <= (MAX_CUMULENE_LEN=2)
|
121
|
+
bit KNOWN_PARITIES_EQL = 0x40: all pairs of const. equ. atoms are connected by stereo bonds
|
122
|
+
and these bonds have identical parities
|
123
|
+
*/
|
124
|
+
|
125
|
+
S_CHAR parity; /* -- Mask 0x07=BITS_PARITY: --
|
126
|
+
0 = AB_PARITY_NONE => no parity; also parity&0x38 = 0
|
127
|
+
1 = AB_PARITY_ODD => odd parity
|
128
|
+
2 = AB_PARITY_EVEN => even parity
|
129
|
+
3 = AB_PARITY_UNKN => user marked as unknown parity
|
130
|
+
4 = AB_PARITY_UNDF => parity cannot be defined because of symmetry or not well defined geometry
|
131
|
+
*/
|
132
|
+
S_CHAR parity2; /* parity including parity due to isotopic terminal H */
|
133
|
+
/* bit msks: 0x07 => known parity (1,2,3,4) or AB_PARITY_CALC=6, AB_PARITY_IISO = 6 */
|
134
|
+
/* 0x40 => KNOWN_PARITIES_EQL */
|
135
|
+
S_CHAR stereo_atom_parity; /* similar to stereo_bond_parity[]: known in advance AB_PARITY_* value + KNOWN_PARITIES_EQL bit */
|
136
|
+
S_CHAR stereo_atom_parity2;
|
137
|
+
S_CHAR final_parity; /* defined by equivalence ranks */
|
138
|
+
S_CHAR final_parity2; /* defined by equivalence ranks, incl. due to terminal isotopic H */
|
139
|
+
S_CHAR bAmbiguousStereo;
|
140
|
+
S_CHAR bHasStereoOrEquToStereo;
|
141
|
+
S_CHAR bHasStereoOrEquToStereo2;
|
142
|
+
#if( FIND_RING_SYSTEMS == 1 )
|
143
|
+
S_CHAR bCutVertex;
|
144
|
+
AT_NUMB nRingSystem;
|
145
|
+
AT_NUMB nNumAtInRingSystem;
|
146
|
+
AT_NUMB nBlockSystem;
|
147
|
+
#if( FIND_RINS_SYSTEMS_DISTANCES == 1 )
|
148
|
+
AT_NUMB nDistanceFromTerminal;
|
149
|
+
#endif
|
150
|
+
#endif
|
151
|
+
S_CHAR z_dir[3];
|
152
|
+
|
153
|
+
} sp_ATOM ;
|
154
|
+
|
155
|
+
#define BOND_SINGLE BOND_TYPE_SINGLE /* 1 */
|
156
|
+
#define BOND_DOUBLE BOND_TYPE_DOUBLE /* 2 */
|
157
|
+
#define BOND_TRIPLE BOND_TYPE_TRIPLE /* 3 */
|
158
|
+
#define BOND_ALTERN BOND_TYPE_ALTERN /* 4 single/double */
|
159
|
+
|
160
|
+
#define BOND_ALT_123 5 /* single/double/triple */
|
161
|
+
#define BOND_ALT_13 6 /* single/triple */
|
162
|
+
#define BOND_ALT_23 7 /* double/triple */
|
163
|
+
#define BOND_TAUTOM 8
|
164
|
+
#define BOND_ALT12NS 9
|
165
|
+
#define BOND_NUMDIF 9 /* number of different kinds of bonds */
|
166
|
+
|
167
|
+
#define BOND_TYPE_MASK 0x0f
|
168
|
+
|
169
|
+
#define BOND_MARK_ALL 0xf0 /* complement to BOND_TYPE_MASK */
|
170
|
+
|
171
|
+
#define BOND_MARK_ALT12 0x10
|
172
|
+
#define BOND_MARK_ALT123 0x20
|
173
|
+
#define BOND_MARK_ALT13 0x30
|
174
|
+
#define BOND_MARK_ALT23 0x40
|
175
|
+
#define BOND_MARK_ALT12NS 0x50 /* 1 or 2, non-stereo */
|
176
|
+
#define BOND_MARK_MASK 0x70
|
177
|
+
|
178
|
+
|
179
|
+
#define BITS_PARITY 0x07 /* mask to retrieve half-bond parity */
|
180
|
+
#define MASK_CUMULENE_LEN 0x38 /* mask to retrieve (cumulene chain length - 1)*MULT_STEREOBOND */
|
181
|
+
#define KNOWN_PARITIES_EQL 0x40 /* parity is same for all pairs of constit. equivalent atoms */
|
182
|
+
#define MAX_CUMULENE_LEN 2 /* max number of bonds in a cumulene chain - 1 */
|
183
|
+
|
184
|
+
#define MULT_STEREOBOND 0x08 /* multiplier for cumulene chain length
|
185
|
+
odd length => chiral, even length => stereogenic bond */
|
186
|
+
|
187
|
+
#define MAKE_BITS_CUMULENE_LEN(X) ((X)*MULT_STEREOBOND)
|
188
|
+
#define GET_BITS_CUMULENE_LEN(X) ((X)&MASK_CUMULENE_LEN)
|
189
|
+
#define BOND_CHAIN_LEN(X) (GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND) /* 0 => double bond, 1 => allene, 2 => cumulene,..*/
|
190
|
+
#define IS_ALLENE_CHAIN(X) ((GET_BITS_CUMULENE_LEN(X)/MULT_STEREOBOND)%2)
|
191
|
+
|
192
|
+
/* atom or bond parity value definitions */
|
193
|
+
#define AB_PARITY_NONE 0 /* 0 => no parity; also parity&0x38 = 0 */
|
194
|
+
#define AB_PARITY_ODD 1 /* 1 => odd parity */
|
195
|
+
#define AB_PARITY_EVEN 2 /* 2 => even parity */
|
196
|
+
#define AB_PARITY_UNKN 3 /* 3 => user marked as unknown parity */
|
197
|
+
#define AB_PARITY_UNDF 4 /* 4 => parity cannot be defined because of symmetry or not well defined geometry */
|
198
|
+
#define AB_PARITY_IISO 5 /* 5 => no parity because of identical atoms */
|
199
|
+
#define AB_PARITY_CALC 6 /* 6 => calculate parity later */
|
200
|
+
#define AB_PARITY_0D 8 /* 8 => bit signifies 0D case -- not used */
|
201
|
+
|
202
|
+
#define AB_INV_PARITY_BITS (AB_PARITY_ODD ^ AB_PARITY_EVEN)
|
203
|
+
|
204
|
+
|
205
|
+
#define AB_MAX_KNOWN_PARITY 4 /* precalculated from const. equivalence parities */
|
206
|
+
#define AB_MIN_KNOWN_PARITY 1
|
207
|
+
|
208
|
+
#define AB_MAX_PART_DEFINED_PARITY 3 /* 1, 2, 3 => defined parities, uncluding 'unknown' */
|
209
|
+
#define AB_MIN_PART_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN, AB_PARITY_UNKN) */
|
210
|
+
|
211
|
+
#define AB_MAX_WELL_DEFINED_PARITY 2 /* 1, 2 => well defined parities, uncluding 'unknown' */
|
212
|
+
#define AB_MIN_WELL_DEFINED_PARITY 1 /* min(AB_PARITY_ODD, AB_PARITY_EVEN) */
|
213
|
+
|
214
|
+
#define AB_MIN_ILL_DEFINED_PARITY 3
|
215
|
+
#define AB_MAX_ILL_DEFINED_PARITY 4
|
216
|
+
|
217
|
+
#define AB_MAX_ANY_PARITY 4
|
218
|
+
#define AB_MIN_ANY_PARITY 1
|
219
|
+
|
220
|
+
#define AMBIGUOUS_STEREO 1
|
221
|
+
#define AMBIGUOUS_STEREO_ATOM 2
|
222
|
+
#define AMBIGUOUS_STEREO_BOND 4
|
223
|
+
#define AMBIGUOUS_STEREO_ATOM_ISO 8
|
224
|
+
#define AMBIGUOUS_STEREO_BOND_ISO 16
|
225
|
+
#define AMBIGUOUS_STEREO_ERROR 32
|
226
|
+
|
227
|
+
|
228
|
+
#define MIN_DOT_PROD 50 /* min value of at->stereo_bond_z_prod[i] to define parity */
|
229
|
+
|
230
|
+
#define ATOM_PARITY_VAL(X) (X)
|
231
|
+
#define ATOM_PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= (X) && (X) <= AB_MAX_PART_DEFINED_PARITY)
|
232
|
+
#define ATOM_PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_ILL_DEFINED_PARITY)
|
233
|
+
#define ATOM_PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= (X) && (X) <= AB_MAX_KNOWN_PARITY)
|
234
|
+
#define ATOM_PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= (X) && (X) <= AB_MAX_WELL_DEFINED_PARITY)
|
235
|
+
#define ATOM_PARITY_NOT_UNKN(X) (ATOM_PARITY_KNOWN(X) && (X) != AB_PARITY_UNKN)
|
236
|
+
|
237
|
+
#define PARITY_VAL(X) ((X) & BITS_PARITY)
|
238
|
+
#define PARITY_PART_DEF(X) (AB_MIN_PART_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_PART_DEFINED_PARITY)
|
239
|
+
#define PARITY_ILL_DEF(X) (AB_MIN_ILL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_ILL_DEFINED_PARITY)
|
240
|
+
#define PARITY_KNOWN(X) (AB_MIN_KNOWN_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_KNOWN_PARITY)
|
241
|
+
#define PARITY_WELL_DEF(X) (AB_MIN_WELL_DEFINED_PARITY <= PARITY_VAL(X) && PARITY_VAL(X) <= AB_MAX_WELL_DEFINED_PARITY)
|
242
|
+
#define PARITY_CALCULATE(X) (AB_PARITY_CALC == PARITY_VAL(X))
|
243
|
+
#define BOND_PARITY_PART_DEFINED(X) (PARITY_PART_DEF(X) || PARITY_CALCULATE(X))
|
244
|
+
#define BOND_PARITY_PART_KNOWN(X) (PARITY_KNOWN(X) || PARITY_CALCULATE(X))
|
245
|
+
#define ALL_BUT_PARITY(X) ((X)&~BITS_PARITY)
|
246
|
+
|
247
|
+
#define ALWAYS_SET_STEREO_PARITY 0
|
248
|
+
#define NO_ISOLATED_NON_6RING_AROM_BOND 0 /* for Yuri */
|
249
|
+
#define SAVE_6_AROM_CENTERS 0 /* for Yuri */
|
250
|
+
|
251
|
+
#endif /* __EXTR_CT_H__ */
|