Package vcf

Class Samples

java.lang.Object
vcf.Samples

public final class Samples extends Object

Class Samples stores a list of samples.

Instances of class Samples are immutable.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Samples(String[] ids, boolean[] isDiploid)
    Constructs a new Samples instance corresponding to the specified list of sample identifiers.
  • Method Summary

    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
    Returns true if the specified object is a Samples object which represents the same ordered list of samples as this, and returns false otherwise.
    int
    Returns a hash code value for the object.
    id(int index)
    Returns the identifier for the sample with the specified index in this list of samples.
    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
    Returns the number of samples in this list.
    Returns java.util.Arrays.toString(this.ids()).

    Methods inherited from class java.lang.Object

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

    • Samples

      public Samples(String[] ids, boolean[] isDiploid)
      Constructs a new Samples instance corresponding to the specified list of sample identifiers. A warning is printed to standard error if any string occurs more than once in the ids array.
      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
      Throws:
      IllegalArgumentException - if ids.length != isDiploid.length
      IllegalArgumentException - if there exists j such that ((0 <= j) && j < ids.length) && (ids[j].length()==0)
      NullPointerException - if ids == null || isDiploid == null
      NullPointerException - if there exists j such that ((0 <= j) && j < ids.length) && (ids[j]==null))
  • Method Details

    • 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:
      IllegalArgumentException - if the two lists of samples are not disjoint
      NullPointerException - if first == null || second == null
    • hashCode

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

      public boolean equals(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 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
    • size

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

      public 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:
      IndexOutOfBoundsException - if index < 0 || index >= this.size()
    • ids

      public 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:
      IndexOutOfBoundsException - if sample < 0 || sample >= this.size()
    • toString

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