baobab.bio.permutation
Class UnsignedPermutationBPGraph

java.lang.Object
  extended by baobab.bio.permutation.UnsignedPermutationBPGraph
All Implemented Interfaces:
PermutationBPGraph, java.lang.Comparable

public class UnsignedPermutationBPGraph
extends java.lang.Object
implements PermutationBPGraph

The UnsignedPermutationBPGraph class represents an unsigned permutation pair and its breakpoint graph

Author:
Marilia D. V. Braga

Constructor Summary
UnsignedPermutationBPGraph(int[] permutationList)
          Creates a new linear permutation (assumes the identity permutation as target)
UnsignedPermutationBPGraph(int[] permutationList, boolean isLinear)
          Creates a new permutation (assumes the identity permutation as target)
UnsignedPermutationBPGraph(int[] originList, int[] targetList)
          Creates a new linear permutation
UnsignedPermutationBPGraph(int[] originList, int[] targetList, boolean isLinear)
          Creates a new permutation
UnsignedPermutationBPGraph(java.util.Vector<java.lang.String> origin, java.util.Vector<java.lang.String> target, boolean isLinear)
          Creates a new permutation
 
Method Summary
static java.util.Vector<int[]> blocksToIntArrays(java.util.Collection blocks)
          Transforms the collection of blocks to a collection of arrays of int (with length = 2)
 java.lang.Object clone()
           
 int compareTo(java.lang.Object object)
          Compares this block to another block
 boolean equals(UnsignedPermutationBPGraph perm)
           
 java.util.TreeSet<BPGraphPoint> getBreakpoints()
          Gets the breakpoint list of this block
 BPGraphCycle getCycle(int number)
          Gets the list of cycles of this group of cycles
 java.util.SortedSet<BPGraphCycle> getCycles()
          Gets the list of cycles of this group of cycles
 java.lang.String getData()
           
 BPGraphPoint getFirstPoint()
          Gets the start point of the permutation
 PermutationBPGraphFormatter getFormatter()
          Gets this breakpoint graph formatter
 BPGraphPoint getLastPoint()
          Gets the end point of the permutation
 int getLastPointIndex()
          Gets the index of the last point of the permutation breakpoint graph
 int getLongestNameLength()
          Gets the longest length of a value name in the breakpoint graph
 int getMappedValueAt(int pos)
          Gets the value of the mapped element located at a specified position of the permutation
 java.lang.String getNameAt(int pos)
          Gets the value of the element located at a specified position of the permutation
 int getNumberOfCycles()
          Gets the number of cycles of this group of cycles
 PermutationBPGraph getPermutationBPGraph()
          Gets this permutation
 BPGraphPoint getPointAt(int pos)
          Gets a point at a specific position of the permutation
 java.util.SortedSet<BPGraphPoint> getPoints()
          Gets all points which belong to this group of cycles
 int getPositionOf(int value)
          Gets the position where a specified element of the permutation is located
 int getPositionOf(java.lang.String name)
          Gets the position of the element identified by the given name
 int getPositionOfMapped(int value)
          Gets the position where a specified mapped element of the permutation is located
 java.util.SortedSet<BPGraphCycle> getUnorientedCycles()
          Gets the list of non-oriented cycles of this group of cycles
 int getValueAt(int pos)
          Gets the value of the element located at a specified position of the permutation
 boolean isAdjacency()
          Tests whether this permutation is sorted
 boolean isLinear()
          Tests whether the permutation is linear or circular
 boolean isRevertedAt(int pos)
          Gets the value of the element located at a specified position of the permutation
 boolean isSorted()
          Tests whether this permutation is sorted
 int length()
          Gets the length of the block (the number of values of the permutation between its start and end points)
 UnsignedPermutationBPGraph revert(BPGraphPoint start, BPGraphPoint end)
          Reverts the permutation between the specified points
 UnsignedPermutationBPGraph revert(BPGraphReversalBlock block)
          Reverts the specified block of the permutation
 UnsignedPermutationBPGraph revert(int start, int end)
          Reverts the permutation between the specified positions
 UnsignedPermutationBPGraph revertToNewPermutation(BPGraphPoint start, BPGraphPoint end)
          Make a new permutation, by reverting the permutation between the specified positions
 int size()
          Gets the size (or the number of elements) of the permutation
 int[] toIntArray()
          Gets a representation of the block as an array of int, with size 2, representing its start and end positions
 java.lang.String toString()
           
 UnsignedPermutationBPGraph transposeToNewPermutation(BPGraphPoint start, BPGraphPoint middle, BPGraphPoint end)
          Make a new permutation, by transposing the permutation between the specified positions
 UnsignedPermutationBPGraph transposeToNewPermutation(int start, int middle, int end)
          Make a new permutation, by transposing the permutation between the specified positions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface baobab.bio.permutation.PermutationBPGraph
