char buffer4 [2];
in.read(buffer4, 2);
header.clipQualLeft = be_int2(*(unsigned short *)(&buffer4));
- header.clipQualLeft = 5;
+ header.clipQualLeft = 5;
//read clip qual right
char buffer5 [2];
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]); }
string seq = read.bases;
if (trim) {
- if(header.clipQualRight != 0){
+ if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){
seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft));
}
else {
try {
if (trim) {
- if(header.clipQualRight != 0){
+ 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'; }
}