Class FastqTools


  • public final class FastqTools
    extends Object
    Utility methods for FASTQ formatted sequences.
    Since:
    3.0.3
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Fastq convert​(Fastq fastq, FastqVariant variant)
      Convert the specified FASTQ formatted sequence to the specified FASTQ sequence format variant.
      static org.biojava.nbio.core.sequence.DNASequence createDNASequence​(Fastq fastq)
      Create and return a new DNASequence from the specified FASTQ formatted sequence.
      static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithErrorProbabilities​(Fastq fastq)
      Create and return a new DNASequence with error probabilities from the specified FASTQ formatted sequence.
      static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithQualityScores​(Fastq fastq)
      Create and return a new DNASequence with quality scores from the specified FASTQ formatted sequence.
      static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithQualityScoresAndErrorProbabilities​(Fastq fastq)
      Create and return a new DNASequence with quality scores and error probabilities from the specified FASTQ formatted sequence.
      static org.biojava.nbio.core.sequence.features.QuantityFeature<org.biojava.nbio.core.sequence.template.AbstractSequence<org.biojava.nbio.core.sequence.compound.NucleotideCompound>,​org.biojava.nbio.core.sequence.compound.NucleotideCompound> createErrorProbabilities​(Fastq fastq)
      Create and return a new QuantityFeature from the error probabilities of the specified FASTQ formatted sequence.
      static org.biojava.nbio.core.sequence.features.QualityFeature<org.biojava.nbio.core.sequence.template.AbstractSequence<org.biojava.nbio.core.sequence.compound.NucleotideCompound>,​org.biojava.nbio.core.sequence.compound.NucleotideCompound> createQualityScores​(Fastq fastq)
      Create and return a new QualityFeature from the quality scores of the specified FASTQ formatted sequence.
      static Iterable<Number> errorProbabilities​(Fastq fastq)
      Return the error probabilities from the specified FASTQ formatted sequence.
      static double[] errorProbabilities​(Fastq fastq, double[] errorProbabilities)
      Copy the error probabilities from the specified FASTQ formatted sequence into the specified double array.
      static Iterable<Number> qualityScores​(Fastq fastq)
      Return the quality scores from the specified FASTQ formatted sequence.
      static int[] qualityScores​(Fastq fastq, int[] qualityScores)
      Copy the quality scores from the specified FASTQ formatted sequence into the specified int array.
    • Method Detail

      • createDNASequence

        public static org.biojava.nbio.core.sequence.DNASequence createDNASequence​(Fastq fastq)
                                                                            throws org.biojava.nbio.core.exceptions.CompoundNotFoundException
        Create and return a new DNASequence from the specified FASTQ formatted sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new DNASequence from the specified FASTQ formatted sequence
        Throws:
        org.biojava.nbio.core.exceptions.CompoundNotFoundException - if DNA sequence in fastq contains unrecognised compounds
      • createDNASequenceWithQualityScores

        public static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithQualityScores​(Fastq fastq)
                                                                                             throws org.biojava.nbio.core.exceptions.CompoundNotFoundException
        Create and return a new DNASequence with quality scores from the specified FASTQ formatted sequence. The quality scores are stored in a QualityFeature with a type "qualityScores" the same length as the sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new DNASequence with quality scores from the specified FASTQ formatted sequence
        Throws:
        org.biojava.nbio.core.exceptions.CompoundNotFoundException - if DNA sequence in fastq contains unrecognised compounds
      • createDNASequenceWithErrorProbabilities

        public static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithErrorProbabilities​(Fastq fastq)
                                                                                                  throws org.biojava.nbio.core.exceptions.CompoundNotFoundException
        Create and return a new DNASequence with error probabilities from the specified FASTQ formatted sequence. The error probabilities are stored in a QuantityFeature with a type "errorProbabilities" the same length as the sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new DNASequence with error probabilities from the specified FASTQ formatted sequence
        Throws:
        org.biojava.nbio.core.exceptions.CompoundNotFoundException - if DNA sequence in fastq contains unrecognised compounds
      • createDNASequenceWithQualityScoresAndErrorProbabilities

        public static org.biojava.nbio.core.sequence.DNASequence createDNASequenceWithQualityScoresAndErrorProbabilities​(Fastq fastq)
                                                                                                                  throws org.biojava.nbio.core.exceptions.CompoundNotFoundException
        Create and return a new DNASequence with quality scores and error probabilities from the specified FASTQ formatted sequence. The quality scores are stored in a QualityFeature with a type "qualityScores" the same length as the sequence and the error probabilities are stored in a QuantityFeature with a type "errorProbabilities" the same length as the sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new DNASequence with quality scores and error probabilities from the specified FASTQ formatted sequence
        Throws:
        org.biojava.nbio.core.exceptions.CompoundNotFoundException - if DNA sequence in fastq contains unrecognised compounds
      • createQualityScores

        public static org.biojava.nbio.core.sequence.features.QualityFeature<org.biojava.nbio.core.sequence.template.AbstractSequence<org.biojava.nbio.core.sequence.compound.NucleotideCompound>,​org.biojava.nbio.core.sequence.compound.NucleotideCompound> createQualityScores​(Fastq fastq)
        Create and return a new QualityFeature from the quality scores of the specified FASTQ formatted sequence. The quality scores feature has a type "qualityScores" and will be the same length as the sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new QualityFeature from the quality scores of the specified FASTQ formatted sequence
      • createErrorProbabilities

        public static org.biojava.nbio.core.sequence.features.QuantityFeature<org.biojava.nbio.core.sequence.template.AbstractSequence<org.biojava.nbio.core.sequence.compound.NucleotideCompound>,​org.biojava.nbio.core.sequence.compound.NucleotideCompound> createErrorProbabilities​(Fastq fastq)
        Create and return a new QuantityFeature from the error probabilities of the specified FASTQ formatted sequence. The error probabilities feature has a type "errorProbabilities" and will be the same length as the sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        a new QualityFeature from the error probabilities of the specified FASTQ formatted sequence
      • qualityScores

        public static Iterable<Number> qualityScores​(Fastq fastq)
        Return the quality scores from the specified FASTQ formatted sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        the quality scores from the specified FASTQ formatted sequence
      • qualityScores

        public static int[] qualityScores​(Fastq fastq,
                                          int[] qualityScores)
        Copy the quality scores from the specified FASTQ formatted sequence into the specified int array.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        qualityScores - int array of quality scores, must not be null and must be the same length as the FASTQ formatted sequence quality
        Returns:
        the specified int array of quality scores
      • errorProbabilities

        public static Iterable<Number> errorProbabilities​(Fastq fastq)
        Return the error probabilities from the specified FASTQ formatted sequence.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        Returns:
        the error probabilities from the specified FASTQ formatted sequence
      • errorProbabilities

        public static double[] errorProbabilities​(Fastq fastq,
                                                  double[] errorProbabilities)
        Copy the error probabilities from the specified FASTQ formatted sequence into the specified double array.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        errorProbabilities - double array of error probabilities, must not be null and must be the same length as the FASTQ formatted sequence quality
        Returns:
        the specified double array of error probabilities
      • convert

        public static Fastq convert​(Fastq fastq,
                                    FastqVariant variant)
        Convert the specified FASTQ formatted sequence to the specified FASTQ sequence format variant.
        Parameters:
        fastq - FASTQ formatted sequence, must not be null
        variant - FASTQ sequence format variant, must not be null
        Returns:
        the specified FASTQ formatted sequence converted to the specified FASTQ sequence format variant
        Since:
        4.2