Package beagleutil

Class ChromIds

java.lang.Object
beagleutil.ChromIds

public final class ChromIds extends Object

Class ChromIds is a singleton class that represents a list of chromosome identifiers.

The singleton instance of ChromIds is thread-safe.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the index of the specified chromosome identifier.
    int
    Returns the index of the specified chromosome identifier, or returns -1 if the specified chromosome identifier is not indexed.
    int[]
    Returns an array of chromosome identifier indices corresponding to the specified array of chromosome identifiers.
    id(int index)
    Returns the chromosome identifier with the specified index.
    ids()
    Returns the list of chromosome identifiers as an array.
    static ChromIds
    Returns the singleton ChromIds instance.
    int
    Returns the number of indexed chromosomes identifiers.
    Returns java.util.Arrays.toString(this.ids()).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • instance

      public static ChromIds instance()
      Returns the singleton ChromIds instance.
      Returns:
      the singleton ChromIds instance
    • getIndex

      public int getIndex(String id)
      Returns the index of the specified chromosome identifier. If the chromosome identifiers is not yet indexed, the chromosome identifier will be indexed. Chromosome identifier indices are assigned in consecutive order beginning with 0.
      Parameters:
      id - a chromosome identifier
      Returns:
      the index of the specified chromosome identifier
      Throws:
      IllegalArgumentException - if id.isEmpty()
      NullPointerException - if id == null
    • getIndices

      public int[] getIndices(String[] ids)
      Returns an array of chromosome identifier indices corresponding to the specified array of chromosome identifiers. If a sample identifier is not yet indexed, the sample identifier will be indexed. Sample identifier indices are assigned in increasing order starting with 0.
      Parameters:
      ids - an array of sample identifiers
      Returns:
      an array of sample identifier indices
      Throws:
      IllegalArgumentException - if there is a j satisfying (0 <= j && j < ids.length) && ids[j].isEmpty()
      NullPointerException - if ids == null
      NullPointerException - if there is a j satisfying (0 <= j && j < ids.length) && (ids[j] == null)
    • getIndexIfIndexed

      public int getIndexIfIndexed(String id)
      Returns the index of the specified chromosome identifier, or returns -1 if the specified chromosome identifier is not indexed.
      Parameters:
      id - a chromosome identifier.
      Returns:
      the index of the specified chromosome identifier, or -1 if the specified chromosome identifier is not indexed.
      Throws:
      IllegalArgumentException - if id.isEmpty()
      NullPointerException - if id == null
    • size

      public int size()
      Returns the number of indexed chromosomes identifiers.
      Returns:
      the number of indexed chromosomes identifiers
    • id

      public String id(int index)
      Returns the chromosome identifier with the specified index.
      Parameters:
      index - a chromosome identifier index.
      Returns:
      the specified chromosome identifier.
      Throws:
      IndexOutOfBoundsException - if index < 0 || index >= this.size()
    • ids

      public String[] ids()
      Returns the list of chromosome identifiers as an array. The returned array will have length this.size(), and it will satisfy this.ids()[k].equals(this.id(k)) == true for 0 <= k < this.size().
      Returns:
      an array of chromosome identifiers
    • toString

      public String toString()
      Returns java.util.Arrays.toString(this.ids()).
      Overrides:
      toString in class Object
      Returns:
      a string representation of this