From 8f7164a88df624fd0a8d1eddbb3d744463cc9ecb Mon Sep 17 00:00:00 2001 From: pschloss Date: Thu, 12 Aug 2010 14:53:23 +0000 Subject: [PATCH] fixed a trimming bug in sffinfo which occurs when the right trim point is smaller than the left trim point --- sffinfocommand.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index 0e860db..4e53f69 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -587,7 +587,10 @@ int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& head string seq = read.bases; if (trim) { - if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){ + if(header.clipQualRight < header.clipQualLeft){ + seq = "NNNN"; + } + else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){ seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft)); } else { @@ -620,7 +623,10 @@ int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& heade try { if (trim) { - if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){ + if(header.clipQualRight < header.clipQualLeft){ + out << "0\t0\t0\t0"; + } + else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){ out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft) << endl; for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { out << read.qualScores[i] << '\t'; } } -- 2.39.2