+ * {@inheritDoc}
+ */
+ @Override
+ public Range findPositions(int fromCol, int toCol)
+ {
+ /*
+ * count residues before fromCol
+ */
+ int j = 0;
+ int count = 0;
+ int seqlen = sequence.length;
+ while (j < fromCol && j < seqlen)
+ {
+ if (!Comparison.isGap(sequence[j]))
+ {
+ count++;
+ }
+ j++;
+ }
+
+ /*
+ * find first and last residues between fromCol and toCol
+ */
+ int firstPos = 0;
+ int lastPos = 0;
+ int firstPosCol = 0;
+ boolean foundFirst = false;
+
+ while (j <= toCol && j < seqlen)
+ {
+ if (!Comparison.isGap(sequence[j]))
+ {
+ count++;
+ if (!foundFirst)
+ {
+ firstPos = count;
+ firstPosCol = j;
+ foundFirst = true;
+ }
+ lastPos = count;
+ }
+ j++;
+ }
+
+ if (firstPos == 0)
+ {
+ /*
+ * no residues in this range
+ */
+ return null;
+ }
+
+ /*
+ * adjust for sequence start coordinate
+ */
+ firstPos += start - 1;
+ lastPos += start - 1;
+
+ return new Range(firstPos, lastPos);
+ }
+
+ /**