org.biojava.bio.seq.projection
Class ProjectionUtils

java.lang.Object
  extended by org.biojava.bio.seq.projection.ProjectionUtils

public class ProjectionUtils
extends Object

Some common things you want to do while projecting features.

Since:
1.3
Author:
Thomas Down, Matthew Pocock

Constructor Summary
ProjectionUtils()
           
 
Method Summary
static Location flipLocation(Location oldLoc, int translation)
          Flip a location.
static StrandedFeature.Strand flipStrand(StrandedFeature.Strand s)
           
static Location revertLocation(Location oldLoc, int translation, boolean oppositeStrand)
          Revert a location, translating and flipping as required.
static Location transformLocation(Location oldLoc, int translation, boolean oppositeStrand)
          Transform a location, translating and flipping as required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectionUtils

public ProjectionUtils()
Method Detail

transformLocation

public static Location transformLocation(Location oldLoc,
                                         int translation,
                                         boolean oppositeStrand)
Transform a location, translating and flipping as required.

If oppositeStrand is false, this is equivalent to translating the location. If it is true, this is equivalent to flipping it.

Parameters:
oldLoc - the Location to transform
translation - the translation to apply
oppositeStrand - wether or not this is a flip
Returns:
the transformed location

revertLocation

public static Location revertLocation(Location oldLoc,
                                      int translation,
                                      boolean oppositeStrand)
Revert a location, translating and flipping as required.

If oppositeStrand is false, this is equivalent to un-translating the location. If it is true, this is equivalent to (un)flipping it.

Parameters:
oldLoc - the Location to revert
translation - the translation to unapply
oppositeStrand - wether or not this is a flip
Returns:
the reverted location

flipLocation

public static Location flipLocation(Location oldLoc,
                                    int translation)
Flip a location.

All points p map to translation - p. Clearly, this mapping is its own inverse. If you wish to flip all locations between 1 and length, you should use a translation of length + 1. In general, if you wish to flip all features between x and y, you should use a translation of x + y.

Parameters:
oldLoc - the Location to flip
translation - the translation to use
Returns:
the flipped Location

flipStrand

public static StrandedFeature.Strand flipStrand(StrandedFeature.Strand s)