Package bref
Class SeqCoder3
java.lang.Object
bref.SeqCoder3
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
FieldsModifier and TypeFieldDescriptionstatic final floatThe major allele frequency threshold for allele coding.static final intThe maximum number of alleles are that permitted in order for theadd()method to returntrue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAttempts to add the specifiedRefGTRecobject to the list of compressedRefGTRecobjects, and returnstrueif theRefGTRecobject was added.static intdefaultMaxNSeq(int nSamples) Returns the default maximum number of sequences for the specified number of samples.Returns and clears the stored list of compressedRefGTRecobjects.intmaxNSeq()Returns the maximum number of distinct allele sequences.intnRecs()Returns the number of compressedRefGTRecobjects.samples()Returns the list of samples whose phased genotype data will be compressed.
-
Field Details
-
MAX_NALLELES
public static final int MAX_NALLELESThe maximum number of alleles are that permitted in order for theadd()method to returntrue- See Also:
-
COMPRESS_FREQ_THRESHOLD
public static final float COMPRESS_FREQ_THRESHOLDThe 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:
-
-
Constructor Details
-
SeqCoder3
Constructs a newSeqCoder3for the specified samples.- Parameters:
samples- the list of samples whose data will be compressed- Throws:
NullPointerException- ifsamples == null
-
SeqCoder3
Constructs a newSeqCoder3for the specified samples.- Parameters:
samples- the list of samples whose data will be compressedmaxNSeq- the maximum number of distinct allele sequences permitted if theadd()method returnstrue- Throws:
NullPointerException- ifsamples == nullIllegalArgumentException-maxNSeq < 0 || maxNSeq >= Character.MAX_VALUE
-
-
Method Details
-
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:
IllegalArgumentException- ifsize < 1
-
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 compressedRefGTRecobjects.- Returns:
- the number of compressed
RefGTRecobjects
-
maxNSeq
public int maxNSeq()Returns the maximum number of distinct allele sequences.- Returns:
- the maximum number of distinct allele sequences
-
add
Attempts to add the specifiedRefGTRecobject to the list of compressedRefGTRecobjects, and returnstrueif theRefGTRecobject was added.- Parameters:
rec- reference genotypes for a marker- Returns:
trueif the specifiedRefGTRecobject was added to the list of compressed markers- Throws:
IllegalArgumentException- ifrec.samples().equals(this.samples()) == falseIllegalArgumentException- ifrec.isAlleleCoded() == falseNullPointerException- ifrec == null
-
getCompressedList
Returns and clears the stored list of compressedRefGTRecobjects.- Returns:
- the list of compressed
RefGTRecobjects
-