#include #include #define TRUE 1 #define FALSE 0 #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) struct data_format { int length; char *nuc; int offset; char name[64]; char type; }; int ReadFlat(file,align,maxseqs) FILE *file; struct data_format align[]; int maxseqs; { int j,len=0, count=-1,offset; unsigned maxlen = 1024; char inline[1025]; extern char *Calloc(),*Realloc(); if(file == NULL) Errorout("Cannot open data file"); for(;fgets(inline,1024,file) != NULL;) { inline[strlen(inline)-1] = '\0'; switch(inline[0]) { case '>': case '#': case '%': case '"': case '@': offset = 0; for(j=0;j maxseqs) Errorout("Sorry, alignment is too large"); align[count].nuc = Calloc(maxlen,sizeof(char)); align[count].type = inline[0]; align[count].offset = offset; if( align[count].nuc == NULL) Errorout("Calloc problem"); sscanf((char*)(inline+1),"%s", align[count].name); len = 0; break; default: if(len+strlen(inline) > maxlen) { maxlen = (maxlen+strlen(inline))*2; align[count].nuc = Realloc(align[count].nuc, maxlen); } for(j=0;j