+//**********************************************************************************************************************
+string ChopSeqsCommand::getChopped(Sequence seq) {
+ try {
+ string temp = seq.getAligned();
+ string tempUnaligned = seq.getUnaligned();
+
+ if (countGaps) {
+ //if needed trim sequence
+ if (keep == "front") {//you want to keep the beginning
+ int tempLength = temp.length();
+
+ if (tempLength > numbases) { //you have enough bases to remove some
+
+ int stopSpot = 0;
+ int numBasesCounted = 0;
+
+ for (int i = 0; i < temp.length(); i++) {
+ //eliminate N's
+ if (toupper(temp[i]) == 'N') { temp[i] == '.'; }
+
+ numBasesCounted++;
+
+ if (numBasesCounted >= numbases) { stopSpot = i; break; }
+ }
+
+ if (stopSpot == 0) { temp = ""; }
+ else { temp = temp.substr(0, stopSpot); }
+
+ }else { temp = ""; } //sequence too short
+
+ }else { //you are keeping the back
+ int tempLength = temp.length();
+ if (tempLength > numbases) { //you have enough bases to remove some
+
+ int stopSpot = 0;
+ int numBasesCounted = 0;
+
+ for (int i = (temp.length()-1); i >= 0; i--) {
+ //eliminate N's
+ if (toupper(temp[i]) == 'N') { temp[i] == '.'; }
+
+ numBasesCounted++;
+
+ if (numBasesCounted >= numbases) { stopSpot = i; break; }
+ }
+
+ if (stopSpot == 0) { temp = ""; }
+ else { temp = temp.substr(stopSpot+1); }
+ }
+ else { temp = ""; } //sequence too short
+ }
+
+ }else{
+
+ //if needed trim sequence
+ if (keep == "front") {//you want to keep the beginning
+ int tempLength = tempUnaligned.length();
+
+ if (tempLength > numbases) { //you have enough bases to remove some
+
+ int stopSpot = 0;
+ int numBasesCounted = 0;
+
+ for (int i = 0; i < temp.length(); i++) {
+ //eliminate N's
+ if (toupper(temp[i]) == 'N') {
+ temp[i] == '.';
+ tempLength--;
+ if (tempLength < numbases) { stopSpot = 0; break; }
+ }
+
+ if(isalpha(temp[i])) { numBasesCounted++; }
+
+ if (numBasesCounted >= numbases) { stopSpot = i; break; }
+ }
+
+ if (stopSpot == 0) { temp = ""; }
+ else { temp = temp.substr(0, stopSpot); }
+
+ }else { temp = ""; } //sequence too short
+
+ }else { //you are keeping the back
+ int tempLength = tempUnaligned.length();
+ if (tempLength > numbases) { //you have enough bases to remove some
+
+ int stopSpot = 0;
+ int numBasesCounted = 0;
+
+ for (int i = (temp.length()-1); i >= 0; i--) {
+ //eliminate N's
+ if (toupper(temp[i]) == 'N') {
+ temp[i] == '.';
+ tempLength--;
+ if (tempLength < numbases) { stopSpot = 0; break; }
+ }
+
+ if(isalpha(temp[i])) { numBasesCounted++; }