Class PhredTools

java.lang.Object
org.biojava.bio.program.phred.PhredTools

public final class PhredTools extends Object

PhredTools contains static methods for working with phred quality data.

Copyright (c) 2001

Company: AgResearch

Since:
1.1 Note that Phred is a copyright of CodonCode Corporation.
Author:
Mark Schreiber, Matthew Pocock
  • Constructor Details

  • Method Details

    • getPhredAlphabet

      public static final FiniteAlphabet getPhredAlphabet()
      Retrieves the PHRED alphabet from the AlphabetManager. The Phred alphabet is a cross product of a subset of the IntegerAlphabet from 0...99 and the DNA alphabet. The Phred alphabet is finite. The Phred Alphabet contains 400 BasisSymbols named, for example, (guanine 47). The BasisSymbols can be fragmented into their component AtomicSymbols using the getSymbols() method of BasisSymbol.
    • dnaSymbolFromPhred

      public static final Symbol dnaSymbolFromPhred(Symbol phredSym) throws IllegalSymbolException
      Retrives the DNA symbol component of the Phred BasisSymbol from the PHRED alphabet.
      Throws:
      IllegalSymbolException - if the provided symbol is not from the PHRED alphabet.
    • integerSymbolFromPhred

      Retrives the IntegerSymbol component of the Phred BasisSymbol from the PHRED alphabet.
      Throws:
      IllegalSymbolException - if the provided symbol is not from the PHRED alphabet.
    • createPhred

      Merges a Symbol List from the DNA alphabet with a SymbolList from the [0..99] subset of the IntegerAlphabet into a SymbolList from the PHRED alphabet.
      Throws:
      IllegalAlphabetException - if the alphabets are not of the required alphabets
      IllegalArgumentException - if the two SymbolLists are not of equal length.
      IllegalSymbolException - if a combination of Symbols cannot be represented by the PHRED alphabet.
    • getPhredSymbol

      public static final Symbol getPhredSymbol(Symbol dna, Symbol integer) throws IllegalSymbolException
      Creates a symbol from the PHRED alphabet by combining a Symbol from the DNA alphabet and a Symbol from the IntegerAlphabet (or one of its subsets).
      Throws:
      IllegalSymbolException - if there is no Symbol in the PHRED alphabet that represents the two arguments.
    • writePhredQuality

      public static void writePhredQuality(OutputStream qual, OutputStream seq, SequenceDB db) throws IOException, BioException
      Writes Phred quality data in a Fasta type format.
      Parameters:
      qual - the OutputStream to write the quality data to.
      seq - the OutputStream to write the sequence data to.
      db - a bunch of PhredSequence objects
      Throws:
      IOException
      BioException
      Since:
      1.2
    • readPhredQuality

      Constructs a StreamReader to read in Phred quality data in FASTA format. The data is converted into sequences consisting of Symbols from the IntegerAlphabet.
    • readPhredSequence

      Calls SeqIOTools.readFastaDNA(br), added here for convinience.
    • qualityFromP

      public static double qualityFromP(double probOfError)
      The quality value is related to the base call error probability by the formula QV = - 10 * log_10( P_e ) where P_e is the probability that the base call is an error.
      Returns:
      a double value, note that for most Phred scores this will be rounded to the nearest int
    • pFromQuality

      public static double pFromQuality(double quality)
      Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)
    • pFromQuality

      public static double pFromQuality(int quality)
      Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)
    • pFromQuality

      public static double pFromQuality(IntegerAlphabet.IntegerSymbol quality)
      Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)
    • phredToDistArray

      Converts a Phred sequence to an array of distributions. Essentially a fuzzy sequence Assumes that all of the non called bases are equiprobable
    • phredAlignmentToDistArray

      converts an Alignment of PhredSequences to a Distribution[] where each position is the average distribution of the underlying column of the alignment.
      Throws:
      ClassCastException - if the sequences in the alignment are not instances of PhredSequence