+
+ @Override
+ public int[] getMappedPositionsFor(final SequenceI localFrame,
+ final int column)
+ {
+ return getMappedPositionsFor(localFrame, column, column);
+ }
+
+ @Override
+ public int[] getMappedPositionsFor(final SequenceI localFrame, int from,
+ int to)
+ {
+ if (localFrame == null)
+ {
+ throw new Error("Unimplemented when no local sequence given.");
+ }
+ SequenceI lf = localFrame, uf = refSeq;
+
+ // check that localFrame is derived from refSeq
+ // just look for dataset sequences and check they are the same.
+ // in future we could use DBRefMappings/whatever.
+ while (lf.getDatasetSequence() != null
+ || uf.getDatasetSequence() != null)
+ {
+ if (lf.getDatasetSequence() != null)
+ {
+ lf = lf.getDatasetSequence();
+ }
+ if (uf.getDatasetSequence() != null)
+ {
+ uf = uf.getDatasetSequence();
+ }
+ }
+ if (lf != uf)
+ {
+ // could try harder to find a mapping
+ throw new Error("This Matrix associated with '" + refSeq.getName()
+ + "' is not mappable for the given localFrame sequence. ("
+ + localFrame.getName() + ")");
+ }
+
+ // now look up from-to matrix columns in toSeq frame
+
+ if (toSeq == null)
+ {
+ // no mapping - so we assume 1:1
+ return new int[] { from, to };
+ }
+ // from-to are matrix columns
+ // first locate on reference sequence
+
+ int[] mappedPositions = toSeq.locateInFrom(from, to);
+ if (mappedPositions==null)
+ {
+ return null;
+ }
+
+ // and now map to localFrame
+ // from-to columns on the associated sequence should be
+ // i. restricted to positions in localFrame
+ // ii.
+
+// int s = -1, e = -1;
+// for (int p = 0; p < mappedPositions.length; p++)
+// {
+// if (s == -1 && mappedPositions[p] >= localFrame.getStart())
+// {
+// s = p; // remember first position within local frame
+// }
+// if (e == -1 || mappedPositions[p] <= localFrame.getEnd())
+// {
+// // update end pointer
+// e = p;
+// // compute local map
+// mappedPositions[p] = localFrame.findIndex(mappedPositions[p]);
+// }
+// }
+// int[] _trimmed = new int[e - s + 1];
+// return _trimmed;
+ return mappedPositions;
+ }
+