getNumberOfCycles
 

Constructor Detail

UnsignedPermutationBPGraph

public UnsignedPermutationBPGraph(int[] permutationList)
Creates a new linear permutation (assumes the identity permutation as target)

Parameters:
permutationList - the list of signed integers (from +/-1 to +/-n), as an array of int

UnsignedPermutationBPGraph

public UnsignedPermutationBPGraph(int[] permutationList,
                                  boolean isLinear)
Creates a new permutation (assumes the identity permutation as target)

Parameters:
permutationList - the list of signed integers (from +/-1 to +/-n), as an array of int
isLinear - indicates whether the permutation is linear or circular

UnsignedPermutationBPGraph

public UnsignedPermutationBPGraph(int[] originList,
                                  int[] targetList)
Creates a new linear permutation

Parameters:
originList - the origin list of signed integers (from +/-1 to +/-n), as an array of int
targetList - the target list of signed integers (from +/-1 to +/-n), as an array of int

UnsignedPermutationBPGraph

public UnsignedPermutationBPGraph(int[] originList,
                                  int[] targetList,
                                  boolean isLinear)
Creates a new permutation

Parameters:
originList - the origin list of signed integers (from +/-1 to +/-n), as an array of int
targetList - the target list of signed integers (from +/-1 to +/-n), as an array of int
isLinear - indicates whether the permutation is linear or circular

UnsignedPermutationBPGraph

public UnsignedPermutationBPGraph(java.util.Vector<java.lang.String> origin,
                                  java.util.Vector<java.lang.String> target,
                                  boolean isLinear)
Creates a new permutation

Parameters:
origin - the origin list of unsigned markers
target - the target list of unsigned markers
isLinear - indicates whether the permutation is linear or circular
Method Detail

isLinear

public boolean isLinear()
Tests whether the permutation is linear or circular

Specified by:
isLinear in interface PermutationBPGraph
Returns:
true / false

getFirstPoint

public BPGraphPoint getFirstPoint()
Gets the start point of the permutation

Specified by:
getFirstPoint in interface PermutationBPGraph
Returns:
the start point

getLastPointIndex

public int getLastPointIndex()
Description copied from interface: PermutationBPGraph
Gets the index of the last point of the permutation breakpoint graph

Specified by:
getLastPointIndex in interface PermutationBPGraph
Returns:
the last point index

getLastPoint

public BPGraphPoint getLastPoint()
Gets the end point of the permutation

Specified by:
getLastPoint in interface PermutationBPGraph
Returns:
the end point

getPermutationBPGraph

public PermutationBPGraph getPermutationBPGraph()
Gets this permutation

Returns:
this permutation

size

public int size()
Gets the size (or the number of elements) of the permutation

Specified by:
size in interface PermutationBPGraph
Returns:
the size of the permutation

getPointAt

public BPGraphPoint getPointAt(int pos)
Gets a point at a specific position of the permutation

Specified by:
getPointAt in interface PermutationBPGraph
Parameters:
pos - the given position
Returns:
the point at the given position

getMappedValueAt

public int getMappedValueAt(int pos)
Gets the value of the mapped element located at a specified position of the permutation

Specified by:
getMappedValueAt in interface PermutationBPGraph
Parameters:
pos - the specified position
Returns:
the value of the mapped element

getValueAt

public int getValueAt(int pos)
Gets the value of the element located at a specified position of the permutation

Specified by:
getValueAt in interface PermutationBPGraph
Parameters:
pos - the specified position
Returns:
the value of the element

getLongestNameLength

public int getLongestNameLength()
Description copied from interface: PermutationBPGraph
Gets the longest length of a value name in the breakpoint graph

Specified by:
getLongestNameLength in interface PermutationBPGraph
Returns:
the longest length of a value name

getNameAt

public java.lang.String getNameAt(int pos)
Gets the value of the element located at a specified position of the permutation

Specified by:
getNameAt in interface PermutationBPGraph
Parameters:
pos - the specified position
Returns:
the value of the element

getPositionOf

public int getPositionOf(java.lang.String name)
Gets the position of the element identified by the given name

Specified by:
getPositionOf in interface PermutationBPGraph
Parameters:
name - the given name
Returns:
the position of the element

isRevertedAt

public boolean isRevertedAt(int pos)
Gets the value of the element located at a specified position of the permutation

Specified by:
isRevertedAt in interface PermutationBPGraph
Parameters:
pos - the specified position
Returns:
the value of the element

