diff --git a/Licence_CeCILL_V2-en.txt b/Licence_CeCILL_V2-en.txt old mode 100644 new mode 100755 diff --git a/Licence_CeCILL_V2-fr.txt b/Licence_CeCILL_V2-fr.txt old mode 100644 new mode 100755 diff --git a/global.mk b/global.mk old mode 100644 new mode 100755 diff --git a/libfasta/Makefile b/libfasta/Makefile old mode 100644 new mode 100755 diff --git a/libfasta/fasta_header_handler.c b/libfasta/fasta_header_handler.c old mode 100644 new mode 100755 index e3e1722..f57d8c7 --- a/libfasta/fasta_header_handler.c +++ b/libfasta/fasta_header_handler.c @@ -69,34 +69,15 @@ char* fastaSeqPtr_header_add_field(fastaSeqPtr seq, char* name, char* value) element_from_header* table_header_add_field(element_from_header* header, char* name, char* value) { int nbf; - int i, j; - element_from_header* new_header; - nbf = atoi(header[0].value); - new_header = (element_from_header*) realloc(header, ((nbf+1)*sizeof(element_from_header))); - - i=0; - while ((strcmp(new_header[i].name, "definition") != 0) && (i < nbf)) - i++; - - if (strcmp(new_header[i].name, "definition") == 0) - { - j = nbf-1; - while (strcmp(new_header[j].name, "definition") == 0) - { - new_header[j+1].name = new_header[j].name; - new_header[j+1].value = new_header[j].value; - j--; - } - } - - new_header[i].name = (char*) malloc((1+strlen(name))*sizeof(char)); - strcpy(new_header[i].name, name); - new_header[i].value = (char*) malloc((1+strlen(value))*sizeof(char)); - strcpy(new_header[i].value, value); - sprintf(new_header[0].value, "%d", nbf+1); - - return(new_header); + nbf++; + header = (element_from_header*) realloc(header, (nbf+1)*sizeof(element_from_header)); + header[nbf].name = (char*) malloc((1+strlen(name))*sizeof(char)); + strcpy(header[nbf].name, name); + header[nbf].value = (char*) malloc((1+strlen(value))*sizeof(char)); + strcpy(header[nbf].value, value); + sprintf(header[0].value, "%d", nbf); + return(header); } @@ -105,7 +86,7 @@ void free_header_table(element_from_header* header) int i; int nbf = atoi(header[0].value); - for (i = 0; i < nbf; i++) + for (i = 0; i <= nbf; i++) { free((header[i]).name); free((header[i]).value); @@ -120,7 +101,7 @@ char* getItemFromHeader(char* name, element_from_header* header) int nbf; int i; nbf = atoi(header[0].value); - for (i = 1; i < nbf; i++) + for (i = 1; i <= nbf; i++) { if (strcmp(header[i].name,name)==0) value = header[i].value; @@ -134,7 +115,7 @@ void changeValue(element_from_header* header, char* name, char* newValue) int i; int nbf = atoi(header[0].value); - for (i = 1; i < nbf; i++) + for (i = 1; i <= nbf; i++) { if (strcmp(header[i].name, name)==0) { diff --git a/libfasta/fasta_header_handler.h b/libfasta/fasta_header_handler.h old mode 100644 new mode 100755 diff --git a/libfasta/fasta_header_parser.c b/libfasta/fasta_header_parser.c old mode 100644 new mode 100755 index 6bf5221..ad18723 --- a/libfasta/fasta_header_parser.c +++ b/libfasta/fasta_header_parser.c @@ -798,7 +798,7 @@ YY_RULE_SETUP (*p_header)[*nbf].value = (char*) malloc(sizeof(char)*size_needed); strcpy(((*p_header)[*nbf]).value,header_yytext); - p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); + (*nbf)++; } YY_BREAK case 3: @@ -820,7 +820,7 @@ YY_RULE_SETUP case 5: YY_RULE_SETUP #line 69 "fasta_header_parser.l" -{ // TODO +{ /*fprintf(stderr,"\n{SPACE} **%s**",header_yytext);*/ if (i != 0) field = store_in_field(field,header_yytext,&free_size,&i); @@ -886,21 +886,24 @@ case YY_STATE_EOF(REGVAL): #line 113 "fasta_header_parser.l" { field = store_in_header_table(field, &((*p_header)[*nbf].value), &free_size, &i); - (*nbf)++; + p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); end_header_table(p_header, *nbf); + free(field); BEGIN(INITIAL); return 0; } YY_BREAK case YY_STATE_EOF(REGNAME): -#line 122 "fasta_header_parser.l" +#line 123 "fasta_header_parser.l" { - (*p_header)[*nbf].name = (char*) malloc(sizeof(char)*19); - strcpy((*p_header)[*nbf].name,"definition"); + /*(*p_header)[*nbf].name = (char*) malloc(sizeof(char)*19); + strcpy((*p_header)[*nbf].name,"other_informations"); field = store_in_header_table(field, &((*p_header)[*nbf].value), &free_size, &i); - (*nbf)++; - end_header_table(p_header, nbf); + p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); + */ + end_header_table(p_header, *nbf); + free(field); BEGIN(INITIAL); return 0; @@ -908,10 +911,10 @@ case YY_STATE_EOF(REGNAME): YY_BREAK case 12: YY_RULE_SETUP -#line 133 "fasta_header_parser.l" +#line 136 "fasta_header_parser.l" ECHO; YY_BREAK -#line 915 "" +#line 918 "" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(REGID): yyterminate(); @@ -1909,7 +1912,7 @@ void header_yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 133 "fasta_header_parser.l" +#line 136 "fasta_header_parser.l" @@ -1920,32 +1923,38 @@ int header_yywrap() element_from_header* header_parser_main(char *h) { - int nbfields, memory_allocated; + int nbfields,memory_allocated; element_from_header* header; char* nbfields_n; - YY_BUFFER_STATE state; - - state=header_yy_scan_string(h); + char* nbfields_v; + + nbfields_n = (char*) malloc(9*sizeof(char)); + nbfields_v = (char*) malloc(5*sizeof(char)); memory_allocated=MEMALLOCATED; - header = (element_from_header*) malloc(memory_allocated * sizeof(element_from_header)); - - nbfields_n = (char*) malloc(9*sizeof(char)); - strcpy(nbfields_n, "nbfields"); - header[0].name = nbfields_n; - - // Initialize memory to store the number of fields - header[0].value = (char*) malloc(10*sizeof(char)); - nbfields=1; + strcpy(nbfields_n, "nbfields"); + strcpy(nbfields_v, "1"); + + header = (element_from_header*) malloc(memory_allocated * sizeof(element_from_header)); + + header[0].name = nbfields_n; + header[0].value = nbfields_v; + + YY_BUFFER_STATE state; + + state=header_yy_scan_string(h); + header_parser(&nbfields, &memory_allocated, &header); - + header_yy_delete_buffer(state); - + return header; } + + diff --git a/libfasta/fasta_header_parser.h b/libfasta/fasta_header_parser.h old mode 100644 new mode 100755 diff --git a/libfasta/fasta_header_parser.l b/libfasta/fasta_header_parser.l old mode 100644 new mode 100755 index bb4c5cd..c270c64 --- a/libfasta/fasta_header_parser.l +++ b/libfasta/fasta_header_parser.l @@ -53,7 +53,7 @@ EQUAL = (*p_header)[*nbf].value = (char*) malloc(sizeof(char)*size_needed); strcpy(((*p_header)[*nbf]).value,yytext); - p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); + (*nbf)++; } @@ -66,7 +66,7 @@ EQUAL = field = store_in_field(field,yytext,&free_size,&i); } -{SPACE} { // TODO +{SPACE} { /*fprintf(stderr,"\n{SPACE} **%s**",yytext);*/ if (i != 0) field = store_in_field(field,yytext,&free_size,&i); @@ -112,19 +112,22 @@ EQUAL = <> { field = store_in_header_table(field, &((*p_header)[*nbf].value), &free_size, &i); - (*nbf)++; + p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); end_header_table(p_header, *nbf); + free(field); BEGIN(INITIAL); return 0; } <> { - (*p_header)[*nbf].name = (char*) malloc(sizeof(char)*19); - strcpy((*p_header)[*nbf].name,"definition"); + /*(*p_header)[*nbf].name = (char*) malloc(sizeof(char)*19); + strcpy((*p_header)[*nbf].name,"other_informations"); field = store_in_header_table(field, &((*p_header)[*nbf].value), &free_size, &i); - (*nbf)++; - end_header_table(p_header, nbf); + p_header = check_and_realloc_mem_in_header_table(p_header, nbf, memory_allocated); + */ + end_header_table(p_header, *nbf); + free(field); BEGIN(INITIAL); return 0; @@ -139,31 +142,37 @@ int header_yywrap() element_from_header* header_parser_main(char *h) { - int nbfields, memory_allocated; + int nbfields,memory_allocated; element_from_header* header; char* nbfields_n; - YY_BUFFER_STATE state; - - state=yy_scan_string(h); + char* nbfields_v; + + nbfields_n = (char*) malloc(9*sizeof(char)); + nbfields_v = (char*) malloc(5*sizeof(char)); memory_allocated=MEMALLOCATED; - header = (element_from_header*) malloc(memory_allocated * sizeof(element_from_header)); - - nbfields_n = (char*) malloc(9*sizeof(char)); - strcpy(nbfields_n, "nbfields"); - header[0].name = nbfields_n; - - // Initialize memory to store the number of fields - header[0].value = (char*) malloc(10*sizeof(char)); - nbfields=1; + strcpy(nbfields_n, "nbfields"); + strcpy(nbfields_v, "1"); + + header = (element_from_header*) malloc(memory_allocated * sizeof(element_from_header)); + + header[0].name = nbfields_n; + header[0].value = nbfields_v; + + YY_BUFFER_STATE state; + + state=yy_scan_string(h); + header_parser(&nbfields, &memory_allocated, &header); - + yy_delete_buffer(state); - + return header; } + + diff --git a/libfasta/fasta_seq_writer.c b/libfasta/fasta_seq_writer.c old mode 100644 new mode 100755 index 5019244..ccee773 --- a/libfasta/fasta_seq_writer.c +++ b/libfasta/fasta_seq_writer.c @@ -52,7 +52,7 @@ void printOnlyHeaderFromTable(element_from_header* header, FILE* output) fprintf(output,">%s ",header[1].value); - for (i = 2; i < nbf; i++) + for (i = 2; i <= nbf; i++) { if (strcmp(header[i].name, "definition") != 0) { @@ -60,10 +60,11 @@ void printOnlyHeaderFromTable(element_from_header* header, FILE* output) fprintf(output,"="); fprintf(output,"%s; ",header[i].value); } - else if (strcmp(header[i].name, "definition") == 0) - fprintf(output,"%s ", header[i].value); } + if (strcmp(header[nbf].name, "definition") == 0) + fprintf(output,"%s; ",header[nbf].value); + fprintf(output,"\n"); } diff --git a/libfasta/fasta_seq_writer.h b/libfasta/fasta_seq_writer.h old mode 100644 new mode 100755 diff --git a/libfasta/header_mem_handler.c b/libfasta/header_mem_handler.c old mode 100644 new mode 100755 index 3619c88..a0b8e7c --- a/libfasta/header_mem_handler.c +++ b/libfasta/header_mem_handler.c @@ -76,7 +76,7 @@ element_from_header** check_and_realloc_mem_in_header_table(element_from_header* { (*nbf)++; - if ((*nbf)+1 == *memory_allocated) + if (*nbf == *memory_allocated) { (*memory_allocated)++; *p_header = (element_from_header*) realloc(*p_header, (*memory_allocated) * sizeof(element_from_header)); @@ -87,6 +87,7 @@ element_from_header** check_and_realloc_mem_in_header_table(element_from_header* void end_header_table(element_from_header** p_header, int nbf) { - *p_header = (element_from_header*) realloc(*p_header, nbf * sizeof(element_from_header)); + nbf = nbf - 1; + //fprintf(stderr, "nbf = %d", nbf); sprintf((*p_header)->value, "%d", nbf); } diff --git a/libfasta/header_mem_handler.h b/libfasta/header_mem_handler.h old mode 100644 new mode 100755 diff --git a/libfasta/sequence.c b/libfasta/sequence.c old mode 100644 new mode 100755 diff --git a/libfasta/sequence.h b/libfasta/sequence.h old mode 100644 new mode 100755 diff --git a/libfile/Makefile b/libfile/Makefile old mode 100644 new mode 100755 diff --git a/libfile/fileHandling.c b/libfile/fileHandling.c old mode 100644 new mode 100755 diff --git a/libfile/fileHandling.h b/libfile/fileHandling.h old mode 100644 new mode 100755 diff --git a/liblcs/Makefile b/liblcs/Makefile old mode 100644 new mode 100755 diff --git a/liblcs/_lcs.ext.1.c b/liblcs/_lcs.ext.1.c old mode 100644 new mode 100755 diff --git a/liblcs/_lcs.ext.2.c b/liblcs/_lcs.ext.2.c old mode 100644 new mode 100755 diff --git a/liblcs/_lcs.ext.3.c b/liblcs/_lcs.ext.3.c old mode 100644 new mode 100755 diff --git a/liblcs/_lcs.h b/liblcs/_lcs.h old mode 100644 new mode 100755 diff --git a/liblcs/_lcs_fast.h b/liblcs/_lcs_fast.h old mode 100644 new mode 100755 diff --git a/liblcs/banded_LCS_alignment.c b/liblcs/banded_LCS_alignment.c old mode 100644 new mode 100755 diff --git a/liblcs/banded_LCS_alignment.h b/liblcs/banded_LCS_alignment.h old mode 100644 new mode 100755 diff --git a/liblcs/sse_banded_LCS_alignment.c b/liblcs/sse_banded_LCS_alignment.c old mode 100644 new mode 100755 diff --git a/liblcs/sse_banded_LCS_alignment.h b/liblcs/sse_banded_LCS_alignment.h old mode 100644 new mode 100755 diff --git a/liblcs/upperband.c b/liblcs/upperband.c old mode 100644 new mode 100755 diff --git a/liblcs/upperband.h b/liblcs/upperband.h old mode 100644 new mode 100755 diff --git a/libsse/_sse.h b/libsse/_sse.h old mode 100644 new mode 100755 diff --git a/libutils/Makefile b/libutils/Makefile old mode 100644 new mode 100755 diff --git a/libutils/debug.c b/libutils/debug.c old mode 100644 new mode 100755 diff --git a/libutils/debug.h b/libutils/debug.h old mode 100644 new mode 100755 diff --git a/libutils/utilities.c b/libutils/utilities.c old mode 100644 new mode 100755 diff --git a/libutils/utilities.h b/libutils/utilities.h old mode 100644 new mode 100755