-
- int newStart = 0;
-// if(compareDNASeq(oligo, temp, length, newStart, pdiffs)){
-// seq.setUnaligned(rawSequence.substr(newStart));
-// success = 1;
-// break;
-// }
+
+ int alnLength = oligo.length();
+
+ for(int i=oligo.length()-1;i>=0;i--){
+ if(oligo[i] != '-'){ alnLength = i+1; break; }
+ }
+ oligo = oligo.substr(0,alnLength);
+ temp = temp.substr(0,alnLength);
+// cout << "barcode = " << oligo << " raw = " << rawSequence.substr(0,alnLength) << " raw aligned = " << temp << endl;
+ cout << seq.getName() << endl;
+ cout << temp << endl;
+ cout << oligo << endl;
+ cout << alnLength << endl;
+ cout << endl;
+
+ int newStart=0;
+ int numDiff = countDiffs(oligo, temp);
+ if(numDiff < minDiff){
+ minDiff = numDiff;
+ minCount = 1;
+ minPos = 0;
+ for(int i=0;i<alnLength;i++){
+ if(temp[i] != '-'){
+ minPos++;
+ }
+ }
+ }
+ else if(numDiff == minDiff){
+ minCount++;
+ }
+
+ }
+ if(minDiff > pdiffs){ success = pdiffs + 1; }
+ else if(minCount > 1) { success = pdiffs + 1; }
+ else{
+ seq.setUnaligned("*" + rawSequence.substr(minPos));
+ success = minDiff;