getPositionOf

public int getPositionOf(int value)
Gets the position where a specified element of the permutation is located

Specified by:
getPositionOf in interface PermutationBPGraph
Parameters:
value - the value of the specified element
Returns:
the position

getPositionOfMapped

public int getPositionOfMapped(int value)
Gets the position where a specified mapped element of the permutation is located

Specified by:
getPositionOfMapped in interface PermutationBPGraph
Parameters:
value - the value of the specified mapped element
Returns:
the position

revert

public UnsignedPermutationBPGraph revert(BPGraphReversalBlock block)
                                  throws PermutationException
Reverts the specified block of the permutation

Parameters:
block - the block to be reverted
Returns:
the resulting Permutation, after performing the reversion
Throws:
PermutationException

revert

public UnsignedPermutationBPGraph revert(BPGraphPoint start,
                                         BPGraphPoint end)
                                  throws PermutationException
Reverts the permutation between the specified points

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting Permutation, after performing the reversion
Throws:
PermutationException

revert

public UnsignedPermutationBPGraph revert(int start,
                                         int end)
Reverts the permutation between the specified positions

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting Permutation, after performing the reversion

revertToNewPermutation

public UnsignedPermutationBPGraph revertToNewPermutation(BPGraphPoint start,
                                                         BPGraphPoint end)
                                                  throws PermutationException
Make a new permutation, by reverting the permutation between the specified positions

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting permutation, after performing the reversion
Throws:
PermutationException

transposeToNewPermutation

public UnsignedPermutationBPGraph transposeToNewPermutation(BPGraphPoint start,
                                                            BPGraphPoint middle,
                                                            BPGraphPoint end)
                                                     throws PermutationException
Make a new permutation, by transposing the permutation between the specified positions

Parameters:
start - the beginning of the transposition block
middle - the middle of the transposition block
end - the end of the transposition block
Returns:
the resulting permutation, after performing the transposition
Throws:
PermutationException

transposeToNewPermutation

public UnsignedPermutationBPGraph transposeToNewPermutation(int start,
                                                            int middle,
                                                            int end)
Make a new permutation, by transposing the permutation between the specified positions

Parameters:
start - the beginning of the transposition block
middle - the middle of the transposition block
end - the end of the transposition block
Returns:
the resulting permutation, after performing the transposition

isAdjacency

public boolean isAdjacency()
Tests whether this permutation is sorted

Returns:
true/false

isSorted

public boolean isSorted()
Tests whether this permutation is sorted

Specified by:
isSorted in interface PermutationBPGraph
Returns:
true / false

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(UnsignedPermutationBPGraph perm)

getFormatter

public PermutationBPGraphFormatter getFormatter()
Description copied from interface: PermutationBPGraph
Gets this breakpoint graph formatter

Specified by:
getFormatter in interface PermutationBPGraph
Returns:
the breakpoint graph formatter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getData

public java.lang.String getData()

getBreakpoints

public java.util.TreeSet<BPGraphPoint> getBreakpoints()
Gets the breakpoint list of this block

Returns:
a Collection with the list of breakpoints (each breakpoint is represented by a Point)

getPoints

public java.util.SortedSet<BPGraphPoint> getPoints()
Gets all points which belong to this group of cycles

Returns:
a Collection with the list of points

getNumberOfCycles

public int getNumberOfCycles()
Gets the number of cycles of this group of cycles

Returns:
the number of cycles

getCycles

public java.util.SortedSet<BPGraphCycle> getCycles()
Gets the list of cycles of this group of cycles

Returns:
a Vector with the list of cycles

getCycle

public BPGraphCycle getCycle(int number)
Gets the list of cycles of this group of cycles

Returns:
a Vector with the list of cycles

getUnorientedCycles

public java.util.SortedSet<BPGraphCycle> getUnorientedCycles()
Gets the list of non-oriented cycles of this group of cycles

Returns:
a Vector with the list of cycles

length

public int length()
Gets the length of the block (the number of values of the permutation between its start and end points)

Returns:
the length

toIntArray

public int[] toIntArray()
Gets a representation of the block as an array of int, with size 2, representing its start and end positions

Returns:
representation of the block as an array of int

compareTo

public int compareTo(java.lang.Object object)
Compares this block to another block

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - the other block
Returns:
the result of the comparison, as an int

blocksToIntArrays

public static java.util.Vector<int[]> blocksToIntArrays(java.util.Collection blocks)
Transforms the collection of blocks to a collection of arrays of int (with length = 2)

Parameters:
blocks - a collection of blocks
Returns:
a collection containing the blocks as arrays of int