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