Package beagleutil

Class SampleIds


  • public final class SampleIds
    extends java.lang.Object

    Class SampleIds is a singleton class that represents a list of sample identifiers.

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIndex​(java.lang.String id)
      Returns the index of the specified sample identifier.
      int getIndexIfIndexed​(java.lang.String id)
      Returns the index of the specified sampled identifier, or returns -1 if the specified sample identifier is not indexed.
      int[] getIndices​(java.lang.String[] ids)
      Returns an array of sample identifier indices corresponding to the specified array of sample identifiers.
      java.lang.String id​(int index)
      Returns the sample identifier with the specified index.
      java.lang.String[] ids()
      Returns the list of indexed sample identifiers as an array.
      java.lang.String[] ids​(int[] indices)
      Returns a list of sample identifiers with the specified indices.
      static SampleIds instance()
      Returns the singleton SampleIds instance.
      int size()
      Returns the number of indexed sample identifiers.
      java.lang.String toString()
      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 Detail

      • instance

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

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

        public int[] getIndices​(java.lang.String[] ids)
        Returns an array of sample identifier indices corresponding to the specified array of sample 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:
        java.lang.IllegalArgumentException - if there is a j satisfying (0 <= j && j < ids.length) && ids[j].isEmpty()
        java.lang.NullPointerException - if ids == null
        java.lang.NullPointerException - if there is a j satisfying (0 <= j && j < ids.length) && (ids[j] == null)
      • getIndexIfIndexed

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

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

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

        public java.lang.String[] ids​(int[] indices)
        Returns a list of sample identifiers with the specified indices.
        Parameters:
        indices - an array of sample identifiers indices
        Returns:
        a list of sample identifiers with the specified indices
        Throws:
        java.lang.IndexOutOfBoundsException - if there exists a j satisfying (0 <= j && j < indices.length) && (indices[j] < 0 || indices[j] >= this.size())
      • ids

        public java.lang.String[] ids()
        Returns the list of indexed sample 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 && k < this.size().
        Returns:
        an array of sample identifiers
      • toString

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