int main(int argc,char *argv[]) { static char *desc[] = { "[TT]gmxdump[tt] reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),", "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]) or an energy", "file ([TT].ene[tt]/[TT].edr[tt]) and prints that to standard", "output in a readable format. This program is essential for", "checking your run input file in case of problems.[PAR]" }; t_filenm fnm[] = { { efTRN, "-f", NULL, ffOPTRD } }; #define NFILE asize(fnm) char *fn; /* Command line options */ CopyRight(stdout,argv[0]); parse_common_args(&argc,argv,0,NFILE,fnm,0,NULL, asize(desc),desc,0,NULL); if (ftp2bSet(efTRN,NFILE,fnm)) { fn = ftp2fn(efTRN,NFILE,fnm); printf("Going to open %s\n",fn); list_trn(fn); } gmx_thanx(stderr); return 0; }
int gmx_anadock(int argc, char *argv[]) { const char *desc[] = { "[THISMODULE] analyses the results of an Autodock run and clusters the", "structures together, based on distance or RMSD. The docked energy", "and free energy estimates are analysed, and for each cluster the", "energy statistics are printed.[PAR]", "An alternative approach to this is to cluster the structures first", "using [gmx-cluster] and then sort the clusters on either lowest", "energy or average energy." }; t_filenm fnm[] = { { efPDB, "-f", NULL, ffREAD }, { efXVG, "-od", "edocked", ffWRITE }, { efXVG, "-of", "efree", ffWRITE }, { efLOG, "-g", "anadock", ffWRITE } }; output_env_t oenv; #define NFILE asize(fnm) static gmx_bool bFree = FALSE, bRMS = TRUE; static real cutoff = 0.2; t_pargs pa[] = { { "-free", FALSE, etBOOL, {&bFree}, "Use Free energy estimate from autodock for sorting the classes" }, { "-rms", FALSE, etBOOL, {&bRMS}, "Cluster on RMS or distance" }, { "-cutoff", FALSE, etREAL, {&cutoff}, "Maximum RMSD/distance for belonging to the same cluster" } }; #define NPA asize(pa) FILE *fp; t_pdbfile **pdbf = NULL; int npdbf; if (!parse_common_args(&argc, argv, 0, NFILE, fnm, NPA, pa, asize(desc), desc, 0, NULL, &oenv)) { return 0; } fp = gmx_ffopen(opt2fn("-g", NFILE, fnm), "w"); please_cite(stdout, "Hetenyi2002b"); please_cite(fp, "Hetenyi2002b"); pdbf = read_em_all(opt2fn("-f", NFILE, fnm), &npdbf); analyse_em_all(npdbf, pdbf, opt2fn("-od", NFILE, fnm), opt2fn("-of", NFILE, fnm), oenv); cluster_em_all(fp, npdbf, pdbf, bFree, bRMS, cutoff); gmx_thanx(fp); gmx_ffclose(fp); return 0; }
int CommandLineModuleManager::run(int argc, char *argv[]) { int argOffset = 0; CommandLineModuleMap::const_iterator module = impl_->findModuleFromBinaryName(impl_->programInfo_); if (!impl_->bQuiet_) { printBinaryInformation(stderr, impl_->programInfo_); } if (module == impl_->modules_.end()) { if (argc < 2) { impl_->helpModule_->printUsage(); if (!impl_->bQuiet_) { gmx_thanx(stderr); } return 2; } module = impl_->findModuleByName(argv[1]); argOffset = 1; } if (module == impl_->modules_.end()) { fprintf(stderr, "Unknown command: '%s'\n\n", argv[1]); impl_->helpModule_->printUsage(); if (!impl_->bQuiet_) { gmx_thanx(stderr); } return 2; } int rc = module->second->run(argc - argOffset, argv + argOffset); if (!impl_->bQuiet_) { gmx_thanx(stderr); } return rc; }
int main(int argc,char *argv[]) { static char *desc[] = { "[TT]g_anavel[tt] computes temperature profiles in a sample. The sample", "can be analysed radial, i.e. the temperature as a function of", "distance from the center, cylindrical, i.e. as a function of distance", "from the vector (0,0,1) through the center of the box, or otherwise", "(will be specified later)" }; t_filenm fnm[] = { { efTRN, "-f", NULL, ffREAD }, { efTPX, "-s", NULL, ffREAD }, { efXPM, "-o", "xcm", ffWRITE } }; #define NFILE asize(fnm) static int mode = 0, nlevels = 10; static real tmax = 300, xmax = -1; t_pargs pa[] = { { "-mode", FALSE, etINT, {&mode}, "mode" }, { "-nlevels", FALSE, etINT, {&nlevels}, "number of levels" }, { "-tmax", FALSE, etREAL, {&tmax}, "max temperature in output" }, { "-xmax", FALSE, etREAL, {&xmax}, "max distance from center" } }; FILE *fp; int *npts,nmax; int status; int i,j,idum,step,nframe=0,index; real temp,rdum,hboxx,hboxy,scale,xnorm=0; real **profile=NULL; real *t_x=NULL,*t_y,hi=0; t_topology *top; int d,m,n; matrix box; atom_id *sysindex; gmx_bool bHaveV,bReadV; t_rgb rgblo = { 0, 0, 1 },rgbhi = { 1, 0, 0 }; int flags = TRX_READ_X | TRX_READ_V; t_trxframe fr; CopyRight(stderr,argv[0]); parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_BE_NICE ,NFILE,fnm, asize(pa),pa,asize(desc),desc,0,NULL); top = read_top(ftp2fn(efTPX,NFILE,fnm)); read_first_frame(&status,ftp2fn(efTRX,NFILE,fnm),&fr,flags); if (xmax > 0) { scale = 5; nmax = xmax*scale; } else { scale = 5; nmax = (0.5*sqrt(sqr(box[XX][XX])+sqr(box[YY][YY])))*scale; } snew(npts,nmax+1); snew(t_y,nmax+1); for(i=0; (i<=nmax); i++) { npts[i] = 0; t_y[i] = i/scale; } do { srenew(profile,++nframe); snew(profile[nframe-1],nmax+1); srenew(t_x,nframe); t_x[nframe-1] = fr.time*1000; hboxx = box[XX][XX]/2; hboxy = box[YY][YY]/2; for(i=0; (i<fr.natoms); i++) { /* determine position dependent on mode */ switch (mode) { case 0: xnorm = sqrt(sqr(fr.x[i][XX]-hboxx) + sqr(fr.x[i][YY]-hboxy)); break; default: gmx_fatal(FARGS,"Unknown mode %d",mode); } index = xnorm*scale; if (index <= nmax) { temp = top->atoms.atom[i].m*iprod(fr.v[i],fr.v[i])/(2*BOLTZ); if (temp > hi) hi = temp; npts[index]++; profile[nframe-1][index] += temp; } } for(i=0; (i<=nmax); i++) { if (npts[i] != 0) profile[nframe-1][i] /= npts[i]; npts[i] = 0; } } while (read_next_frame(status,&fr)); close_trx(status); fp = ftp2FILE(efXPM,NFILE,fnm,"w"); write_xpm(fp,0,"Temp. profile","T (a.u.)", "t (fs)","R (nm)", nframe,nmax+1,t_x,t_y,profile,0,tmax, rgblo,rgbhi,&nlevels); gmx_thanx(stderr); return 0; }
int main(int argc,char *argv[]) { const char *desc[] = { "[TT]do_multiprot[tt] ", "reads a trajectory file and aligns it to a reference structure ", "each time frame", "calling the multiprot program. This allows you to use a reference", "structure whose sequence is different than that of the protein in the ", "trajectory, since the alignment is based on the geometry, not sequence.", "The output of [TT]do_multiprot[tt] includes the rmsd and the number of residues", "on which it was calculated.", "[PAR]", "An aligned trajectory file is generated with the [TT]-ox[tt] option.[PAR]", "With the [TT]-cr[tt] option, the number of hits in the alignment is given", "per residue. This number can be between 0 and the number of frames, and", "indicates the structural conservation of this residue.[PAR]", "If you do not have the [TT]multiprot[tt] program, get it. [TT]do_multiprot[tt] assumes", "that the [TT]multiprot[tt] executable is [TT]/usr/local/bin/multiprot[tt]. If this is ", "not the case, then you should set an environment variable [BB]MULTIPROT[bb]", "pointing to the [TT]multiprot[tt] executable, e.g.: [PAR]", "[TT]setenv MULTIPROT /usr/MultiProtInstall/multiprot.Linux[tt][PAR]", "Note that at the current implementation only binary alignment (your", "molecule to a reference) is supported. In addition, note that the ", "by default [TT]multiprot[tt] aligns the two proteins on their C-alpha carbons.", "and that this depends on the [TT]multiprot[tt] parameters which are not dealt ", "with here. Thus, the C-alpha carbons is expected to give the same " "results as choosing the whole protein and will be slightly faster.[PAR]", "For information about [TT]multiprot[tt], see:", "http://bioinfo3d.cs.tau.ac.il/MultiProt/.[PAR]" }; static bool bVerbose; t_pargs pa[] = { { "-v", FALSE, etBOOL, {&bVerbose}, "HIDDENGenerate miles of useless information" } }; const char *bugs[] = { "The program is very slow, since multiprot is run externally" }; t_trxstatus *status; t_trxstatus *trxout=NULL; FILE *tapein,*fo,*frc,*tmpf,*out=NULL,*fres=NULL; const char *fnRef; const char *fn="2_sol.res"; t_topology top; int ePBC; t_atoms *atoms,ratoms,useatoms; t_trxframe fr; t_pdbinfo p; int nres,nres2,nr0; real t; int i,j,natoms,nratoms,nframe=0,model_nr=-1; int cur_res,prev_res; int nout; t_countres *countres=NULL; matrix box,rbox; int gnx; char *grpnm,*ss_str; atom_id *index; rvec *xp,*x,*xr; char pdbfile[32],refpdb[256],title[256],rtitle[256],filemode[5]; char out_title[256]; char multiprot[256],*mptr; int ftp; int outftp=-1; real rmsd; bool bTrjout,bCountres; const char *TrjoutFile=NULL; output_env_t oenv; static rvec translation={0,0,0},rotangles={0,0,0}; gmx_rmpbc_t gpbc=NULL; t_filenm fnm[] = { { efTRX, "-f", NULL, ffREAD }, { efTPS, NULL, NULL, ffREAD }, { efNDX, NULL, NULL, ffOPTRD }, { efSTX, "-r", NULL , ffREAD }, { efXVG, "-o", "rmss", ffWRITE }, { efXVG, "-rc", "rescount", ffWRITE}, { efXVG, "-cr", "countres", ffOPTWR}, { efTRX, "-ox", "aligned", ffOPTWR } }; #define NFILE asize(fnm) CopyRight(stderr,argv[0]); parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW | PCA_TIME_UNIT, NFILE,fnm, asize(pa),pa, asize(desc),desc, asize(bugs),bugs,&oenv ); fnRef=opt2fn("-r",NFILE,fnm); bTrjout = opt2bSet("-ox",NFILE,fnm); bCountres= opt2bSet("-cr",NFILE,fnm); if (bTrjout) { TrjoutFile = opt2fn_null("-ox",NFILE,fnm); } read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&ePBC,&xp,NULL,box,FALSE); gpbc = gmx_rmpbc_init(&top.idef,ePBC,top.atoms.nr,box); atoms=&(top.atoms); ftp=fn2ftp(fnRef); get_stx_coordnum(fnRef,&nratoms); init_t_atoms(&ratoms,nratoms,TRUE); snew(xr,nratoms); read_stx_conf(fnRef,rtitle,&ratoms,xr,NULL,&ePBC,rbox); if (bVerbose) { fprintf(stderr,"Read %d atoms\n",atoms->nr); fprintf(stderr,"Read %d reference atoms\n",ratoms.nr); } if (bCountres) { snew(countres,ratoms.nres); j=0; cur_res=0; for (i=0;i<ratoms.nr;i++) { prev_res=cur_res; cur_res=ratoms.atom[i].resind; if (cur_res != prev_res) { countres[j].resnr=cur_res; countres[j].count=0; j++; } } } get_index(atoms,ftp2fn_null(efNDX,NFILE,fnm),1,&gnx,&index,&grpnm); nres=0; nr0=-1; for(i=0; (i<gnx); i++) { if (atoms->atom[index[i]].resind != nr0) { nr0=atoms->atom[index[i]].resind; nres++; } } fprintf(stderr,"There are %d residues in your selected group\n",nres); strcpy(pdbfile,"ddXXXXXX"); gmx_tmpnam(pdbfile); if ((tmpf = fopen(pdbfile,"w")) == NULL) { sprintf(pdbfile,"%ctmp%cfilterXXXXXX",DIR_SEPARATOR,DIR_SEPARATOR); gmx_tmpnam(pdbfile); if ((tmpf = fopen(pdbfile,"w")) == NULL) { gmx_fatal(FARGS,"Can not open tmp file %s",pdbfile); } } else { gmx_ffclose(tmpf); } if (ftp != efPDB) { strcpy(refpdb,"ddXXXXXX"); gmx_tmpnam(refpdb); strcat(refpdb,".pdb"); write_sto_conf(refpdb,rtitle,&ratoms,xr,NULL,ePBC,rbox); } else { strcpy(refpdb,fnRef); } if ((mptr=getenv("MULTIPROT")) == NULL) { mptr="/usr/local/bin/multiprot"; } if (!gmx_fexist(mptr)) { gmx_fatal(FARGS,"MULTIPROT executable (%s) does not exist (use setenv MULTIPROT)", mptr); } sprintf (multiprot,"%s %s %s > /dev/null %s", mptr, refpdb, pdbfile, "2> /dev/null"); if (bVerbose) fprintf(stderr,"multiprot cmd='%s'\n",multiprot); if (!read_first_frame(oenv,&status,ftp2fn(efTRX,NFILE,fnm),&fr,TRX_READ_X)) gmx_fatal(FARGS,"Could not read a frame from %s",ftp2fn(efTRX,NFILE,fnm)); natoms = fr.natoms; if (bTrjout) { nout=natoms; /* open file now */ outftp=fn2ftp(TrjoutFile); if (bVerbose) fprintf(stderr,"Will write %s: %s\n",ftp2ext(ftp),ftp2desc(outftp)); strcpy(filemode,"w"); switch (outftp) { case efXTC: case efG87: case efTRR: case efTRJ: out=NULL; trxout = open_trx(TrjoutFile,filemode); break; case efGRO: case efG96: case efPDB: /* Make atoms struct for output in GRO or PDB files */ /* get memory for stuff to go in pdb file */ init_t_atoms(&useatoms,nout,FALSE); sfree(useatoms.resinfo); useatoms.resinfo=atoms->resinfo; for(i=0;(i<nout);i++) { useatoms.atomname[i]=atoms->atomname[i]; useatoms.atom[i]=atoms->atom[i]; useatoms.nres=max(useatoms.nres,useatoms.atom[i].resind+1); } useatoms.nr=nout; out=gmx_ffopen(TrjoutFile,filemode); break; } } if (natoms > atoms->nr) { gmx_fatal(FARGS,"\nTrajectory does not match topology!"); } if (gnx > natoms) { gmx_fatal(FARGS,"\nTrajectory does not match selected group!"); } fo = xvgropen(opt2fn("-o",NFILE,fnm),"RMSD","Time (ps)","RMSD (nm)",oenv); frc = xvgropen(opt2fn("-rc",NFILE,fnm),"Number of Residues in the alignment","Time (ps)","Residues",oenv); do { t = output_env_conv_time(oenv,fr.time); gmx_rmpbc(gpbc,natoms,fr.box,fr.x); tapein=gmx_ffopen(pdbfile,"w"); write_pdbfile_indexed(tapein,NULL,atoms,fr.x,ePBC,fr.box,' ',-1,gnx,index,NULL,TRUE); gmx_ffclose(tapein); system(multiprot); remove(pdbfile); process_multiprot_output(fn, &rmsd, &nres2,rotangles,translation,bCountres,countres); fprintf(fo,"%12.7f",t); fprintf(fo," %12.7f\n",rmsd); fprintf(frc,"%12.7f",t); fprintf(frc,"%12d\n",nres2); if (bTrjout) { rotate_conf(natoms,fr.x,NULL,rotangles[XX],rotangles[YY],rotangles[ZZ]); for(i=0; i<natoms; i++) { rvec_inc(fr.x[i],translation); } switch(outftp) { case efTRJ: case efTRR: case efG87: case efXTC: write_trxframe(trxout,&fr,NULL); break; case efGRO: case efG96: case efPDB: sprintf(out_title,"Generated by do_multiprot : %s t= %g %s", title,output_env_conv_time(oenv,fr.time),output_env_get_time_unit(oenv)); switch(outftp) { case efGRO: write_hconf_p(out,out_title,&useatoms,prec2ndec(fr.prec), fr.x,NULL,fr.box); break; case efPDB: fprintf(out,"REMARK GENERATED BY DO_MULTIPROT\n"); sprintf(out_title,"%s t= %g %s",title,output_env_conv_time(oenv,fr.time),output_env_get_time_unit(oenv)); /* if reading from pdb, we want to keep the original model numbering else we write the output frame number plus one, because model 0 is not allowed in pdb */ if (ftp==efPDB && fr.step > model_nr) { model_nr = fr.step; } else { model_nr++; } write_pdbfile(out,out_title,&useatoms,fr.x,ePBC,fr.box,' ',model_nr,NULL,TRUE); break; case efG96: fr.title = out_title; fr.bTitle = (nframe == 0); fr.bAtoms = FALSE; fr.bStep = TRUE; fr.bTime = TRUE; write_g96_conf(out,&fr,-1,NULL); } break; } } nframe++; } while(read_next_frame(oenv,status,&fr)); if (bCountres) { fres= xvgropen(opt2fn("-cr",NFILE,fnm),"Number of frames in which the residues are aligned to","Residue","Number",oenv); for (i=0;i<ratoms.nres;i++) { fprintf(fres,"%10d %12d\n",countres[i].resnr,countres[i].count); } gmx_ffclose(fres); } gmx_ffclose(fo); gmx_ffclose(frc); fprintf(stderr,"\n"); close_trj(status); if (trxout != NULL) { close_trx(trxout); } else if (out != NULL) { gmx_ffclose(out); } view_all(oenv,NFILE, fnm); sfree(xr); if (bCountres) { sfree(countres); } free_t_atoms(&ratoms,TRUE); if (bTrjout) { if (outftp==efPDB || outftp==efGRO || outftp==efG96) { free_t_atoms(&useatoms,TRUE); } } gmx_thanx(stderr); return 0; }
int CommandLineModuleManager::run(int argc, char *argv[]) { CommandLineModuleInterface *module; const bool bMaster = (gmx_node_rank() == 0); bool bQuiet = impl_->bQuiet_ || !bMaster; CommandLineCommonOptionsHolder optionsHolder; try { optionsHolder.initOptions(); module = impl_->processCommonOptions(&optionsHolder, &argc, &argv); } catch (const std::exception &) { bQuiet |= optionsHolder.shouldBeQuiet(); if (!bQuiet) { printBinaryInformation(stderr, impl_->programContext_, optionsHolder.binaryInfoSettings()); } throw; } bQuiet |= optionsHolder.shouldBeQuiet(); if (!bQuiet) { FILE *out = optionsHolder.startupInfoFile(); printBinaryInformation(out, impl_->programContext_, optionsHolder.binaryInfoSettings()); fprintf(out, "\n"); } if (module == NULL) { return 0; } CommandLineModuleSettings settings; module->init(&settings); optionsHolder.adjustFromSettings(settings); gmx_set_max_backup_count(optionsHolder.shouldBackup() ? -1 : 0); // Open the debug file. if (optionsHolder.debugLevel() > 0) { std::string filename(impl_->programContext_.programName()); if (gmx_node_num() > 1) { filename.append(formatString("%d", gmx_node_rank())); } filename.append(".debug"); fprintf(stderr, "Will write debug log file: %s\n", filename.c_str()); gmx_init_debug(optionsHolder.debugLevel(), filename.c_str()); } // Set the nice level unless disabled in the configuration. if (optionsHolder.niceLevel() != 0) { static bool bNiceSet = false; // Only set it once. if (!bNiceSet) { // TODO: Diagnostic if this fails and the user explicitly requested it. gmx_set_nice(optionsHolder.niceLevel()); bNiceSet = true; } } if (optionsHolder.enableFPExceptions()) { //TODO: currently it is always enabled for mdrun (verlet) and tests. gmx_feenableexcept(); } int rc = 0; if (!(module == impl_->helpModule_ && !bMaster)) { rc = module->run(argc, argv); } if (!bQuiet) { gmx_thanx(stderr); } return rc; }
int main(int argc, char *argv[]) { t_symtab tab; static char *desc[] = { "[TT]hexamer[tt] takes a single input coordinate file and makes five symmetry", "related copies." }; #define NPA asize(pa) t_filenm fnm[] = { { efSTX, "-f", NULL, ffREAD }, { efPDB, "-o", NULL, ffWRITE } }; #define NFILE asize(fnm) gmx_bool bCenter = FALSE; gmx_bool bTrimer = FALSE; gmx_bool bAlternate = FALSE; real rDist = 0,rAngleZ = 0,rAngleX = 0, alterz = 0; t_pargs pa[] = { { "-center", FALSE, etBOOL, {&bCenter}, "Center molecule on Z-axis first" }, { "-trimer", FALSE, etBOOL, {&bTrimer}, "Make trimer rather than hexamer" }, { "-alternate",FALSE, etBOOL, {&bAlternate}, "Turn every other molecule upside down" }, { "-alterz", FALSE, etREAL, {&alterz}, "Add this amount to Z-coordinate in every other molecule" }, { "-radius", FALSE, etREAL, {&rDist}, "Distance of protein axis from Z-axis (implies [TT]-center[tt])" }, { "-anglez", FALSE, etREAL, {&rAngleZ}, "Initial angle of rotation around Z-axis of protein" }, { "-anglex", FALSE, etREAL, {&rAngleX}, "Initial angle of rotation around X-axis of protein" } }; #define NPA asize(pa) FILE *fp; int i,iout,now,natom; rvec *xin,*vin,*xout; matrix box; t_atoms atoms,aout; char *infile,*outfile,title[256],buf[32]; CopyRight(stderr,argv[0]); parse_common_args(&argc,argv,0,NFILE,fnm,NPA,pa, asize(desc),desc,0,NULL); bCenter = bCenter || (rDist > 0) || bAlternate; infile = ftp2fn(efSTX,NFILE,fnm); outfile = ftp2fn(efPDB,NFILE,fnm); get_stx_coordnum(infile,&natom); init_t_atoms(&atoms,natom,TRUE); snew(xin,natom); snew(xout,natom); snew(vin,natom); read_stx_conf(infile,title,&atoms,xin,vin,box); printf("Read %d atoms\n",atoms.nr); if (bCenter) prep_x(atoms.nr,xin,rDist,rAngleZ,rAngleX); fp = gmx_ffopen(outfile,"w"); for(i=0; (i<(bTrimer ? 3 : 6)); i++) { rotate_x(atoms.nr,xin,i*(bTrimer ? 120.0 : 60.0),xout,TRUE, bAlternate && ((i % 2) != 0),alterz*(((i % 2) == 0) ? 0 : 1)); sprintf(buf,"Rotated %d degrees",i*(bTrimer ? 120 : 60)); write_pdbfile(fp,buf,&atoms,xout,box,'A'+i,1+i); } gmx_ffclose(fp); gmx_thanx(stderr); return 0; }
int main(int argc,char *argv[]) { static char *desc[] = { "[TT]do_shift[tt] reads a trajectory file and computes the chemical", "shift for each time frame (or every [BB]dt[bb] ps) by", "calling the 'total' program. If you do not have the total program,", "get it. do_shift assumes that the total executable is in", "[TT]/home/mdgroup/total/total[tt]. If that is not the case, then you should", "set an environment variable [BB]TOTAL[bb] as in: [PAR]", "[TT]setenv TOTAL /usr/local/bin/total[tt][PAR]", "where the right hand side should point to the total executable.[PAR]", "Output is printed in files [TT]shift.out[tt] where t is the time of the frame.[PAR]", "The program also needs an input file called [BB]random.dat[bb] which", "contains the random coil chemical shifts of all protons." }; static real dt=0.0; t_pargs pa[] = { { "-dt", FALSE, etREAL, { &dt }, "Time interval between frames." } }; static char *bugs[] = { "The program is very slow" }; static char *OXYGEN="O"; FILE *out,*tot,*fp; t_topology *top; t_atoms *atoms; int status,nres; real t,nt; int i,natoms,nframe=0; matrix box; int gnx; char *grpnm,*randf; atom_id *index; rvec *x,*x_s; char pdbfile[32],tmpfile[32]; char total[256],*dptr; t_filenm fnm[] = { { efTRX, "-f", NULL, ffREAD }, { efTPX, NULL, NULL, ffREAD }, { efNDX, NULL, NULL, ffREAD }, { efOUT, "-o", "shift", ffWRITE }, { efDAT, "-d", "random", ffREAD } }; char *leg[] = { "shift","ring","anisCO","anisCN","sigmaE","sum" }; #define NFILE asize(fnm) CopyRight(stdout,argv[0]); parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_BE_NICE ,NFILE,fnm, asize(pa),pa,asize(desc),desc,asize(bugs),bugs); top=read_top(ftp2fn(efTPX,NFILE,fnm)); atoms=&(top->atoms); nres=atoms->nres; for(i=0; (i<atoms->nr); i++) if ((strcmp(*atoms->atomname[i],"O1") == 0) || (strcmp(*atoms->atomname[i],"O2") == 0) || (strcmp(*atoms->atomname[i],"OXT") == 0) || (strcmp(*atoms->atomname[i],"OT") == 0)) atoms->atomname[i]=&OXYGEN; rd_index(ftp2fn(efNDX,NFILE,fnm),1,&gnx,&index,&grpnm); snew(x_s,atoms->nr); strcpy(pdbfile,"dsXXXXXX"); gmx_tmpnam(pdbfile); strcpy(tmpfile,"dsXXXXXX"); gmx_tmpnam(tmpfile); fprintf(stderr,"pdbfile = %s\ntmpfile = %s\n",pdbfile,tmpfile); if ((dptr=getenv("TOTAL")) == NULL) dptr="/home/mdgroup/total/total"; sprintf(total,"%s > /dev/null",dptr); fprintf(stderr,"total cmd='%s'\n",total); randf=ftp2fn(efDAT,NFILE,fnm); natoms=read_first_x(&status,ftp2fn(efTRX,NFILE,fnm),&t,&x,box); if (natoms != atoms->nr) gmx_fatal(FARGS,"Trajectory does not match topology!"); out=ftp2FILE(efOUT,NFILE,fnm,"w"); xvgr_legend(out,asize(leg),leg); nt=t; do { if (t >= nt) { rm_pbc(&(top->idef),top->atoms.nr,box,x,x_s); fp=gmx_ffopen(pdbfile,"w"); write_pdbfile_indexed(fp,"Generated by do_shift", atoms,x_s,box,0,-1,gnx,index); gmx_ffclose(fp); if ((tot=popen(total,"w")) == NULL) perror("opening pipe to total"); fprintf(tot,"%s\n",pdbfile); fprintf(tot,"%s\n",tmpfile); fprintf(tot,"3\n"); fprintf(tot,"N\n"); fprintf(tot,"%s\n",randf); fprintf(tot,"N\n"); fprintf(tot,"N\n"); if (pclose(tot) != 0) perror("closing pipe to total"); cat(out,tmpfile,t); remove(pdbfile); remove(tmpfile); nt+=dt; nframe++; } } while(read_next_x(status,&t,natoms,x,box)); close_trj(status); gmx_ffclose(out); gmx_thanx(stderr); return 0; }
int gmx_sdf(int argc,char *argv[]) { const char *desc[] = { "[TT]g_sdf[tt] calculates the spatial distribution function (SDF) of a set of atoms", "within a coordinate system defined by three atoms. There is single body, ", "two body and three body SDF implemented (select with option [TT]-mode[tt]). ", "In the single body case the local coordinate system is defined by using", "a triple of atoms from one single molecule, for the two and three body case", "the configurations are dynamically searched complexes of two or three", "molecules (or residues) meeting certain distance consitions (see below).[PAR]", "The program needs a trajectory, a GROMACS run input file and an index ", "file to work. ", "You have to setup 4 groups in the index file before using g_sdf: [PAR]", "The first three groups are used to define the SDF coordinate system.", "The program will dynamically generate the atom triples according to ", "the selected [TT]-mode[tt]: ", "In [TT]-mode[tt] 1 the triples will be just the 1st, 2nd, 3rd, ... atoms from ", "groups 1, 2 and 3. Hence the nth entries in groups 1, 2 and 3 must be from the", "same residue. In [TT]-mode[tt] 2 the triples will be 1st, 2nd, 3rd, ... atoms from", "groups 1 and 2 (with the nth entries in groups 1 and 2 having the same res-id).", "For each pair from groups 1 and 2 group 3 is searched for an atom meeting the", "distance conditions set with [TT]-triangle[tt] and [TT]-dtri[tt] relative to atoms 1 and 2. In", "[TT]-mode[tt] 3 for each atom in group 1 group 2 is searched for an atom meeting the", "distance condition and if a pair is found group 3 is searched for an atom", "meeting the further conditions. The triple will only be used if all three atoms", "have different res-id's.[PAR]", "The local coordinate system is always defined using the following scheme:", "Atom 1 will be used as the point of origin for the SDF. ", "Atom 1 and 2 will define the principle axis (Z) of the coordinate system.", "The other two axis will be defined inplane (Y) and normal (X) to the plane through", "Atoms 1, 2 and 3. ", "The fourth group", "contains the atoms for which the SDF will be evaluated.[PAR]", "For [TT]-mode[tt] 2 and 3 you have to define the distance conditions for the ", "2 resp. 3 molecule complexes to be searched for using [TT]-triangle[tt] and [TT]-dtri[tt].[PAR]", "The SDF will be sampled in cartesian coordinates.", "Use [TT]-grid x y z[tt] to define the size of the SDF grid around the ", "reference molecule. ", "The Volume of the SDF grid will be V=x*y*z (nm^3). ", "Use [TT]-bin[tt] to set the binwidth for grid.[PAR]", "The output will be a binary 3D-grid file ([TT]gom_plt.dat[tt]) in the [TT].plt[tt] format that can be be", "read directly by gOpenMol. ", "The option [TT]-r[tt] will generate a [TT].gro[tt] file with the reference molecule(s) transferred to", "the SDF coordinate system. Load this file into gOpenMol and display the", "SDF as a contour plot (see http://www.csc.fi/gopenmol/index.phtml for ", "further documentation). [PAR]", "For further information about SDF's have a look at: A. Vishnyakov, JPC A, 105,", "2001, 1702 and the references cited within." }; output_env_t oenv; static gmx_bool bRef=FALSE; static int mode=1; static rvec triangle={0.0,0.0,0.0}; static rvec dtri={0.03,0.03,0.03}; static rvec cutoff={1,1,1}; static real binwidth=0.05; t_pargs pa[] = { { "-mode", FALSE, etINT, {&mode}, "SDF in [1,2,3] particle mode"}, { "-triangle", FALSE, etRVEC, {&triangle}, "r(1,3), r(2,3), r(1,2)"}, { "-dtri", FALSE, etRVEC, {&dtri}, "dr(1,3), dr(2,3), dr(1,2)"}, { "-bin", FALSE, etREAL, {&binwidth}, "Binwidth for the 3D-grid (nm)" }, { "-grid", FALSE, etRVEC, {&cutoff}, "Size of the 3D-grid (nm,nm,nm)"} }; #define NPA asize(pa) const char *fnTPS,*fnNDX,*fnREF; t_filenm fnm[] = { { efTRX, "-f", NULL, ffREAD }, { efNDX, NULL, NULL, ffREAD }, { efTPS, NULL, NULL, ffOPTRD }, { efDAT, "-o", "gom_plt", ffWRITE }, { efSTO, "-r", "refmol", ffOPTWR }, }; #define NFILE asize(fnm) CopyRight(stderr,argv[0]); parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_BE_NICE, NFILE,fnm,NPA,pa,asize(desc),desc,0,NULL,&oenv); fnTPS = ftp2fn_null(efTPS,NFILE,fnm); fnNDX = ftp2fn_null(efNDX,NFILE,fnm); fnREF = opt2fn_null("-r",NFILE,fnm); bRef = opt2bSet("-r",NFILE,fnm); if (!fnNDX) gmx_fatal(FARGS,"No index file specified\n" " Nothing to do!"); if (!fnTPS) gmx_fatal(FARGS,"No topology file specified\n" " Nothing to do!"); if ( bRef && (fn2ftp(fnREF) != efGRO)) { fprintf(stderr,"\nOnly GROMACS format is supported for reference structures.\n"); fprintf(stderr,"Option -r will be ignored!\n"); bRef = FALSE; } if ((mode < 1) || (mode > 3)) gmx_fatal(FARGS,"Wrong -mode selection. Chose 1-, 2- oder 3-particle mode.\n"); do_sdf(fnNDX,fnTPS,ftp2fn(efTRX,NFILE,fnm),opt2fn("-o",NFILE,fnm), fnREF,bRef,cutoff,binwidth,mode,triangle,dtri,oenv); gmx_thanx(stderr); return 0; }
int main(int argc,char *argv[]) { static char *desc[] = { "[TT]compnl[tt] compares two neighborlists as generated by [TT]mdrun[tt]", "in the log file, when the environment variable DUMPNL is set to", "a number larger than 0. [TT]compnl[tt] is mainly used for debugging the", "[TT]mdrun[tt] internals and not for end-users." }; FILE *in,*out; int i,j,nmiss,mod; char **fn,title[256]; int ***mat,nnb; real mb; gmx_bool bConf; rvec *x = NULL; rvec dx; matrix box; t_atoms atoms; t_pbc pbc; t_filenm fnm[] = { { efLOG, "-f1", NULL, ffREAD }, { efLOG, "-f2", NULL, ffREAD }, { efOUT, "-o", "compnl", ffWRITE }, { efSTX, "-c", NULL, ffOPTRD } }; #define NFILE asize(fnm) static int natoms=648; static gmx_bool bSymm=TRUE; static t_pargs pa[] = { { "-nat", FALSE, etINT, { &natoms }, "Number of atoms" }, { "-symm", FALSE, etBOOL,{ &bSymm }, "Symmetrize the matrices" }, }; CopyRight(stderr,argv[0]); parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa, asize(desc),desc,0,NULL); bConf = (opt2bSet("-c",NFILE,fnm)); if (bConf) { get_stx_coordnum (opt2fn("-c",NFILE,fnm),&natoms); init_t_atoms(&atoms,natoms,FALSE); snew(x,natoms); read_stx_conf(opt2fn("-c",NFILE,fnm),title,&atoms,x,NULL,box); set_pbc(&pbc,box); } snew(fn,2); fn[0] = opt2fn("-f1",NFILE,fnm); fn[1] = opt2fn("-f2",NFILE,fnm); snew(mat,2); out = gmx_fio_fopen(ftp2fn(efOUT,NFILE,fnm),"w"); mb = sizeof(int)*sqr(natoms/1024.0); for(i=0; (i<2); i++) { in = gmx_fio_fopen(fn[i],"r"); fprintf(stderr,"Reading %s\n",fn[i]); fprintf(out, "Reading %s\n",fn[i]); fprintf(stderr,"Going to allocate %.0f Mb of memory\n",mb); fprintf(out, "Going to allocate %.0f Mb of memory\n",mb); snew(mat[i],natoms); for(j=0; (j<natoms); j++) snew(mat[i][j],natoms); nnb = read_nblist(in,out,mat[i],natoms,bSymm); gmx_fio_fclose(in); fprintf(stderr,"Interaction matrix %d has %d entries\n",i,nnb); fprintf(out, "Interaction matrix %d has %d entries\n",i,nnb); } fprintf(stderr,"Comparing Interaction Matrices\n"); mod=1; nmiss = 0; for(i=0; (i<natoms); i+=mod) { for(j=0; (j<natoms); j+=mod) { if (mat[0][i][j] != mat[1][i][j]) { fprintf(out,"i: %5d, j: %5d, shift[%s]: %3d, shift[%s]: %3d", i,j,fn[0],mat[0][i][j]-1,fn[1],mat[1][i][j]-1); if (bConf) { pbc_dx(&pbc,x[i],x[j],dx); fprintf(out," dist: %8.3f\n",norm(dx)); } else fprintf(out,"\n"); nmiss++; } } } fprintf(out,"There were %d mismatches\n",nmiss); fprintf(out,"Done.\n"); gmx_fio_fclose(out); fprintf(stderr,"There were %d mismatches\n",nmiss); fprintf(stderr,"Finished\n"); gmx_thanx(stdout); return 0; }
int main(int argc,char *argv[]) { static char *desc[] = { "The [TT]pmetest[tt] program tests the scaling of the PME code. When only given", "a [TT].tpr[tt] file it will compute PME for one frame. When given a trajectory", "it will do so for all the frames in the trajectory. Before the PME", "routine is called the coordinates are sorted along the X-axis.[PAR]", "As an extra service to the public the program can also compute", "long-range Coulomb energies for components of the system. When the", "[TT]-groups[tt] flag is given to the program the energy groups", "from the [TT].tpr[tt] file will be read, and half an energy matrix computed." }; t_commrec *cr,*mcr; static t_filenm fnm[] = { { efTPX, NULL, NULL, ffREAD }, { efTRN, "-o", NULL, ffWRITE }, { efLOG, "-g", "pme", ffWRITE }, { efTRX, "-f", NULL, ffOPTRD }, { efXVG, "-x", "ener-pme", ffWRITE } }; #define NFILE asize(fnm) /* Command line options ! */ static gmx_bool bVerbose=FALSE; static gmx_bool bOptFFT=FALSE; static gmx_bool bSort=FALSE; static int ewald_geometry=eewg3D; static int nnodes=1; static int pme_order=0; static rvec grid = { -1, -1, -1 }; static real rc = 0.0; static real dtol = 0.0; static gmx_bool bGroups = FALSE; static t_pargs pa[] = { { "-np", FALSE, etINT, {&nnodes}, "Number of nodes, must be the same as used for [TT]grompp[tt]" }, { "-v", FALSE, etBOOL,{&bVerbose}, "Be loud and noisy" }, { "-sort", FALSE, etBOOL,{&bSort}, "Sort coordinates. Crucial for domain decomposition." }, { "-grid", FALSE, etRVEC,{&grid}, "Number of grid cells in X, Y, Z dimension (if -1 use from [TT].tpr[tt])" }, { "-order", FALSE, etINT, {&pme_order}, "Order of the PME spreading algorithm" }, { "-groups", FALSE, etBOOL, {&bGroups}, "Compute half an energy matrix based on the energy groups in your [TT].tpr[tt] file" }, { "-rc", FALSE, etREAL, {&rc}, "Rcoulomb for Ewald summation" }, { "-tol", FALSE, etREAL, {&dtol}, "Tolerance for Ewald summation" } }; FILE *fp; t_inputrec *ir; t_topology top; t_tpxheader tpx; t_nrnb nrnb; t_nsborder *nsb; t_forcerec *fr; t_mdatoms *mdatoms; char title[STRLEN]; int natoms,step,status,i,ncg,root; real t,lambda,ewaldcoeff,qtot; rvec *x,*f,*xbuf; int *index; gmx_bool bCont; real *charge,*qbuf,*qqbuf; matrix box; /* Start the actual parallel code if necessary */ cr = init_par(&argc,&argv); root = 0; if (MASTER(cr)) CopyRight(stderr,argv[0]); /* Parse command line on all processors, arguments are passed on in * init_par (see above) */ parse_common_args(&argc,argv, PCA_KEEP_ARGS | PCA_NOEXIT_ON_ARGS | PCA_BE_NICE | PCA_CAN_SET_DEFFNM | (MASTER(cr) ? 0 : PCA_QUIET), NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL); #ifndef GMX_MPI if (nnodes > 1) gmx_fatal(FARGS,"GROMACS compiled without MPI support - can't do parallel runs"); #endif /* Open log files on all processors */ open_log(ftp2fn(efLOG,NFILE,fnm),cr); snew(ir,1); if (MASTER(cr)) { /* Read tpr file etc. */ read_tpxheader(ftp2fn(efTPX,NFILE,fnm),&tpx,FALSE,NULL,NULL); snew(x,tpx.natoms); read_tpx(ftp2fn(efTPX,NFILE,fnm),&step,&t,&lambda,ir, box,&natoms,x,NULL,NULL,&top); /* Charges */ qtot = 0; snew(charge,natoms); for(i=0; (i<natoms); i++) { charge[i] = top.atoms.atom[i].q; qtot += charge[i]; } /* Grid stuff */ if (opt2parg_bSet("-grid",asize(pa),pa)) { ir->nkx = grid[XX]; ir->nky = grid[YY]; ir->nkz = grid[ZZ]; } /* Check command line parameters for consistency */ if ((ir->nkx <= 0) || (ir->nky <= 0) || (ir->nkz <= 0)) gmx_fatal(FARGS,"PME grid = %d %d %d",ir->nkx,ir->nky,ir->nkz); if (opt2parg_bSet("-rc",asize(pa),pa)) ir->rcoulomb = rc; if (ir->rcoulomb <= 0) gmx_fatal(FARGS,"rcoulomb should be > 0 (not %f)",ir->rcoulomb); if (opt2parg_bSet("-order",asize(pa),pa)) ir->pme_order = pme_order; if (ir->pme_order <= 0) gmx_fatal(FARGS,"pme_order should be > 0 (not %d)",ir->pme_order); if (opt2parg_bSet("-tol",asize(pa),pa)) ir->ewald_rtol = dtol; if (ir->ewald_rtol <= 0) gmx_fatal(FARGS,"ewald_tol should be > 0 (not %f)",ir->ewald_rtol); } else { init_top(&top); } /* Add parallellization code here */ snew(nsb,1); if (MASTER(cr)) { ncg = top.blocks[ebCGS].multinr[0]; for(i=0; (i<cr->nnodes-1); i++) top.blocks[ebCGS].multinr[i] = min(ncg,(ncg*(i+1))/cr->nnodes); for( ; (i<MAXNODES); i++) top.blocks[ebCGS].multinr[i] = ncg; } if (PAR(cr)) { /* Set some variables to zero to avoid core dumps */ ir->opts.ngtc = ir->opts.ngacc = ir->opts.ngfrz = ir->opts.ngener = 0; #ifdef GMX_MPI /* Distribute the data over processors */ MPI_Bcast(&natoms,1,MPI_INT,root,MPI_COMM_WORLD); MPI_Bcast(ir,sizeof(*ir),MPI_BYTE,root,MPI_COMM_WORLD); MPI_Bcast(&qtot,1,GMX_MPI_REAL,root,MPI_COMM_WORLD); #endif /* Call some dedicated communication routines, master sends n-1 times */ if (MASTER(cr)) { for(i=1; (i<cr->nnodes); i++) { mv_block(i,&(top.blocks[ebCGS])); mv_block(i,&(top.atoms.excl)); } } else { ld_block(root,&(top.blocks[ebCGS])); ld_block(root,&(top.atoms.excl)); } if (!MASTER(cr)) { snew(charge,natoms); snew(x,natoms); } #ifdef GMX_MPI MPI_Bcast(charge,natoms,GMX_MPI_REAL,root,MPI_COMM_WORLD); #endif } ewaldcoeff = calc_ewaldcoeff(ir->rcoulomb,ir->ewald_rtol); if (bVerbose) pr_inputrec(stdlog,0,"Inputrec",ir); /* Allocate memory for temp arrays etc. */ snew(xbuf,natoms); snew(f,natoms); snew(qbuf,natoms); snew(qqbuf,natoms); snew(index,natoms); /* Initialize the PME code */ init_pme(stdlog,cr,ir->nkx,ir->nky,ir->nkz,ir->pme_order, natoms,FALSE,bOptFFT,ewald_geometry); /* MFlops accounting */ init_nrnb(&nrnb); /* Initialize the work division */ calc_nsb(stdlog,&(top.blocks[ebCGS]),cr->nnodes,nsb,0); nsb->nodeid = cr->nodeid; print_nsb(stdlog,"pmetest",nsb); /* Initiate forcerec */ mdatoms = atoms2md(stdlog,&top.atoms,ir->opts.nFreeze,ir->eI, ir->delta_t,0,ir->opts.tau_t,FALSE,FALSE); snew(fr,1); init_forcerec(stdlog,fr,ir,&top,cr,mdatoms,nsb,box,FALSE,NULL,NULL,FALSE); /* First do PME based on coordinates in tpr file, send them to * other processors if needed. */ if (MASTER(cr)) fprintf(stdlog,"-----\n" "Results based on tpr file %s\n",ftp2fn(efTPX,NFILE,fnm)); #ifdef GMX_MPI if (PAR(cr)) { MPI_Bcast(x[0],natoms*DIM,GMX_MPI_REAL,root,MPI_COMM_WORLD); MPI_Bcast(box[0],DIM*DIM,GMX_MPI_REAL,root,MPI_COMM_WORLD); MPI_Bcast(&t,1,GMX_MPI_REAL,root,MPI_COMM_WORLD); } #endif do_my_pme(stdlog,0,bVerbose,ir,x,xbuf,f,charge,qbuf,qqbuf,box,bSort, cr,nsb,&nrnb,&(top.atoms.excl),qtot,fr,index,NULL, bGroups ? ir->opts.ngener : 1,mdatoms->cENER); /* If we have a trajectry file, we will read the frames in it and compute * the PME energy. */ if (ftp2bSet(efTRX,NFILE,fnm)) { fprintf(stdlog,"-----\n" "Results based on trx file %s\n",ftp2fn(efTRX,NFILE,fnm)); if (MASTER(cr)) { sfree(x); natoms = read_first_x(&status,ftp2fn(efTRX,NFILE,fnm),&t,&x,box); if (natoms != top.atoms.nr) gmx_fatal(FARGS,"natoms in trx = %d, in tpr = %d",natoms,top.atoms.nr); fp = xvgropen(ftp2fn(efXVG,NFILE,fnm),"PME Energy","Time (ps)","E (kJ/mol)"); } else fp = NULL; do { /* Send coordinates, box and time to the other nodes */ #ifdef GMX_MPI if (PAR(cr)) { MPI_Bcast(x[0],natoms*DIM,GMX_MPI_REAL,root,MPI_COMM_WORLD); MPI_Bcast(box[0],DIM*DIM,GMX_MPI_REAL,root,MPI_COMM_WORLD); MPI_Bcast(&t,1,GMX_MPI_REAL,root,MPI_COMM_WORLD); } #endif rm_pbc(&top.idef,nsb->natoms,box,x,x); /* Call the PME wrapper function */ do_my_pme(stdlog,t,bVerbose,ir,x,xbuf,f,charge,qbuf,qqbuf,box,bSort,cr, nsb,&nrnb,&(top.atoms.excl),qtot,fr,index,fp, bGroups ? ir->opts.ngener : 1,mdatoms->cENER); /* Only the master processor reads more data */ if (MASTER(cr)) bCont = read_next_x(status,&t,natoms,x,box); /* Check whether we need to continue */ #ifdef GMX_MPI if (PAR(cr)) MPI_Bcast(&bCont,1,MPI_INT,root,MPI_COMM_WORLD); #endif } while (bCont); /* Finish I/O, close files */ if (MASTER(cr)) { close_trx(status); ffclose(fp); } } if (bVerbose) { /* Do some final I/O about performance, might be useful in debugging */ fprintf(stdlog,"-----\n"); print_nrnb(stdlog,&nrnb); } /* Finish the parallel stuff */ if (gmx_parallel_env_initialized()) gmx_finalize(cr); /* Thank the audience, as usual */ if (MASTER(cr)) gmx_thanx(stderr); return 0; }