Skip to content

QualitySequence

Dan Katzel edited this page Jul 22, 2017 · 1 revision

QualitySequence

A QualitySequence is a Sequence of PhredQuality values that often accompanies NucleotideSequence data.

QualitySequenceBuilder

A QualitySequenceBuilder is a class that allows code to programmatically construct an immutable QualitySequence in a similar manner to how a Java StringBuilder can build an immutable String. QualitySequenceBuilder uses method chaining which allows calls to get chained together for easier reading.

The build() method will return an immutable instance of the QualitySequence interface which will have the same sequence as the current sequence in the builder. Jillion has several built-in implementations of QualitySequence to provide the different memory or performance characteristics. For example, many QualitySequences such as consensus qualities have several equal consecutive values which can be compressed into a very small amount of memory using run-length encoding.

Creating new Builders

QualitySequenceBuilder has a constructor that takes a byte array which assumes each value in the byte array is a phred quality score. This byte array should not be encoded: a byte value of 20 means QV 20 etc.

QualitySequence quals = new QualitySequenceBuilder(new byte[]{20,30,40,40,50,60})
 
//add QV 35 to end of sequence
quals.append(PhredQuality.valueOf(35);
 
//the 4th offset (in zero based)
//has a quality value of 50
PhredQuality quality =quals.get(4);
 
assertEquals(50, quality.getQualityScore());

Clone this wiki locally