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,231 @@
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 __INCHI_BNS_H___
11
+ #define __INCHI_BNS_H___
12
+
13
+ #define BN_MAX_ALTP 16
14
+ #define MAX_VERTEX 1024 /* including s; if vert[] has num_vert then MAX_VERTEX has (2*num_vert+2+FIRST_INDX) elements */
15
+
16
+ /* forward declarations */
17
+
18
+ struct BalancedNetworkStructure;
19
+ struct BalancedNetworkData;
20
+ struct tagTautomerGroupsInfo;
21
+ struct tagChargeGroupsInfo;
22
+ struct BN_AtomsAtTautGroup;
23
+ struct tagSaltChargeCandidate;
24
+
25
+ /* define BNS types */
26
+
27
+ typedef S_SHORT Vertex;
28
+ typedef S_SHORT EdgeIndex;
29
+ typedef S_SHORT Edge[2]; /* Edge[0] = vertex1, Edge[1] = iedge or -(1+vertex1) if vertex2 = s or t */
30
+ typedef S_SHORT BNS_IEDGE;
31
+ typedef S_SHORT EdgeFlow;
32
+ typedef S_SHORT VertexFlow;
33
+
34
+
35
+ #define BNS_EDGE_FORBIDDEN_MASK 1
36
+ #define BNS_EDGE_FORBIDDEN_TEMP 2
37
+
38
+ /**************************** BNS_EDGE ************************************/
39
+ typedef struct BnsEdge {
40
+ AT_NUMB neighbor1; /* the smaller neighbor */
41
+ AT_NUMB neighbor12; /* neighbor1 ^ neighbor2 */
42
+ AT_NUMB neigh_ord[2]; /* ordering number of the neighbor: [0]: at<neighbor, [1]: at>neighbor */
43
+ EdgeFlow cap; /* Edge capacity */
44
+ EdgeFlow cap0; /* Initial edge capacity */
45
+ EdgeFlow flow; /* Edge flow */
46
+ EdgeFlow flow0; /* Initial flow */
47
+ /*S_CHAR delta; */
48
+ S_CHAR pass; /* number of times changed in AugmentEdge() */
49
+ S_CHAR forbidden;
50
+ } BNS_EDGE;
51
+
52
+ /**************************** BNS_ST_EDGE ************************************/
53
+ typedef struct BnsStEdge {
54
+ VertexFlow cap; /* Edge capacity */
55
+ VertexFlow cap0; /* Initial edge capacity */
56
+ VertexFlow flow; /* Edge flow */
57
+ VertexFlow flow0; /* Initial edge flow */
58
+ S_CHAR pass; /* number of times changed in AugmentEdge() */
59
+ /*S_CHAR delta; */
60
+ } BNS_ST_EDGE;
61
+
62
+ /**************************** BNS_VERTEX ************************************/
63
+ typedef struct BnsVertex {
64
+
65
+ BNS_ST_EDGE st_edge; /* 0,1 capacity and flow of the edge to s or t */
66
+ AT_NUMB type; /* 2, atom, t-group, or added atom: BNS_VERT_TYPE_TGROUP, etc. */
67
+ AT_NUMB num_adj_edges; /* 3, actual number of neighbors incl. t-groups, excl. s or t */
68
+ AT_NUMB max_adj_edges; /* 4, including reserved */
69
+ /*S_CHAR path_neigh[2];*/ /* 5 found path information */
70
+ /* indexes of Edges */
71
+ BNS_IEDGE *iedge; /* 6 a pointer to the array of edge indexes adjacent to this vertex */
72
+ }BNS_VERTEX;
73
+
74
+ /**************************** BNS_ALT_PATH ************************************/
75
+ typedef union BnsAltPath {
76
+ VertexFlow flow[2];
77
+ Vertex number;
78
+ AT_NUMB ineigh[2];
79
+ } BNS_ALT_PATH;
80
+
81
+ /**************************** BN_STRUCT ************************************/
82
+ typedef struct BalancedNetworkStructure {
83
+
84
+ int num_atoms; /* number of real atoms */
85
+ /*int len_atoms; */ /* size of filled with real atoms portion of the BNS_VERTEX data */
86
+ int num_added_atoms; /* number of added fictitious atoms */
87
+ int nMaxAddAtoms; /* max. number of atoms to add (not including t-groups) */
88
+ int num_c_groups; /* number of added c-groups */
89
+ int num_t_groups; /* number of added t-groups */
90
+ int num_vertices; /* total number currently in effect; includes t-groups and added atoms */
91
+ /*int len_vertices; */ /* allocation size for BNS_VERTEX data */
92
+ int num_bonds; /* number of real bonds/2 = number of edges between real atoms */
93
+ int num_edges; /* number of currently in effect */
94
+ int num_added_edges; /* number of added edges (not including edges to t-groups) */
95
+ int nMaxAddEdges; /* max. number edges of add to each atom (not including edges to t-groups) */
96
+
97
+ int max_vertices; /* allocation size for BNS_VERTEX structures */
98
+ int max_edges; /* allocation size for edge[]; iedge has length 2*max_edges */
99
+ int max_iedges; /* allocation size for iedge */
100
+
101
+ int tot_st_cap; /* not used, only calculated */
102
+ int tot_st_flow; /* not used, only calculated */
103
+
104
+ int len_alt_path; /* length of alt_path[] */
105
+
106
+ int bNotASimplePath; /* alternating path traversed same bond 2 times in opposite directions */
107
+ int bChangeFlow; /* actually change flow */
108
+
109
+ BNS_VERTEX *vert; /* vertices */
110
+ BNS_EDGE *edge; /* edges */
111
+ BNS_IEDGE *iedge;
112
+ BNS_ALT_PATH *alt_path; /* current altp[] element */
113
+ BNS_ALT_PATH *altp[BN_MAX_ALTP]; /* keep alt. paths */
114
+
115
+ int max_altp;
116
+ int num_altp;
117
+
118
+ INCHI_MODE *pbTautFlags; /* carry it through all functions; never NULL */
119
+ INCHI_MODE *pbTautFlagsDone; /* carry it through all functions; never NULL */
120
+ AT_NUMB type_TACN; /* BNS_VERT_TYPE_ACID: if non-zero than only for it path type_T-type_TACN-type_CN allowed */
121
+ AT_NUMB type_T; /* BNS_VERT_TYPE_TGROUP */
122
+ AT_NUMB type_CN; /* BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_C_NEGATIVE */
123
+ S_CHAR edge_forbidden_mask;
124
+
125
+ } BN_STRUCT;
126
+
127
+ /********************* BN_DATA *******************************************/
128
+ typedef struct BalancedNetworkData {
129
+ Vertex *BasePtr; /*[MAX_VERTEX]; pointer toward the base of C(v) */
130
+ Edge *SwitchEdge; /*[MAX_VERTEX]; a pair of vertices and an edge, implemented here as [*][2] array */
131
+ S_CHAR *Tree; /*[MAX_VERTEX]; indicates presence in ScanQ, T, T', s-reachability */
132
+ Vertex *ScanQ; /*[MAX_VERTEX]; contains the set S of s-reachable vertices */
133
+ int QSize; /* index of the last element added to ScanQ */
134
+ Vertex *Pu; /*[MAX_VERTEX/2+1] */
135
+ Vertex *Pv; /*[MAX_VERTEX/2+1] */
136
+ int max_num_vertices; /* allocation size of all except Pu, Pv */
137
+ int max_len_Pu_Pv; /* allocation size of Pu and Pv */
138
+
139
+ } BN_DATA;
140
+
141
+ /* internal array size */
142
+ #define MAX_ALT_AATG_ARRAY_LEN 127
143
+ /* detected endpoint markings */
144
+ #define AATG_MARK_IN_PATH 1 /* atom in path detected by the BNS */
145
+ #define AATG_MARK_WAS_IN_PATH 2 /* found to be in path before next level */
146
+ /* output */
147
+ #define AATG_MARK_MAIN_TYPE 4 /* atom O-"salt" */
148
+ #define AATG_MARK_OTHER_TYPE 8 /* other atom to be tested */
149
+
150
+ struct tagTautomerGroupsInfo; /* forward declaration */
151
+
152
+ /******************** atoms in alt path through taut group ****************/
153
+ typedef struct BN_AtomsAtTautGroup {
154
+ int nAllocLen;
155
+ int nNumFound;
156
+ int nNumMainAdj2Tgroup;
157
+ int nNumOthersAdj2Tgroup;
158
+ AT_NUMB *nEndPoint; /* original t-group number */
159
+ S_CHAR *nMarkedAtom; /* atom mark, see AATG_MARK_* */
160
+ int *nAtTypeTotals;
161
+ struct tagTautomerGroupsInfo *t_group_info;
162
+ } BN_AATG;
163
+
164
+
165
+ /************ store changes in flow and capacity to test a bond ****************/
166
+
167
+ typedef struct tagBNS_FLOW_CHANGES {
168
+ BNS_IEDGE iedge;
169
+ EdgeFlow flow;
170
+ EdgeFlow cap;
171
+ Vertex v1;
172
+ VertexFlow cap_st1;
173
+ VertexFlow flow_st1;
174
+ Vertex v2;
175
+ VertexFlow cap_st2;
176
+ VertexFlow flow_st2;
177
+ } BNS_FLOW_CHANGES;
178
+
179
+
180
+ #define ALT_PATH_MODE_TAUTOM 1
181
+ #define ALT_PATH_MODE_CHARGE 2
182
+ #define ALT_PATH_MODE_4_SALT 3 /* mark alt bonds along the path */
183
+ #define ALT_PATH_MODE_4_SALT2 4 /* mark alt bonds along the path, path to taut. group fict. vertex if exists */
184
+ #define ALT_PATH_MODE_REM2H_CHG 5 /* remove 2 H along alt. path AH-=-BH => A=-=B and change bonds to alternating */
185
+ #define ALT_PATH_MODE_ADD2H_CHG 6 /* add 2 H along alt. path A=-=B => AH-=-BH and change bonds to alternating */
186
+ #define ALT_PATH_MODE_REM2H_TST 7 /* test-remove 2 H along alt. path AH-=-BH => A=-=B; restore changed bonds */
187
+ #define ALT_PATH_MODE_ADD2H_TST 8 /* test-add 2 H along alt. path A=-=B => AH-=-BH; restore changed bonds */
188
+ #define ALT_PATH_MODE_REM_PROTON 9 /* remove proton, adjust bonds, charges, H-counts 2004-03-05 */
189
+
190
+ #ifndef INCHI_ALL_CPP
191
+ #ifdef __cplusplus
192
+ extern "C" {
193
+ #endif
194
+ #endif
195
+
196
+
197
+ int nExists2AtMoveAltPath( struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD,
198
+ struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms,
199
+ int jj2, int jj1, struct tagSaltChargeCandidate *s_candidate, int nNumCandidates,
200
+ AT_NUMB *nForbiddenAtom, int nNumForbiddenAtoms);
201
+ int bExistsAltPath( struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD,
202
+ struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type );
203
+ int bExistsAnyAltPath( struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD,
204
+ inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type );
205
+ int AddTGroups2BnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
206
+ struct tagTautomerGroupsInfo *tgi );
207
+ int AddSuperTGroup2BnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
208
+ struct tagTautomerGroupsInfo *tgi );
209
+ int AddCGroups2BnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
210
+ struct tagChargeGroupsInfo *cgi );
211
+
212
+ int ReInitBnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_at, int bRemoveGroupsFromAtoms );
213
+ int ReInitBnStructAddGroups( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
214
+ struct tagTautomerGroupsInfo *tgi, struct tagChargeGroupsInfo *cgi );
215
+
216
+
217
+ int DisconnectTestAtomFromTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv2, BNS_FLOW_CHANGES *fcd );
218
+ int DisconnectTGroupFromSuperTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv1, int *pv2,
219
+ BNS_FLOW_CHANGES *fcd );
220
+ int ReconnectTestAtomToTGroup( struct BalancedNetworkStructure *pBNS, int v1, int v2, int ie, BNS_FLOW_CHANGES *fcd );
221
+
222
+ int bIsHardRemHCandidate( inp_ATOM *at, int i, int *cSubType );
223
+
224
+ #ifndef INCHI_ALL_CPP
225
+ #ifdef __cplusplus
226
+ }
227
+ #endif
228
+ #endif
229
+
230
+
231
+ #endif /* __INCHI_BNS_H___ */