/* @author: joao lopes @workplace: Reading University @date: 8th May 2009 */ #include "interface.h" /* It creates an ABC .len file given an GenePop input file. @arg length format filename @arg output filename */ int createFreqTab3(char *input,char *output){ int cloc, cpop, cdna, csamp, i, j, cplo, //iterators nsamp, //total nr. of samples loctype, //0 = locus divided by ','; 1 = locus divided by lines searchInd, //check if ',' is found in the sample file reachEND, //check if EOF have been reached searchPop, //check if the word 'pop' is found in the sample file npop, //number of populations nloc, //number of loci equalDna, //auxiliar to build the .len file outsize, //size of output file name *ldna, //number of different dna data by loci *lplo, //nr of markers per loci *lsamp = NULL, //total number of samples per loci ***freq, //freq of dna data by no_pop by no. of diff dna data **valM, //list of all the diff microsatellite sizes **IDsort, //list of the order of the diff microsatellite sizes ***genotM2, //list of all the individual's haplotype per pop per loci ****genotM; //list of all the individual's haplotype per pop per loci char c1, //gets the value of a char temporarly info[LOCMAXCHAR+1], //information of a locus info1[LOCMAXCHAR+1], //information of a locus info2[LOCMAXCHAR+1], //information of a locus aux[MAXCHAR], //auxiliar *outname, //name of the output file **locname; //name of the loci FILE *inp, //pntr to the input file *outp; //pntr to the output file time_t startClock; //time when the program starts const struct tm *startTime; //struct time when the program starts inp = fopen(input,"r"); if(inp == NULL) return 1; //cannot open sample file outsize = strlen(output) + 5; outname = (char *)malloc(outsize*sizeof(char)); strcpy(outname,output); outp = fopen(strcat(outname,".len"),"w"); if(outp == NULL) return 2; //cannot create .len file time( &startClock ); // Get time in seconds startTime = localtime( &startClock ); // Convert time to struct tm form //get nloc fgets(aux,MAXCHAR,inp); nloc=1; loctype=1; fgets(aux,MAXCHAR,inp); for(i=0;i=ldna[cloc]){ for(j=0;j