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/ichicano.c
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
3
|
* International Chemical Identifier (InChI)
|
4
4
|
* Version 1
|
5
|
-
* Software version 1.
|
6
|
-
*
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
7
|
* Developed at NIST
|
8
8
|
*/
|
9
9
|
|
@@ -93,7 +93,7 @@ static void FillMaxMinClock(void); /* keep compiler happy */
|
|
93
93
|
static void FillMaxMinClock(void)
|
94
94
|
{
|
95
95
|
if ( !MaxPositiveClock ) {
|
96
|
-
clock_t valPos, val1 = 1;
|
96
|
+
clock_t valPos=0, val1 = 1;
|
97
97
|
while ( 0 < ((val1 <<= 1), (val1 |= 1)) ) {
|
98
98
|
valPos = val1;
|
99
99
|
}
|
@@ -704,23 +704,18 @@ int FillTautLinearCT2( int num_atoms, int num_at_tg, int bIsoTaut,
|
|
704
704
|
int num_t_groups = t_group_info->num_t_groups;
|
705
705
|
AT_NUMB *tGroupNumber = t_group_info->tGroupNumber;
|
706
706
|
AT_NUMB *tSymmRank = tGroupNumber + TGSO_SYMM_RANK*num_t_groups; /* equivalence */
|
707
|
-
AT_NUMB *tPrevGroupNumber = tGroupNumber + TGSO_PREV_ORDER*num_t_groups; /* prev. order or symm rank sort order */
|
708
|
-
AT_NUMB *tSortRank = tGroupNumber + TGSO_SORT_RANK*num_t_groups; /* ranks */
|
709
707
|
AT_NUMB *tiSymmRank = tGroupNumber + TGSO_SYMM_IRANK*num_t_groups;
|
710
708
|
AT_NUMB *tiGroupNumber = tGroupNumber + TGSO_SYMM_IORDER*num_t_groups;
|
711
|
-
AT_NUMB *tiSortRank = tGroupNumber + TGSO_SORT_IRANK*num_t_groups;
|
712
709
|
AT_RANK nOffset = (AT_RANK)num_atoms;
|
713
710
|
/* Fill Canonical ranks and Symmetry Ranks */
|
714
|
-
memcpy( tPrevGroupNumber, tGroupNumber, num_t_groups*sizeof(tPrevGroupNumber[0]));
|
711
|
+
/* memcpy( tPrevGroupNumber, tGroupNumber, num_t_groups*sizeof(tPrevGroupNumber[0])); */
|
715
712
|
for ( i = num_atoms, j = 0; i < num_at_tg; i ++, j ++ ) {
|
716
|
-
tPrevGroupNumber[j] =
|
713
|
+
/* tPrevGroupNumber[j] = */
|
717
714
|
tGroupNumber[j] = nAtomNumber[i] - nOffset;
|
718
715
|
tSymmRank[j] = nSymmRank[i] - nOffset;
|
719
|
-
|
720
|
-
if ( bIsoTaut /*nMaxLenLinearCTIsotopicTautomer*/ ) {
|
716
|
+
if ( bIsoTaut ) {
|
721
717
|
tiGroupNumber[j] = nAtomNumberIso[i] - nOffset;
|
722
718
|
tiSymmRank[j] = nSymmRankIso[i] - nOffset;
|
723
|
-
tiSortRank[j] = nRankIso[i] - nOffset;
|
724
719
|
}
|
725
720
|
}
|
726
721
|
/* Sort enpoints within each tautomeric group according to the canonical ranks */
|
@@ -766,8 +761,8 @@ int FillTautLinearCT2( int num_atoms, int num_at_tg, int bIsoTaut,
|
|
766
761
|
/* t_group header: number of endpoints */
|
767
762
|
LinearCTTautomer[len++] = t_group->nNumEndpoints;
|
768
763
|
/* t_group header: */
|
769
|
-
/* (a) number of mobile groups in the t_group and */
|
770
|
-
/* (b) number of mobile negative charges in the t_group
|
764
|
+
/* (a) number of mobile groups in the t_group (number of H + number of (-) ) and */
|
765
|
+
/* (b) number of mobile negative charges (-) in the t_group */
|
771
766
|
for ( j = 0; j < T_NUM_NO_ISOTOPIC; j ++ ) {
|
772
767
|
LinearCTTautomer[len++] = t_group->num[j];
|
773
768
|
}
|
data/ext/src/ichicano.h
CHANGED
data/ext/src/ichicans.c
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
3
|
* International Chemical Identifier (InChI)
|
4
4
|
* Version 1
|
5
|
-
* Software version 1.
|
6
|
-
*
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
7
|
* Developed at NIST
|
8
8
|
*/
|
9
9
|
|
@@ -1577,11 +1577,16 @@ int GetPermutationParity( sp_ATOM *at, AT_RANK nAvoidNeighbor, AT_RANK *nCanonRa
|
|
1577
1577
|
nNeighRank[k++] = nCanonRank[(int)at->neighbor[j]];
|
1578
1578
|
}
|
1579
1579
|
}
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1580
|
+
if ( k ) {
|
1581
|
+
parity = insertions_sort( nNeighRank, k, sizeof(nNeighRank[0]), comp_AT_RANK);
|
1582
|
+
if ( nNeighRank[0] ) {
|
1583
|
+
parity = 2 - parity % 2;
|
1584
|
+
} else {
|
1585
|
+
parity = 0; /* not all ranks are known */
|
1586
|
+
}
|
1583
1587
|
} else {
|
1584
|
-
|
1588
|
+
/* special case: HX= with implicit H */
|
1589
|
+
parity = 2;
|
1585
1590
|
}
|
1586
1591
|
}
|
1587
1592
|
return parity;
|
data/ext/src/ichicant.h
CHANGED
data/ext/src/ichicomn.h
CHANGED
data/ext/src/ichicomp.h
CHANGED
@@ -2,15 +2,21 @@
|
|
2
2
|
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
3
|
* International Chemical Identifier (InChI)
|
4
4
|
* Version 1
|
5
|
-
* Software version 1.
|
6
|
-
*
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
7
|
* Developed at NIST
|
8
8
|
*/
|
9
9
|
|
10
10
|
#ifndef __INCHI_COMPAT_H__
|
11
11
|
#define __INCHI_COMPAT_H__
|
12
12
|
|
13
|
-
|
13
|
+
#ifndef INCHI_ALL_CPP
|
14
|
+
#ifdef __cplusplus
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
#endif
|
18
|
+
|
19
|
+
/* compatibility */
|
14
20
|
|
15
21
|
#if( defined(__GNUC__) && defined(__MINGW32__) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 0 && defined(_WIN32) )
|
16
22
|
/* replace with the proper definition for GNU gcc & MinGW-2.0.0-3 (mingw special 20020817-1), gcc 3.2 core */
|
@@ -32,7 +38,10 @@
|
|
32
38
|
#include <stdio.h>
|
33
39
|
/* this #include provides size_t definition */
|
34
40
|
/* implementation is located in util.c */
|
35
|
-
|
41
|
+
/*#if ( !defined(_MSC_VER) || defined(__STDC__) && __STDC__ == 1 )*/
|
42
|
+
|
43
|
+
#if ( defined(ADD_NON_ANSI_FUNCTIONS) || defined(__STDC__) && __STDC__ == 1 )
|
44
|
+
|
36
45
|
/* support (VC++ Language extensions) = OFF && defined(INCHI_ANSI_ONLY) */
|
37
46
|
int memicmp (const void*, const void*, size_t);
|
38
47
|
int stricmp( const char *s1, const char *s2 );
|
@@ -46,5 +55,11 @@ char *_strdup( const char *string );
|
|
46
55
|
#define inchi_max(a,b) (((a)>(b))?(a):(b))
|
47
56
|
#define inchi_min(a,b) (((a)<(b))?(a):(b))
|
48
57
|
|
58
|
+
#ifndef INCHI_ALL_CPP
|
59
|
+
#ifdef __cplusplus
|
60
|
+
}
|
61
|
+
#endif
|
62
|
+
#endif
|
63
|
+
|
49
64
|
|
50
65
|
#endif /* __INCHI_COMPAT_H__ */
|
data/ext/src/ichidrp.h
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
3
|
* International Chemical Identifier (InChI)
|
4
4
|
* Version 1
|
5
|
-
* Software version 1.
|
6
|
-
*
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
7
|
* Developed at NIST
|
8
8
|
*/
|
9
9
|
|
@@ -62,7 +62,7 @@ typedef struct tagDrawParms {
|
|
62
62
|
#define MAX_NUM_PATHS 4
|
63
63
|
#endif
|
64
64
|
|
65
|
-
typedef enum tagInputType { INPUT_NONE=0, INPUT_MOLFILE=1, INPUT_SDFILE=2, INPUT_INCHI_XML=3, INPUT_INCHI_PLAIN=4, INPUT_CMLFILE=5, INPUT_MAX } INPUT_TYPE;
|
65
|
+
typedef enum tagInputType { INPUT_NONE=0, INPUT_MOLFILE=1, INPUT_SDFILE=2, INPUT_INCHI_XML=3, INPUT_INCHI_PLAIN=4, INPUT_CMLFILE=5, INPUT_INCHI=6, INPUT_MAX } INPUT_TYPE;
|
66
66
|
typedef struct tagInputParms {
|
67
67
|
char szSdfDataHeader[MAX_SDF_HEADER+1];
|
68
68
|
char *pSdfLabel;
|
@@ -85,8 +85,8 @@ typedef struct tagInputParms {
|
|
85
85
|
*/
|
86
86
|
const char *path[MAX_NUM_PATHS];
|
87
87
|
int num_paths;
|
88
|
-
|
89
|
-
|
88
|
+
long first_struct_number;
|
89
|
+
long last_struct_number;
|
90
90
|
INPUT_TYPE nInputType;
|
91
91
|
INCHI_MODE nMode;
|
92
92
|
int bAbcNumbers;
|
@@ -101,6 +101,7 @@ typedef struct tagInputParms {
|
|
101
101
|
|
102
102
|
long ulDisplTime; /* not used: max structure or question display time */
|
103
103
|
int bDisplay;
|
104
|
+
int bDisplayIfRestoreWarnings; /* InChI->Struct debug */
|
104
105
|
int bMergeAllInputStructures;
|
105
106
|
int bSaveWarningStructsAsProblem;
|
106
107
|
int bSaveAllGoodStructsAsProblem;
|
@@ -114,6 +115,9 @@ typedef struct tagInputParms {
|
|
114
115
|
int bAllowEmptyStructure;
|
115
116
|
INCHI_MODE bTautFlags;
|
116
117
|
INCHI_MODE bTautFlagsDone;
|
118
|
+
#if( READ_INCHI_STRING == 1 )
|
119
|
+
int bReadInChIOptions;
|
120
|
+
#endif
|
117
121
|
} INPUT_PARMS;
|
118
122
|
|
119
123
|
#endif /* __INCHIDRP_H__ */
|
data/ext/src/ichierr.h
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
3
|
* International Chemical Identifier (InChI)
|
4
4
|
* Version 1
|
5
|
-
* Software version 1.
|
6
|
-
*
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
7
|
* Developed at NIST
|
8
8
|
*/
|
9
9
|
|
@@ -37,7 +37,8 @@
|
|
37
37
|
#define CT_CALC_STEREO_ERR (CT_ERR_FIRST-15) /*(-30015) */
|
38
38
|
#define CT_CANON_ERR (CT_ERR_FIRST-16) /*(-30016) */
|
39
39
|
#define CT_STEREO_CANON_ERR (CT_ERR_FIRST-17) /*(-30017) */
|
40
|
-
#define
|
40
|
+
#define CT_WRONG_FORMULA (CT_ERR_FIRST-18) /*(-30017) */
|
41
|
+
#define CT_UNKNOWN_ERR (CT_ERR_FIRST-19) /*(-30019) */
|
41
42
|
|
42
43
|
#define CT_ERR_MIN CT_UNKNOWN_ERR
|
43
44
|
#define CT_ERR_MAX CT_ERR_FIRST
|
@@ -60,6 +61,7 @@
|
|
60
61
|
#define BNS_CAP_FLOW_ERR (BNS_ERR + 10) /*(-9989)*/
|
61
62
|
#define BNS_RADICAL_ERR (BNS_ERR + 11) /*(-9988)*/
|
62
63
|
#define BNS_REINIT_ERR (BNS_ERR + 12) /*(-9987)*/
|
64
|
+
#define BNS_ALTBOND_ERR (BNS_ERR + 13) /*(-9986)*/
|
63
65
|
|
64
66
|
#define BNS_MAX_ERR_VALUE (BNS_ERR + 19) /*(-9980)*/
|
65
67
|
|
data/ext/src/ichiisot.c
CHANGED
data/ext/src/ichimain.c
ADDED
@@ -0,0 +1,461 @@
|
|
1
|
+
/*
|
2
|
+
* International Union of Pure and Applied Chemistry (IUPAC)
|
3
|
+
* International Chemical Identifier (InChI)
|
4
|
+
* Version 1
|
5
|
+
* Software version 1.01
|
6
|
+
* July 21, 2006
|
7
|
+
* Developed at NIST
|
8
|
+
*/
|
9
|
+
|
10
|
+
#include "mode.h"
|
11
|
+
|
12
|
+
#ifndef INCHI_ANSI_ONLY
|
13
|
+
#ifndef INCHI_LIB
|
14
|
+
#include <windows.h>
|
15
|
+
#endif
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include <stdio.h>
|
19
|
+
#include <stdlib.h>
|
20
|
+
|
21
|
+
#ifndef INCHI_ANSI_ONLY
|
22
|
+
#include <conio.h>
|
23
|
+
#endif
|
24
|
+
|
25
|
+
#include <string.h>
|
26
|
+
#include <ctype.h>
|
27
|
+
#include <stdarg.h>
|
28
|
+
#include <errno.h>
|
29
|
+
#include <limits.h>
|
30
|
+
#include <float.h>
|
31
|
+
|
32
|
+
#include "ichitime.h"
|
33
|
+
#include "inpdef.h"
|
34
|
+
#include "ichi.h"
|
35
|
+
#include "strutil.h"
|
36
|
+
#include "util.h"
|
37
|
+
#include "ichidrp.h"
|
38
|
+
#include "ichierr.h"
|
39
|
+
#include "ichimain.h"
|
40
|
+
|
41
|
+
#include "ichicomp.h"
|
42
|
+
|
43
|
+
#if( ADD_CMLPP == 1 )
|
44
|
+
#include "readcml.hpp"
|
45
|
+
#endif
|
46
|
+
|
47
|
+
/* console-specific */
|
48
|
+
#ifndef INCHI_ANSI_ONLY
|
49
|
+
/********************************************************************/
|
50
|
+
int user_quit( const char *msg, unsigned long ulMaxTime )
|
51
|
+
{
|
52
|
+
#ifdef INCHI_LIB
|
53
|
+
return 0;
|
54
|
+
#endif
|
55
|
+
#if( defined(_WIN32) && !defined(INCHI_LIB) )
|
56
|
+
int quit, enter, ret;
|
57
|
+
printf(msg);
|
58
|
+
if ( ulMaxTime ) {
|
59
|
+
inchiTime ulEndTime;
|
60
|
+
InchiTimeGet( &ulEndTime );
|
61
|
+
InchiTimeAddMsec( &ulEndTime, ulMaxTime );
|
62
|
+
while ( !_kbhit() ) {
|
63
|
+
if ( bInchiTimeIsOver( &ulEndTime ) ) {
|
64
|
+
printf("\n");
|
65
|
+
return 0;
|
66
|
+
}
|
67
|
+
MySleep( 100 );
|
68
|
+
}
|
69
|
+
}
|
70
|
+
while( 1 ) {
|
71
|
+
quit = ( 'q' == (ret = _getch()) || 'Q'==ret || /*Esc*/ 27==ret );
|
72
|
+
enter = ( '\r' == ret );
|
73
|
+
if ( ret == 0xE0 )
|
74
|
+
ret = _getch();
|
75
|
+
else {
|
76
|
+
_putch(ret); /* echo */
|
77
|
+
}
|
78
|
+
if ( quit || enter )
|
79
|
+
break;
|
80
|
+
printf( "\r" );
|
81
|
+
printf( msg );
|
82
|
+
}
|
83
|
+
|
84
|
+
_putch('\n');
|
85
|
+
return quit;
|
86
|
+
#else
|
87
|
+
return 0;
|
88
|
+
#endif
|
89
|
+
}
|
90
|
+
/*****************************************************************/
|
91
|
+
void eat_keyboard_input( void )
|
92
|
+
{
|
93
|
+
#ifndef INCHI_LIB
|
94
|
+
while ( _kbhit() ) {
|
95
|
+
if ( 0xE0 == _getch() )
|
96
|
+
_getch();
|
97
|
+
}
|
98
|
+
#endif
|
99
|
+
}
|
100
|
+
#endif /* ifndef INCHI_ANSI_ONLY */
|
101
|
+
|
102
|
+
#ifdef INCHI_ANSI_ONLY
|
103
|
+
/*****************************************************************/
|
104
|
+
int user_quit( const char *msg, unsigned long ulMaxTime )
|
105
|
+
{
|
106
|
+
return 0;
|
107
|
+
}
|
108
|
+
/*****************************************************************/
|
109
|
+
void eat_keyboard_input( void )
|
110
|
+
{
|
111
|
+
}
|
112
|
+
#endif
|
113
|
+
|
114
|
+
|
115
|
+
/*****************************************************************/
|
116
|
+
#ifndef INCHI_LIB
|
117
|
+
|
118
|
+
int bInterrupted = 0;
|
119
|
+
#if( defined( _WIN32 ) && defined( _CONSOLE ) )
|
120
|
+
|
121
|
+
#ifndef INCHI_ANSI_ONLY
|
122
|
+
BOOL WINAPI MyHandlerRoutine(
|
123
|
+
DWORD dwCtrlType /* control signal type */
|
124
|
+
) {
|
125
|
+
if ( dwCtrlType == CTRL_C_EVENT ||
|
126
|
+
dwCtrlType == CTRL_BREAK_EVENT ||
|
127
|
+
dwCtrlType == CTRL_CLOSE_EVENT ||
|
128
|
+
dwCtrlType == CTRL_LOGOFF_EVENT ) {
|
129
|
+
bInterrupted = 1;
|
130
|
+
return TRUE;
|
131
|
+
}
|
132
|
+
return FALSE;
|
133
|
+
}
|
134
|
+
int WasInterrupted(void) {
|
135
|
+
#ifdef _DEBUG
|
136
|
+
if ( bInterrupted ) {
|
137
|
+
int stop=1; /* for debug only <BRKPT> */
|
138
|
+
}
|
139
|
+
#endif
|
140
|
+
return bInterrupted;
|
141
|
+
}
|
142
|
+
#endif
|
143
|
+
|
144
|
+
#endif
|
145
|
+
|
146
|
+
#define REPEAT_ALL 0
|
147
|
+
/*#define TEST_FPTRS*/ /* uncomment for INCHI_LIB testing only */
|
148
|
+
/********************************************************************/
|
149
|
+
int run( int argc, char **argv);
|
150
|
+
|
151
|
+
int run( int argc, char **argv)
|
152
|
+
{
|
153
|
+
|
154
|
+
STRUCT_DATA struct_data;
|
155
|
+
STRUCT_DATA *sd = &struct_data;
|
156
|
+
FILE *inp_file = NULL, *output_file = NULL, *log_file = NULL, *prb_file = NULL;
|
157
|
+
char szTitle[MAX_SDF_HEADER+MAX_SDF_VALUE+256];
|
158
|
+
/* long rcPict[4] = {0,0,0,0}; */
|
159
|
+
|
160
|
+
int i;
|
161
|
+
long num_err, num_output;
|
162
|
+
long num_inp;
|
163
|
+
char szSdfDataValue[MAX_SDF_VALUE+1];
|
164
|
+
|
165
|
+
PINChI2 *pINChI[INCHI_NUM];
|
166
|
+
PINChI_Aux2 *pINChI_Aux[INCHI_NUM];
|
167
|
+
|
168
|
+
unsigned long ulDisplTime = 0; /* infinite, milliseconds */
|
169
|
+
unsigned long ulTotalProcessingTime = 0;
|
170
|
+
/*long fPtrStart=0L, fPtrEnd=0L;*/
|
171
|
+
INPUT_PARMS inp_parms;
|
172
|
+
INPUT_PARMS *ip = &inp_parms;
|
173
|
+
|
174
|
+
ORIG_ATOM_DATA OrigAtData; /* 0=> disconnected, 1=> original */
|
175
|
+
ORIG_ATOM_DATA *orig_inp_data = &OrigAtData;
|
176
|
+
ORIG_ATOM_DATA PrepAtData[2]; /* 0=> disconnected, 1=> original */
|
177
|
+
ORIG_ATOM_DATA *prep_inp_data = PrepAtData;
|
178
|
+
int bReleaseVersion = bRELEASE_VERSION;
|
179
|
+
const int nStrLen = INCHI_SEGM_BUFLEN;
|
180
|
+
char *pStr = NULL;
|
181
|
+
int nRet = 0, nRet1;
|
182
|
+
|
183
|
+
#ifndef TEST_FPTRS
|
184
|
+
STRUCT_FPTRS *pStructPtrs = NULL;
|
185
|
+
#else
|
186
|
+
STRUCT_FPTRS struct_fptrs, *pStructPtrs =&struct_fptrs; /* INCHI_LIB debug only */
|
187
|
+
#endif
|
188
|
+
|
189
|
+
#if ( defined(REPEAT_ALL) && REPEAT_ALL > 0 )
|
190
|
+
int num_repeat = REPEAT_ALL;
|
191
|
+
#endif
|
192
|
+
|
193
|
+
|
194
|
+
#if( TRACE_MEMORY_LEAKS == 1 )
|
195
|
+
_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
|
196
|
+
/* for execution outside the VC++ debugger uncomment one of the following two */
|
197
|
+
/*#define MY_REPORT_FILE _CRTDBG_FILE_STDERR */
|
198
|
+
/*#define MY_REPORT_FILE _CRTDBG_FILE_STDOUT */
|
199
|
+
#ifdef MY_REPORT_FILE
|
200
|
+
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
|
201
|
+
_CrtSetReportFile( _CRT_WARN, MY_REPORT_FILE );
|
202
|
+
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
|
203
|
+
_CrtSetReportFile( _CRT_ERROR, MY_REPORT_FILE );
|
204
|
+
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
205
|
+
_CrtSetReportFile( _CRT_ASSERT, MY_REPORT_FILE );
|
206
|
+
#else
|
207
|
+
_CrtSetReportMode(_CRT_WARN | _CRT_ERROR, _CRTDBG_MODE_DEBUG);
|
208
|
+
#endif
|
209
|
+
/* turn on floating point exceptions */
|
210
|
+
{
|
211
|
+
/* Get the default control word. */
|
212
|
+
int cw = _controlfp( 0,0 );
|
213
|
+
|
214
|
+
/* Set the exception masks OFF, turn exceptions on. */
|
215
|
+
/*cw &=~(EM_OVERFLOW|EM_UNDERFLOW|EM_INEXACT|EM_ZERODIVIDE|EM_DENORMAL);*/
|
216
|
+
cw &=~(EM_OVERFLOW|EM_UNDERFLOW|EM_ZERODIVIDE|EM_DENORMAL);
|
217
|
+
|
218
|
+
/* Set the control word. */
|
219
|
+
_controlfp( cw, MCW_EM );
|
220
|
+
|
221
|
+
}
|
222
|
+
#endif
|
223
|
+
/*
|
224
|
+
inp_norm_data[0] = &InpNormAtData;
|
225
|
+
inp_norm_data[1] = &InpNormTautData;
|
226
|
+
inp_norm_data[2] = &InpNormAtDataR;
|
227
|
+
inp_norm_data[3] = &InpNormTautDataR;
|
228
|
+
*/
|
229
|
+
#if ( defined(REPEAT_ALL) && REPEAT_ALL > 0 )
|
230
|
+
repeat:
|
231
|
+
inp_file = output_file = log_file = prb_file = NULL;
|
232
|
+
pStr = NULL;
|
233
|
+
#endif
|
234
|
+
|
235
|
+
num_inp = 0;
|
236
|
+
num_err = 0;
|
237
|
+
num_output = 0;
|
238
|
+
sd->bUserQuit = 0;
|
239
|
+
|
240
|
+
#if( defined( _WIN32 ) && defined( _CONSOLE ) && !defined( INCHI_ANSI_ONLY ) )
|
241
|
+
if ( SetConsoleCtrlHandler( MyHandlerRoutine, 1 ) ) {
|
242
|
+
ConsoleQuit = WasInterrupted;
|
243
|
+
}
|
244
|
+
#endif
|
245
|
+
|
246
|
+
|
247
|
+
if ( argc == 1 || argc==2 && ( argv[1][0]==INCHI_OPTION_PREFX ) &&
|
248
|
+
(!strcmp(argv[1]+1, "?") || !stricmp(argv[1]+1, "help") ) ) {
|
249
|
+
//HelpCommandLineParms(stdout);
|
250
|
+
return 0;
|
251
|
+
}
|
252
|
+
/* original input structure */
|
253
|
+
memset( orig_inp_data , 0, sizeof( *orig_inp_data ) );
|
254
|
+
memset( prep_inp_data , 0, 2*sizeof( *prep_inp_data ) );
|
255
|
+
memset( pINChI, 0, sizeof(pINChI ) );
|
256
|
+
memset( pINChI_Aux, 0, sizeof(pINChI_Aux) );
|
257
|
+
|
258
|
+
/*
|
259
|
+
memset( inp_cur_data , 0, sizeof( *inp_cur_data ) );
|
260
|
+
memset( inp_norm_data[0] , 0, sizeof( *inp_norm_data[0] ) );
|
261
|
+
memset( inp_norm_data[1] , 0, sizeof( *inp_norm_data[0] ) );
|
262
|
+
*/
|
263
|
+
memset( szSdfDataValue , 0, sizeof( szSdfDataValue ) );
|
264
|
+
|
265
|
+
/* explicitly cast to (const char **) to avoid a warning about "incompatible pointer type":*/
|
266
|
+
if ( 0 > ReadCommandLineParms( argc, (const char **)argv, ip, szSdfDataValue, &ulDisplTime, bReleaseVersion, stderr ) ) {
|
267
|
+
goto exit_function;
|
268
|
+
}
|
269
|
+
if ( !OpenFiles( &inp_file, &output_file, &log_file, &prb_file, ip ) ) {
|
270
|
+
goto exit_function;
|
271
|
+
}
|
272
|
+
if ( ip->bNoStructLabels ) {
|
273
|
+
ip->pSdfLabel = NULL;
|
274
|
+
ip->pSdfValue = NULL;
|
275
|
+
} else
|
276
|
+
if ( ip->nInputType == INPUT_INCHI_XML || ip->nInputType == INPUT_INCHI_PLAIN ||
|
277
|
+
ip->nInputType == INPUT_CMLFILE || ip->nInputType == INPUT_INCHI ) {
|
278
|
+
/* the input may contain both the header and the label of the structure */
|
279
|
+
if ( !ip->pSdfLabel )
|
280
|
+
ip->pSdfLabel = ip->szSdfDataHeader;
|
281
|
+
if ( !ip->pSdfValue )
|
282
|
+
ip->pSdfValue = szSdfDataValue;
|
283
|
+
}
|
284
|
+
//PrintInputParms( log_file, ip );
|
285
|
+
if ( !(pStr = (char*)inchi_malloc(nStrLen))) {
|
286
|
+
my_fprintf( log_file, "Cannot allocate output buffer. Terminating\n");
|
287
|
+
goto exit_function;
|
288
|
+
}
|
289
|
+
pStr[0] = '\0';
|
290
|
+
|
291
|
+
#if( READ_INCHI_STRING == 1 )
|
292
|
+
if ( ip->nInputType == INPUT_INCHI ) {
|
293
|
+
memset( sd, 0, sizeof(*sd) );
|
294
|
+
ReadWriteInChI( inp_file, output_file, log_file, ip, sd, NULL, NULL, NULL, 0, NULL);
|
295
|
+
ulTotalProcessingTime = sd->ulStructTime;
|
296
|
+
num_inp = sd->fPtrStart;
|
297
|
+
num_err = sd->fPtrEnd;
|
298
|
+
goto exit_function;
|
299
|
+
}
|
300
|
+
#endif
|
301
|
+
/**********************************************************************************************/
|
302
|
+
/* Main cycle */
|
303
|
+
/* read input structures and create their INChI */
|
304
|
+
ulTotalProcessingTime = 0;
|
305
|
+
|
306
|
+
if ( pStructPtrs ) {
|
307
|
+
memset ( pStructPtrs, 0, sizeof(pStructPtrs[0]) );
|
308
|
+
/* debug: set CML reading sequence
|
309
|
+
pStructPtrs->fptr = (INCHI_FPTR *)inchi_calloc(16, sizeof(INCHI_FPTR));
|
310
|
+
for ( i = 0; i < 15; i ++ )
|
311
|
+
pStructPtrs->fptr[i] = 15-i;
|
312
|
+
pStructPtrs->cur_fptr = 7;
|
313
|
+
pStructPtrs->len_fptr = 16;
|
314
|
+
pStructPtrs->max_fptr = 14;
|
315
|
+
*/
|
316
|
+
}
|
317
|
+
|
318
|
+
while ( !sd->bUserQuit && !bInterrupted ) {
|
319
|
+
if ( ip->last_struct_number && num_inp >= ip->last_struct_number ) {
|
320
|
+
nRet = _IS_EOF; /* simulate end of file */
|
321
|
+
goto exit_function;
|
322
|
+
}
|
323
|
+
|
324
|
+
/* read one structure from input and display optionally it */
|
325
|
+
nRet = GetOneStructure( sd, ip, szTitle, inp_file, log_file, output_file, prb_file,
|
326
|
+
orig_inp_data, &num_inp, pStr, nStrLen, pStructPtrs );
|
327
|
+
|
328
|
+
if ( pStructPtrs ) {
|
329
|
+
pStructPtrs->cur_fptr ++;
|
330
|
+
}
|
331
|
+
|
332
|
+
if ( sd->bUserQuit ) {
|
333
|
+
break;
|
334
|
+
}
|
335
|
+
switch ( nRet ) {
|
336
|
+
case _IS_FATAL:
|
337
|
+
num_err ++;
|
338
|
+
case _IS_EOF:
|
339
|
+
goto exit_function;
|
340
|
+
case _IS_ERROR:
|
341
|
+
num_err ++;
|
342
|
+
case _IS_SKIP:
|
343
|
+
continue;
|
344
|
+
}
|
345
|
+
|
346
|
+
/* create INChI for each connected component of the structure and optionally display them */
|
347
|
+
/* output INChI for the whole structure */
|
348
|
+
nRet1 = ProcessOneStructure( sd, ip, szTitle, pINChI, pINChI_Aux,
|
349
|
+
inp_file, log_file, output_file, prb_file,
|
350
|
+
orig_inp_data, prep_inp_data,
|
351
|
+
num_inp, pStr, nStrLen );
|
352
|
+
|
353
|
+
/* free INChI memory */
|
354
|
+
FreeAllINChIArrays( pINChI, pINChI_Aux, sd->num_components );
|
355
|
+
/* free structure data */
|
356
|
+
FreeOrigAtData( orig_inp_data );
|
357
|
+
FreeOrigAtData( prep_inp_data );
|
358
|
+
FreeOrigAtData( prep_inp_data+1 );
|
359
|
+
|
360
|
+
ulTotalProcessingTime += sd->ulStructTime;
|
361
|
+
nRet = inchi_max(nRet, nRet1);
|
362
|
+
switch ( nRet ) {
|
363
|
+
case _IS_FATAL:
|
364
|
+
num_err ++;
|
365
|
+
goto exit_function;
|
366
|
+
case _IS_ERROR:
|
367
|
+
num_err ++;
|
368
|
+
continue;
|
369
|
+
}
|
370
|
+
/* --- debug only ---
|
371
|
+
if ( pStructPtrs->cur_fptr > 5 ) {
|
372
|
+
pStructPtrs->cur_fptr = 5;
|
373
|
+
}
|
374
|
+
*/
|
375
|
+
|
376
|
+
}
|
377
|
+
|
378
|
+
exit_function:
|
379
|
+
if ( (ip->bINChIOutputOptions & INCHI_OUT_XML) && sd->bXmlStructStarted > 0 ) {
|
380
|
+
if ( !OutputINChIXmlStructEndTag( output_file, pStr, nStrLen, 1 ) ) {
|
381
|
+
my_fprintf( log_file, "Cannot create end xml tag for structure #%ld.%s%s%s%s Terminating.\n", num_inp, SDF_LBL_VAL(ip->pSdfLabel,ip->pSdfValue) );
|
382
|
+
sd->bXmlStructStarted = -1; /* do not repeat same message */
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
|
387
|
+
if ( (ip->bINChIOutputOptions & INCHI_OUT_XML) && ip->bXmlStarted ) {
|
388
|
+
OutputINChIXmlRootEndTag( output_file );
|
389
|
+
ip->bXmlStarted = 0;
|
390
|
+
}
|
391
|
+
|
392
|
+
|
393
|
+
/* avoid memory leaks in case of fatal error */
|
394
|
+
if ( pStructPtrs && pStructPtrs->fptr ) {
|
395
|
+
inchi_free( pStructPtrs->fptr );
|
396
|
+
}
|
397
|
+
|
398
|
+
/* free INChI memory */
|
399
|
+
FreeAllINChIArrays( pINChI, pINChI_Aux, sd->num_components );
|
400
|
+
/* free structure data */
|
401
|
+
FreeOrigAtData( orig_inp_data );
|
402
|
+
FreeOrigAtData( prep_inp_data );
|
403
|
+
FreeOrigAtData( prep_inp_data+1 );
|
404
|
+
|
405
|
+
#if( ADD_CMLPP == 1 )
|
406
|
+
/* BILLY 8/6/04 */
|
407
|
+
/* free CML memory */
|
408
|
+
FreeCml ();
|
409
|
+
FreeCmlDoc( 1 );
|
410
|
+
#endif
|
411
|
+
|
412
|
+
if ( inp_file && inp_file != stdin) {
|
413
|
+
fclose ( inp_file );
|
414
|
+
}
|
415
|
+
if ( prb_file ) {
|
416
|
+
fclose ( prb_file );
|
417
|
+
}
|
418
|
+
if ( output_file && output_file != stdout ) {
|
419
|
+
fclose( output_file );
|
420
|
+
}
|
421
|
+
|
422
|
+
if ( log_file )
|
423
|
+
{
|
424
|
+
int hours, minutes, seconds, mseconds;
|
425
|
+
SplitTime( ulTotalProcessingTime, &hours, &minutes, &seconds, &mseconds );
|
426
|
+
//my_fprintf( log_file, "Finished processing %ld structure%s: %ld error%s, processing time %d:%02d:%02d.%02d\n",
|
427
|
+
// num_inp, num_inp==1?"":"s",
|
428
|
+
// num_err, num_err==1?"":"s",
|
429
|
+
// hours, minutes, seconds,mseconds/10);
|
430
|
+
}
|
431
|
+
if ( log_file && log_file != stderr ) {
|
432
|
+
fclose( log_file );
|
433
|
+
}
|
434
|
+
if ( pStr ) {
|
435
|
+
inchi_free( pStr );
|
436
|
+
}
|
437
|
+
for ( i = 0; i < MAX_NUM_PATHS; i ++ ) {
|
438
|
+
if ( ip->path[i] ) {
|
439
|
+
inchi_free( (void*) ip->path[i] ); /* cast deliberately discards 'const' qualifier */
|
440
|
+
ip->path[i] = NULL;
|
441
|
+
}
|
442
|
+
}
|
443
|
+
SetBitFree( );
|
444
|
+
|
445
|
+
#if ( defined(REPEAT_ALL) && REPEAT_ALL > 0 )
|
446
|
+
if ( num_repeat-- > 0 ) {
|
447
|
+
goto repeat;
|
448
|
+
}
|
449
|
+
#endif
|
450
|
+
|
451
|
+
#if( bRELEASE_VERSION != 1 && defined(_DEBUG) )
|
452
|
+
if ( inp_file && inp_file != stdin ) {
|
453
|
+
user_quit("Press Enter to exit ?", ulDisplTime);
|
454
|
+
}
|
455
|
+
#endif
|
456
|
+
|
457
|
+
|
458
|
+
return 0;
|
459
|
+
}
|
460
|
+
|
461
|
+
#endif /* ifndef INCHI_LIB */
|