-//***************************************************************************************************************
-
-bool TrimSeqsCommand::stripQualThreshold(Sequence& seq, ifstream& qFile){
- try {
-// string rawSequence = seq.getUnaligned();
-// int seqLength; // = rawSequence.length();
-// string name, temp, temp2;
-//
-// qFile >> name;
-//
-// //get rest of line
-// temp = "";
-// while (!qFile.eof()) {
-// char c = qFile.get();
-// if (c == 10 || c == 13){ break; }
-// else { temp += c; }
-// }
-//
-// int pos = temp.find("length");
-// if (pos == temp.npos) { m->mothurOut("Cannot find length in qfile for " + seq.getName()); m->mothurOutEndLine(); seqLength = 0; }
-// else {
-// string tempLength = temp.substr(pos);
-// istringstream iss (tempLength,istringstream::in);
-// iss >> temp;
-// }
-//
-// splitAtEquals(temp2, temp); //separates length=242, temp=length, temp2=242
-// convert(temp, seqLength); //converts string to int
-//
-// if (name.length() != 0) { if(name.substr(1) != seq.getName()) { m->mothurOut("sequence name mismatch btwn fasta and qual file"); m->mothurOutEndLine(); } }
-
- string rawSequence = seq.getUnaligned();
- int seqLength = seq.getNumBases();
- bool success = 0; //guilty until proven innocent
- string name;
-
- qFile >> name;
- if (name[0] == '>') { if(name.substr(1) != seq.getName()) { m->mothurOut("sequence name mismatch btwn fasta: " + seq.getName() + " and qual file: " + name); m->mothurOutEndLine(); } }
-
- while (!qFile.eof()) { char c = qFile.get(); if (c == 10 || c == 13){ break; } }
-
- int score;
- int end = seqLength;
-
- for(int i=0;i<seqLength;i++){
- qFile >> score;
-
- if(score < qThreshold){
- end = i;
- break;
- }
- }
- for(int i=end+1;i<seqLength;i++){
- qFile >> score;
- }
-
- seq.setUnaligned(rawSequence.substr(0,end));
-
- return 1;
- }
- catch(exception& e) {
- m->errorOut(e, "TrimSeqsCommand", "stripQualThreshold");
- exit(1);
- }
-}
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::cullQualAverage(Sequence& seq, ifstream& qFile){
- try {
- string rawSequence = seq.getUnaligned();
- int seqLength = seq.getNumBases();
- bool success = 0; //guilty until proven innocent
- string name;
-
- qFile >> name;
- if (name[0] == '>') { if(name.substr(1) != seq.getName()) { m->mothurOut("sequence name mismatch btwn fasta: " + seq.getName() + " and qual file: " + name); m->mothurOutEndLine(); } }
-
- while (!qFile.eof()) { char c = qFile.get(); if (c == 10 || c == 13){ break; } }
-
- float score;
- float average = 0;
-
- for(int i=0;i<seqLength;i++){
- qFile >> score;
- average += score;
- }
- average /= seqLength;
-
- if(average >= qAverage) { success = 1; }
- else { success = 0; }
-
- return success;
- }
- catch(exception& e) {
- m->errorOut(e, "TrimSeqsCommand", "cullQualAverage");
- exit(1);
- }
-}