ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/mengine.c
Revision: 61
Committed: Mon Dec 1 22:23:40 2008 UTC (10 years, 8 months ago) by wdelano
File size: 4919 byte(s)
Log Message:
minor
Line User Rev File contents
1 tjod 48 /* NOTICE: this source code file has been modified for use with FreeMOL */
2 wdelano 58
3 wdelano 61 #define notKEG_DEBUG
4 wdelano 58
5 tjod 15 #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 tjod 34 //#include <malloc.h>
30 tjod 15
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 tjod 16
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 tjod 20 "-a\tAdd hydrogen atoms; delete existing ones\n"
71 tjod 16 "-d\tEvaluate dipole moment\n"
72     "-x\tEvaluate XlogP\n"
73     "-i\tEvaluate vibrational data\n\n");
74     }
75    
76 tjod 15 /* ==================================================== */
77     int main(int argc, char *argv[])
78     {
79     int i;
80 wdelano 58 FILE *infile;
81 tjod 15 char *line = NULL;
82    
83 wdelano 58 char *infilename = NULL;
84     char *outfilename = NULL;
85     char *mmff94filename = NULL;
86     char *mmxfilename = NULL;
87     char *logfilename = NULL;
88 tjod 15
89 wdelano 58 int c;
90 tjod 15 int flags = 0;
91    
92 tjod 20 while ((c = getopt(argc, argv, "e:o:p:c:havdxi")) != -1) {
93 tjod 16 switch(c) {
94 tjod 20 case 'a':
95     flags = flags | DO_ADDH;
96     break;
97 tjod 16 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 wdelano 58 outfilename = strdup(optarg);
114 tjod 16 break;
115 wdelano 58 #if 0
116     // EXTERNAL PARAM FILES STILL NOT WORKING
117 wdelano 60 // SOON THEY WILL
118 tjod 16 case 'p':
119 wdelano 58 mmff94filename = strdup(optarg);
120 tjod 16 break;
121     case 'c':
122 wdelano 58 mmxfilename = strdup(optarg);
123 tjod 16 break;
124 wdelano 58 #endif
125 tjod 16 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 wdelano 58 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 wdelano 60 }
174 wdelano 58
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 tjod 15 initialize();
187     minim_values.iprint = 0; //FALSE;
188     initialize_gmmx();
189    
190 wdelano 58 /* run the job */
191 tjod 15
192 wdelano 58 if (infile) {
193     read_gmmxinp(mmff94filename, infile, flags);
194     }
195 tjod 15
196 wdelano 58 /* release temporary strings */
197 tjod 15
198 wdelano 58 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 tjod 15 exit(0);
211     }