]> git.donarmstrong.com Git - mothur.git/commitdiff
sffinfo bug with flow grams right index when clipQualRight=0
authorSarahsWork <sarahswork@141-213-172-215.vpn.umnet.umich.edu>
Fri, 5 Apr 2013 12:44:08 +0000 (08:44 -0400)
committerSarahsWork <sarahswork@141-213-172-215.vpn.umnet.umich.edu>
Fri, 5 Apr 2013 12:44:08 +0000 (08:44 -0400)
sffinfocommand.cpp

index 911009982a3ed7a3e5da2845094a82b1338b74a3..3961802804f02c5d60c2a017803b666f43e74047 100644 (file)
@@ -1054,11 +1054,12 @@ int SffInfoCommand::findGroup(Header header, seqRead read, int& barcode, int& pr
         }else{
             //if you wanted the sfftxt then you already converted the bases to the right case
             if (!sfftxt) {
+                int endValue = header.clipQualRight;
                 //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();    }
+                if(endValue == 0){     endValue = 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]);  }
+                for (int i = (header.clipQualLeft-1); i < (endValue-1); i++)  {   seq[i] = toupper(seq[i]);  }
+                for (int i = (endValue-1); i < seq.length(); i++) {   seq[i] = tolower(seq[i]);  }
             }
         }
         
@@ -1239,10 +1240,11 @@ 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();     }
+        int endValue = header.clipQualRight;
+               if(endValue == 0){      endValue = 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]);  }
+               for (int i = (header.clipQualLeft-1); i < (endValue-1); i++) {   read.bases[i] = toupper(read.bases[i]);  }
+               for (int i = (endValue-1); i < read.bases.length(); i++) {   read.bases[i] = tolower(read.bases[i]);  }
                
                out << endl <<  "Bases: " << read.bases << endl << "Quality Scores: ";
                for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
@@ -1279,11 +1281,12 @@ int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& head
                }else{
                        //if you wanted the sfftxt then you already converted the bases to the right case
                        if (!sfftxt) {
+                int endValue = header.clipQualRight;
                                //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();    }
+                               if(endValue == 0){      endValue = 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]);  }
+                               for (int i = (header.clipQualLeft-1); i < (endValue-1); i++)  {   seq[i] = toupper(seq[i]);  }
+                               for (int i = (endValue-1); i < seq.length(); i++) {   seq[i] = tolower(seq[i]);  }
                        }
                }
                
@@ -1338,17 +1341,18 @@ int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& heade
 //**********************************************************************************************************************
 int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {
        try {
-        if (header.clipQualRight == 0) { header.clipQualRight = read.flowgram.size(); }
         
-               if(header.clipQualRight > header.clipQualLeft){
-                       
-                       int rightIndex = 0;
-                       for (int i = 0; i < header.clipQualRight; i++) {  rightIndex +=  read.flowIndex[i];     }
-
-                       out << header.name << ' ' << rightIndex;
-                       for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << ' ' << (read.flowgram[i]/(float)100);  }
-                       out << endl;
-               }
+        int endValue = header.clipQualRight;
+        if (header.clipQualRight == 0) {  endValue = read.flowIndex.size(); }
+        if(endValue > header.clipQualLeft){
+            
+            int rightIndex = 0;
+            for (int i = 0; i < endValue; i++) {  rightIndex +=  read.flowIndex[i];     }
+            
+            out << header.name << ' ' << rightIndex;
+            for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << ' ' << (read.flowgram[i]/(float)100);  }
+            out << endl;
+        }
                
                
                return 0;