+ int resNo = getPDBResNum(i);
+ if (resNo == UNASSIGNED)
+ {
+ continue; // no mapping from this sequence position
+ }
+ if (startRes == -1)
+ {
+ startRes = resNo;
+ endRes = resNo;
+ }
+ if (resNo >= startRes && resNo <= endRes)
+ {
+ // within the current range - no change
+ continue;
+ }
+ if (resNo == startRes - 1)
+ {
+ // extend beginning of current range
+ startRes--;
+ continue;
+ }
+ if (resNo == endRes + 1)
+ {
+ // extend end of current range
+ endRes++;
+ continue;
+ }
+
+ /*
+ * resNo is not within or contiguous with last range,
+ * so write out the last range
+ */
+ result.add(new int[] { startRes, endRes });
+ startRes = resNo;
+ endRes = resNo;