# include "util.h" # include "pdb.h" void FlagAllAtomsInCYS(file_records * f) { int ii,jj; for (ii = 0; iiatomnum; ii++) { atom_record * a = f->atoms[ii]; if (a->flags & SULPHUR_BRIDGE) { residue_record * res = find_atom_residue(f,a); if (!STREQ(res->resname,"CYS")) { STDERR("(!STREQ(res->resname,'CYS'))"); ITOE(res->number); ATOE(res->resname); } for (jj=res->start; jjend; jj++) { atom_record * a2 = f->atoms[jj]; SWITCH_ON(a2,SULPHUR_BRIDGE); } } } } int AtomIndexInFile(const atom_record * atom ,file_records * f2) { int ii; for (ii = 0 ; ii < f2->atomnum ; ii++) { atom_record * a2 = f2->atoms[ii]; if ((atom->atomtype == a2->atomtype ) && (atom->chain == a2->chain) && (atom->resnum == a2->resnum) && StreqWithSpaces(atom->resname,a2->resname) && StreqWithSpaces(atom->name,a2->name)) return ii ; } return -1 ; } void PrintField(char *s, char *fmt, void *x, bool FirstTime) { int max; char s2[BUFSIZ], smax[BUFSIZ]; # ifdef OFF ATOE(s); ATOE((char *) x); FTOE(*((double *) x)); ITOE(*((int *) x)); # endif if (strpbrk(fmt,"fgFeE")) { double *pp = x, p = *pp ; sprintf(s2, fmt,p) ; sprintf(smax,fmt,0) ; max = strlen(smax); } else if (strpbrk(fmt,"di")) { int *pp = x, p = *pp; sprintf(s2, fmt,p) ; sprintf(smax,fmt,0) ; max = strlen(smax); } else if (strpbrk(fmt,"s")) { char *p = x; sprintf(s2, fmt,p) ; sprintf(smax,fmt," ") ; max = strlen(smax); } else if (strpbrk(fmt,"c")) { char *pp = x, p = *pp; sprintf(s2, fmt,p) ; sprintf(smax,fmt," ") ; max = strlen(smax); } if (strlen(s2) > max) { STDERR("(strlen(s2) > max)"); s2[max+1] = '\0' ; } if (FirstTime) { char nfmt[BUFSIZ] ; if (strlen(s) > strlen(s2)) { STDERR("(strlen(s) > strlen(s2))"); ATOE(s2); ATOE(s); } sprintf(nfmt,"%%%ds",strlen(s2)); printf(nfmt,s); } else { printf("%s",s2); } printf(" "); } char * SubsPercent(const char c, const char * s) { char *p, * s2 = (char *) malloc (strlen(s)+1); strcpy(s2,s); for (p=s2; *p != 0; p++) if (*p == '%') *p = c; return s2 ; } char * SubsTilde(const char c, const char * s) { char *p, * s2 = (char *) malloc (strlen(s)+1); strcpy(s2,s); for (p=s2; *p != 0; p++) if (*p == '~') *p = c; return s2 ; } char * string_from_option(char * string, char * the_default) { char * a = command_line_arg(string); if (a == NULL) return the_default ; else return a ; } void WriteExtendedRecord (FILE *ff, atom_record * atom, int format, double * Array) { int index = 1 ; int type = atom->atomtype ; if (RECORD_ATOM > type) { fputs(atom->ident, ff) ; } else { if( (format & IO_ONLY_SELECTED) && (atom->flags & (IGNORE_ATOM | DONT_CALCULATE_ATOM))) return ; if( (format & IO_NOT_IGNORED) && (atom->flags & IGNORE_ATOM)) return ; if (format & IO_SHORT) fprintf (ff , "%s%3.3d:%4.4s ", atom->resname,atom->resnum, atom->name) ; else { #undef LF_STRING_09 #undef LF_STRING_10 #define LF_STRING_09 "%6.6s%5d %4.4s%c%3.3s %c%4d%c %8.3Lf%8.3Lf%8.3Lf%6.2Lf%6.2Lf" #define LF_STRING_10 "%6.6s%5d %3.3s%c%3.3s %c%4d%c %8.3Lf%8.3Lf%8.3Lf%6.2Lf%6.2Lf" char * fmt = (atom->name[3] == '\0' ? LF_STRING_09 : LF_STRING_10 ); fprintf(ff , fmt, atom->ident, atom->number, atom->name, atom->extraflag, atom->resname, atom->chain, atom->resnum, atom->x_char, atom->x, atom->y, atom->z, Array[1], Array[2]) ; index = 3; } if (format & IO_SURFACE) fprintf(ff,LF_STRING_11, atom->surface); if (format & IO_VOLUME) fprintf(ff,(format & IO_SURFACE) ? LF_STRING_12 : LF_STRING_13, atom->volume,atom->dumm_solvents); while (index <= Array[0]) { fprintf(ff," %5.1f",Array[index]); index++ ; } fputc('\n', ff) ; } } file_records * write_pdb_all (FILE *ff, file_records *file,int format) { int num ; for (num = 0 ; num < file->atomnum ; num++) write_pdb_record (ff , file->atoms[num],format) ; return file ; } file_records * WriteExtendedFile (FILE *ff, file_records *file, int format, double ** Array) { int num ; for (num = 0 ; num < file->atomnum ; num++) { WriteExtendedRecord( ff , file->atoms[num],format,Array[num] ) ; } return file ; } debug_res(residue_record *res, char *s) { fprintf(stderr,"%s\n",s); ITOE(res->number); ITOE(res->start); ITOE(res->end); ITOE(res->index); ATOE(res->resname); } residue_record * previous_residue(residue_record *res) { file_records *file = res->file ; int chain = res->chain; int prev_index = res->index - 1 ; if (prev_index >= 0) return file->residues[chain][prev_index] ; return NULL ; } int Nterm(file_records * file, atom_record *atom) { residue_record * res = find_atom_residue(file,atom); if (previous_residue(res) == NULL && atom->name[0] == 'N') { STDERR("N terminus"); write_pdb_record(stderr,atom,0); return 1; } else return 0; } int OK_atom(atom_record *atom) { if (atom == NULL) return 0; if (STRNEQ(atom->ident,"ATOM",4) && atom->chain != '_' && (atom->occ > 0.5 || (atom->occ == 0.5 && atom->extraflag == 'A')) && PROTEIN_ATOM_P(atom) && atom->name[0] != 'H') return 1; else return 0; } void switch_on(atom_record *atom, int flag) { SWITCH_ON(atom,flag); } void switch_off(atom_record *atom, int flag) { SWITCH_OFF(atom,flag); } void new_read_standard_volumes(char * filename) { TokenizeData d = {0}; # ifdef OFF d.debug = 1; # endif InitTokens(&d,filename); while (TokenizeLine(&d)) { if (InclusiveTrueBetweenP((StrEq(d.T[1],"GLY") && StrEq(d.T[2],"O")), (StrEq(d.T[1],"LYS") && StrEq(d.T[2],"NZ")),1)) { if (!BlankLineP(d.T) && (Contains1in2P("(SS)",d.T[1]))) { residue_description * res = find_residue_type("CYS"); atom_definition *ad = find_atom_definition(res, d.T[2]) ; ad->eradsq = d.D[4] ; ATOE(d.T[0]); } else if (!BlankLineP(d.T)) { residue_description * res = find_residue_type(d.T[1]); atom_definition *ad = find_atom_definition(res, d.T[2]) ; ad->eradius = d.D[4] ; } } } { residue_description * res = find_residue_type("CYS"); atom_definition * ad = find_atom_definition(res,"SG"); FTOE(ad->eradius); FTOE(ad->eradsq); } { residue_description * res = find_residue_type("CYS"); atom_definition * ad = find_atom_definition(res,"CB"); FTOE(ad->eradius); FTOE(ad->eradsq); } }