Package org.biojava.bio.program.phred
Class PhredTools
java.lang.Object
org.biojava.bio.program.phred.PhredTools
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SymbolList
createPhred
(SymbolList dna, SymbolList quality) 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.static final Symbol
dnaSymbolFromPhred
(Symbol phredSym) Retrives the DNA symbol component of the Phred BasisSymbol from the PHRED alphabet.static final FiniteAlphabet
Retrieves the PHRED alphabet from the AlphabetManager.static final Symbol
getPhredSymbol
(Symbol dna, Symbol integer) 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).static final IntegerAlphabet.IntegerSymbol
integerSymbolFromPhred
(Symbol phredSym) Retrives the IntegerSymbol component of the Phred BasisSymbol from the PHRED alphabet.static double
pFromQuality
(double quality) Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)static double
pFromQuality
(int quality) Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)static double
Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10)static Distribution[]
converts an Alignment of PhredSequences to a Distribution[] where each position is the average distribution of the underlying column of the alignment.static Distribution[]
Converts a Phred sequence to an array of distributions.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.static StreamReader
Constructs a StreamReader to read in Phred quality data in FASTA format.static StreamReader
Calls SeqIOTools.readFastaDNA(br), added here for convinience.static void
writePhredQuality
(OutputStream qual, OutputStream seq, SequenceDB db) Writes Phred quality data in a Fasta type format.
-
Constructor Details
-
PhredTools
public PhredTools()
-
-
Method Details
-
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 thegetSymbols()
method of BasisSymbol. -
dnaSymbolFromPhred
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
public static final IntegerAlphabet.IntegerSymbol integerSymbolFromPhred(Symbol phredSym) throws IllegalSymbolException 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
public static SymbolList createPhred(SymbolList dna, SymbolList quality) throws IllegalArgumentException, IllegalAlphabetException, IllegalSymbolException 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 alphabetsIllegalArgumentException
- if the two SymbolLists are not of equal length.IllegalSymbolException
- if a combination of Symbols cannot be represented by the PHRED alphabet.
-
getPhredSymbol
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
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 nearestint
-
pFromQuality
Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10) -
pFromQuality
Calculates the probability of an error from the quality score via the formula P_e = 10**(QV/-10) -
pFromQuality
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
-