public class CompactQualityOnlyGraph extends Object implements ExtendedNucleotideGraph
NucleotideGraph.ImmutableGraphProvider
Constructor and Description |
---|
CompactQualityOnlyGraph(byte[] qualities)
Constructs a new graph.
|
Modifier and Type | Method and Description |
---|---|
int |
getChromatogramLength()
The number of points for which this graph has values, which is typically larger than the
length of the nucleotide sequence because a base isn't called at every position in the graph.
|
int |
getChromatogramPositionForResidue(int residueIndex)
The graph position (can be used as an argument to
NucleotideGraph.getChromatogramValue(int, int) ) where the
nucleotide at the specified residue index has been called. |
int |
getChromatogramValue(int nucleotideStateNumber,
int graphPosition)
Returns the graph value for the specified nucleotide and at the specified position.
|
int |
getLeadingGapsLength()
Get the number of leading residues in the sequence this graph corresponds to that are all gaps.
|
int |
getSequenceLength()
The
length of the nucleotide sequence that can be annotated with this graph. |
int |
getSequenceQuality(int residueIndex)
Returns a measurement of confidence in the residue reported at the specified residueIndex in the sequence.
|
int |
getTrailingGapsLength()
Get the number of trailing residues in the sequence this graph corresponds to that are all gaps.
|
boolean |
hasChromatogramPositionsForResidues()
Tests whether this NucleotideGraph contains information about the position of the base calls,
i.e.
|
boolean |
hasChromatogramValues(int nucleotideStateNumber)
Specifies whether it is legal to call
NucleotideGraph.getChromatogramValue(int, int) for the specified nucleotide. |
boolean |
hasSequenceQualities()
Tests whether this graph contains information about the confidence in the associated sequence's
residues, i.e.
|
public CompactQualityOnlyGraph(byte[] qualities)
qualities
- the qualities of the graph. The contents of this array must not change after calling this method. The quality values may be negative values (because Java bytes
range in value from -128 to +127). Negative byte values are interpreted as postive integers (by adding 256) when returned from getSequenceQuality(int)
.public boolean hasSequenceQualities()
NucleotideGraph
NucleotideGraph.getSequenceQuality(int)
.hasSequenceQualities
in interface NucleotideGraph
NucleotideGraph.getSequenceQuality(int)
on this graph.public int getSequenceQuality(int residueIndex) throws IndexOutOfBoundsException, UnsupportedOperationException
NucleotideGraph
Integer.MIN_VALUE
if it is an end gap. If it is an internal gap, it should return the average quality of the non-gap positions
on either side of the gap.
This method may only be called if NucleotideGraph.hasSequenceQualities()
returns true.getSequenceQuality
in interface NucleotideGraph
residueIndex
- A value 0 <= residueIndex < NucleotideGraph.getSequenceLength()
specifying
the index in the nucleotide sequence for which to calculate the quality of the graph.IndexOutOfBoundsException
- if residueIndex < 0 or residueIndex > NucleotideGraph.getSequenceLength()
.UnsupportedOperationException
- if !hasSequenceQualities().public int getSequenceLength()
NucleotideGraph
length
of the nucleotide sequence that can be annotated with this graph.
If a class implements both this interface and SequenceDocument
, then the return value
of this method must be equal to getCharSequence()
.length()
Also if NucleotideGraph.hasChromatogramPositionsForResidues()
or NucleotideGraph.hasSequenceQualities()
is true, the return
value indicates the range of legal values to pass to NucleotideGraph.getChromatogramPositionForResidue(int)
and NucleotideGraph.getSequenceQuality(int)
.getSequenceLength
in interface NucleotideGraph
public int getChromatogramLength()
NucleotideGraph
getChromatogramLength
in interface NucleotideGraph
public int getChromatogramValue(int nucleotideStateNumber, int graphPosition) throws IndexOutOfBoundsException
NucleotideGraph
NucleotideGraph.hasChromatogramValues(int)
returns true for the
specified nucleotide.getChromatogramValue
in interface NucleotideGraph
nucleotideStateNumber
- The nucleotide for which to retrieve the graph value, encoded as
0 = A, 1 = C, 2 = G, 3 = T (alphabetic order, same as in Nucleotides
)graphPosition
- The position in the sequence for which to query the graph value,
with 0 <= graphPosition < graph length
IndexOutOfBoundsException
- if graphPosition < 0 or graphPosition >= NucleotideGraph.getChromatogramLength()
public boolean hasChromatogramValues(int nucleotideStateNumber)
NucleotideGraph
NucleotideGraph.getChromatogramValue(int, int)
for the specified nucleotide.hasChromatogramValues
in interface NucleotideGraph
nucleotideStateNumber
- A nucleotide state number encoded in the same way as for NucleotideGraph.getChromatogramValue(int, int)
,
i.e. 0 = A, 1 = C, 2 = G, 3 = TNucleotideGraph.getChromatogramValue(int, int)
for the specified nucleotidepublic int getChromatogramPositionForResidue(int residueIndex) throws IndexOutOfBoundsException, UnsupportedOperationException
NucleotideGraph
NucleotideGraph.getChromatogramValue(int, int)
) where the
nucleotide at the specified residue index has been called. This method may only be called if
NucleotideGraph.hasChromatogramPositionsForResidues()
returns true.
The graph sites are guaranteed to have the same order as the sequence nucleotides. Therefore,
any implementation must ensure that if i < j
, then
getChromatogramPositionForResidue(i) <= getChromatogramPositionForResidue(j)
.getChromatogramPositionForResidue
in interface NucleotideGraph
residueIndex
- A value 0 <= residueIndex < NucleotideGraph.getSequenceLength()
specifying
the index in the nucleotide sequence for which to calculate the corresponding position in the graph.NucleotideGraph.getChromatogramLength()
, specifiying the
graph position where the nucleotide that is at position residueIndex
has been
called. For positions residueIndex
where the
sequence
length
consisting of values
between 0 and getChromatogramLength()-1 inclusive. For a residueIndex where the sequence holds
a '-', the returned site position must always be Integer.MIN_VALUE
.IndexOutOfBoundsException
- if residueIndex < 0 or residueIndex > NucleotideGraph.getSequenceLength()
.UnsupportedOperationException
- if !hasChromatogramPositionsForResidues().public boolean hasChromatogramPositionsForResidues()
NucleotideGraph
NucleotideGraph.getChromatogramPositionForResidue(int)
.hasChromatogramPositionsForResidues
in interface NucleotideGraph
public int getLeadingGapsLength()
ExtendedNucleotideGraph
NucleotideGraph.getSequenceQuality(int)
and NucleotideGraph.getChromatogramPositionForResidue(int)
will both
return Integer.MIN_VALUE
for residueIndices less than the number of leading gaps.
Note, an implementation may choose to return 0 from this method even if it has leading end gaps or any value less than or equal to the number of leading gaps it has.getLeadingGapsLength
in interface ExtendedNucleotideGraph
public int getTrailingGapsLength()
ExtendedNucleotideGraph
NucleotideGraph.getSequenceQuality(int)
and NucleotideGraph.getChromatogramPositionForResidue(int)
will both
return Integer.MIN_VALUE
for residueIndices within this much of NucleotideGraph.getSequenceLength()
.
Note, an implementation may choose to return 0 from this method even if it has trailing end gaps or any value less than or equal to the number of trailing gaps it has.getTrailingGapsLength
in interface ExtendedNucleotideGraph