rino 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/strutil.h
ADDED
@@ -0,0 +1,182 @@
|
|
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 __STRUTIL_H__
|
11
|
+
#define __STRUTIL_H__
|
12
|
+
|
13
|
+
|
14
|
+
#ifndef INCHI_ALL_CPP
|
15
|
+
#ifdef __cplusplus
|
16
|
+
extern "C" {
|
17
|
+
#endif
|
18
|
+
#endif
|
19
|
+
|
20
|
+
int ExtractConnectedComponent( inp_ATOM *at, int num_at, int component_number, inp_ATOM *component_at );
|
21
|
+
int SetConnectedComponentNumber( inp_ATOM *at, int num_at, int component_number );
|
22
|
+
INChI *Alloc_INChI( inp_ATOM *at, int num_at, int *found_num_bonds, int *found_num_isotopic, int nAllocMode );
|
23
|
+
int Free_INChI(INChI **ppINChI);
|
24
|
+
INChI_Aux *Alloc_INChI_Aux( int num_at, int num_isotopic_atoms, int nAllocMode, int bOrigData );
|
25
|
+
int Free_INChI_Aux( INChI_Aux **ppINChI_Aux );
|
26
|
+
int Create_INChI( INChI **ppINChI, INChI_Aux **ppINChI_Aux, ORIG_ATOM_DATA *orig_inp_data,
|
27
|
+
inp_ATOM *inp_at, INP_ATOM_DATA *inp_norm_data[2],
|
28
|
+
int num_inp_at, INCHI_MODE nUserMode,
|
29
|
+
INCHI_MODE *pbTautFlags, INCHI_MODE *pbTautFlagsDone,
|
30
|
+
struct tagInchiTime *ulMaxTime, char *pStrErrStruct);
|
31
|
+
int FillOutInfAtom(inp_ATOM *norm_at, INF_ATOM_DATA *inf_norm_at_data, int init_num_at,
|
32
|
+
int num_removed_H, int nNumRemovedProtons, NUM_H *nNumRemovedProtonsIsotopic, int bIsotopic,
|
33
|
+
INChI *pINChI, INChI_Aux *pINChI_Aux, int bAbcNumbers, INCHI_MODE nMode );
|
34
|
+
int FillOutCompositeCanonInfAtom(COMP_ATOM_DATA *composite_norm_data, INF_ATOM_DATA *inf_norm_at_data,
|
35
|
+
int bIsotopic, int bTautomeric,
|
36
|
+
PINChI2 *pINChI2, PINChI_Aux2 *pINChI_Aux2, int bAbcNumbers, INCHI_MODE nMode);
|
37
|
+
|
38
|
+
#define EQL_EXISTS 1
|
39
|
+
#define EQL_SP3 2
|
40
|
+
#define EQL_SP3_INV 4
|
41
|
+
#define EQL_SP2 8
|
42
|
+
int Eql_INChI_Stereo( INChI_Stereo *s1, int eql1, INChI_Stereo *s2, int eql2, int bRelRac );
|
43
|
+
|
44
|
+
int Eql_INChI_Isotopic( INChI *i1, INChI *i2 );
|
45
|
+
|
46
|
+
#define EQL_EQU 0
|
47
|
+
#define EQL_EQU_TG 1
|
48
|
+
#define EQL_EQU_ISO 2
|
49
|
+
int Eql_INChI_Aux_Equ( INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2 );
|
50
|
+
|
51
|
+
#define EQL_NUM 0
|
52
|
+
#define EQL_NUM_INV 1
|
53
|
+
#define EQL_NUM_ISO 2
|
54
|
+
int Eql_INChI_Aux_Num( INChI_Aux *a1, int eql1, INChI_Aux *a2, int eql2 );
|
55
|
+
|
56
|
+
int bHasEquString( AT_NUMB *LinearCT, int nLenCT );
|
57
|
+
|
58
|
+
int CompINChINonTaut2(const void *p1, const void *p2);
|
59
|
+
int CompINChITaut2(const void *p1, const void *p2);
|
60
|
+
int CompINChI2(const INCHI_SORT *p1, const INCHI_SORT *p2, int bTaut, int bCompareIsotopic);
|
61
|
+
int CompINChITautVsNonTaut(const INCHI_SORT *p1, const INCHI_SORT *p2, int bCompareIsotopic);
|
62
|
+
|
63
|
+
|
64
|
+
typedef enum tagDiffINChISegments { /* r = repetitive, n = non-repetitive */
|
65
|
+
DIFS_f_FORMULA, /* 0 r; fixed-H <-> mobile-H */
|
66
|
+
DIFS_c_CONNECT, /* 1 n; connection table; mobile-H only */
|
67
|
+
DIFS_h_H_ATOMS, /* 2 n; hydrogen atoms: mobile-H and Fixed-H; have different meanings */
|
68
|
+
DIFS_q_CHARGE, /* 3 r; charge; fixed-H <-> mobile-H */
|
69
|
+
DIFS_p_PROTONS, /* 4 n; protons; mobile-H only */
|
70
|
+
DIFS_b_SBONDS, /* 5 r: stereobonds: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
|
71
|
+
DIFS_t_SATOMS, /* 6 r: stereoatoms: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
|
72
|
+
DIFS_m_SP3INV, /* 7 r: stereo-abs-inv: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
|
73
|
+
DIFS_s_STYPE, /* 8 r: stereo-type: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
|
74
|
+
DIFS_i_IATOMS, /* 9 r: isotopic atoms: fixed-H <-> mobile-H * isotopic <-> non-isotopic */
|
75
|
+
DIFS_o_TRANSP, /* 10 n: Fixed-H transposition */
|
76
|
+
DIFS_idf_LENGTH, /* 11 length of the array relevant to the INChI Identifier */
|
77
|
+
/* later elements referring to AuxInfo may be added */
|
78
|
+
DIFS_LENGTH = DIFS_idf_LENGTH /* length of the array */
|
79
|
+
} DIF_SEGMENTS;
|
80
|
+
|
81
|
+
typedef enum tagDiffINChILayers {
|
82
|
+
DIFL_M, /* 0 main layer */
|
83
|
+
DIFL_MI, /* 1 main isotopic */
|
84
|
+
DIFL_F, /* 2 fixed-H */
|
85
|
+
DIFL_FI, /* 3 fixed-H isotopic */
|
86
|
+
DIFL_LENGTH /* number of layers */
|
87
|
+
} DIF_LAYERS;
|
88
|
+
|
89
|
+
/* Value meaning */
|
90
|
+
typedef enum tagMarkDiff {
|
91
|
+
DIFV_BOTH_EMPTY = 0, /* both this and the component in the preceding namesake segment are empty */
|
92
|
+
DIFV_EQL2PRECED = 1, /* equal to the component in the preceding namesake segment */
|
93
|
+
DIFV_NEQ2PRECED = 2, /* different from the component in the preceding namesake segment */
|
94
|
+
DIFV_IS_EMPTY = 4, /* is empty while the preceding namesake segment is not empty */
|
95
|
+
DIFV_FI_EQ_MI = 8, /* FI stereo component is equal to the component in the MI namesake segment */
|
96
|
+
/* while M and F components are empty */
|
97
|
+
/* decision_F = bitmask: bits that should not be present */
|
98
|
+
/* decision_T = bitmask: at least one of the bits should be present */
|
99
|
+
/* decision = true if( !( BITS & decision_F ) && ( BITS & decision_F ) ) */
|
100
|
+
DIFV_OUTPUT_EMPTY_T = (DIFV_IS_EMPTY), /* bits present for empty segment output */
|
101
|
+
DIFV_OUTPUT_EMPTY_F = (DIFV_EQL2PRECED | DIFV_NEQ2PRECED | DIFV_FI_EQ_MI), /* bits NOT present */
|
102
|
+
|
103
|
+
DIFV_OUTPUT_OMIT_F = (DIFV_NEQ2PRECED | DIFV_IS_EMPTY), /* bits NOT present for omitting */
|
104
|
+
|
105
|
+
DIFV_OUTPUT_FILL_T = (DIFV_EQL2PRECED | DIFV_NEQ2PRECED | DIFV_FI_EQ_MI)
|
106
|
+
|
107
|
+
} DIF_VALUES;
|
108
|
+
|
109
|
+
typedef enum tagINChISegmAction {
|
110
|
+
INCHI_SEGM_OMIT = 0,
|
111
|
+
INCHI_SEGM_FILL = 1, /* the value is used in str_LineEnd() */
|
112
|
+
INCHI_SEGM_EMPTY = 2 /* the value is used in str_LineEnd() */
|
113
|
+
} INCHI_SEGM_ACTION;
|
114
|
+
|
115
|
+
int CompINChILayers(const INCHI_SORT *p1, const INCHI_SORT *p2, char sDifSegs[][DIFS_LENGTH] );
|
116
|
+
int MarkUnusedAndEmptyLayers( char sDifSegs[][DIFS_LENGTH] );
|
117
|
+
int INChI_SegmentAction( char cDifSegs );
|
118
|
+
|
119
|
+
#define FLAG_SORT_PRINT_TRANSPOS_BAS 1 /* transposition in the main InChI layer */
|
120
|
+
#define FLAG_SORT_PRINT_TRANSPOS_REC 2 /* transposition in the reconnected InChI layer */
|
121
|
+
#define FLAG_SORT_PRINT_NO_NFIX_H_BAS 4 /* no fixed H non-isotopic in the main InChI layer */
|
122
|
+
#define FLAG_SORT_PRINT_NO_NFIX_H_REC 8 /* no fixed H non-isotopic in the reconnected InChI layer */
|
123
|
+
#define FLAG_SORT_PRINT_NO_IFIX_H_BAS 16 /* no fixed H isotopic in the main InChI layer */
|
124
|
+
#define FLAG_SORT_PRINT_NO_IFIX_H_REC 32 /* no fixed H isotopic in the the reconnected InChI layer */
|
125
|
+
|
126
|
+
int OutputINChI1( char *pStr, int nStrLen, INCHI_SORT *pINChISortTautAndNonTaut[][TAUT_NUM], int iINChI,
|
127
|
+
ORIG_STRUCT *pOrigStruct,
|
128
|
+
int bDisconnectedCoord, int bOutputType, int bINChIOutputOptions, int bXml, int bAbcNumbers,
|
129
|
+
int bCtPredecessors, int bNoStructLabels,
|
130
|
+
int num_components[], int num_non_taut[], int num_taut[],
|
131
|
+
INCHI_FILE *output_file, INCHI_FILE *log_file, int num_input_struct,
|
132
|
+
const char *szSdfLabel, const char *szSdfValue, long lSdfId, int *pSortPrintINChIFlags );
|
133
|
+
int OutputINChI2( char *pStr, int nStrLen, INCHI_SORT *pINChISortTautAndNonTaut[][TAUT_NUM], int iINChI,
|
134
|
+
ORIG_STRUCT *pOrigStruct,
|
135
|
+
int bDisconnectedCoord, int bOutputType, int bINChIOutputOptions, int bXml, int bAbcNumbers,
|
136
|
+
int bCtPredecessors, int bNoStructLabels,
|
137
|
+
int num_components[], int num_non_taut[], int num_taut[],
|
138
|
+
INCHI_FILE *output_file, INCHI_FILE *log_file, int num_input_struct,
|
139
|
+
const char *szSdfLabel, const char *szSdfValue, long lSdfId, int *pSortPrintINChIFlags );
|
140
|
+
int SaveEquComponentsInfoAndSortOrder ( int iINChI, INCHI_SORT *pINChISort[TAUT_NUM], int *num_components,
|
141
|
+
ORIG_ATOM_DATA *orig_inp_data, ORIG_ATOM_DATA *prep_inp_data,
|
142
|
+
COMP_ATOM_DATA composite_norm_data[TAUT_NUM],
|
143
|
+
int bCompareComponents );
|
144
|
+
int OutputINChIXmlRootStartTag( INCHI_FILE *output_file );
|
145
|
+
int OutputINChIXmlRootEndTag( INCHI_FILE *output_file );
|
146
|
+
int OutputINChIXmlError( INCHI_FILE *output_file, char *pStr, int nStrLen, int ind,
|
147
|
+
/*int nErrorNumber,*/ char *szErrorText, int bError );
|
148
|
+
int OutputINChIPlainError( INCHI_FILE *output_file, char *pStr, int nStrLen,
|
149
|
+
char *pErrorText, int bError );
|
150
|
+
int OutputINChIXmlStructStartTag( INCHI_FILE *output_file, char *pStr, int ind /* indent*/, int nStrLen, int bNoStructLabels,
|
151
|
+
int num_input_struct, const char *szSdfLabel, const char *szSdfValue );
|
152
|
+
int OutputINChIXmlStructEndTag( INCHI_FILE *output_file, char *pStr, int nStrLen, int ind );
|
153
|
+
|
154
|
+
int GetInpStructErrorType(INPUT_PARMS *ip, int err, char *pStrErrStruct, int num_inp_atoms );
|
155
|
+
int ProcessStructError( INCHI_FILE *output_file, INCHI_FILE *log_file, /*int err,*/ char *pStrErrStruct, int nErrorType,
|
156
|
+
int *bXmlStructStarted, int num_inp, INPUT_PARMS *ip, char *pStr, int nStrLen );
|
157
|
+
|
158
|
+
int bNumHeterAtomHasIsotopicH( inp_ATOM *atom, int num_atoms );
|
159
|
+
|
160
|
+
int WriteToSDfile( const INP_ATOM_DATA *inp_at_data, INCHI_FILE* fcb, const char* name, const char* comment,
|
161
|
+
const char *szLabel, const char *szValue );
|
162
|
+
int WriteOrigAtomDataToSDfile( const ORIG_ATOM_DATA *inp_at_data, INCHI_FILE* fcb, const char* name, const char* comment,
|
163
|
+
int bChiral, const char *szLabel, const char *szValue);
|
164
|
+
|
165
|
+
|
166
|
+
extern char gsMissing[];
|
167
|
+
extern char gsEmpty[];
|
168
|
+
extern char gsSpace[];
|
169
|
+
extern char gsEqual[];
|
170
|
+
/* format string for SDF_LBL_VAL(L,V): %s%s%s%s (four strings) */
|
171
|
+
/*#define SDF_LBL_VAL(L,V) ((L)&&(L)[0])?gsSpace:gsEmpty, ((L)&&(L)[0])?L:gsEmpty, ((L)&&(L)[0])? (((V)&&(V)[0])?gsEqual:gsSpace):gsEmpty, ((L)&&(L)[0])?((V)&&(V)[0]?V:gsMissing):gsEmpty*/
|
172
|
+
#define SDF_LBL_VAL(L,V) ((L)&&(L)[0])?gsSpace:gsEmpty, ((L)&&(L)[0])?L:gsEmpty, ((L)&&(L)[0])? (((V)&&(V)[0])?gsEqual:gsSpace):gsEmpty, ((V)&&(V)[0])?V:((L)&&(L)[0])?gsMissing:gsEmpty
|
173
|
+
|
174
|
+
#ifndef INCHI_ALL_CPP
|
175
|
+
#ifdef __cplusplus
|
176
|
+
}
|
177
|
+
#endif
|
178
|
+
#endif
|
179
|
+
|
180
|
+
|
181
|
+
#endif /* __STRUTIL_H__ */
|
182
|
+
|