|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.bio.dist.DistributionTools
Title: DistributionTools.java Description: A class to hold static methods for calculations and manipulations using Distributions.
Method Summary | |
static boolean |
areEmissionSpectraEqual(Distribution[] a,
Distribution[] b)
Compares the emission spectra of two distribution arrays |
static boolean |
areEmissionSpectraEqual(Distribution a,
Distribution b)
Compares the emission spectra of two distributions |
static Distribution |
average(Distribution[] dists)
Averages two or more distributions. |
static double |
bitsOfInformation(Distribution observed)
Calculates the total bits of information for a distribution. |
static Distribution |
countToDistribution(Count c)
Make a distribution from a count |
static Distribution[] |
distOverAlignment(Alignment a)
|
static Distribution[] |
distOverAlignment(Alignment a,
boolean countGaps)
Creates an array of distributions, one for each column of the alignment. |
static Distribution[] |
distOverAlignment(Alignment a,
boolean countGaps,
double nullWeight)
Creates an array of distributions, one for each column of the alignment |
protected static Sequence |
generateOrderNSequence(java.lang.String name,
OrderNDistribution d,
int length)
|
static Sequence |
generateSequence(java.lang.String name,
Distribution d,
int length)
Produces a sequence by randomly sampling the Distribution |
static Distribution |
jointDistOverAlignment(Alignment a,
boolean countGaps,
double nullWeight,
int[] cols)
Creates a joint distribution |
static java.util.HashMap |
KLDistance(Distribution observed,
Distribution expected,
double logBase)
A method to calculate the Kullback-Liebler Distance (relative entropy) |
static void |
randomizeDistribution(Distribution d)
Randomizes the weights of a Distribution |
static Distribution |
readFromXML(java.io.InputStream is)
|
static java.util.HashMap |
shannonEntropy(Distribution observed,
double logBase)
A method to calculate the Shannon Entropy for a Distribution |
static double |
totalEntropy(Distribution observed)
Calculates the total Entropy for a Distribution. |
static void |
writeToXML(Distribution d,
java.io.OutputStream os)
Writes a Distribution to XML that can be read with the readFromXML method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void writeToXML(Distribution d, java.io.OutputStream os) throws java.io.IOException
d
- the Distribution to write.os
- where to write it to.
java.io.IOException
- if writing failspublic static Distribution readFromXML(java.io.InputStream is) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public static void randomizeDistribution(Distribution d) throws ChangeVetoException
Distribution
d
- the Distribution
to randomize
ChangeVetoException
- if the Distribution is lockedpublic static Distribution countToDistribution(Count c)
c
- the count
FiniteAlphabet
as c
and trained with the counts of c
public static final boolean areEmissionSpectraEqual(Distribution a, Distribution b) throws BioException
a
- A Distribution
with the same Alphabet
as
b
b
- A Distribution
with the same Alphabet
as
a
BioException
- if one or both of the Distributions are over infinite alphabets.public static final boolean areEmissionSpectraEqual(Distribution[] a, Distribution[] b) throws BioException
a
- A Distribution[]
consisting of Distributions
over a FiniteAlphabet
b
- A Distribution[]
consisting of Distributions
over a FiniteAlphabet
BioException
- if one of the Distributions is over an infinite
alphabet.public static final java.util.HashMap KLDistance(Distribution observed, Distribution expected, double logBase)
logBase
- - the log base for the entropy calculation. 2 is standard.observed
- - the observed frequence of Symbols
.expected
- - the excpected or background frequency.
(Double)
relative entropy.public static final java.util.HashMap shannonEntropy(Distribution observed, double logBase)
logBase
- - the log base for the entropy calculation. 2 is standard.observed
- - the observed frequence of Symbols
.
(Double)
entropy.public static double totalEntropy(Distribution observed)
Symbols
are weighted by their probability of occurence.
observed
- the observed frequence of Symbols
.
Distribution
.public static final double bitsOfInformation(Distribution observed)
observed
- - the observed frequence of Symbols
.
Distribution
.public static Distribution[] distOverAlignment(Alignment a) throws IllegalAlphabetException
IllegalAlphabetException
public static final Distribution jointDistOverAlignment(Alignment a, boolean countGaps, double nullWeight, int[] cols) throws IllegalAlphabetException
a
- the Alignment
to build the Distribution[]
over.countGaps
- if true gaps will be included in the distributions
(NOT YET IMPLEMENTED!!, CURRENTLY EITHER OPTION WILL PRODUCE THE SAME RESULT)nullWeight
- the number of pseudo counts to add to each distribution
Distribution
IllegalAlphabetException
- if all sequences don't use the same alphabetpublic static final Distribution[] distOverAlignment(Alignment a, boolean countGaps, double nullWeight) throws IllegalAlphabetException
a
- the Alignment
to build the Distribution[]
over.countGaps
- if true gaps will be included in the distributions
(NOT YET IMPLEMENTED!!, CURRENTLY EITHER OPTION WILL PRODUCE THE SAME RESULT)nullWeight
- the number of pseudo counts to add to each distribution
Distribution[]
where each member of the array is a
Distribution
of the Symbols
found at that position
of the Alignment
.
IllegalAlphabetException
- if all sequences don't use the same alphabetpublic static final Distribution[] distOverAlignment(Alignment a, boolean countGaps) throws IllegalAlphabetException
countGaps
- if true gaps will be included in the distributionsa
- the Alignment
to build the Distribution[]
over.
Distribution[]
where each member of the array is a
Distribution
of the Symbols
found at that position
of the Alignment
.
IllegalAlphabetException
- if the alignment is not composed from sequences all
with the same alphabetpublic static final Distribution average(Distribution[] dists)
dists
- the Distributions
to average
Distribution
were the weight of each Symbol
is the average of the weights of that Symbol
in each Distribution
.public static final Sequence generateSequence(java.lang.String name, Distribution d, int length)
name
- the name for the sequenced
- the distribution to sample. If this distribution is of order N a
seed sequence is generated allowed to 'burn in' for 1000 iterations and used
to produce a sequence over the conditioned alphabet.length
- the number of symbols in the sequence.
protected static final Sequence generateOrderNSequence(java.lang.String name, OrderNDistribution d, int length)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |