#include #include #include #include #include #include #include "clustalw.h" extern char **seq_array; extern sint *seqlen_array; extern char **names,**titles; extern sint *output_index; extern sint *seq_weight; extern double **tmat; /* * ckalloc() * * Tries to allocate "bytes" bytes of memory. Exits program if failed. * Return value: * Generic pointer to the newly allocated memory. */ void *ckalloc(size_t bytes) { register void *ret; if( (ret = calloc(bytes, sizeof(char))) == NULL) /* if( (ret = malloc(bytes)) == NULL) */ fatal("Out of memory\n"); else return ret; return ret; } /* * ckrealloc() * * Tries to reallocate "bytes" bytes of memory. Exits program if failed. * Return value: * Generic pointer to the re-allocated memory. */ void *ckrealloc(void *ptr, size_t bytes) { register void *ret=NULL; if (ptr == NULL) fatal("Bad call to ckrealloc\n"); else if( (ret = realloc(ptr, bytes)) == NULL) fatal("Out of memory\n"); else return ret; return ret; } /* * ckfree() * * Tries to free memory allocated by ckalloc. * Return value: * None. */ void *ckfree(void *ptr) { if (ptr == NULL) warning("Bad call to ckfree\n"); else { free(ptr); ptr = NULL; } return ptr; } /* * rtrim() * * Removes trailing blanks from a string * * Return values: * Pointer to the processed string */ char * rtrim(char *str) { register int p; p = strlen(str) - 1; while ( isspace(str[p]) ) p--; str[p + 1] = EOS; return str; } /* * blank_to_() * * Replace blanks in a string with underscores * * Also replaces , ; : ( or ) with _ * * Return value: * Pointer to the processed string */ char * blank_to_(char *str) { int i,p; p = strlen(str) - 1; for(i=0;i<=p;i++) if( (str[i]==' ') || (str[i]==';') || (str[i]==',') || (str[i]=='(') || (str[i]==')') || (str[i]==':') ) str[i] = '_'; return str; } /* * upstr() * * Converts string str to uppercase. * Return values: * Pointer to the converted string. */ char * upstr(char *str) { register char *s = str; while( (*s = toupper(*s)) ) s++; return str; } /* * lowstr() * * Converts string str to lower case. * Return values: * Pointer to the converted string. */ char * lowstr(char *str) { register char *s = str; while( (*s = tolower(*s)) ) s++; return str; } void getstr(char *instr,char *outstr) { fprintf(stdout,"%s: ",instr); gets(outstr); } double getreal(char *instr,double minx,double maxx,double def) { int status; float ret; char line[MAXLINE]; while(TRUE) { fprintf(stdout,"%s (%.1f-%.1f) [%.1f]: ",instr,minx,maxx,def); gets(line); status=sscanf(line,"%f",&ret); if(status == EOF) return def; if(ret>maxx) { fprintf(stdout,"ERROR: Max. value=%.1f\n\n",maxx); continue; } if(retmaxx) { fprintf(stdout,"ERROR: Max. value=%d\n\n",(pint)maxx); continue; } if(ret-1;--i) { if(str[i]==DIRDELIM) { i = -1; break; } if(str[i]=='.') break; } if(i<0) strcat(path,"."); else path[i+1]=EOS; } void alloc_aln(sint nseqs) { sint i,j; seqlen_array = (sint *)ckalloc( (nseqs+1) * sizeof (sint)); seq_array = (char **)ckalloc( (nseqs + 1) * sizeof (char *) ); for(i=0;i