Class DefaultNucleotideGraph

    • Field Detail

      • EDITED_NUCLEOTIDE_QUALITY

        public static final int EDITED_NUCLEOTIDE_QUALITY
        The quality score assigned to a nucleotide which is edited in a sequence with quality. This has a value of 63, which is higher than any quality score assigned by a Sanger machine and can therefore be used by consensus calling to know not to further inspect the trace to make a call, but instead respect what the user has assigned for the base call.
        Since:
        API 4.201910
        See Also:
        Constant Field Values
    • Method Detail

      • getChromatogramValues

        public static int[][] getChromatogramValues​(NucleotideGraph graph)
      • getChromatogramValues

        public static int[] getChromatogramValues​(NucleotideGraph graph,
                                                  int i)
      • setChromatogramPositionsForResidues

        public DefaultNucleotideGraph setChromatogramPositionsForResidues​(int[] newSitePositions)
      • createNucleotideGraph

        public static NucleotideGraph createNucleotideGraph​(int[][] chromatogramValues,
                                                            int[] chromatogramPositionsForResidues,
                                                            int[] sequenceQualities,
                                                            int sequenceLength,
                                                            int chromatogramLength,
                                                            int leadingGapsLength,
                                                            int trailingGapsLength)
        Creates a new nucleotide graph. This method always returns an ExtendedNucleotideGraph but is declared to return a NucleotideGraph for backwards compatilbity reasons.
        Parameters:
        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 regions
        trailingGapsLength - the number of leading gaps in the sequence. chromatogramPositionsForResidues and sequenceQualities do not need to cover the leading gaps regions
        Returns:
        the new graph.
      • createNucleotideGraph

        public static NucleotideGraph createNucleotideGraph​(int[] internalQualities,
                                                            int leadingGapsLength,
                                                            int trailingGapsLength)
        Creates a new nucleotide graph with qualities but no traces.
        Parameters:
        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 length
        trailingGapsLength - trailing gaps length
        Returns:
        the new graph
        Since:
        API 4.50 (Geneious 5.5.0)
      • createNucleotideGraph

        public static NucleotideGraph createNucleotideGraph​(int[][] chromatogramValues,
                                                            int[] chromatogramPositionsForResidues,
                                                            int[] sequenceQualities,
                                                            int sequenceLength,
                                                            int chromatogramLength)
        Creates a new nucleotide graph. This method always returns an ExtendedNucleotideGraph but is declared to return a NucleotideGraph for backwards compatilbity reasons.
        Parameters:
        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()
        Returns:
        the new graph.
      • createNucleotideGraphAdjustedForGapInsertion

        public static ExtendedNucleotideGraph createNucleotideGraphAdjustedForGapInsertion​(NucleotideGraph graphToCopy,
                                                                                           java.lang.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.
        Parameters:
        graphToCopy - the graph to copy
        charSequence - a CharSequence used for determining the positions of gaps to insert into the graph.
        Returns:
        a deep copy of the graph adjusted for gap insertion
      • reverseComplement

        public static ExtendedNucleotideGraph reverseComplement​(NucleotideGraph graphToReverseComplement)
        Creates a new graph that is the reverse complement of the given graph.
        Parameters:
        graphToReverseComplement - the graph to reverse complement
        Returns:
        a newly created graph which is the reverse complement of the given graph.
      • createNucleotideGraph

        public static NucleotideGraph createNucleotideGraph​(NucleotideGraph graphToCopy)
        Creates a deep copy of the given graph. This method always returns an ExtendedNucleotideGraph but is declared to return a NucleotideGraph for backwards compatilbity reasons.
        Parameters:
        graphToCopy - the graph to copy
        Returns:
        a deep copy of the graph.
      • createGraphWithAdjustedEndGaps

        public static ExtendedNucleotideGraph createGraphWithAdjustedEndGaps​(ExtendedNucleotideGraph originalGraph,
                                                                             int newLeadingGapsLength,
                                                                             int newTrailingGapsLength)
        Creates a copy of the given graph with the length of its end gaps adjusted. If the original graph was created using one of the createNucleotideGraph methods in this class, then this method will be efficient in that the actual graph data can be resued in the returned class since original graph is immutable.
        Parameters:
        originalGraph - the graph to create a copy of
        newLeadingGapsLength - the length of the leading gaps in the returned graph
        newTrailingGapsLength - the length of the trailing gaps in the returned graph
        Returns:
        a new graph
      • getChromatogramLength

        public int getChromatogramLength()
        Description copied from interface: NucleotideGraph
        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.
        Specified by:
        getChromatogramLength in interface NucleotideGraph
        Returns:
        the length of this graph, or 0 if this graph has no graph values for any nucleotide (i.e. 0 if NucleotideGraph.hasChromatogramPositionsForResidues() is false).
      • getChromatogramValue

        public int getChromatogramValue​(int nucleotideStateNumber,
                                        int graphPosition)
                                 throws java.lang.IndexOutOfBoundsException
        Description copied from interface: NucleotideGraph
        Returns the graph value for the specified nucleotide and at the specified position. If the graph is a chromatogram, this is a measure of the support for the specified nucleotide at this position. May only be called if NucleotideGraph.hasChromatogramValues(int) returns true for the specified nucleotide.
        Specified by:
        getChromatogramValue in interface NucleotideGraph
        Parameters:
        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
        Returns:
        the graph value for the specified nucleotide and at the specified position.
        Throws:
        java.lang.IndexOutOfBoundsException - if graphPosition < 0 or graphPosition >= NucleotideGraph.getChromatogramLength()
      • getChromatogramPositionForResidue

        public int getChromatogramPositionForResidue​(int residueIndex)
                                              throws java.lang.IndexOutOfBoundsException,
                                                     java.lang.UnsupportedOperationException
        Description copied from interface: NucleotideGraph
        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. 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).
        Specified by:
        getChromatogramPositionForResidue in interface NucleotideGraph
        Parameters:
        residueIndex - A value 0 <= residueIndex < NucleotideGraph.getSequenceLength() specifying the index in the nucleotide sequence for which to calculate the corresponding position in the graph.
        Returns:
        A value in the range 0 <= value < 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.
        Throws:
        java.lang.IndexOutOfBoundsException - if residueIndex < 0 or residueIndex > NucleotideGraph.getSequenceLength().
        java.lang.UnsupportedOperationException - if !hasChromatogramPositionsForResidues().
      • getSequenceQuality

        public int getSequenceQuality​(int residueIndex)
                               throws java.lang.IndexOutOfBoundsException,
                                      java.lang.UnsupportedOperationException
        Description copied from interface: NucleotideGraph
        Returns a measurement of confidence in the residue reported at the specified residueIndex in the sequence. The measure is on a logaritmic scale: P(call correct) = 1 - 10^(-v/10) where v is the quality returned from this method.

        If the sequence contains a gap at the specified position, this method should return 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.

        Specified by:
        getSequenceQuality in interface NucleotideGraph
        Parameters:
        residueIndex - A value 0 <= residueIndex < NucleotideGraph.getSequenceLength() specifying the index in the nucleotide sequence for which to calculate the quality of the graph.
        Returns:
        The quality score v for the residue at the specified index in the nucleotide sequence, which indicates the reliability of the nucleotide on a logarithmic scale as described above.
        Throws:
        java.lang.IndexOutOfBoundsException - if residueIndex < 0 or residueIndex > NucleotideGraph.getSequenceLength().
        java.lang.UnsupportedOperationException - if !hasSequenceQualities().
      • writeObject

        public static void writeObject​(GeneiousObjectOutputStream out,
                                       NucleotideGraph graph)
                                throws java.io.IOException
        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). 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.
        Parameters:
        out - the stream to write to.
        graph - the graph to write to the stream
        Throws:
        java.io.IOException - if it cannot be written to the stream.
      • writeObject

        public static void writeObject​(java.io.DataOutput out,
                                       NucleotideGraph graph)
                                throws java.io.IOException
        Equivalent to writeObject(Geneious.getMajorVersion(), out, graph)
        Parameters:
        out - the stream to write to. If out is not a GeneiousObjectOutputStream and the graph is an ImmutableSequence its name may be uncompacted during deserialization
        graph - the graph to write to the stream
        Throws:
        java.io.IOException - if it cannot be written to the stream.
        Since:
        API 4.30 (Geneious 5.3.0)
      • writeObject

        public static void writeObject​(Geneious.MajorVersion version,
                                       java.io.DataOutput out,
                                       NucleotideGraph graph)
                                throws java.io.IOException
        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). 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.
        Parameters:
        version - the Geneious version to ensure the data is compatible with
        out - the stream to write to. If out is not a GeneiousObjectOutputStream and the graph is an ImmutableSequence its name may be uncompacted during deserialization
        graph - the graph to write to the stream
        Throws:
        java.io.IOException - if it cannot be written to the stream.
        Since:
        API 4.600 (Geneious 6.0.0)
      • readObject

        public static ExtendedNucleotideGraph readObject​(java.io.DataInput in)
                                                  throws java.io.IOException
        Reads a graph previously written using writeObject(java.io.DataOutput, NucleotideGraph)
        Parameters:
        in - the stream to read from
        Returns:
        the graph read from the stream
        Throws:
        java.io.IOException - if it cannot be read from the stream.
        Since:
        API 4.30 (Geneious 5.3.0)
      • getGraphAdjustedForReplacement

        public ExtendedNucleotideGraph getGraphAdjustedForReplacement​(int residueIndex,
                                                                      int numberOfResiduesReplaced)
        Returns a new graph equivalent to this one, but with quality scores in the replaced nucleotides adjusted to be EDITED_NUCLEOTIDE_QUALITY
        Parameters:
        residueIndex - the first (zero based) position of a replaced nucleotide
        numberOfResiduesReplaced - the number of nucleotides replaced
        Returns:
        a new graph, or this graph if no nucleotides were replaced.
        Since:
        API 4.201910
      • getGraphAdjustedForInsertion

        public DefaultNucleotideGraph getGraphAdjustedForInsertion​(int residueIndex,
                                                                   java.lang.CharSequence insertedChars)
        Returns a new graph equivalent to this one, but adjusted to take into account an insertion into the associated sequence.
        Parameters:
        residueIndex - the 0-based index to insert the new sequence at
        insertedChars - the newly inserted characters.
        Returns:
        a new graph equivalent to this one, but adjusted to take into account an insertion into the associated sequence or this graph if no changes were needed.
        Since:
        API 4.700 (Geneious 7.0.0)
      • getGraphAdjustedForDeletion

        public 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.
        Parameters:
        firstResidueIndex - the 0-based index to begin the deletion from
        lastResidueIndexExclusive - the 0-based index (exclusive) to finish the deletion at
        newCharSequence - 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
        Returns:
        a new graph equivalent to this one, but adjusted to take into account a deletion from the associated sequence or this graph if no changes were needed.
        Since:
        API 4.700 (Geneious 7.0.0)