public final class DefaultNucleotideGraph extends Object implements ExtendedNucleotideGraph
NucleotideGraph that stores its values in int[] arrays internally,
and allows getting and setting those arrays.NucleotideGraph.ImmutableGraphProvider| Constructor and Description |
|---|
DefaultNucleotideGraph(int[][] chromatogramValues,
int[] chromatogramPositionsForResidues,
int[] sequenceQualities,
int sequenceLength,
int chromatogramLength)
Construct a new DefaultNucleotideGraph.
|
| Modifier and Type | Method and Description |
|---|---|
static DefaultNucleotideGraph |
copyOf(NucleotideGraph graph)
Creates a copy of the given graph.
|
static ExtendedNucleotideGraph |
createGraphWithAdjustedEndGaps(ExtendedNucleotideGraph originalGraph,
int newLeadingGapsLength,
int newTrailingGapsLength)
Creates a copy of the given graph with the length of its end gaps adjusted.
|
static NucleotideGraph |
createNucleotideGraph(int[][] chromatogramValues,
int[] chromatogramPositionsForResidues,
int[] sequenceQualities,
int sequenceLength,
int chromatogramLength)
Creates a new nucleotide graph.
|
static NucleotideGraph |
createNucleotideGraph(int[][] chromatogramValues,
int[] chromatogramPositionsForResidues,
int[] sequenceQualities,
int sequenceLength,
int chromatogramLength,
int leadingGapsLength,
int trailingGapsLength)
Creates a new nucleotide graph.
|
static NucleotideGraph |
createNucleotideGraph(int[] internalQualities,
int leadingGapsLength,
int trailingGapsLength)
Creates a new nucleotide graph with qualities but no traces.
|
static NucleotideGraph |
createNucleotideGraph(NucleotideGraph graphToCopy)
Creates a deep copy of the given graph.
|
static ExtendedNucleotideGraph |
createNucleotideGraphAdjustedForGapInsertion(NucleotideGraph graphToCopy,
CharSequence charSequence)
Creates a deep copy of the given graph with all graph values adjusted to compensate for gap insertion as indicated by the presense of gaps in charSequence.
|
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. |
static int[] |
getChromatogramPositionsForResidues(NucleotideGraph graph)
Equivalent to calling
getChromatogramPositionsForResidues(graph,0,graph.getSequenceLength()) |
static int[] |
getChromatogramPositionsForResidues(NucleotideGraph graph,
int startIndex,
int endIndex)
Get all the values returned from
NucleotideGraph.getChromatogramPositionForResidue(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive). |
int |
getChromatogramValue(int nucleotideStateNumber,
int graphPosition)
Returns the graph value for the specified nucleotide and at the specified position.
|
static int[][] |
getChromatogramValues(NucleotideGraph graph) |
static int[] |
getChromatogramValues(NucleotideGraph graph,
int i) |
DefaultNucleotideGraph |
getGraphAdjustedForDeletion(int firstResidueIndex,
int lastResidueIndexExclusive,
SequenceCharSequence newCharSequence)
Returns a new graph equivalent to this one, but adjusted to take into account a deletion from the associated sequence.
|
DefaultNucleotideGraph |
getGraphAdjustedForInsertion(int residueIndex,
CharSequence insertedChars)
Returns a new graph equivalent to this one, but adjusted to take into account an insertion into the associated sequence.
|
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. |
static int[] |
getSequenceQualities(NucleotideGraph graph)
Equivalent to calling
getSequenceQualities(graph,0,graph.getSequenceLength()) |
static int[] |
getSequenceQualities(NucleotideGraph graph,
int startIndex,
int endIndex)
Get all the values returned from
NucleotideGraph.getSequenceQuality(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive). |
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.
|
static ExtendedNucleotideGraph |
readObject(DataInput in)
Reads a graph previously written using
writeObject(java.io.DataOutput, NucleotideGraph) |
static ExtendedNucleotideGraph |
readObject(GeneiousObjectInputStream in)
Reads a graph previously written using
writeObject(GeneiousObjectOutputStream , NucleotideGraph) |
static ExtendedNucleotideGraph |
reverseComplement(NucleotideGraph graphToReverseComplement)
Creates a new graph that is the reverse complement of the given graph.
|
DefaultNucleotideGraph |
setChromatogramPositionsForResidues(int[] newSitePositions) |
DefaultNucleotideGraph |
setChromatogramValues(int[][] newGraphValues) |
DefaultNucleotideGraph |
setSequenceQualities(int[] newQualities) |
static void |
writeObject(DataOutput out,
NucleotideGraph graph)
Equivalent to
writeObject(Geneious.getMajorVersion(), out, graph) |
static void |
writeObject(Geneious.MajorVersion version,
DataOutput out,
NucleotideGraph graph)
Writes the given graph in a binary format to an output stream (as specified by
Serializable)
such that it can be recreated using readObject(java.io.DataInput). |
static void |
writeObject(GeneiousObjectOutputStream out,
NucleotideGraph graph)
Writes the given graph in a binary format to an output stream (as specified by
Serializable)
such that it can be recreated using readObject(GeneiousObjectInputStream). |
public DefaultNucleotideGraph(int[][] chromatogramValues,
int[] chromatogramPositionsForResidues,
int[] sequenceQualities,
int sequenceLength,
int chromatogramLength)
createNucleotideGraph(int[][], int[], int[], int, int) instead
unless you require the returned graph to be a DefaultNucleotideGraph rather than just a NucleotideGraph.public int getLeadingGapsLength()
ExtendedNucleotideGraphNucleotideGraph.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 ExtendedNucleotideGraphpublic int getTrailingGapsLength()
ExtendedNucleotideGraphNucleotideGraph.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 ExtendedNucleotideGraphpublic static int[][] getChromatogramValues(NucleotideGraph graph)
public static int[] getChromatogramValues(NucleotideGraph graph, int i)
public static int[] getChromatogramPositionsForResidues(NucleotideGraph graph)
getChromatogramPositionsForResidues(graph,0,graph.getSequenceLength())public static int[] getChromatogramPositionsForResidues(NucleotideGraph graph, int startIndex, int endIndex)
NucleotideGraph.getChromatogramPositionForResidue(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive).NucleotideGraph.getChromatogramPositionForResidue(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive) or null if NucleotideGraph.hasChromatogramPositionsForResidues()==false.public static int[] getSequenceQualities(NucleotideGraph graph)
getSequenceQualities(graph,0,graph.getSequenceLength())public static int[] getSequenceQualities(NucleotideGraph graph, int startIndex, int endIndex)
NucleotideGraph.getSequenceQuality(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive).NucleotideGraph.getSequenceQuality(int) for all
residues indices in the range startIndex (inclusive) to endIndex (exclusive) or null if NucleotideGraph.hasSequenceQualities()==false.public DefaultNucleotideGraph setSequenceQualities(int[] newQualities)
public DefaultNucleotideGraph setChromatogramPositionsForResidues(int[] newSitePositions)
public DefaultNucleotideGraph setChromatogramValues(int[][] newGraphValues)
public static NucleotideGraph createNucleotideGraph(int[][] chromatogramValues, int[] chromatogramPositionsForResidues, int[] sequenceQualities, int sequenceLength, int chromatogramLength, int leadingGapsLength, int trailingGapsLength)
ExtendedNucleotideGraph
but is declared to return a NucleotideGraph for backwards compatilbity reasons.chromatogramValues - the values to be returned from getChromatogramValue(int, int). May be null.chromatogramPositionsForResidues - the values to be returned from getChromatogramPositionForResidue(int) . May be null.sequenceQualities - the values to be returned from getSequenceQualities(NucleotideGraph). May be null. The quality values must not include those in end gap regions (specified by leadingGapsLength and trailingGapsLength)sequenceLength - the value to return from getSequenceLength()chromatogramLength - the value to return from getChromatogramLength()leadingGapsLength - the number of leading gaps in the sequence. chromatogramPositionsForResidues and sequenceQualities do not need to cover the leading gaps regionstrailingGapsLength - the number of leading gaps in the sequence. chromatogramPositionsForResidues and sequenceQualities do not need to cover the leading gaps regionspublic static NucleotideGraph createNucleotideGraph(int[] internalQualities, int leadingGapsLength, int trailingGapsLength)
internalQualities - the values to be returned from getSequenceQualities(NucleotideGraph). The quality values must not include those in end gap regions (specified by leadingGapsLength and trailingGapsLength)leadingGapsLength - leading gaps lengthtrailingGapsLength - trailing gaps lengthpublic static NucleotideGraph createNucleotideGraph(int[][] chromatogramValues, int[] chromatogramPositionsForResidues, int[] sequenceQualities, int sequenceLength, int chromatogramLength)
ExtendedNucleotideGraph
but is declared to return a NucleotideGraph for backwards compatilbity reasons.chromatogramValues - the values to be returned from getChromatogramValue(int, int). May be null.chromatogramPositionsForResidues - the values to be returned from getChromatogramPositionForResidue(int) . May be null.sequenceQualities - the values to be returned from getSequenceQualities(NucleotideGraph). May be null. The quality values must not include those in end gap regions (specified by leadingGapsLength and trailingGapsLength)sequenceLength - the value to return from getSequenceLength()chromatogramLength - the value to return from getChromatogramLength()public static ExtendedNucleotideGraph createNucleotideGraphAdjustedForGapInsertion(NucleotideGraph graphToCopy, CharSequence charSequence)
graphToCopy - the graph to copycharSequence - a CharSequence used for determining the positions of gaps to insert into the graph.public static ExtendedNucleotideGraph reverseComplement(NucleotideGraph graphToReverseComplement)
graphToReverseComplement - the graph to reverse complementpublic static NucleotideGraph createNucleotideGraph(NucleotideGraph graphToCopy)
ExtendedNucleotideGraph
but is declared to return a NucleotideGraph for backwards compatilbity reasons.graphToCopy - the graph to copypublic static ExtendedNucleotideGraph createGraphWithAdjustedEndGaps(ExtendedNucleotideGraph originalGraph, int newLeadingGapsLength, int newTrailingGapsLength)
originalGraph - the graph to create a copy ofnewLeadingGapsLength - the length of the leading gaps in the returned graphnewTrailingGapsLength - the length of the trailing gaps in the returned graphpublic static DefaultNucleotideGraph copyOf(NucleotideGraph graph)
createNucleotideGraph(NucleotideGraph) instead
unless you require the returned graph to be a DefaultNucleotideGraph rather than just a NucleotideGraph.graph - the graph to copypublic int getChromatogramLength()
NucleotideGraphgetChromatogramLength in interface NucleotideGraphpublic int getChromatogramValue(int nucleotideStateNumber,
int graphPosition)
throws IndexOutOfBoundsException
NucleotideGraphNucleotideGraph.hasChromatogramValues(int) returns true for the
specified nucleotide.getChromatogramValue in interface NucleotideGraphnucleotideStateNumber - 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 lengthIndexOutOfBoundsException - if graphPosition < 0 or graphPosition >= NucleotideGraph.getChromatogramLength()public boolean hasChromatogramValues(int nucleotideStateNumber)
NucleotideGraphNucleotideGraph.getChromatogramValue(int, int) for the specified nucleotide.hasChromatogramValues in interface NucleotideGraphnucleotideStateNumber - 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 getSequenceLength()
NucleotideGraphlength 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 NucleotideGraphpublic int getChromatogramPositionForResidue(int residueIndex)
throws IndexOutOfBoundsException,
UnsupportedOperationException
NucleotideGraphNucleotideGraph.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 NucleotideGraphresidueIndex - 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()
NucleotideGraphNucleotideGraph.getChromatogramPositionForResidue(int).hasChromatogramPositionsForResidues in interface NucleotideGraphpublic int getSequenceQuality(int residueIndex)
throws IndexOutOfBoundsException,
UnsupportedOperationException
NucleotideGraphInteger.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 NucleotideGraphresidueIndex - 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 boolean hasSequenceQualities()
NucleotideGraphNucleotideGraph.getSequenceQuality(int).hasSequenceQualities in interface NucleotideGraphNucleotideGraph.getSequenceQuality(int) on this graph.public static void writeObject(GeneiousObjectOutputStream out, NucleotideGraph graph) throws IOException
Serializable)
such that it can be recreated using readObject(GeneiousObjectInputStream).
Note, if the given graph is not a standard NucleotideGraph implementation (one created by
createNucleotideGraph(NucleotideGraph)),
then the object read back in will be converted to a standard NucleotideGraph implementation.out - the stream to write to.graph - the graph to write to the streamIOException - if it cannot be written to the stream.public static void writeObject(DataOutput out, NucleotideGraph graph) throws IOException
writeObject(Geneious.getMajorVersion(), out, graph)out - the stream to write to. If out is not a GeneiousObjectOutputStream and the graph is an ImmutableSequence its name may be uncompacted during deserializationgraph - the graph to write to the streamIOException - if it cannot be written to the stream.public static void writeObject(Geneious.MajorVersion version, DataOutput out, NucleotideGraph graph) throws IOException
Serializable)
such that it can be recreated using readObject(java.io.DataInput).
Note, if the given graph is not a standard NucleotideGraph implementation (one created by
createNucleotideGraph(NucleotideGraph)),
then the object read back in will be converted to a standard NucleotideGraph implementation.version - the Geneious version to ensure the data is compatible without - the stream to write to. If out is not a GeneiousObjectOutputStream and the graph is an ImmutableSequence its name may be uncompacted during deserializationgraph - the graph to write to the streamIOException - if it cannot be written to the stream.public static ExtendedNucleotideGraph readObject(GeneiousObjectInputStream in) throws IOException
writeObject(GeneiousObjectOutputStream , NucleotideGraph)in - the stream to read fromIOException - if it cannot be read from the stream.public static ExtendedNucleotideGraph readObject(DataInput in) throws IOException
writeObject(java.io.DataOutput, NucleotideGraph)in - the stream to read fromIOException - if it cannot be read from the stream.public DefaultNucleotideGraph getGraphAdjustedForInsertion(int residueIndex, CharSequence insertedChars)
residueIndex - the 0-based index to insert the new sequence atinsertedChars - the newly inserted characters.public DefaultNucleotideGraph getGraphAdjustedForDeletion(int firstResidueIndex, int lastResidueIndexExclusive, SequenceCharSequence newCharSequence)
firstResidueIndex - the 0-based index to begin the deletion fromlastResidueIndexExclusive - the 0-based index (exclusive) to finish the deletion atnewCharSequence - required if the leading and trailing gaps of the result are to be correct. (in case we delete all bases between and end gap and an internal gap then the end gaps need to be incremented). May be null if the calling code doesn't care if the leading and end gaps might be not as high as they should be