import jalview.util.MapList;
import jalview.ws.datamodel.MappableContactMatrixI;
-public abstract class MappableContactMatrix<T extends MappableContactMatrix<T>> implements MappableContactMatrixI
+public abstract class MappableContactMatrix<T extends MappableContactMatrix<T>>
+ implements MappableContactMatrixI
{
SequenceI refSeq = null;
+
MapList toSeq = null;
/**
*/
int length;
-
@Override
public boolean hasReferenceSeq()
{
{
return refSeq;
}
+
/**
* container for groups - defined on matrix columns
*/
- GroupSet grps=new GroupSet();
+ GroupSet grps = new GroupSet();
+
@Override
public GroupSetI getGroupSet()
{
return grps;
};
+
@Override
public void setGroupSet(GroupSet makeGroups)
{
@Override
public MapList getMapFor(SequenceI mapSeq)
{
- if (refSeq!=null)
+ if (refSeq != null)
{
- while (mapSeq!=refSeq && mapSeq.getDatasetSequence()!=null)
+ while (mapSeq != refSeq && mapSeq.getDatasetSequence() != null)
{
mapSeq = mapSeq.getDatasetSequence();
}
- if (mapSeq!=refSeq)
+ if (mapSeq != refSeq)
{
return null;
}
- } else {
- if (mapSeq!=null) {
+ }
+ else
+ {
+ if (mapSeq != null)
+ {
// our MapList does not concern this seq
return null;
}
}
-
+
return toSeq;
}
/**
- * set the reference sequence and construct the mapping between the start-end positions of given sequence and row/columns of contact matrix
+ * set the reference sequence and construct the mapping between the start-end
+ * positions of given sequence and row/columns of contact matrix
+ *
* @param _refSeq
*/
public void setRefSeq(SequenceI _refSeq)
refSeq = refSeq.getDatasetSequence();
}
length = _refSeq.getEnd() - _refSeq.getStart() + 1;
-// if (length!=refSeq.getLength() || _refSeq.getStart()!=1)
+ // if (length!=refSeq.getLength() || _refSeq.getStart()!=1)
{
- toSeq = new MapList(new int[] { _refSeq.getStart(), _refSeq.getEnd()}, new int[] { 0,length-1}, 1,1);
+ toSeq = new MapList(
+ new int[]
+ { _refSeq.getStart(), _refSeq.getEnd() },
+ new int[]
+ { 0, length - 1 }, 1, 1);
}
}
return newCM;
}
- protected abstract T newMappableContactMatrix(SequenceI newRefSeq,
+ protected abstract T newMappableContactMatrix(SequenceI newRefSeq,
MapList newFromMapList);
+
@Override
public int[] getMappedPositionsFor(final SequenceI localFrame,
final int column)
{
- return getMappedPositionsFor(localFrame,column,column);
+ return getMappedPositionsFor(localFrame, column, column);
}
- public int[] getMappedPositionsFor(final SequenceI localFrame,
- int from,int to)
+
+ public int[] getMappedPositionsFor(final SequenceI localFrame, int from,
+ int to)
{
- if (localFrame==null)
+ if (localFrame == null)
{
throw new Error("Unimplemented when no local sequence given.");
}
// return a ContactListI for column
// column is index into localFrame
// 1. map column to corresponding column in matrix
-
- final int _lcolumn=localFrame.findPosition(from);
- final int _rcolumn=(from==to) ? _lcolumn:localFrame.findPosition(to);
+
+ final int _lcolumn = localFrame.findPosition(from);
+ final int _rcolumn = (from == to) ? _lcolumn
+ : localFrame.findPosition(to);
if (toSeq == null)
{
// no mapping
- return new int[] { _lcolumn,_rcolumn};
+ return new int[] { _lcolumn, _rcolumn };
}
SequenceI lf = localFrame, uf = refSeq;
+ "' is not mappable for the given localFrame sequence. ("
+ localFrame.getName() + ")");
}
-
- int[] mappedPositions = toSeq.locateInFrom(_lcolumn,_rcolumn);
+
+ int[] mappedPositions = toSeq.locateInFrom(_lcolumn, _rcolumn);
// TODO - trim to localFrame ?
-// if (mappedPositions!=null) {
-// 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]);
-// }
-// }
-// }
+ // if (mappedPositions!=null) {
+ // 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]);
+ // }
+ // }
+ // }
return mappedPositions;
}
{
final int _column;
final int _lcolumn;
- if (localFrame==null)
+ if (localFrame == null)
{
throw new Error("Unimplemented when no local sequence given.");
}
// return a ContactListI for column
// column is index into localFrame
// 1. map column to corresponding column in matrix
- final MappableContactMatrix us=this;
- _lcolumn=localFrame.findPosition(column);
-
+ final MappableContactMatrix us = this;
+ _lcolumn = localFrame.findPosition(column);
+
if (toSeq != null)
{
SequenceI lf = localFrame, uf = refSeq;
}
else
{
- // no mapping
+ // no mapping
_column = _lcolumn;
}
- // TODO - remove ? this may be a redundant check
+ // TODO - remove ? this may be a redundant check
if (_column < 0 || ((toSeq != null && _column > toSeq.getToHighest())
|| (toSeq == null && getHeight() <= _column)))
{
int h = 0;
for (int p = 0; p < matrixRange.length; p += 2)
{
- h += 1+Math.abs(matrixRange[p + 1] - matrixRange[p]);
+ h += 1 + Math.abs(matrixRange[p + 1] - matrixRange[p]);
}
final int rangeHeight = h;
// 3. Construct ContactListImpl instance for just those segments.
-
+
return new ContactListImpl(new ContactListProviderI()
{
}
return matrixRange[p] + mcolumn - h;
}
+
@Override
public Color getColourForGroup()
{
/**
* get a specific element of the contact matrix in its data-local coordinates
- * rather than the mapped frame. Implementations are allowed to throw RunTimeExceptions if _column/i are out of bounds
+ * rather than the mapped frame. Implementations are allowed to throw
+ * RunTimeExceptions if _column/i are out of bounds
*
* @param _column
* @param i
* @return
*/
protected abstract double getElementAt(int _column, int i);
-
+
}