//loads a batch of reads where the read IDs are in genomic coordinate order (signal+information needed for pA conversion) from file, process the batch (convert to pA and sum), and write output //only the time for loading a batch is measured //make zstd=1 //gcc -Wall -O2 -g -I include/ -o convert_to_pa_rand test/bench/convert_to_pa_rand.c lib/libslow5.a -lm -lz -lzstd -fopenmp //only the time for loading a batch to memory (Disk I/O + decompression + parsing and filling the memory arrays) is measured // to generate read id list: samtools view reads.sorted.bam | awk '{print $1}' > rid.txt #include #include #include #include #include static inline double realtime(void) { struct timeval tp; struct timezone tzp; gettimeofday(&tp, &tzp); return tp.tv_sec + tp.tv_usec * 1e-6; } int main(int argc, char *argv[]) { if(argc != 5) { fprintf(stderr, "Usage: %s reads.blow5 rid_list.txt num_thread batch_size\n", argv[0]); return EXIT_FAILURE; } int batch_size = atoi(argv[4]); int num_thread = atoi(argv[3]); int ret=batch_size; omp_set_num_threads(num_thread); int read_count = 0; double *sums = malloc(sizeof(uint64_t)*batch_size); double tot_time = 0; double t0 = 0; //read id list FILE *fpr = fopen(argv[2],"r"); if(fpr==NULL){ fprintf(stderr,"Error in opening file %s for reading\n",argv[2]); perror("perr: ");; exit(EXIT_FAILURE); } char **rid = malloc(sizeof(char*)*batch_size); char tmp[1024]; /**** Initialisation and opening of the file ***/ t0 = realtime(); slow5_file_t *sp = slow5_open(argv[1],"r"); if(sp==NULL){ fprintf(stderr,"Error in opening file\n"); perror("perr: "); exit(EXIT_FAILURE); } ret = slow5_idx_load(sp); if(ret<0){ fprintf(stderr,"Error in loading index\n"); exit(EXIT_FAILURE); } tot_time += realtime() - t0; /**** End of init ***/ while(1){ int i=0; for(i=0; irange / rec[i]->digitisation; for(int j=0; jlen_raw_signal; j++){ sum += ((rec[i]->raw_signal[j] + rec[i]->offset) * scale); } sums[i] = sum; } fprintf(stderr,"batch processed with %d reads\n",ret); for(int i=0;iread_id,sums[i]); } fprintf(stderr,"batch printed with %d reads\n",ret); /**** Deinit ***/ t0 = realtime(); for(int i=0;i