-
- while (it.hasNext())
- {
- CigarElement el = it.next();
- int length = el.getLength();
- char[] gaps;
-
- switch (el.getOperator())
- {
- case M:
- // matched residues
- newRead.append(
- read.substring(next, next + length));
- next += length;
- break;
- case N: // intron in RNA
- case D: // deletion
- // add gaps
- gaps = new char[length];
- Arrays.fill(gaps, gapChar);
- newRead.append(gaps);
- break;
- case S:
- // soft clipping - just skip this bit of the read
- // do nothing
-
- // work out how many gaps we need before the start of the soft clip -
- // don't do this at the end of the read!
- if (next == 0) // at start of read
- {
- int numgaps = rec.getUnclippedStart();
- gaps = new char[numgaps];
- Arrays.fill(gaps, ' ');
- newRead.append(gaps);
- }
-
- newRead.append(
- read.substring(next, next + length).toLowerCase());
- next += length;
- break;
- case I:
- // the reference sequence and other reads should have been gapped for
- // this insertion, so just add in the residues
- newRead.append(read.substring(next, next + length));
- next += length;
- break;
- case H:
- // hard clipping - this stretch will not appear in the read
- break;
- default:
- // P, X EQ don't know what to do with these
- break;
- }
-
- }
- return newRead.toString();