diff --git a/src/f5c.c b/src/f5c.c index 0f396be4..dbc6f5c6 100644 --- a/src/f5c.c +++ b/src/f5c.c @@ -247,6 +247,7 @@ core_t* init_core(const char* bamfilename, const char* fastafile, STDERR("Error in loading SLOW5 index for %s\n",slow5file); exit(EXIT_FAILURE); } + slow5_set_skip_rid(); if(drna_detect(core->sf)) { opt.flag |= F5C_RNA; diff --git a/src/f5cio.c b/src/f5cio.c index ec772368..274ebbb7 100644 --- a/src/f5cio.c +++ b/src/f5cio.c @@ -433,9 +433,10 @@ void read_slow5_single(core_t* core, db_t* db, int i){ if(record==NULL || len <0){ //todo : should we free if len<0 - db->bad_fast5_file++; + //db->bad_fast5_file++; + __sync_fetch_and_add(&db->bad_fast5_file,1); if (core->opt.flag & F5C_SKIP_UNREADABLE) { - WARNING("Slow5 record for read [%s] is unavailable/unreadable and will be skipped", qname.c_str()); + //WARNING("Slow5 record for read [%s] is unavailable/unreadable and will be skipped", qname.c_str()); db->sig[i]->nsample = 0; db->sig[i]->rawptr = NULL; } else { diff --git a/src/meth_main.c b/src/meth_main.c index 7d6401a8..126905f1 100644 --- a/src/meth_main.c +++ b/src/meth_main.c @@ -826,7 +826,17 @@ int meth_main(int argc, char* argv[], int8_t mode) { if(core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads > core->total_reads/2){ WARNING("%ld out of %ld reads failed. Double check --pore and --rna options.",(long)core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads,(long)core->total_reads); } - + if(core->bad_fast5_file > core->total_reads/10.0){ + WARNING("%ld out of %ld reads missing in FAST5/SLOW5.",(long)core->bad_fast5_file,(long)core->total_reads); + } + if(core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads + core->bad_fast5_file >= core->total_reads){ + ERROR("all %ld out of %ld reads failed. Check the input files.",(long)core->total_reads,(long)core->total_reads); + exit(EXIT_FAILURE); + } + if(core->total_reads==0){ + ERROR("%s","0 reads processed. Check the input files."); + exit(EXIT_FAILURE); + } //free the core data structure free_core(core,opt); diff --git a/src/resquiggle.c b/src/resquiggle.c index c5965820..e1de676d 100644 --- a/src/resquiggle.c +++ b/src/resquiggle.c @@ -95,6 +95,7 @@ core_t* init_core_rsq(opt_t opt, const char *slow5file, double realtime0) { STDERR("Error in loading SLOW5 index for %s\n",slow5file); exit(EXIT_FAILURE); } + slow5_set_skip_rid(); if(drna_detect(core->sf)) { core->opt.flag |= F5C_RNA; opt.flag |= F5C_RNA; @@ -483,9 +484,10 @@ static void read_slow5_single(core_t* core, db_t* db, int i){ MALLOC_CHK(db->sig[i]); if(record==NULL || len <0){ //todo : should we free if len<0 - db->bad_fast5_file++; + __sync_fetch_and_add(&db->bad_fast5_file,1); + //db->bad_fast5_file++; if (core->opt.flag & F5C_SKIP_UNREADABLE) { - WARNING("Slow5 record for read [%s] is unavailable/unreadable and will be skipped", db->read_id[i]); + //WARNING("Slow5 record for read [%s] is unavailable/unreadable and will be skipped", db->read_id[i]); db->sig[i]->nsample = 0; db->sig[i]->rawptr = NULL; } else { @@ -785,9 +787,21 @@ int resquiggle_main(int argc, char **argv) { fprintf(stderr,"\n"); + //todo duplicate code from meth_main.c - can be modularised if(core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads > core->total_reads/2){ WARNING("%ld out of %ld reads failed. Double check --pore and --rna options.",(long)core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads,(long)core->total_reads); } + if(core->bad_fast5_file > core->total_reads/10.0){ + WARNING("%ld out of %ld reads missing in SLOW5.",(long)core->bad_fast5_file,(long)core->total_reads); + } + if(core->qc_fail_reads + core->failed_calibration_reads + core->failed_alignment_reads + core->bad_fast5_file >= core->total_reads){ + ERROR("all %ld out of %ld reads failed. Check the input files.",(long)core->total_reads,(long)core->total_reads); + exit(EXIT_FAILURE); + } + if(core->total_reads==0){ + ERROR("%s","0 reads processed. Check the input files."); + exit(EXIT_FAILURE); + } kseq_destroy(seq); gzclose(fp);