Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipelouza committed Jun 28, 2018
1 parent 723ee0c commit d86fd08
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion experiments/lib/document_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int document_array_print(unsigned char *T, int_t *SA, int_da *DA, size_t n, int
int_t i;
for(i=0; i<n; i++){

printf("%" PRIdN ") %" PRIdN "\t %" PRIdN " \t", i, SA[i], DA[i]);
printf("%" PRIdN ") %" PRIdN "\t %" PRIdN " \t", i, SA[i], (int_t) DA[i]);
int_t j=SA[i];
for(j=SA[i]; (j<SA[i]+10); j++) printf("%" PRIdT " ", chr(j));
printf("\n");
Expand Down
8 changes: 4 additions & 4 deletions experiments/lib/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ return c_buffer;
/*******************************************************************/

// read line by line
char** load_multiple_txt(FILE* f_in, int k, int_t *n) {
char** load_multiple_txt(FILE* f_in, int k, size_t *n) {

char **c_buffer = (char**) malloc(k*sizeof(char*));

Expand All @@ -131,7 +131,7 @@ return c_buffer;
}

// read sequences separeted by '@' line
char** load_multiple_fastq(FILE* f_in, int k, int_t *n){
char** load_multiple_fastq(FILE* f_in, int k, size_t *n){

char **c_buffer = (char**) malloc(k*sizeof(char*));

Expand Down Expand Up @@ -163,7 +163,7 @@ return c_buffer;
}

// read sequences separeted by '>' line
char** load_multiple_fasta(FILE* f_in, int k, int_t *n){
char** load_multiple_fasta(FILE* f_in, int k, size_t *n){

char **c_buffer = (char**) malloc(k*sizeof(char*));

Expand Down Expand Up @@ -212,7 +212,7 @@ return c_buffer;

/*******************************************************************/

char** file_load_multiple(char* c_file, int k, int_t *n) {
char** file_load_multiple(char* c_file, int k, size_t *n) {

/* .ext
* .txt - strings per line
Expand Down
2 changes: 1 addition & 1 deletion experiments/lib/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int file_write(FILE* f_out, uint_t array);
uint_t file_read(FILE* f_in);

char* file_load(FILE* f_in) ;
char** file_load_multiple(char* c_file, int k, int_t* n) ;
char** file_load_multiple(char* c_file, int k, size_t* n) ;

int file_text_write(unsigned char *str, int_t n, char* c_file, const char* ext);
int file_text_int_write(int_text *str_int, int_t n, char* c_file, const char* ext);
Expand Down
2 changes: 1 addition & 1 deletion experiments/lib/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef uint32_t int_text; //4N bytes for s[0..n-1]

/*! @option type for array DA
*/
typedef int_t int_da;
typedef uint_t int_da;

/**********************************************************************/

Expand Down
32 changes: 26 additions & 6 deletions experiments/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define DEBUG 0
#endif

#define WORD (size_t)(pow(256,sizeof(int_t))/2.0)

/*******************************************************************/

int main(int argc, char** argv){
Expand All @@ -45,12 +47,12 @@ clock_t c_start=0, c_total=0;

unsigned char **R;
int_t i, n=0;
int k;
int_t k;

char* c_dir = argv[1];
char* c_file = argv[2];

sscanf(argv[3], "%d", &k);
sscanf(argv[3], "%"PRIdN"", &k);
sscanf(argv[4], "%u", &MODE);
sscanf(argv[5], "%u", &LCP_COMPUTE);
sscanf(argv[6], "%u", &DA_COMPUTE);
Expand All @@ -64,13 +66,21 @@ clock_t c_start=0, c_total=0;

file_chdir(c_dir);

size_t size=0;
//disk access
R = (unsigned char**) file_load_multiple(c_file, k, &n);
R = (unsigned char**) file_load_multiple(c_file, k, &size);
if(!R){
fprintf(stderr, "Error: less than %d strings in %s\n", k, c_file);
fprintf(stderr, "Error: less than %" PRIdN " strings in %s\n", k, c_file);
return 1;
}

if(size>WORD){
fprintf(stderr, "ERROR: N larger than %.1lf GB (%.1lf GB)\n", WORD/pow(2,30), (double)n/pow(2,30));
if(sizeof(int_t)<8) fprintf(stderr, "Please, compile with -DM64=1\n");
return 0;
}

n = (int_t) size;
unsigned char *str = NULL;
int_text *str_int = NULL;

Expand All @@ -95,17 +105,27 @@ clock_t c_start=0, c_total=0;
#endif
}

printf("K = %" PRId32 "\n", k);
printf("K = %" PRIdN "\n", k);
printf("N = %" PRIdN "\n", n+1);
printf("sizeof(int) = %zu bytes\n", sizeof(int_t));

if(MODE==1 || MODE==2){//sais or saca-k (int)
printf("sizeof(int_text) = %zu byte(s)\n", sizeof(int_text));
}

if(DA_COMPUTE)
if(DA_COMPUTE){
printf("sizeof(int_da) = %zu byte(s)\n", sizeof(int_da));

if(k>=(size_t)(pow(256,sizeof(int_da)))){
int word=0;
if(k<pow(256,sizeof(2))) word = 2; //bytes
else if (k<pow(256,sizeof(4))) word = 4;
else word = 8;
fprintf(stderr, "ERROR: typeof(int_da) must be at least %d bytes\n", word);
return 0;
}
}

#if DEBUG
printf("R:\n");
for(i=0; i<min(5,k); i++)
Expand Down
4 changes: 2 additions & 2 deletions gsacak.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ int_t gSACA_K_DA(uint_t *s, uint_t *SA, int_da *DA,

/**/
for(i=0; i<n1; i++) {DA[i]=d1[SA[i]]; SA[i]=s1[SA[i]];}
for(i=n1; i<n; i++) {SA[i]=0; DA[i]=-1;}
for(i=n1; i<n; i++) {SA[i]=0; DA[i]=0;}
/**/

#if DEBUG
Expand Down Expand Up @@ -2366,7 +2366,7 @@ int_t gSACA_K_LCP_DA(uint_t *s, uint_t *SA, int_t *LCP, int_da *DA,
#endif

for(i=0; i<n1; i++) {DA[i]=d1[SA[i]]; SA[i]=s1[SA[i]];}
for(i=n1; i<n; i++) {SA[i]=U_MAX; DA[i]=-1;}
for(i=n1; i<n; i++) {SA[i]=U_MAX; DA[i]=0;}
for(i=n1;i<n;i++) LCP[i]=0;

//DA for(i=n1; i<n; i++) {SA[i]=0; DA[i]=-1;}
Expand Down
2 changes: 1 addition & 1 deletion gsacak.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef uint32_t int_text; //4N bytes for s[0..n-1]

/*! @option type for array DA
*/
typedef int_t int_da;
typedef uint_t int_da;

/******************************************************************************/

Expand Down
4 changes: 2 additions & 2 deletions gsais.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ int_t gSAIS_DA(uint_t *s, int_t *SA, int_da *DA, int_t n, int_t K, int cs, unsig
#endif

for(i=0; i<n1; i++) {DA[i]=d1[SA[i]]; SA1[i]=s1[SA1[i]];} // get index in s1
for(i=n1; i<n; i++) {SA[i]=EMPTY;DA[i]=-1;} // init SA[n1..n-1]
for(i=n1; i<n; i++) {SA[i]=EMPTY;DA[i]=0;} // init SA[n1..n-1]

#if DEBUG
printf("\nstage 3:\n\n");
Expand Down Expand Up @@ -1673,7 +1673,7 @@ int_t gSAIS_LCP_DA(uint_t *s, int_t *SA, int_t *LCP, int_da *DA, int_t n, int_t
/**/

for(i=0; i<n1; i++) {DA[i]=d1[SA[i]]; SA1[i]=s1[SA1[i]];} // get index in s1
for(i=n1; i<n; i++) {SA[i]=U_MAX; DA[i]=-1;} //EMPTY; // init SA[n1..n-1]
for(i=n1; i<n; i++) {SA[i]=U_MAX; DA[i]=0;} //EMPTY; // init SA[n1..n-1]
/**/
for(i=n1;i<n;i++) LCP[i]=0;
/**/
Expand Down
2 changes: 1 addition & 1 deletion gsais.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef uint32_t int_text; //4N bytes for s[0..n-1]

/*! @option type for array DA
*/
typedef int_t int_da;
typedef uint_t int_da;

/******************************************************************************/

Expand Down

0 comments on commit d86fd08

Please sign in to comment.