+ * Returns a (possibly empty) list of [start, end] residue positions in the
+ * mapped structure, corresponding to the given range of sequence positions
+ *
+ * @param fromSeqPos
+ * @param toSeqPos
+ * @return
+ */
+ public List<int[]> getPDBResNumRanges(int fromSeqPos, int toSeqPos)
+ {
+ List<int[]> result = new ArrayList<int[]>();
+ int startRes = -1;
+ int endRes = -1;
+
+ for (int i = fromSeqPos; i <= toSeqPos; i++)
+ {
+ int resNo = getPDBResNum(i);
+ if (resNo == UNASSIGNED_VALUE)
+ {
+ 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;
+ }
+
+ /*
+ * and add the last range
+ */
+ if (startRes != -1)
+ {
+ result.add(new int[] { startRes, endRes });
+ }
+
+ return result;
+ }
+
+ /**