Skip to content

Commit 5abca08

Browse files
committed
debugging with Luca 2
1 parent aac906e commit 5abca08

File tree

6 files changed

+40
-33
lines changed

6 files changed

+40
-33
lines changed

include/bloom.h

-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
#include "defines.h"
3535

3636

37-
/**
38-
* @brief bitMask, ith bit set to 1 in position i
39-
* */
40-
static const unsigned char bitMask[0x08] = {0x01, 0x02, 0x04, 0x08,
41-
0x10, 0x20, 0x40, 0x80};
4237
/**
4338
* @brief Bloom filter structure
4439
*

include/defines.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define DEFINES_H_
3131

3232
#include <stdint.h>
33+
#include <inttypes.h>
3334

3435
// General
3536
#define B_LEN 131072 /**< buffer size */
@@ -48,13 +49,13 @@
4849

4950
#ifndef mem_usageMB
5051
#define mem_usageMB() fprintf(stderr, \
51-
"- Current allocated memory: %lu MB.\n", \
52+
"- Current allocated memory: %" PRIu64 "MB.\n", \
5253
alloc_mem >> 20) /**< returns allocated memory in MB */
5354
#endif
5455

5556
#ifndef mem_usage
5657
#define mem_usage() fprintf(stderr, \
57-
"- Current allocated memory: %lu Bytes.\n", \
58+
"- Current allocated memory: %" PRIu64 "Bytes.\n", \
5859
alloc_mem) /**< returns allocated memory in Bytes */
5960
#endif
6061

src/bloom.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
static uint8_t fw0[256], fw1[256], fw2[256], fw3[256];
3838
static uint8_t bw0[256], bw1[256], bw2[256], bw3[256];
3939

40+
/**
41+
* @brief bitMask, ith bit set to 1 in position i
42+
* */
43+
static const unsigned char bitMask[0x08] = {0x01, 0x02, 0x04, 0x08,
44+
0x10, 0x20, 0x40, 0x80};
45+
4046
extern uint64_t alloc_mem; /**< allocated memory */
4147

