📄 cmdmode.cc
字号:
/* cmdmode.cc */#include <math.h>#ifdef sgi #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/times.h> #include <time.h> #include <string.h> #include <ctype.h> #include "cmdmode.h" #include "cmdtokens.h" #include "trjtokens.h"#else extern "C" { #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/times.h> #include <time.h> #include <string.h> #include <ctype.h> #include "cmdmode.h" #include "cmdtokens.h" #include "trjtokens.h" }#endifextern FILE *logFile;extern FILE *command_in_fp;extern FILE *command_out_fp;extern char *programname;extern char dock_param_fn[];extern char AutoDockHelp[];extern int oldpdbq;extern int ignore_errors;extern int keepresnum;extern int debug;extern int parse_tors_mode;int cmdmode( int natom, Clock jobStart, struct tms tms_jobStart, float xlo, float ylo, float zlo, float xhi, float yhi, float zhi, float inv_spacing, float map[MAX_GRID_PTS][MAX_GRID_PTS][MAX_GRID_PTS][MAX_MAPS], float e_internal[NEINT][ATOM_MAPS][ATOM_MAPS], float WallEnergy, float vt[MAX_TORS][SPACE], int tlist[MAX_TORS][MAX_ATOMS], int ntor, int Nnb, int nonbondlist[MAX_NONBONDS][2], char atomstuff[MAX_ATOMS][MAX_CHARS], float crdpdb[MAX_ATOMS][SPACE], char hostnm[MAX_CHARS], int type[MAX_ATOMS], float charge[MAX_ATOMS], Boole B_calcIntElec, float q1q2[MAX_NONBONDS], char atm_typ_str[ATOM_MAPS], float torsFreeEnergy){ char message[LINE_LEN], command[LINE_LEN], trjline[LINE_LEN], filename[MAX_CHARS], line[LINE_LEN], rec5[5], pdbaname[MAX_ATOMS][5], rec8[MAX_ATOMS][9], /* rec[X] gives (X+1) elements... */ rec14[MAX_ATOMS][15], trjFileName[MAX_CHARS], lastmove = '?'; int com_id = 0, nframes = 0, indpf = 0, offset[VECLENMAX], nat = 0, outside = FALSE, ntor_old = 0, keyword_id = -1, irun = -1, icycle = -1, nstep = 0, veclen = 0, movecode = -1; register int i = 0, ii = 0; Clock jobEnd; struct tms tms_jobEnd; float eintra = 0., einter = 0., etotal = 0., etot = 0., crd[MAX_ATOMS][SPACE], elec[MAX_ATOMS], emap[MAX_ATOMS], T = 0., charge_total = 0., emap_total = 0., elec_total = 0., E = 0., Eint = 0.; FILE *pdbFile, *trjFile; State S; for (i = 0; i < natom; i++) { strncpy( rec8[i], &atomstuff[i][13], ( size_t )8 ); strncpy( rec14[i], &atomstuff[i][6], ( size_t )14 ); }/* Set up the command file-pointers to standard i/o,*/ set_cmd_io_std(); pr_2x( logFile, stderr, UnderLine ); prStr( message, "%s: NOW IN COMMAND MODE.\n", programname ); pr_2x( logFile, stderr, message ); fflush( logFile ); fflush( stderr );/* Now read in the Commands...*/ while( ( fgets( command, LINE_LEN, command_in_fp ) ) != NULL ) {/* Parse the command line...*/ com_id = parse_com_line( command ); if ( com_id == -1 ) { pr( stderr, "%s: ERROR: Unrecognized command: \"%c%c%c%c\"\n", programname, command[0], command[1], command[2], command[3] ); continue; } /* endif *//* Act on that command...*/ switch( com_id ) {/* ____________________________________________________________________*/ case COM_NULL: pr( logFile, "%s\n", command ); break;/* ____________________________________________________________________*/ case COM_STOP:/* Write out AVS field-file suitable for "animating" a trajectory file.*/ pr( logFile, "\n\nTotal number of atoms = %d\n", natom ); pr( logFile, "Total number of trajectory frames = %d\n\n", nframes ); indpf = strindex( dock_param_fn, ".dpf" ); strncpy( filename, dock_param_fn, (size_t)indpf ); filename[ indpf ] = '\0'; strcat( filename, ".dlg.pdb\0" ); offset[0]=5; offset[1]=6; offset[2]=7; offset[3]=4; offset[4]=1; print_avsfld( logFile, 5, natom, nframes, offset, 8, "x y z ResidueNum AtomNum", filename ); pr( logFile, "COMMAND: stop\n\n" ); success( hostnm, jobStart, tms_jobStart ); return 0;/* ____________________________________________________________________*/ case COM_EPDB:/* EPDB filename flag Return the energy of the Small Molecule. filename must be in PDBQ-format; flag can be:- 0 = NEW, or PDBQ-71, and 1 = OLD, or PDBQ-55 (old PDBq format).*/ sscanf( command, "%*s %s %d", filename, &oldpdbq ); pr( logFile, "COMMAND: epdb %s %d\n\n", filename, oldpdbq ); nat = 0; eintra = einter = etotal = 0.; outside = FALSE; if (openFile(filename,"r",&pdbFile,jobStart,tms_jobStart,FALSE)) { while( ( fgets( line, LINE_LEN, pdbFile ) ) != NULL ) { for ( ii = 0; ii < 4; ii++ ) { rec5[ii] = (char) tolower( (int)line[ii] ); } if ( equal( rec5, "atom", 4 ) || equal( rec5, "heta", 4 ) ) { readPDBQLine( line, crd[nat], &charge[nat] ); strncpy( pdbaname[natom], &line[12], (size_t)4 ); type[nat]=get_atom_type( pdbaname[natom], atm_typ_str ); if ( type[nat] == -1 ) { jobEnd = times( &tms_jobEnd ); timesys( jobEnd - jobStart, &tms_jobStart, &tms_jobEnd ); pr_2x( logFile, stderr, UnderLine ); return -1; } /* endif */ outside = is_out_grid( crd[nat][X], crd[nat][Y], crd[nat][Z] ); nat++; } /* endif atom or hetatm */ } /* endwhile */ fclose( pdbFile ); natom = nat; if ( ntor > 0 ) { eintra = eintcalPrint( nonbondlist, e_internal, crd, type, Nnb, B_calcIntElec, q1q2 ); } else { eintra = 0.0; } if ( outside ) { etotal = (einter = WallEnergy) + eintra; } else { etotal = (einter = trilinterp( crd, charge, type, natom, map, inv_spacing, elec, emap, xlo, ylo, zlo )) + eintra; } /* endif */ pr( logFile, "\n\n\t\tIntermolecular Energy Analysis\n" ); pr( logFile, "\t\t==============================\n\n\n" ); pr( logFile, "Atom NB.+ Elec. Non-bonded Electrosta Partial Coordinates \n" ); pr( logFile, "Type Energy Energy tic Energy Charge x y z \n" ); pr( logFile, "____ __________ __________ __________ _______ ________ ________ ________\n" ); /* 1234 0123456789 0123456789 0123456789 1234567 12345678 12345678 12345678"*/ /* " --- ---------- ---------- ---------- ------- -------- -------- --------"*/ emap_total = 0.; elec_total = 0.; charge_total = 0.; for (i = 0; i < natom; i++) { etot = emap[i] + elec[i]; pr( logFile, "%4d %10.2f %10.2f %10.2f %7.3f %8.4f %8.4f %8.4f\n", (type[i]+1), etot, emap[i], elec[i], charge[i], crd[i][X], crd[i][Y], crd[i][Z] );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -