uk.ac.vamsas.objects.utils
Class MapList

java.lang.Object
  extended byuk.ac.vamsas.objects.utils.MapList

public class MapList
extends java.lang.Object

MapList Simple way of bijectively mapping a non-contiguous linear range to another non-contiguous linear range Use at your own risk! TODO: efficient implementation of private posMap method TODO: test/ensure that sense of from and to ratio start position is conserved (codon start position recovery) TODO: optimize to use int[][] arrays rather than vectors.


Field Summary
 java.util.Vector fromShifts
           
 java.util.Vector toShifts
           
 
Constructor Summary
MapList(int[] from, int[] to, int fromRatio, int toRatio)
           
MapList(MapList map)
           
 
Method Summary
 boolean equals(MapList obj)
           
 int getFromHighest()
           
 int getFromLowest()
           
 int[] getFromRanges()
           
 int getFromRatio()
           
 MapList getInverse()
           
 int getMappedPosition(int pos)
          get From position in the associated reference frame for position pos in the associated sequence.
 int[] getMappedWord(int pos)
           
 int getToHighest()
           
 int getToLowest()
           
 int getToPosition(int mpos)
          get the 'initial' position of mpos in To
 int[] getToRanges()
           
 int getToRatio()
           
 int[] getToWord(int mpos)
          get range of positions in To frame for the mpos word in From
 int[] locateInFrom(int start, int end)
          find series of intervals mapping from start-end in the From map.
 int[] locateInTo(int start, int end)
          find series of intervals mapping from start-end in the to map.
static void main(java.lang.String[] argv)
           
 int[][] makeFromMap()
          get all mapped positions from 'from' to 'to'
 int[][] makeToMap()
          get all mapped positions from 'to' to 'from'
 int[] shiftFrom(int pos)
          shift from pos to To(pos)
 int[] shiftTo(int pos)
          inverse of shiftFrom - maps pos in To to a position in From
static void testMap(MapList ml, int fromS, int fromE)
          test routine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fromShifts

public java.util.Vector fromShifts

toShifts

public java.util.Vector toShifts
Constructor Detail

MapList

public MapList(int[] from,
               int[] to,
               int fromRatio,
               int toRatio)

MapList

public MapList(MapList map)
Method Detail

equals

public boolean equals(MapList obj)

getFromRanges

public int[] getFromRanges()
Returns:
series of intervals mapped in from

getToRanges

public int[] getToRanges()

getFromRatio

public int getFromRatio()
Returns:
length of mapped phrase in from

getToRatio

public int getToRatio()
Returns:
length of mapped phrase in to

getFromLowest

public int getFromLowest()

getFromHighest

public int getFromHighest()

getToLowest

public int getToLowest()

getToHighest

public int getToHighest()

makeFromMap

public int[][] makeFromMap()
get all mapped positions from 'from' to 'to'

Returns:
int[][] { int[] { fromStart, fromFinish, toStart, toFinish }, int [fromFinish-fromStart+2] { toStart..toFinish mappings}}

makeToMap

public int[][] makeToMap()
get all mapped positions from 'to' to 'from'

Returns:
int[to position]=position mapped in from

shiftFrom

public int[] shiftFrom(int pos)
shift from pos to To(pos)

Parameters:
pos - int
Returns:
int shifted position in To, frameshift in From, direction of mapped symbol in To

shiftTo

public int[] shiftTo(int pos)
inverse of shiftFrom - maps pos in To to a position in From

Parameters:
pos - (in To)
Returns:
shifted position in From, frameshift in To, direction of mapped symbol in From

locateInFrom

public int[] locateInFrom(int start,
                          int end)
find series of intervals mapping from start-end in the From map.

Parameters:
start - position in to map
end - position in to map
Returns:
series of ranges in from map

locateInTo

public int[] locateInTo(int start,
                        int end)
find series of intervals mapping from start-end in the to map.

Parameters:
start - position in from map
end - position in from map
Returns:
series of ranges in to map

getToPosition

public int getToPosition(int mpos)
get the 'initial' position of mpos in To

Parameters:
mpos - position in from
Returns:
position of first word in to reference frame

getToWord

public int[] getToWord(int mpos)
get range of positions in To frame for the mpos word in From

Parameters:
mpos - position in From
Returns:
null or int[] first position in To for mpos, last position in to for Mpos

getMappedPosition

public int getMappedPosition(int pos)
get From position in the associated reference frame for position pos in the associated sequence.

Parameters:
pos -
Returns:

getMappedWord

public int[] getMappedWord(int pos)

testMap

public static void testMap(MapList ml,
                           int fromS,
                           int fromE)
test routine. not incremental.

Parameters:
ml -
fromS -
fromE -

main

public static void main(java.lang.String[] argv)

getInverse

public MapList getInverse()
Returns:
a MapList whose From range is this maplist's To Range, and vice versa