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.
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
data/ext/src/ichi.h ADDED
@@ -0,0 +1,206 @@
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_H__
11
+ #define __INCHI_H__
12
+
13
+ #include "comdef.h"
14
+
15
+ #define REQ_MODE_BASIC 0x000001 /* B */
16
+ #define REQ_MODE_TAUT 0x000002 /* T */
17
+ #define REQ_MODE_ISO 0x000004 /* I */
18
+ #define REQ_MODE_NON_ISO 0x000008 /* NI */
19
+ #define REQ_MODE_STEREO 0x000010 /* S */
20
+ #define REQ_MODE_ISO_STEREO 0x000020 /* IS */
21
+ #define REQ_MODE_NOEQ_STEREO 0x000040 /* SS */
22
+ #define REQ_MODE_REDNDNT_STEREO 0x000080 /* RS */
23
+ #define REQ_MODE_NO_ALT_SBONDS 0x000100 /* NASB */
24
+ /* new 10-10-2003 */
25
+ #define REQ_MODE_RELATIVE_STEREO 0x000200 /* REL All Relative Stereo */
26
+ #define REQ_MODE_RACEMIC_STEREO 0x000400 /* RAC All Racemic Stereo */
27
+ #define REQ_MODE_SC_IGN_ALL_UU 0x000800 /* IAUSC Ignore stereocenters if All Undef/Unknown */
28
+ #define REQ_MODE_SB_IGN_ALL_UU 0x001000 /* IAUSC Ignore stereobonds if All Undef/Unknown */
29
+ #define REQ_MODE_CHIR_FLG_STEREO 0x002000 /* SUCF If Chiral flag then Abs otherwise Rel stereo */
30
+ /* end of 10-10-2003 */
31
+ #define REQ_MODE_MIN_SB_RING_MASK 0x0F0000 /* RSB */
32
+ #define REQ_MODE_MIN_SB_RING_SHFT 16
33
+
34
+ #define REQ_MODE_DEFAULT (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO)
35
+
36
+ #define WARN_FAILED_STEREO 0x0001
37
+ #define WARN_FAILED_ISOTOPIC 0x0002
38
+ #define WARN_FAILED_ISOTOPIC_STEREO 0x0004
39
+ #define ERR_NO_CANON_RESULTS 0x0008
40
+
41
+ /*********** compare components flags **********************************/
42
+ #define CMP_COMPONENTS 0x0001 /* perform compare components */
43
+ #define CMP_COMPONENTS_NONISO 0x0002 /* ignore isotopic */
44
+ #define CMP_COMPONENTS_NONTAUT 0x0004 /* compare non-tautomeric */
45
+ /****************** chemical identifier member definitions *************/
46
+ typedef struct tagINChI_IsotopicAtom {
47
+ AT_NUMB nAtomNumber; /* Canonical atom number */
48
+ NUM_H nIsoDifference; /* 0=non-isotopic; 1=only most abundant */
49
+ NUM_H nNum_H; /* number of 1H isotopic atoms attached */
50
+ NUM_H nNum_D; /* number of 2H isotopic atoms attached */
51
+ NUM_H nNum_T; /* number of 3H isotopic atoms attached */
52
+ } INChI_IsotopicAtom;
53
+ typedef struct tagINChI_IsotopicTGroup {
54
+ AT_NUMB nTGroupNumber; /* Tautomeric group number */
55
+ AT_NUMB nNum_H; /* number of 1H isotopic atoms */
56
+ AT_NUMB nNum_D; /* number of 2H isotopic atoms */
57
+ AT_NUMB nNum_T; /* number of 3H isotopic atoms */
58
+ } INChI_IsotopicTGroup;
59
+ typedef struct tagINChI_Stereo { /* [N] = allocated length */
60
+ /* ---- possibly tetrahedral stereogenic atoms */
61
+ int nNumberOfStereoCenters;
62
+ AT_NUMB *nNumber; /* Canonical number of a possibly tetrahedral
63
+ * stereogenic atom or allenes [nNumberOfAtoms] */
64
+ S_CHAR *t_parity; /* tetrahedral (relative, see nCompInv2Abs) atom parities [nNumberOfAtoms] */
65
+ /* ---- possibly tetrahedral stereogenic atoms of the iverted structure */
66
+ AT_NUMB *nNumberInv; /* Canonical number of a possibly tetrahedral
67
+ * stereogenic atom or allene [nNumberOfAtoms] */
68
+ S_CHAR *t_parityInv; /* tetrahedral inverted atom parities [nNumberOfAtoms] */
69
+ /* bFlagAbsStereoIsInverted = nCompInv2Abs==-1: Abs stereo = Inverted */
70
+ int nCompInv2Abs; /* 0=>Inv = Abs stereo; -1=> Inv < Abs stereo, +1=> Inv > Abs stereo */
71
+ int bTrivialInv; /* 1=> nCompInv2Abs!= 0 && Inverted = Abs stereo with inverted parities 1<-->2 */
72
+ /* ---- possibly stereogenic bonds and tetrahedral cumuleles */
73
+ int nNumberOfStereoBonds;
74
+ AT_NUMB *nBondAtom1; /* Canonical number of a first atom
75
+ * [number of bonds] */
76
+ AT_NUMB *nBondAtom2; /* Canonical number of a second atom
77
+ * [number of bonds] */
78
+ S_CHAR *b_parity; /* possibly stereogenic bond parities
79
+ * [number of bonds] */
80
+ } INChI_Stereo;
81
+ #define INCHI_FLAG_ACID_TAUT 0x0001 /* tautomerism of dissociated acid invoked */
82
+ #define INCHI_FLAG_REL_STEREO 0x0002 /* requested relative stereo */
83
+ #define INCHI_FLAG_RAC_STEREO 0x0004 /* requested racemic stereo */
84
+ #define INCHI_FLAG_SC_IGN_ALL_UU 0x0008 /* ignored all undefined/unknown stereocenters, non-isotopic */
85
+ #define INCHI_FLAG_SB_IGN_ALL_UU 0x0010 /* ignored all undefined/unknown stereocenters, non-isotopic */
86
+ #define INCHI_FLAG_SC_IGN_ALL_ISO_UU 0x0020 /* ignored all undefined/unknown stereocenters, isotopic */
87
+ #define INCHI_FLAG_SB_IGN_ALL_ISO_UU 0x0040 /* ignored all undefined/unknown stereocenters, isotopic */
88
+ #define INCHI_FLAG_HARD_ADD_REM_PROTON 0x0080 /* in normalization a proton has been added or removed along alt path */
89
+
90
+ #define INCHI_OUT_NO_AUX_INFO 0x0001 /* do not output Aux Info */
91
+ #define INCHI_OUT_SHORT_AUX_INFO 0x0002 /* output short version of Aux Info */
92
+ #define INCHI_OUT_ONLY_AUX_INFO 0x0004 /* output only Aux Info */
93
+ #define INCHI_OUT_EMBED_REC 0x0008 /* embed reconnected INChI into disconnected INChI */
94
+ #define INCHI_OUT_SDFILE_ONLY 0x0010 /* save input data in a Molfile instead of creating INChI */
95
+ #define INCHI_OUT_XML 0x0020 /* output xml INChI */
96
+ #define INCHI_OUT_PLAIN_TEXT 0x0040 /* output plain text INChI */
97
+ #define INCHI_OUT_PLAIN_TEXT_COMMENTS 0x0080 /* output plain text annotation */
98
+ #define INCHI_OUT_XML_TEXT_COMMENTS 0x0100 /* output xml text annotation */
99
+ #define INCHI_OUT_WINCHI_WINDOW 0x0200 /* output into wINChI text window */
100
+ #define INCHI_OUT_TABBED_OUTPUT 0x0400 /* tab-delimited (only for plain text) */
101
+
102
+ /*******REQ_MODE_SB_IGN_ALL_UU*************** chemical identifier definition *****************/
103
+ typedef struct tagINChI { /* [N] = allocated length */
104
+
105
+ int nErrorCode; /* 0 = success */
106
+ INCHI_MODE nFlags; /* INCHI_FLAG_ACID_TAUT tautomerism of dissociated acid invoked
107
+ INCHI_FLAG_REL_STEREO requested relative stereo
108
+ INCHI_FLAG_RAC_STEREO requested racemic stereo
109
+ INCHI_FLAG_SC_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic
110
+ INCHI_FLAG_SB_IGN_ALL_UU ignored all undefined/unknown stereocenters, non-isotopic
111
+ INCHI_FLAG_SC_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic
112
+ INCHI_FLAG_SB_IGN_ALL_ISO_UU ignored all undefined/unknown stereocenters, isotopic
113
+ INCHI_FLAG_HARD_ADD_REM_PROTON in normalization a proton has been added or removed along alt path
114
+ */
115
+ /* ---- basic & tautomer layer */
116
+ int nTotalCharge;
117
+ int nNumberOfAtoms;
118
+ char *szHillFormula;
119
+ U_CHAR *nAtom; /* atomic numbers [nNumberOfAtoms] from the Periodic Table */
120
+ int lenConnTable;
121
+ AT_NUMB *nConnTable; /* Connection table [nNumberOfAtoms+NumberOfBonds] */
122
+ int lenTautomer;
123
+ AT_NUMB *nTautomer; /* NumGroups; ((NumAt+1, NumH, At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 1} - old
124
+ * NumGroups; ((NumAt+2, NumH, Num(-), At1..AtNumAt),...); {INCHI_T_NUM_MOVABLE = 2} - new
125
+ * Allocated length: [5*nNumberOfAtoms/2+1], see Alloc_INChI(...) */
126
+ S_CHAR *nNum_H; /* number of terminal hydrogen atoms on each atom; in tautomeric
127
+ * representation these H on tautomeric atoms are not included [nNumberOfAtoms] */
128
+ S_CHAR *nNum_H_fixed;/* number of terminal hydrogen atoms on tautomeric atoms,
129
+ * in non-atautomeric representation only [nNumberOfAtoms] */
130
+ /* ---- isotopic & isotopic tautomeric layer */
131
+ int nNumberOfIsotopicAtoms;
132
+ INChI_IsotopicAtom *IsotopicAtom; /* [nNumberOfIsotopicAtoms] */
133
+ int nNumberOfIsotopicTGroups;
134
+ INChI_IsotopicTGroup *IsotopicTGroup; /* [nNumberOfIsotopicAtoms] */
135
+ /* ---- stereo layer */
136
+ INChI_Stereo *Stereo;
137
+ INChI_Stereo *StereoIsotopic;
138
+ /* not including mobile H groups */
139
+ AT_NUMB *nPossibleLocationsOfIsotopicH; /* [0]=> length including 0th element, location1,...*/
140
+ int bDeleted;
141
+ #if( bREUSE_INCHI == 1 )
142
+ int nRefCount;
143
+ #endif
144
+ #if( bRELEASE_VERSION == 0 )
145
+ int bExtract;
146
+ #endif
147
+
148
+ } INChI;
149
+
150
+ typedef INChI *PINChI2[TAUT_NUM];
151
+
152
+ typedef struct tagOrigInfo {
153
+ S_CHAR cCharge;
154
+ S_CHAR cRadical; /* 0=none, 1=doublet, 2=triplet, 3=unknown */
155
+ S_CHAR cUnusualValence; /* see get_unusual_el_valence() */
156
+ } ORIG_INFO;
157
+ /******************** auxiliary chemical identifier info **************/
158
+ typedef struct tagINChI_Aux { /* [N] = allocated length */
159
+
160
+ int nErrorCode; /* 0 = success */
161
+ int nNumberOfAtoms;
162
+ int nNumberOfTGroups; /* non-zero only in tautomeric representation */
163
+ int bIsIsotopic; /* filled out even though isotopic has not been requested */
164
+ int bIsTautomeric; /* filled out even though tautomeric has not been requested; non-zero if taut exists */
165
+ /* canonical numbers of the atoms: nOrigAtNosInCanonOrd[i-1]+1 = */
166
+ /* input atom number for the canonical number i */
167
+ AT_NUMB *nOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */
168
+ AT_NUMB *nIsotopicOrigAtNosInCanonOrd; /* [nNumberOfInputAtoms*1.5]; */
169
+ /* same for the inverted structure */
170
+ AT_NUMB *nOrigAtNosInCanonOrdInv; /* inveterted stereo [nNumberOfInputAtoms*1.5]; */
171
+ AT_NUMB *nIsotopicOrigAtNosInCanonOrdInv; /* [nNumberOfInputAtoms*1.5]; */
172
+ AT_NUMB *nConstitEquNumbers; /* [nNumberOfAtoms*1.5] */
173
+ AT_NUMB *nConstitEquTGroupNumbers; /* [nNumberOfAtoms/2] */
174
+ AT_NUMB *nConstitEquIsotopicNumbers; /* [nNumberOfAtoms*1.5] */
175
+ AT_NUMB *nConstitEquIsotopicTGroupNumbers; /* [nNumberOfAtoms/2] */
176
+ #if( bREUSE_INCHI == 1 )
177
+ int nRefCount;
178
+ #endif
179
+ #if( TEST_RENUMB_ATOMS == 1 )
180
+ unsigned long ulNormTime;
181
+ unsigned long ulCanonTime;
182
+ #endif
183
+
184
+ ORIG_INFO *OrigInfo;
185
+ MOL_COORD *szOrigCoord;
186
+ NUM_H nNumRemovedProtons;
187
+ NUM_H nNumRemovedIsotopicH[NUM_H_ISOTOPES]; /* isotopic H that may be exchanged and considered
188
+ randomly distributed, including removed protons */
189
+ int bDeleted;
190
+ INCHI_MODE bTautFlags;
191
+ INCHI_MODE bTautFlagsDone;
192
+ INCHI_MODE bNormalizationFlags;
193
+ int nCanonFlags;
194
+ } INChI_Aux;
195
+
196
+ typedef INChI_Aux *PINChI_Aux2[TAUT_NUM];
197
+
198
+ /********************* array of pointers for sorting components and INChI output *********/
199
+ typedef struct tagINChIforSort {
200
+ INChI *pINChI[TAUT_NUM];
201
+ INChI_Aux *pINChI_Aux[TAUT_NUM];
202
+ int ord_number; /* for stable sort */
203
+ }INCHI_SORT;
204
+
205
+
206
+ #endif /* __INCHI_H__ */