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