X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sffinfocommand.cpp;h=0e860db9df44f7c5a4380469ff823c0bd999c82b;hb=0b99c6b6ea875e13febda76903fd4d9cda7add7d;hp=7511a2e613bb08912044ad3c044cf3a6a8f91c40;hpb=cd4c86f68cb53017f0f98a82dd2c2e56a64c67bd;p=mothur.git diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index 7511a2e..0e860db 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -405,12 +405,12 @@ int SffInfoCommand::readHeader(ifstream& in, Header& header){ char buffer4 [2]; in.read(buffer4, 2); header.clipQualLeft = be_int2(*(unsigned short *)(&buffer4)); + header.clipQualLeft = 5; //read clip qual right char buffer5 [2]; in.read(buffer5, 2); header.clipQualRight = be_int2(*(unsigned short *)(&buffer5)); - if(header.clipQualRight == 0){ header.clipQualRight = header.numBases; } //read clipAdapterLeft char buffer6 [2]; @@ -562,6 +562,7 @@ int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& hea for (int i = 0; i < read.flowIndex.size(); i++) { sum += read.flowIndex[i]; out << sum << '\t'; } //make the bases you want to clip lowercase and the bases you want to keep upper case + if(header.clipQualRight == 0){ header.clipQualRight = read.bases.length(); } for (int i = 0; i < (header.clipQualLeft-1); i++) { read.bases[i] = tolower(read.bases[i]); } for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { read.bases[i] = toupper(read.bases[i]); } for (int i = (header.clipQualRight-1); i < read.bases.length(); i++) { read.bases[i] = tolower(read.bases[i]); } @@ -586,11 +587,17 @@ int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& head string seq = read.bases; if (trim) { - seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft+1)); + if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){ + seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft)); + } + else { + seq = seq.substr(header.clipQualLeft-1); + } }else{ //if you wanted the sfftxt then you already converted the bases to the right case if (!sfftxt) { //make the bases you want to clip lowercase and the bases you want to keep upper case + if(header.clipQualRight == 0){ header.clipQualRight = seq.length(); } for (int i = 0; i < (header.clipQualLeft-1); i++) { seq[i] = tolower(seq[i]); } for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { seq[i] = toupper(seq[i]); } for (int i = (header.clipQualRight-1); i < seq.length(); i++) { seq[i] = tolower(seq[i]); } @@ -613,8 +620,14 @@ int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& heade try { if (trim) { - out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft+1) << endl; - for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { out << read.qualScores[i] << '\t'; } + 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'; } + } + else{ + out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft) << endl; + for (int i = (header.clipQualLeft-1); i < read.qualScores.size(); i++) { out << read.qualScores[i] << '\t'; } + } }else{ out << ">" << header.name << " length=" << read.qualScores.size() << endl; for (int i = 0; i < read.qualScores.size(); i++) { out << read.qualScores[i] << '\t'; }