1 |
/* NOTICE: this source code file has been modified for use with FreeMOL */ |
2 |
|
3 |
#define notKEG_DEBUG |
4 |
|
5 |
#define EXTERN |
6 |
#include "pcwin.h" |
7 |
#include "pcmod.h" |
8 |
#include "energies.h" |
9 |
#include "pot.h" |
10 |
#include "angles.h" |
11 |
|
12 |
#include "rings.h" |
13 |
#include "torsions.h" |
14 |
#include "nonbond.h" |
15 |
#include "bonds_ff.h" |
16 |
#include "derivs.h" |
17 |
#include "hess.h" |
18 |
#include "field.h" |
19 |
#include "atom_k.h" |
20 |
#include "cutoffs.h" |
21 |
#include "solv.h" |
22 |
#include "gmmx.h" |
23 |
#include "fix.h" |
24 |
|
25 |
#include <stdio.h> |
26 |
#include <stdlib.h> |
27 |
#include <unistd.h> |
28 |
#include <string.h> |
29 |
//#include <malloc.h> |
30 |
|
31 |
struct t_rotbond { |
32 |
int nbonds, bond[200][2], bond_res[200]; |
33 |
int incl_amide, incl_alkene; |
34 |
} rotbond; |
35 |
struct t_minim_values { |
36 |
int iprint, ndc, nconst; |
37 |
float dielc; |
38 |
} minim_values; |
39 |
|
40 |
struct t_minim_control { |
41 |
int type, method, field, added_const; |
42 |
char added_path[256],added_name[256]; |
43 |
} minim_control; |
44 |
EXTERN struct t_files { |
45 |
int nfiles, append, batch, icurrent, ibatno; |
46 |
} files; |
47 |
char Savename[80]; |
48 |
|
49 |
/* |
50 |
void initialize_pcmodel(char*); |
51 |
void mmp22mod(int,int); |
52 |
void pcmfin(int, int); |
53 |
void initialize(void); |
54 |
void mmxsub(int); |
55 |
void check_numfile(int, char *); |
56 |
void mac2mod(int, int); |
57 |
void bbchk(void); |
58 |
void type(void); |
59 |
void initialize_gmmx(void); |
60 |
void read_gmmxinp(char*, char*, char*, FILE*, int); |
61 |
void run_gmmx(void); |
62 |
void search_rings(int); |
63 |
*/ |
64 |
|
65 |
|
66 |
void usage(void) { |
67 |
printf("\nUsage: mengine [-hvdxi] reads sdf on stdin, writes on stdout\n\n" |
68 |
"-h\tThis help page\n" |
69 |
"-v\tVerbose output\n" |
70 |
"-a\tAdd hydrogen atoms; delete existing ones\n" |
71 |
"-d\tEvaluate dipole moment\n" |
72 |
"-x\tEvaluate XlogP\n" |
73 |
"-i\tEvaluate vibrational data\n\n"); |
74 |
} |
75 |
|
76 |
/* ==================================================== */ |
77 |
int main(int argc, char *argv[]) |
78 |
{ |
79 |
int i; |
80 |
FILE *infile; |
81 |
char *line = NULL; |
82 |
|
83 |
char *infilename = NULL; |
84 |
char *outfilename = NULL; |
85 |
char *mmff94filename = NULL; |
86 |
char *mmxfilename = NULL; |
87 |
char *logfilename = NULL; |
88 |
|
89 |
int c; |
90 |
int flags = 0; |
91 |
|
92 |
while ((c = getopt(argc, argv, "e:o:p:c:havdxi")) != -1) { |
93 |
switch(c) { |
94 |
case 'a': |
95 |
flags = flags | DO_ADDH; |
96 |
break; |
97 |
case 'd': |
98 |
flags = flags | DO_DIPOLE; |
99 |
break; |
100 |
case 'x': |
101 |
flags = flags | DO_XLOGP; |
102 |
break; |
103 |
case 'i': |
104 |
flags = flags | DO_VIBRATION; |
105 |
break; |
106 |
case 'v': |
107 |
VERBOSE = 1; |
108 |
break; |
109 |
case 'h': |
110 |
usage(); |
111 |
exit(-1); |
112 |
case 'o': |
113 |
outfilename = strdup(optarg); |
114 |
break; |
115 |
#if 0 |
116 |
// EXTERNAL PARAM FILES STILL NOT WORKING |
117 |
// SOON THEY WILL |
118 |
case 'p': |
119 |
mmff94filename = strdup(optarg); |
120 |
break; |
121 |
case 'c': |
122 |
mmxfilename = strdup(optarg); |
123 |
break; |
124 |
#endif |
125 |
case 'e': |
126 |
logfilename = strdup(optarg); |
127 |
break; |
128 |
case '?': |
129 |
if (isprint (optopt)) |
130 |
fprintf (stderr, "Unknown option `-%c'.\n", optopt); |
131 |
else |
132 |
fprintf (stderr, |
133 |
"Unknown option character `\\x%x'.\n", |
134 |
optopt); |
135 |
return 1; |
136 |
default: |
137 |
abort (); |
138 |
} |
139 |
} |
140 |
|
141 |
argc -= optind; |
142 |
argv += optind; |
143 |
|
144 |
if (argc == 1) |
145 |
infilename = strdup(argv[0]); |
146 |
|
147 |
#ifdef KEG_DEBUG |
148 |
if(!infilename) |
149 |
infilename = strdup("caffeine.sdf"); |
150 |
if(!outfilename) |
151 |
outfilename = strdup("output.sdf"); |
152 |
#endif |
153 |
|
154 |
/* default behavior is to use the hardcoded parameter files */ |
155 |
|
156 |
if(!mmff94filename) mmff94filename = strdup("|mmff94"); /* hard-coded builtins */ |
157 |
if(!mmxfilename) mmxfilename = strdup("|mmxconst"); /* hard-coded builtins */ |
158 |
|
159 |
/* if no input file provide, then use standard input */ |
160 |
|
161 |
if(infilename) { |
162 |
infile = fopen(infilename,"rb"); |
163 |
} else { |
164 |
infile = stdin; |
165 |
} |
166 |
|
167 |
/* if no output file provided, then use standard output */ |
168 |
|
169 |
if(outfilename) { |
170 |
pcmoutfile = fopen(outfilename,"wb"); |
171 |
} else { |
172 |
pcmoutfile = stdout; |
173 |
} |
174 |
|
175 |
/* if no log file provided, then use standard error */ |
176 |
|
177 |
if(logfilename) { |
178 |
pcmlogfile = fopen(logfilename,"wb"); |
179 |
} else { |
180 |
pcmlogfile = stderr; |
181 |
} |
182 |
|
183 |
/* initialize the system using parameter file */ |
184 |
|
185 |
initialize_pcmodel(mmxfilename); |
186 |
initialize(); |
187 |
minim_values.iprint = 0; //FALSE; |
188 |
initialize_gmmx(); |
189 |
|
190 |
/* run the job */ |
191 |
|
192 |
if (infile) { |
193 |
read_gmmxinp(mmff94filename, infile, flags); |
194 |
} |
195 |
|
196 |
/* release temporary strings */ |
197 |
|
198 |
if(infilename) free(infilename); |
199 |
if(outfilename) free(outfilename); |
200 |
if(mmff94filename) free(mmff94filename); |
201 |
if(mmxfilename) free(mmxfilename); |
202 |
if(logfilename) free(logfilename); |
203 |
|
204 |
/* close file handles */ |
205 |
|
206 |
if(infile && (infile!=stdin)) fclose(infile); |
207 |
if(pcmoutfile && (pcmoutfile!=stdout)) fclose(pcmoutfile); |
208 |
if(pcmlogfile && (pcmlogfile!=stderr)) fclose(pcmlogfile); |
209 |
|
210 |
exit(0); |
211 |
} |