4248
/**
@@ -503,9 +509,9 @@ Bfilter *create_Bfilter(Fa_data *ptr_fasta, int kmersize, uint64_t bfsizeBits,
503509
fprintf(stderr, "Creating a bloomfilter.\n");
504510
fprintf(stderr, "- false positive rate: %f\n", falsePosRate);
505511
fprintf(stderr, "- kmersize: %d\n", kmersize);
506-
fprintf(stderr, "- size of bloom filter (in bits): %ld\n", bfsizeBits);
512+
fprintf(stderr, "- size of bloom filter (in bits): %" PRIu64 "\n", bfsizeBits);
507513
fprintf(stderr, "- number of hash functions used: %d\n", hashNum);
508-
fprintf(stderr, "- number of elements that will be inserted: %ld\n", nelem);
514+
fprintf(stderr, "- number of elements that will be inserted: %" PRIu64 "\n", nelem);
509515
for (i=0; i < ptr_fasta -> nentries; i++) {
510516
maxN = ptr_fasta -> entry[i].N - kmersize + 1;
511517
for (position = 0; position < maxN; position++) {
@@ -538,7 +544,7 @@ Bfilter *create_Bfilter(Fa_data *ptr_fasta, int kmersize, uint64_t bfsizeBits,
538544
void save_Bfilter(Bfilter *ptr_bf, char *filterfile, char *paramfile) {
539545
fprintf(stderr, "Store a bloom filter in: %s (filter), %s (param) \n",
540546
filterfile, paramfile);
541-
fprintf(stderr, "Bloom filter size in bytes, %ld\n", ptr_bf -> bfsizeBytes);
547+
fprintf(stderr, "Bloom filter size in bytes, %" PRIu64 "\n", ptr_bf -> bfsizeBytes);
542548
FILE *fout = fopen(filterfile, "wb");
543549
if (fout == NULL) {
544550
free_Bfilter(ptr_bf);
@@ -559,9 +565,9 @@ void save_Bfilter(Bfilter *ptr_bf, char *filterfile, char *paramfile) {
559565
}
560566
fprintf(fout, "kmersize = %d\n", ptr_bf -> kmersize);
561567
fprintf(fout, "hashNum = %d\n", ptr_bf -> hashNum);
562-
fprintf(fout, "bfsizeBits = %ld\n", ptr_bf -> bfsizeBits);
568+
fprintf(fout, "bfsizeBits = %" PRIu64 "\n", ptr_bf -> bfsizeBits);
563569
fprintf(fout, "falsePosRate = %lf\n", ptr_bf -> falsePosRate);
564-
fprintf(fout, "nelem = %ld\n", ptr_bf -> nelem);
570+
fprintf(fout, "nelem = %" PRIu64 "\n", ptr_bf -> nelem);
565571
fclose(fout);
566572
}
567573

@@ -594,9 +600,9 @@ Bfilter *read_Bfilter(char *filterfile, char *paramfile) {
594600
char tmp1[30], tmp2[30];
595601
fscanf(fin, "%s %s %d", tmp1, tmp2, &kmersize);
596602
fscanf(fin, "%s %s %d", tmp1, tmp2, &hashNum);
597-
fscanf(fin, "%s %s %ld", tmp1, tmp2, &bfsizeBits);
603+
fscanf(fin, "%s %s %" SCNu64 , tmp1, tmp2, &bfsizeBits);
598604
fscanf(fin, "%s %s %lf", tmp1, tmp2, &falsePosRate);
599-
fscanf(fin, "%s %s %ld", tmp1, tmp2, &nelem);
605+
fscanf(fin, "%s %s %" SCNu64 ,tmp1, tmp2, &nelem);
600606
fclose(fin);
601607
Bfilter *ptr_bf = init_Bfilter(kmersize, bfsizeBits, hashNum,
602608
falsePosRate, nelem);
@@ -620,7 +626,7 @@ Bfilter *read_Bfilter(char *filterfile, char *paramfile) {
620626
}
621627
if (ftell(fin) != ptr_bf -> bfsizeBytes) {
622628
free_Bfilter(ptr_bf);
623-
fprintf(stderr, "Expected bfsizeBytes (%ld) != real bfsizeBytes.(%ld)\n",
629+
fprintf(stderr, "Expected bfsizeBytes (%" PRIu64 ") != real bfsizeBytes.(%ld)\n",
624630
ptr_bf -> bfsizeBytes, ftell(fin));
625631
fprintf(stderr, "Exiting program.\n");
626632
fprintf(stderr, "File: %s, line: %d\n", __FILE__, __LINE__);
@@ -639,10 +645,10 @@ Bfilter *read_Bfilter(char *filterfile, char *paramfile) {
639645
filterfile, paramfile);
640646
fprintf(stderr, "kmersize = %d\n", ptr_bf -> kmersize);
641647
fprintf(stderr, "hashNum = %d\n", ptr_bf -> hashNum);
642-
fprintf(stderr, "bfsizeBits = %ld\n", ptr_bf -> bfsizeBits);
643-
fprintf(stderr, "bfsizeBytes: %ld\n", ptr_bf -> bfsizeBytes);
648+
fprintf(stderr, "bfsizeBits = %" PRIu64 "\n", ptr_bf -> bfsizeBits);
649+
fprintf(stderr, "bfsizeBytes: %" PRIu64 "\n", ptr_bf -> bfsizeBytes);
644650
fprintf(stderr, "falsePosRate: %lf\n", ptr_bf -> falsePosRate);
645-
fprintf(stderr, "nelem: %ld\n", ptr_bf -> nelem);
651+
fprintf(stderr, "nelem: %" PRIu64 "\n", ptr_bf -> nelem);
646652
fread(ptr_bf -> filter, sizeof(char), ptr_bf -> bfsizeBytes, fin);
647653
fclose(fin);
648654
return ptr_bf;

src/fa_read.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ int read_fasta(char *filename, Fa_data * ptr_fa) {
216216
fprintf(stderr, "- Allocating memory to store the contents of %s.\n",
217217
filename);
218218
mem_usageMB();
219-
fprintf(stderr, " * Number of lines: %ld\n", ptr_fa -> nlines);
219+
fprintf(stderr, " * Number of lines: %" PRIu64 "\n", ptr_fa -> nlines);
220220
fprintf(stderr, " * Number of entries: %d\n", ptr_fa -> nentries);
221221
fprintf(stderr, " * Length of lines: %d\n", ptr_fa -> linelen);
222222
fprintf(stderr, " * Length of sequences in entries : [ ");
223223
fflush(stderr);
224224
int i;
225225
for (i = 0; i < ptr_fa -> nentries ; i++)
226-
fprintf(stderr, "%ld ", ptr_fa -> entrylen[i]);
226+
fprintf(stderr, "%" PRIu64, ptr_fa -> entrylen[i]);
227227
fprintf(stderr, "].\n");
228228
FILE *fa_in;
229229
fa_in = fopen_gen(filename, "r");
@@ -233,12 +233,12 @@ int read_fasta(char *filename, Fa_data * ptr_fa) {
233233
exit(EXIT_FAILURE);
234234
}
235235
// Allocate memory to read the file in one step
236-
fprintf(stderr, "- Fasta file size: %ld bytes. \n", sz);
237-
fprintf(stderr, "- Allocating %ld bytes in the buffer. \n", sz);
236+
fprintf(stderr, "- Fasta file size: %" PRIu64 "bytes. \n", sz);
237+
fprintf(stderr, "- Allocating %" PRIu64 "bytes in the buffer. \n", sz);
238238
char* buffer = (char *) malloc(sizeof(char)*sz);
239239
if (buffer == NULL) {
240-
fprintf(stderr, "Error occured. Could not allocate %ld Bytes.\n",
241-
sizeof(char)*sz);
240+
fprintf(stderr, "Error occured. Could not allocate %" PRIu64 " Bytes.\n",
241+
sz*sizeof(char));
242242
fprintf(stderr, "File: %s, line: %d\n", __FILE__, __LINE__);
243243
fprintf(stderr, "Exiting program.\n");
244244
exit(EXIT_FAILURE);
@@ -322,7 +322,7 @@ void free_fasta(Fa_data *ptr_fa) {
322322
mem_freed += sizeof(uint64_t) * (ptr_fa -> nentries);
323323
free(ptr_fa);
324324
mem_freed += sizeof(Fa_data);
325-
fprintf(stderr, " %ld bytes freed\n", mem_freed);
325+
fprintf(stderr, " %" PRIu64 "bytes freed\n", mem_freed);
326326
alloc_mem -= mem_freed;
327327
mem_usageMB();
328328
}

src/stats_info.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,16 @@ void print_info(Info* res, char *infofile) {
245245
res -> lane_tags[0]);
246246
fprintf(f, "- Min Quality: %d\n", res -> minQ);
247247
fprintf(f, "- Number of ACGT in the first tile: \n");
248-
fprintf(f, " A = %ld, C = %ld, G = %ld, T = %ld , N = %ld\n",
248+
fprintf(f, " A = %" PRIu64 ", C = %" PRIu64 ", G = %" PRIu64
249+
", T = %" PRIu64 " , N = %" PRIu64 "\n",
249250
res -> ACGT_tile[0],
250251
res -> ACGT_tile[1],
251252
res -> ACGT_tile[2],
252253
res -> ACGT_tile[3],
253254
res -> ACGT_tile[4]);
254255
fprintf(f, "\n- Number of ACGT with low Quality in the first tile:\n");
255-
fprintf(f, " A = %ld, C = %ld, G = %ld, T = %ld, N = %ld\n",
256+
fprintf(f, " A = %" PRIu64 ", C = %" PRIu64 ", G = %" PRIu64
257+
", T = %" PRIu64 " , N = %" PRIu64 "\n",
256258
res -> lowQ_ACGT_tile[0],
257259
res -> lowQ_ACGT_tile[1],
258260
res -> lowQ_ACGT_tile[2],
@@ -266,13 +268,15 @@ void print_info(Info* res, char *infofile) {
266268
for (i = 0; i < (res -> nQ); i++) {
267269
fprintf(f, " Q = %c : ", (char) (res -> qual_tags[i] + ZEROQ));
268270
for (j = 0 ; j< res -> read_len; j++) {
269-
fprintf(f, "%ld ", res -> QPosTile_table[i*(res -> read_len) +j]);
271+
fprintf(f, "%" PRIu64,
272+
res -> QPosTile_table[i*(res -> read_len) +j]);
270273
}
271-
fprintf(f, "\n");
274+
fprintf(f, " \n");
272275
}
273276
fprintf(f, "\n- Number of reads with M low quality nucleotides: \n");
274277
for (i = 0; i < (res -> read_len +1); i++) {
275-
fprintf(f, " M lowQ = %2d, Nreads = %ld \n", i, res -> reads_MlowQ[i]);
278+
fprintf(f, " M lowQ = %2d, Nreads = %" PRIu64 "\n",
279+
i, res -> reads_MlowQ[i]);
276280
if (res -> reads_MlowQ[i] > max && i >0) max = res -> reads_MlowQ[i];
277281
}
278282
fprintf(f, "\n- Histogram with M low quality nucleotides in tile 1: \n\n");
@@ -290,7 +294,8 @@ void print_info(Info* res, char *infofile) {
290294
fprintf(f, "\n- Number of nucleotides per position: \n\n");
291295
fprintf(f, " A C G T N \n");
292296
for (j = 0; j < res -> read_len; j++) {
293-
fprintf(f, "%3d: %7ld %7ld %7ld %7ld %7ld \n", j+1,
297+
fprintf(f, "%3d: %7" PRIu64 " %7" PRIu64 " %7" PRIu64
298+
" %7" PRIu64 " %7" PRIu64 " \n", j+1,
294299
res -> ACGT_pos[N_ACGT *j ],
295300
res -> ACGT_pos[N_ACGT *j+ 1 ],
296301
res -> ACGT_pos[N_ACGT *j+ 2 ],

src/tree.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void free_all_nodes(Tree *tree_ptr) {
133133
tree_ptr -> pool_available = 0;
134134
tree_ptr -> nnodes = 0;
135135
tree_ptr -> L = 0;
136-
fprintf(stderr, "%ld Bytes deallocated.\n", dealloc_mem);
136+
fprintf(stderr, "%" PRIu64 " Bytes deallocated.\n", dealloc_mem);
137137
alloc_mem -= dealloc_mem;
138138
mem_usageMB();
139139
}
@@ -355,7 +355,7 @@ Tree* read_tree(char *filename) {
355355
}
356356
alloc_mem += sizeof(Node)*sz;
357357
}
358-
fprintf(stderr, "- Allocating %ld bytes.\n",
358+
fprintf(stderr, "- Allocating %" PRIu64 " bytes.\n",
359359
(uint64_t)(sizeof(Node)*sz + sizeof(Node*))*(tree_ptr -> pool_count));
360360
// Reconstructing addresses
361361
for (i = 0; i < tree_ptr -> pool_count; i++) {

0 commit comments

Comments
 (0)