Package bref

Class SeqCoder3


  • public class SeqCoder3
    extends java.lang.Object

    Class SeqCoder3 compresses a sequence of allele-coded RefGTRec objects. The class is designed for use with bref v3 format. Compression is performed by storing the list of distinct allele sequences and the allele sequence carried by each haplotype.

    Class SeqCoder3 is not thread-safe.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static float COMPRESS_FREQ_THRESHOLD
      The major allele frequency threshold for allele coding.
      static int MAX_NALLELES
      The maximum number of alleles are that permitted in order for the add() method to return true
    • Constructor Summary

      Constructors 
      Constructor Description
      SeqCoder3​(Samples samples)
      Constructs a new SeqCoder3 for the specified samples.
      SeqCoder3​(Samples samples, int maxNSeq)
      Constructs a new SeqCoder3 for the specified samples.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(RefGTRec rec)
      Attempts to add the specified RefGTRec object to the list of compressed RefGTRec objects, and returns true if the RefGTRec object was added.
      static int defaultMaxNSeq​(int nSamples)
      Returns the default maximum number of sequences for the specified number of samples.
      java.util.List<RefGTRec> getCompressedList()
      Returns and clears the stored list of compressed RefGTRec objects.
      int maxNSeq()
      Returns the maximum number of distinct allele sequences.
      int nRecs()
      Returns the number of compressed RefGTRec objects.
      Samples samples()
      Returns the list of samples whose phased genotype data will be compressed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_NALLELES

        public static final int MAX_NALLELES
        The maximum number of alleles are that permitted in order for the add() method to return true
        See Also:
        Constant Field Values
      • COMPRESS_FREQ_THRESHOLD

        public static final float COMPRESS_FREQ_THRESHOLD
        The major allele frequency threshold for allele coding. Sequence coding should only be applied if the major allele frequency less than or equal to this threshold.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SeqCoder3

        public SeqCoder3​(Samples samples)
        Constructs a new SeqCoder3 for the specified samples.
        Parameters:
        samples - the list of samples whose data will be compressed
        Throws:
        java.lang.NullPointerException - if samples == null
      • SeqCoder3

        public SeqCoder3​(Samples samples,
                         int maxNSeq)
        Constructs a new SeqCoder3 for the specified samples.
        Parameters:
        samples - the list of samples whose data will be compressed
        maxNSeq - the maximum number of distinct allele sequences permitted if the add() method returns true
        Throws:
        java.lang.NullPointerException - if samples == null
        java.lang.IllegalArgumentException - maxNSeq < 0 || maxNSeq >= Chracter.MAX_VALUE
    • Method Detail

      • defaultMaxNSeq

        public static int defaultMaxNSeq​(int nSamples)
        Returns the default maximum number of sequences for the specified number of samples. The default value is equal to (int) Math.min((long) Math.pow(2, 2*Math.log10(size) + 1), Character.MAX_VALUE)
        Parameters:
        nSamples - the number of samples
        Returns:
        the default maximum number of sequences for the specified number of samples
        Throws:
        java.lang.IllegalArgumentException - if size < 1
      • samples

        public Samples samples()
        Returns the list of samples whose phased genotype data will be compressed.
        Returns:
        the list of samples whose phased genotype data will be compressed
      • nRecs

        public int nRecs()
        Returns the number of compressed RefGTRec objects.
        Returns:
        the number of compressed RefGTRec objects
      • maxNSeq

        public int maxNSeq()
        Returns the maximum number of distinct allele sequences.
        Returns:
        the maximum number of distinct allele sequences
      • add

        public boolean add​(RefGTRec rec)
        Attempts to add the specified RefGTRec object to the list of compressed RefGTRec objects, and returns true if the RefGTRec object was added.
        Parameters:
        rec - reference genotypes for a marker
        Returns:
        true if the specified RefGTRec object was added to the list of compressed markers
        Throws:
        java.lang.IllegalArgumentException - if em.samples().equals(this.samples()) == false
        java.lang.IllegalArgumentException - if rec.isAlleleCoded() == false
        java.lang.NullPointerException - if rec == null
      • getCompressedList

        public java.util.List<RefGTRec> getCompressedList()
        Returns and clears the stored list of compressed RefGTRec objects.
        Returns:
        the list of compressed RefGTRec objects