Package vcf

Class Samples


  • public final class Samples
    extends java.lang.Object

    Class Samples stores a list of samples.

    Instances of class Samples are immutable.
    • Constructor Summary

      Constructors 
      Constructor Description
      Samples​(int[] idIndices, boolean[] isDiploid)
      Constructs a new instance of Samples corresponding to the specified list of diploid sample identifier indices.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Samples combine​(Samples first, Samples second)
      Returns a new samples instance by combining the two list of samples in the specified order
      boolean equals​(java.lang.Object obj)
      Returns true if the specified object is a Samples object which represents the same ordered list of samples as this, and returns false otherwise.
      static Samples fromIds​(java.lang.String[] ids, boolean[] isDiploid)
      Constructs and returns a Samples instance corresponding to the specified list of sample identifiers.
      int hashCode()
      Returns a hash code value for the object.
      java.lang.String id​(int index)
      Returns the identifier for the sample with the specified index in this list of samples.
      int idIndex​(int index)
      Returns the sample identifier index corresponding to the sample with the specified index in this list of samples.
      int[] idIndexToIndex()
      Returns an array mapping sample identifier indices to sample indices.
      java.lang.String[] ids()
      Returns this list of samples as an array of sample identifiers.
      boolean isDiploid​(int sample)
      Returns true if the specified sample has two alleles per genotype, and returns false if the sample has one allele per genotype.
      int size()
      Returns the number of samples in this list.
      java.lang.String toString()
      Returns java.util.Arrays.toString(this.ids()).
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Samples

        public Samples​(int[] idIndices,
                       boolean[] isDiploid)
        Constructs a new instance of Samples corresponding to the specified list of diploid sample identifier indices.
        Parameters:
        idIndices - an array of sample identifier indices
        isDiploid - a boolean array whose k-th value is true if the k-th sample is diploid, and is false if the k-th sample is haploid
        Throws:
        java.lang.IllegalArgumentException - if idIndices.length != isDiploid.length
        java.lang.IllegalArgumentException - if the specified idIndices array has two or more elements that are equal
        java.lang.IndexOutOfBoundsException - if any element of the specified idIndices array is negative or greater than or equal to beagleutil.SampleIds.instance().size()
        java.lang.NullPointerException - if idIndices == null || isDiploid == null
    • Method Detail

      • combine

        public static Samples combine​(Samples first,
                                      Samples second)
        Returns a new samples instance by combining the two list of samples in the specified order
        Parameters:
        first - the first list of samples
        second - the second list of samples
        Returns:
        the combined samples
        Throws:
        java.lang.IllegalArgumentException - if the two lists of samples are not disjoint
        java.lang.NullPointerException - if first == null || second == null
      • idIndexToIndex

        public int[] idIndexToIndex()
        Returns an array mapping sample identifier indices to sample indices. Indices for sample identifiers not present in this list of samples are mapped to -1.
        Returns:
        an array mapping sample identifier indices to sample indices
      • fromIds

        public static Samples fromIds​(java.lang.String[] ids,
                                      boolean[] isDiploid)
        Constructs and returns a Samples instance corresponding to the specified list of sample identifiers.
        Parameters:
        ids - an array of sample identifiers
        isDiploid - a boolean array whose k-th value is true if the k-th sample is diploid, and is false if the k-th sample is haploid
        Returns:
        a Samples instance corresponding to the specified list of sample identifiers
        Throws:
        java.lang.IllegalArgumentException - if ids.length != isDiploid.length
        java.lang.IllegalArgumentException - if the specified array has two or more elements that are equal as strings
        java.lang.NullPointerException - if ids == null || isDiploid == null
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for the object.
      • equals

        public boolean equals​(java.lang.Object obj)
        Returns true if the specified object is a Samples object which represents the same ordered list of samples as this, and returns false otherwise.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to be tested for equality with this
        Returns:
        true if the specified object is a Samples object which represents the same ordered list of samples as this
      • idIndex

        public int idIndex​(int index)
        Returns the sample identifier index corresponding to the sample with the specified index in this list of samples.
        Parameters:
        index - a sample index
        Returns:
        the sample identifier index corresponding to the sample with the specified index in this list of samples
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= this.size()
      • size

        public int size()
        Returns the number of samples in this list.
        Returns:
        the number of samples in this list
      • id

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

        public java.lang.String[] ids()
        Returns this list of samples as an array of sample identifiers. The returned array has length this.size(), and it satisfies this.ids()[j].equals(this.id(j)) for 0 <= j && j < this.size()
        Returns:
        this list of samples as an array of sample identifiers
      • isDiploid

        public boolean isDiploid​(int sample)
        Returns true if the specified sample has two alleles per genotype, and returns false if the sample has one allele per genotype.
        Parameters:
        sample - a sample index
        Returns:
        true if the specified sample is diploid
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.size()
      • 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