Class RichLocation.Tools

java.lang.Object
org.biojavax.bio.seq.RichLocation.Tools
Enclosing interface:
RichLocation

public static class RichLocation.Tools extends Object
Some useful tools for working with Locations.
  • Method Details

    • construct

      public static RichLocation construct(Collection<Location> members)
      Constructs a RichLocation object based on the given collection of members. It the collection contains a single location, that is returned. If it contains multiple locations it returns a CompoundRichLocation covering them all, with the default term associated. It returns the empty location if the collection was empty.
      Parameters:
      members - the members to construct a location from.
      Returns:
      the corresponding RichLocation
    • isMultiSource

      public static boolean isMultiSource(Collection<Location> members)
      Returns false if all the locations in the set are from the same strand of the same sequence.
      Parameters:
      members - the set of locations to check.
      Returns:
      true if they are from multiple sources.
    • merge

      public static Collection<Location> merge(Collection<Location> members)
      Takes a set of locations and tries to merge all pairs where the union operation results in a simple rich location, not a compound one.
      Parameters:
      members - the members to merge
      Returns:
      the resulting merged set, which may have only one location in it.
    • flatten

      public static Collection<Location> flatten(RichLocation location)
      Takes a location and returns the set of all members. If any members are compound, it flattens them too.
      Parameters:
      location - the location to flatten
      Returns:
      the flattened collection of members.
    • flatten

      public static Collection<Location> flatten(Collection<Location> members)
      Takes a set of locations and returns the set of all members. If any members are compound, it flattens them too.
      Parameters:
      members - the locations to flatten
      Returns:
      the flattened collection of members.
    • modulateCircularLocation

      public static int[] modulateCircularLocation(int start, int end, int seqLength)
      Takes a start and end position on a circular location of given length, and shifts them left along the sequence until they sit at the earliest possible point where they still would represent the same sequence.
      Parameters:
      start - the start of the circular location
      end - the end of the circular location
      seqLength - the circular length of the sequence underlying the location
      Returns:
      an integer array where [0] is the translated start and [1] the end.
    • modulateCircularLocationPair

      public static int[] modulateCircularLocationPair(Location a, Location b, int seqLength)
      Takes two circular locations of given length, and shifts them left along the sequence until they sit at the earliest possible point where they still would represent the same sequence. The end result ensures that simple overlap calculations will always work on the coordinates returned.
      Parameters:
      a - the first location to shift
      b - the second location to shift
      seqLength - the circular length of the sequence underlying the location
      Returns:
      an integer array where [0] is the translated start and [1] the end of location a, and [2] and [3] are the translated start and end of location b.
    • modulateCircularIndex

      public static int modulateCircularIndex(int index, int seqLength)
      Takes a point on a circular location and moves it left until it falls at the earliest possible point that represents the same base.
      Parameters:
      index - the point on the location to shift
      seqLength - the size of the circular location
      Returns:
      the shifted point
    • enrich

      public static RichLocation enrich(Location l)
      Attempts to convert a plain Location into a RichLocation.
      Parameters:
      l - the location to convert
      Returns:
      the converted location