From ae399836993cf7b712a912968eda5034a179a393 Mon Sep 17 00:00:00 2001 From: Veronique Legrand <vlegrand@pasteur.fr> Date: Thu, 19 May 2016 15:02:25 +0200 Subject: [PATCH] bugfix: pb sometimes occured while computing fastq record length. --- src/FqBaseBackend.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/FqBaseBackend.cpp b/src/FqBaseBackend.cpp index 74c8a6a..1e85010 100644 --- a/src/FqBaseBackend.cpp +++ b/src/FqBaseBackend.cpp @@ -112,7 +112,8 @@ void FqBaseBackend::writeToOutput(const unsigned long& offset) { int fq_rec_size=getRead(offset,pos_in_w_buf); // here aim is to avoid multiple strcpy into buffer: read directly at the right place in the buffer. #ifdef DEBUG - cout<<*(pos_in_w_buf+fq_rec_size-1)<<endl; + cout<<"read "<<fq_rec_size<<" char from offset: "<<offset<<" and stored them in o_buf at position: "<<pos_in_w_buf<<endl; + cout<<"last char read: "<<*(pos_in_w_buf+fq_rec_size-1)<<endl; assert(*(pos_in_w_buf+fq_rec_size-1)=='\n'); assert(*(pos_in_w_buf)=='@'); #endif @@ -147,12 +148,14 @@ int FqBaseBackend::getRead(const unsigned long& offset, char * fq_record) { } nread=read(i_f_desc,fq_record,MAX_FQ_RECORD_LENGTH); #ifdef DEBUG + assert(nread<=MAX_FQ_RECORD_LENGTH); assert(*(fq_record)=='@'); + cout<<"read: "<<nread<<" char from input file"<<endl; #endif nb_lines=0; i=1; pchar=fq_record; - while(i<nread) { + while(i<=nread) { if (*pchar=='\n') { nb_lines++; if (nb_lines==4) { @@ -163,5 +166,8 @@ int FqBaseBackend::getRead(const unsigned long& offset, char * fq_record) { pchar++; i++; } +#ifdef DEBUG + cout<<"found that fq record size is : "<<fq_rec_size<<endl; +#endif return fq_rec_size; } -- GitLab