void read_atoms_neb(str255 infilename) { str255 fname; int i, k, n; /* keep a copy of the outfile name without replica suffix */ neb_outfilename = strdup(outfilename); /* read positions of initial configuration */ if (0==myrank) { sprintf(fname, "%s.%02d", infilename, 0); myrank = 1; /* avoid double info messages */ read_atoms(fname); myrank = 0; alloc_pos(); /* compute and write energy of initial configuration */ calc_forces(0); neb_image_energies[0]=tot_pot_energy; sprintf(outfilename, "%s.%02d", neb_outfilename, 0); write_eng_file_header(); write_eng_file(0); fclose(eng_file); eng_file = NULL; } /* read positions of final configuration */ else if (neb_nrep-1==myrank) { sprintf(fname, "%s.%02d", infilename, neb_nrep-1); read_atoms(fname); if (NULL==pos) alloc_pos(); /* compute and write energy of initial configuration */ calc_forces(0); neb_image_energies[ neb_nrep-1]=tot_pot_energy; sprintf(outfilename, "%s.%02d", neb_outfilename, neb_nrep-1); write_eng_file_header(); write_eng_file(0); fclose(eng_file); eng_file = NULL; } else { /* read positions of my configuration */ sprintf(fname, "%s.%02d", infilename, myrank); printf("rank: %d reading %s.%02d\n",myrank, infilename, myrank);fflush(stdout); read_atoms(fname); if (NULL==pos) alloc_pos(); sprintf(outfilename, "%s.%02d", neb_outfilename, myrank); } }
int main(int argc, char **argv) { int tablesize; int n,i,j,k,l; /* Read command line arguments */ read_command_line(argc,argv); /* Read Parameters from parameter file */ read_parameters(); tablesize = slots*ntypes*ntypes*ntypes*ntypes*sizeof(real); histogram = (real *) malloc(tablesize); if (NULL==histogram) error("Cannot allocate memory for histograms."); hist_dim.n = slots; hist_dim.i = ntypes; hist_dim.j = ntypes; hist_dim.k = ntypes; hist_dim.l = ntypes; for (n=0; n<slots; ++n) for (i=0; i<ntypes; ++i) for (j=0; j<ntypes; ++j) for (k=0; k<ntypes; ++k) for (l=0; l<ntypes; ++l) *PTR_5D_V(histogram,n,i,j,k,l,hist_dim) = 0.0; r2_cut = SQR(r_max); /* read box from file header */ if (box_from_header) read_box(infilename); /* Initialize cell data structures */ init_cells(); /* Read atoms */ read_atoms(infilename); /* Calculate the torsion angles */ calc_angles(); /* Output results */ write_data(); return 0; }
static struct classifier_config* read_config(FILE *input) { assert(input); struct file_range types_section, atoms_section; struct classifier_config *config = NULL; struct classifier_types *types = NULL; if (!(types = classifier_types_new()) || !(config = classifier_config_new()) || check_file(input, &types_section, &atoms_section) || read_types(types, input, types_section) || read_atoms(config, types, input, atoms_section) || config_copy_classes(config, types)) { classifier_config_free(config); config = NULL; } classifier_types_free(types); return config; }
int main(int argc, char **argv) { /* Read command line arguments */ read_command_line(argc,argv); /* Read Parameters from parameter file */ read_parameters(); /* read box from file header */ if (box_from_header) read_box(infilename); #ifdef TERSOFF /* Compute Tersoff parameters */ init_tersoff(); #endif /* Initialize cell data structures */ init_cells(); /* Read atoms */ read_atoms(infilename); /* Compute neighbour tables */ do_work(do_neighbour_tables); first = 0; do_work(do_neighbour_tables); /* Search for rings */ search_rings(); /* Output ring statistics */ write_data(); return 0; }
void read_resall(char *rrdb, int *nrtpptr, t_restp **rtp, gpp_atomtype_t atype, t_symtab *tab, gmx_bool bAllowOverrideRTP) { FILE *in; char filebase[STRLEN], line[STRLEN], header[STRLEN]; int i, nrtp, maxrtp, bt, nparam; int dum1, dum2, dum3; t_restp *rrtp, *header_settings; gmx_bool bNextResidue, bError; int firstrtp; fflib_filename_base(rrdb, filebase, STRLEN); in = fflib_open(rrdb); if (debug) { fprintf(debug, "%9s %5s", "Residue", "atoms"); for (i = 0; i < ebtsNR; i++) { fprintf(debug, " %10s", btsNames[i]); } fprintf(debug, "\n"); } snew(header_settings, 1); /* these bonded parameters will overwritten be when * * there is a [ bondedtypes ] entry in the .rtp file */ header_settings->rb[ebtsBONDS].type = 1; /* normal bonds */ header_settings->rb[ebtsANGLES].type = 1; /* normal angles */ header_settings->rb[ebtsPDIHS].type = 1; /* normal dihedrals */ header_settings->rb[ebtsIDIHS].type = 2; /* normal impropers */ header_settings->rb[ebtsEXCLS].type = 1; /* normal exclusions */ header_settings->rb[ebtsCMAP].type = 1; /* normal cmap torsions */ header_settings->bKeepAllGeneratedDihedrals = FALSE; header_settings->nrexcl = 3; header_settings->bGenerateHH14Interactions = TRUE; header_settings->bRemoveDihedralIfWithImproper = TRUE; /* Column 5 & 6 aren't really bonded types, but we include * them here to avoid introducing a new section: * Column 5 : This controls the generation of dihedrals from the bonding. * All possible dihedrals are generated automatically. A value of * 1 here means that all these are retained. A value of * 0 here requires generated dihedrals be removed if * * there are any dihedrals on the same central atoms * specified in the residue topology, or * * there are other identical generated dihedrals * sharing the same central atoms, or * * there are other generated dihedrals sharing the * same central bond that have fewer hydrogen atoms * Column 6: Number of bonded neighbors to exclude. * Column 7: Generate 1,4 interactions between two hydrogen atoms * Column 8: Remove proper dihedrals if centered on the same bond * as an improper dihedral */ get_a_line(in, line, STRLEN); if (!get_header(line, header)) { gmx_fatal(FARGS, "in .rtp file at line:\n%s\n", line); } if (gmx_strncasecmp("bondedtypes", header, 5) == 0) { get_a_line(in, line, STRLEN); if ((nparam = sscanf(line, "%d %d %d %d %d %d %d %d", &header_settings->rb[ebtsBONDS].type, &header_settings->rb[ebtsANGLES].type, &header_settings->rb[ebtsPDIHS].type, &header_settings->rb[ebtsIDIHS].type, &dum1, &header_settings->nrexcl, &dum2, &dum3)) < 4) { gmx_fatal(FARGS, "need 4 to 8 parameters in the header of .rtp file %s at line:\n%s\n", rrdb, line); } header_settings->bKeepAllGeneratedDihedrals = (dum1 != 0); header_settings->bGenerateHH14Interactions = (dum2 != 0); header_settings->bRemoveDihedralIfWithImproper = (dum3 != 0); get_a_line(in, line, STRLEN); if (nparam < 5) { fprintf(stderr, "Using default: not generating all possible dihedrals\n"); header_settings->bKeepAllGeneratedDihedrals = FALSE; } if (nparam < 6) { fprintf(stderr, "Using default: excluding 3 bonded neighbors\n"); header_settings->nrexcl = 3; } if (nparam < 7) { fprintf(stderr, "Using default: generating 1,4 H--H interactions\n"); header_settings->bGenerateHH14Interactions = TRUE; } if (nparam < 8) { fprintf(stderr, "Using default: removing proper dihedrals found on the same bond as a proper dihedral\n"); header_settings->bRemoveDihedralIfWithImproper = TRUE; } } else { fprintf(stderr, "Reading .rtp file without '[ bondedtypes ]' directive,\n" "Will proceed as if the entry was:\n"); print_resall_header(stderr, header_settings); } /* We don't know the current size of rrtp, but simply realloc immediately */ nrtp = *nrtpptr; rrtp = *rtp; maxrtp = nrtp; while (!feof(in)) { if (nrtp >= maxrtp) { maxrtp += 100; srenew(rrtp, maxrtp); } /* Initialise rtp entry structure */ rrtp[nrtp] = *header_settings; if (!get_header(line, header)) { gmx_fatal(FARGS, "in .rtp file at line:\n%s\n", line); } rrtp[nrtp].resname = gmx_strdup(header); rrtp[nrtp].filebase = gmx_strdup(filebase); get_a_line(in, line, STRLEN); bError = FALSE; bNextResidue = FALSE; do { if (!get_header(line, header)) { bError = TRUE; } else { bt = get_bt(header); if (bt != NOTSET) { /* header is an bonded directive */ bError = !read_bondeds(bt, in, line, &rrtp[nrtp]); } else if (gmx_strncasecmp("atoms", header, 5) == 0) { /* header is the atoms directive */ bError = !read_atoms(in, line, &(rrtp[nrtp]), tab, atype); } else { /* else header must be a residue name */ bNextResidue = TRUE; } } if (bError) { gmx_fatal(FARGS, "in .rtp file in residue %s at line:\n%s\n", rrtp[nrtp].resname, line); } } while (!feof(in) && !bNextResidue); if (rrtp[nrtp].natom == 0) { gmx_fatal(FARGS, "No atoms found in .rtp file in residue %s\n", rrtp[nrtp].resname); } if (debug) { fprintf(debug, "%3d %5s %5d", nrtp+1, rrtp[nrtp].resname, rrtp[nrtp].natom); for (i = 0; i < ebtsNR; i++) { fprintf(debug, " %10d", rrtp[nrtp].rb[i].nb); } fprintf(debug, "\n"); } firstrtp = -1; for (i = 0; i < nrtp; i++) { if (gmx_strcasecmp(rrtp[i].resname, rrtp[nrtp].resname) == 0) { firstrtp = i; } } if (firstrtp == -1) { nrtp++; fprintf(stderr, "\rResidue %d", nrtp); fflush(stderr); } else { if (firstrtp >= *nrtpptr) { gmx_fatal(FARGS, "Found a second entry for '%s' in '%s'", rrtp[nrtp].resname, rrdb); } if (bAllowOverrideRTP) { fprintf(stderr, "\n"); fprintf(stderr, "Found another rtp entry for '%s' in '%s', ignoring this entry and keeping the one from '%s.rtp'\n", rrtp[nrtp].resname, rrdb, rrtp[firstrtp].filebase); /* We should free all the data for this entry. * The current code gives a lot of dangling pointers. */ clear_t_restp(&rrtp[nrtp]); } else { gmx_fatal(FARGS, "Found rtp entries for '%s' in both '%s' and '%s'. If you want the first definition to override the second one, set the -rtpo option of pdb2gmx.", rrtp[nrtp].resname, rrtp[firstrtp].filebase, rrdb); } } } gmx_ffclose(in); /* give back unused memory */ srenew(rrtp, nrtp); fprintf(stderr, "\nSorting it all out...\n"); qsort(rrtp, nrtp, (size_t)sizeof(rrtp[0]), comprtp); check_rtp(nrtp, rrtp, rrdb); *nrtpptr = nrtp; *rtp = rrtp; }
void read_resall(char *rrdb, int *nrtpptr, t_restp **rtp, gpp_atomtype_t atype, t_symtab *tab, gmx_bool bAllowOverrideRTP) { FILE *in; char filebase[STRLEN],*ptr,line[STRLEN],header[STRLEN]; int i,nrtp,maxrtp,bt,nparam; int dum1,dum2,dum3; t_restp *rrtp; gmx_bool bNextResidue,bError; int bts[ebtsNR]; gmx_bool bAlldih; int nrexcl; gmx_bool HH14; gmx_bool bRemoveDih; int firstrtp; fflib_filename_base(rrdb,filebase,STRLEN); in = fflib_open(rrdb); if (debug) { fprintf(debug,"%9s %5s", "Residue", "atoms"); for(i=0; i<ebtsNR; i++) fprintf(debug," %10s",btsNames[i]); fprintf(debug,"\n"); } /* these bonded parameters will overwritten be when * * there is a [ bondedtypes ] entry in the .rtp file */ bts[ebtsBONDS] = 1; /* normal bonds */ bts[ebtsANGLES] = 1; /* normal angles */ bts[ebtsPDIHS] = 1; /* normal dihedrals */ bts[ebtsIDIHS] = 2; /* normal impropers */ bts[ebtsEXCLS] = 1; /* normal exclusions */ bts[ebtsCMAP] = 1; /* normal cmap torsions */ bAlldih = FALSE; nrexcl = 3; HH14 = TRUE; bRemoveDih = TRUE; /* Column 5 & 6 aren't really bonded types, but we include * them here to avoid introducing a new section: * Column 5: 1 means generate all dihedrals, 0 not. * Column 6: Number of bonded neighbors to exclude. * Coulmn 7: Generate 1,4 interactions between pairs of hydrogens * Column 8: Remove impropers over the same bond as a proper dihedral */ get_a_line(in,line,STRLEN); if (!get_header(line,header)) gmx_fatal(FARGS,"in .rtp file at line:\n%s\n",line); if (gmx_strncasecmp("bondedtypes",header,5)==0) { get_a_line(in,line,STRLEN); if ((nparam=sscanf(line,"%d %d %d %d %d %d %d %d", &bts[ebtsBONDS],&bts[ebtsANGLES], &bts[ebtsPDIHS],&bts[ebtsIDIHS], &dum1,&nrexcl,&dum2,&dum3)) < 4 ) { gmx_fatal(FARGS,"need at least 4 (up to 8) parameters in .rtp file at line:\n%s\n",line); } bAlldih = (dum1 != 0); HH14 = (dum2 != 0); bRemoveDih = (dum3 != 0); get_a_line(in,line,STRLEN); if(nparam<5) { fprintf(stderr,"Using default: not generating all possible dihedrals\n"); bAlldih = FALSE; } if(nparam<6) { fprintf(stderr,"Using default: excluding 3 bonded neighbors\n"); nrexcl = 3; } if(nparam<7) { fprintf(stderr,"Using default: generating 1,4 H--H interactions\n"); HH14 = TRUE; } if(nparam<8) { fprintf(stderr,"Using default: removing impropers on same bond as a proper\n"); bRemoveDih = TRUE; } } else { fprintf(stderr, "Reading .rtp file without '[ bondedtypes ]' directive,\n" "Will proceed as if the entry\n" "\n" "\n[ bondedtypes ]" "\n; bonds angles dihedrals impropers all_dihedrals nr_exclusions HH14 remove_dih" "\n %3d %3d %3d %3d %3d %3d %3d %3d" "\n" "was present at the beginning of %s", bts[0],bts[1],bts[2],bts[3], bAlldih ? 1 : 0,nrexcl,HH14,bRemoveDih,rrdb); } /* We don't know the current size of rrtp, but simply realloc immediately */ nrtp = *nrtpptr; rrtp = *rtp; maxrtp = nrtp; while (!feof(in)) { if (nrtp >= maxrtp) { maxrtp+=100; srenew(rrtp,maxrtp); } clear_t_restp(&rrtp[nrtp]); if (!get_header(line,header)) gmx_fatal(FARGS,"in .rtp file at line:\n%s\n",line); rrtp[nrtp].resname = strdup(header); rrtp[nrtp].filebase = strdup(filebase); /* Set the bonded types */ rrtp[nrtp].bAlldih = bAlldih; rrtp[nrtp].nrexcl = nrexcl; rrtp[nrtp].HH14 = HH14; rrtp[nrtp].bRemoveDih = bRemoveDih; for(i=0; i<ebtsNR; i++) { rrtp[nrtp].rb[i].type = bts[i]; } get_a_line(in,line,STRLEN); bError=FALSE; bNextResidue=FALSE; do { if (!get_header(line,header)) { bError = TRUE; } else { bt = get_bt(header); if (bt != NOTSET) { /* header is an bonded directive */ bError = !read_bondeds(bt,in,line,&rrtp[nrtp]); } else if (gmx_strncasecmp("atoms",header,5) == 0) { /* header is the atoms directive */ bError = !read_atoms(in,line,&(rrtp[nrtp]),tab,atype); } else { /* else header must be a residue name */ bNextResidue = TRUE; } } if (bError) gmx_fatal(FARGS,"in .rtp file in residue %s at line:\n%s\n", rrtp[nrtp].resname,line); } while (!feof(in) && !bNextResidue); if (rrtp[nrtp].natom == 0) gmx_fatal(FARGS,"No atoms found in .rtp file in residue %s\n", rrtp[nrtp].resname); if (debug) { fprintf(debug,"%3d %5s %5d", nrtp+1,rrtp[nrtp].resname,rrtp[nrtp].natom); for(i=0; i<ebtsNR; i++) fprintf(debug," %10d",rrtp[nrtp].rb[i].nb); fprintf(debug,"\n"); } firstrtp = -1; for(i=0; i<nrtp; i++) { if (gmx_strcasecmp(rrtp[i].resname,rrtp[nrtp].resname) == 0) { firstrtp = i; } } if (firstrtp == -1) { nrtp++; fprintf(stderr,"\rResidue %d",nrtp); } else { if (firstrtp >= *nrtpptr) { gmx_fatal(FARGS,"Found a second entry for '%s' in '%s'", rrtp[nrtp].resname,rrdb); } if (bAllowOverrideRTP) { fprintf(stderr,"\n"); fprintf(stderr,"Found another rtp entry for '%s' in '%s', ignoring this entry and keeping the one from '%s.rtp'\n", rrtp[nrtp].resname,rrdb,rrtp[firstrtp].filebase); /* We should free all the data for this entry. * The current code gives a lot of dangling pointers. */ clear_t_restp(&rrtp[nrtp]); } else { gmx_fatal(FARGS,"Found rtp entries for '%s' in both '%s' and '%s'. If you want the first definition to override the second one, set the -rtpo option of pdb2gmx.",rrtp[nrtp].resname,rrtp[firstrtp].filebase,rrdb); } } } ffclose(in); /* give back unused memory */ srenew(rrtp,nrtp); fprintf(stderr,"\nSorting it all out...\n"); qsort(rrtp,nrtp,(size_t)sizeof(rrtp[0]),comprtp); check_rtp(nrtp,rrtp,rrdb); *nrtpptr = nrtp; *rtp = rrtp; }
int main() { char coordinate_input[BUFSIZ]; char ammp_output[BUFSIZ]; char dictionary[BUFSIZ]; char work[1000],keep[1000]; char atype[20],aname[20]; char *fgets(); float sigma,emin; int ifile,i,imreading,ii,myres; FILE *in1,*dict,*output,*fopen(); printf(" atom definition file:>\n"); /* strip out the file name and put it in the right place for opening */ fgets( work,80,stdin ); for(i= 0; i<80; i++) if( work[i] != ' ') break; for( ifile = i; ifile < 80 ; ifile++) { if( work[ifile] == ' ' ) break; if( work[ifile] == '\0' ) break; if( work[ifile] == '\n' ) break; dictionary[ifile -i ] = work[ifile]; dictionary[ifile -i +1 ] = '\0'; } /* now read in the atoms */ dict = fopen( dictionary, "r"); if( dict == NULL) { fprintf(stderr," sorry i can't open %s\n",dictionary); exit(0);} inkinds = 0; while ( fgets( work,256, dict) != NULL) { sscanf( work,"%s %f %f %f %f %f %f %f %f %f %f %f %f %f \n", &kinds[inkinds].type[0], &kinds[inkinds].r , &kinds[inkinds].theta , &sigma , &emin , &kinds[inkinds].Z , &kinds[inkinds].angle_inc, &kinds[inkinds].X , &kinds[inkinds].jaa , &kinds[inkinds].mass , &kinds[inkinds].charge , &kinds[inkinds].V, &kinds[inkinds].U , &kinds[inkinds].hybrid ); /* kinds[inkinds].theta *= 3.14159265/180.; */ sigma = sigma*sigma; sigma = sigma*sigma*sigma; /* kinds[inkinds].b = sqrt( 4.*emin*sigma*sigma); kinds[inkinds].a = sqrt( 4.*emin*sigma); */ kinds[inkinds].b = sqrt( emin*sigma*sigma); kinds[inkinds].a = sqrt( 2*emin*sigma); inkinds ++; if( inkinds > MAX_ATOM) { fprintf( stderr," too many kinds of atoms in dictionary\n"); exit(0); } } fclose( dict); printf(" Residue dictionary directory:>\n"); /* strip out the file name and put it in the right place for opening */ fgets( work,80,stdin ); for(i= 0; i<80; i++) if( work[i] != ' ') break; for( ifile = i; ifile < 80 ; ifile++) { if( work[ifile] == ' ' ) break; if( work[ifile] == '\0' ) break; if( work[ifile] == '\n' ) break; dictionary[ifile -i ] = work[ifile]; dictionary[ifile -i +1 ] = '\0'; } ifile = ifile -i ; if( ifile == 0 ){ dictionary[ifile++] = '.'; dictionary[ifile] = '\0'; } if( dictionary[ifile-1] != '/') { ifile++; dictionary[ifile-1] = '/'; dictionary[ifile] = '\0';} printf(" atom input coordinate file:>\n"); /* strip out the file name and put it in the right place for opening */ fgets( work,80,stdin ); for(i= 0; i<80; i++) if( work[i] != ' ') break; for( ifile = i; ifile < 80 ; ifile++) { if( work[ifile] == ' ' ) break; if( work[ifile] == '\0' ) break; if( work[ifile] == '\n' ) break; coordinate_input[ifile -i ] = work[ifile]; coordinate_input[ifile -i +1 ] = '\0'; } printf(" AMMP file:>\n"); /* strip out the file name and put it in the right place for opening */ fgets( work,80,stdin ); for(i= 0; i<80; i++) if( work[i] != ' ') break; for( ifile = i; ifile < 80 ; ifile++) { if( work[ifile] == ' ' ) break; if( work[ifile] == '\0' ) break; if( work[ifile] == '\n' ) break; ammp_output[ifile -i ] = work[ifile]; ammp_output[ifile -i +1 ] = '\0'; } in1 = fopen( coordinate_input, "r"); output = fopen( ammp_output, "w"); if (in1 == NULL) goto NO_IN1_FILE; /* read in the first residue * stuff is read into work when the residue number changes then * work is copied into keep, so the first atom of any residue is * going to be in the keep buffer. to initialize we read the * first atom into keep */ keep[0] = '\0'; while( !(keep[0] == 'A' && keep[1] == 'T' && keep[2] == 'O' && keep[3] == 'M') && !(keep[0] == 'H'&& keep[1] == 'E' && keep[1] == 'T'&& keep[1] == 'A'&& keep[1] == 'T' ) ) { if( fgets(keep,90,in1) == NULL) { fprintf(stderr," no atoms in input file ? \n") ; NO_IN1_FILE: printf(" enter the dictionary name >\n"); fgets( keep, 90, stdin); i=0; while( (keep[i] == ' ' || keep[i] == '\t') && keep[i] != '\0') i++; for( imreading = 0; imreading < 3; imreading++) { aname[imreading] = toupper( keep[i + imreading] ); } aname[3] = '\0'; goto NO_ATOMS; } } imreading = 0; while( imreading == 0) {/* begining of imreading loop */ inres = 0; for(i=0; i< MAX_RES; i++) { mykind[i] = -1; defined[i] = -1; name[i][0] = '\0'; x[i] = 0.; y[i] = 0.; z[i] = 0.; } sscanf( &keep[22],"%d",&myres); sscanf(&keep[29],"%f %f %f",&x[inres],&y[inres],&z[inres]); sscanf(&keep[11],"%s",&atype[0]); sscanf(&keep[17],"%s",&aname[0]); serial[inres] = 100*myres + inres; ii = 0; for( i=0; i< 3; i++ ) { if( aname[i] == '\0') break; name[inres][ii++] = (char)tolower(aname[i]); } name[inres][ii++] = '.'; for(i=0; i< 4; i++) { if( atype[i] == '\0' ) break; name[inres][ii++] = (char)tolower(atype[i]); } name[inres][ii] = '\0'; a[inres] = 0.; b[inres] = 0.; q[inres] = 0.; mass[inres] = 1.; defined[inres] = 0; for( inres = 1; inres < MAX_RES; inres ++) { /* start of reading an atom loop */ if( fgets( work,90,in1) == NULL) { imreading = 1; break; } if( work[0] != 'A' && work[0] != 'H') { imreading = 1; break; } /* printf("%s\n",work); printf("%d\n",inres); */ sscanf( &work[22],"%d",&ii); if( ii != myres ) {ii = 0; while( work[ii] != '\0'){ keep[ii] = work[ii] ; ii++;} /* inres += 1; */ break; } sscanf(&work[29],"%f %f %f",&x[inres],&y[inres],&z[inres]); sscanf(&work[11],"%s",&atype[0]); sscanf(&work[17],"%s",&aname[0]); serial[inres] = 100*myres + inres; ii = 0; for( i=0; i< 3; i++ ) { if( aname[i] == '\0') break; name[inres][ii++] = (char)tolower(aname[i]); } name[inres][ii++] = '.'; for(i=0; i< 4; i++) { if( atype[i] == '\0' ) break; name[inres][ii++] = (char)tolower(atype[i]); } name[inres][ii] = '\0'; a[inres] = 0.; b[inres] = 0.; q[inres] = 0.; mass[inres] = 1.; defined[inres] = 0; }/* end of reading an atom loop */ /* for( i=0; i< inres; i++) printf(">%s<\n",&name[i][0]); */ /* if here then all of the atoms in the residue are read in */ /* now we have to open and read the dictionary file * there could be atoms in either the residue or dictionary which * are not there i.e. oxt for a residue or a missing H */ /* prepare the filename */ NO_ATOMS: i = 0; while(dictionary[i] != '\0') { work[i] = dictionary[i]; i++;} ii = 0; while(aname[ii] != '\0') {work[i] = aname[ii]; i++; ii++;} work[i++] = '\0'; dict = fopen(work,"r"); if( dict == NULL ){ fprintf(stderr," dictionary %s not found \n", work); write_atoms(output); goto DONE; } /* read the number of atoms */ if(fgets( work,80,dict)==NULL) { fprintf(stderr,"BAD DICTIONARY %s\n",aname); exit(0);} sscanf(work,"%d",&natoms); read_atoms( dict,natoms ); write_atoms(output); if(fgets( work,80,dict)==NULL) { fprintf(stderr,"BAD DICTIONARY %s\n",aname); exit(0);} sscanf(work,"%d",&nbond); do_bonds( dict,nbond,output); inbondlist = nbond; nangle = 0; if(fgets( work,80,dict)!=NULL) sscanf(work,"%d",&nangle); do_angle(dict,nangle,output); nhybrid = 0; if(fgets( work,80,dict)!=NULL) sscanf(work,"%d",&nhybrid); do_hybrid(dict,nhybrid,output); ntorsion = 0; if(fgets( work,80,dict)!=NULL) sscanf(work,"%d",&ntorsion); do_torsion(dict,ntorsion,output); DONE: fclose( dict ); }/* end of imreading loop */ }/* end of module main */
/* * md_initialize: Initializes MD module: loads initial atoms positions, * velocities, setups parameters of potentials. * Parameters: * cls_file - file in CLSMAN format (initial positions, * velocities, atom species) * input_file - file with modelling parameters */ void md_initialize(const char *cls_file, const char *input_file) { read_atoms(cls_file); read_inputfile(input_file); }