baobab.bio.permutation
Class SignedPermutation

java.lang.Object
  extended by baobab.bio.permutation.SignedPermutation
All Implemented Interfaces:
Permutation, java.lang.Comparable
Direct Known Subclasses:
ComplexSignedPermutation

public class SignedPermutation
extends java.lang.Object
implements Permutation

The SignedPermutation class represents a signed permutation and its brekpoint graph (the SignedPermutation class does not deal with hurdles)

Version:
1.0, May 2006
Author:
Marilia D. V. Braga

Constructor Summary
SignedPermutation(int[] permutationList)
          Creates a new linear permutation (assumes the identity permutation as target)
SignedPermutation(int[] permutationList, boolean isLinear)
          Creates a new permutation (assumes the identity permutation as target)
SignedPermutation(int[] originList, int[] targetList)
          Creates a new linear permutation
SignedPermutation(int[] originList, int[] targetList, 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(SignedPermutation perm)
           
 java.util.SortedSet<Point> getBreakpoints()
          Gets the breakpoint list of this block
 java.util.SortedSet<Cycle> getCycles()
          Gets the list of cycles of this group of cycles
 java.lang.String getData()
           
 Point getEndPoint()
          Gets the end point of the permutation
 int getEndPointIndex()
           
 PermutationFormatter getFormatter()
           
 int[] getMappedPositions()
           
 int getMappedValueOf(int pos)
          Gets the value of the mapped element located at a specified position of the permutation
 int[] getMappedValues()
           
 int getMinimalReversalDistance()
          Gets the minimal reversal distance of this permutation (considering only the number of cycles property)
 int getNumberOfCycles()
          Gets the number of cycles of this group of cycles
 java.util.SortedSet getOrientedCycles()
          Gets the list of oriented cycles of this group of cycles
 Permutation getPermutation()
          Gets this permutation
 Point getPointAt(int pos)
          Gets a point at a specific position of the permutation
 java.util.SortedSet<Point> 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 getPositionOfMapped(int value)
          Gets the position where a specified mapped element of the permutation is located
 int getReversalDistance()
          Gets the reversal distance of this permutation
 SignedPermutationReversalFilter getReversalFilter()
           
 Point getStartPoint()
          Gets the start point of the permutation
 java.util.SortedSet<Cycle> getUnorientedCycles()
          Gets the list of non-oriented cycles of this group of cycles
 int getValueOf(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 isOriented()
          Tests whether this cycle group is oriented
 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)
 SignedPermutation revert(int start, int end)
          Reverts the permutation between the specified positions
 SignedPermutation revert(Point start, Point end)
          Reverts the permutation between the specified points
 SignedPermutation revertToNewPermutation(int start, int end)
          Make a new permutation, by reverting the permutation between the specified positions
 SignedPermutation revertToNewPermutation(Point start, Point 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()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface baobab.bio.permutation.Permutation
getNumberOfCycles
 

Constructor Detail

SignedPermutation

public SignedPermutation(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

SignedPermutation

public SignedPermutation(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

SignedPermutation

public SignedPermutation(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

SignedPermutation

public SignedPermutation(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
Method Detail

isLinear

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

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

getStartPoint

public Point getStartPoint()
Gets the start point of the permutation

Returns:
the start point

getEndPointIndex

public int getEndPointIndex()

getEndPoint

public Point getEndPoint()
Gets the end point of the permutation

Returns:
the end point

getPermutation

public Permutation getPermutation()
Gets this permutation

Returns:
this permutation

getMappedValues

public int[] getMappedValues()

getMappedPositions

public int[] getMappedPositions()

getMinimalReversalDistance

public int getMinimalReversalDistance()
Gets the minimal reversal distance of this permutation (considering only the number of cycles property)

Returns:
the minimal reversal distance

getReversalDistance

public int getReversalDistance()
Gets the reversal distance of this permutation

Returns:
the reversal distance

size

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

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

getPointAt

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

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

getMappedValueOf

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

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

getValueOf

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

Specified by:
getValueOf in interface Permutation
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 Permutation
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 Permutation
Parameters:
value - the value of the specified mapped element
Returns:
the position

revert

public SignedPermutation revert(Point start,
                                Point 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 SignedPermutation 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 SignedPermutation revertToNewPermutation(Point start,
                                                Point 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

revertToNewPermutation

public SignedPermutation revertToNewPermutation(int start,
                                                int end)
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

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 Permutation

getReversalFilter

public SignedPermutationReversalFilter getReversalFilter()

clone

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

equals

public boolean equals(SignedPermutation perm)

getFormatter

public PermutationFormatter getFormatter()
Specified by:
getFormatter in interface Permutation

toString

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

getData

public java.lang.String getData()

getBreakpoints

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

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

getNumberOfCycles

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

Returns:
the number of cycles

getCycles

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

Returns:
a Vector with the list of cycles

getOrientedCycles

public java.util.SortedSet getOrientedCycles()
Gets the list of oriented cycles of this group of cycles

Returns:
a Vector with the list of cycles

isOriented

public boolean isOriented()
Tests whether this cycle group is oriented


getPoints

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

Returns:
a Collection with the list of points

getUnorientedCycles

public java.util.SortedSet<Cycle> 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