use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class UncertainAlignmentTest method testUncertainAlignment.
@Test
public void testUncertainAlignment() throws Exception {
Alignment data = getUncertainAlignment();
DataType dataType = data.getDataType();
System.out.println("Tip likelihoods:");
int sites = data.getCounts().get(0).size();
for (int taxon = 0; taxon < data.getTaxonCount(); taxon++) {
for (int i = 0; i < sites; i++) {
double[] probs = data.getTipLikelihoods(taxon, i);
for (int j = 0; j < probs.length; j++) {
System.out.print(probs[j] + " ");
}
System.out.print("; ");
}
System.out.println();
}
System.out.println("Most likely sequences:");
for (List<Integer> seq : data.getCounts()) {
System.out.println(dataType.state2string(seq));
}
Alignment data2 = getAlignment();
for (int taxon = 0; taxon < data.getTaxonCount(); taxon++) {
assertEquals(data.getCounts().get(taxon), data2.getCounts().get(taxon));
}
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class UncertainAlignmentTest method getUncertainAlignment.
public static Alignment getUncertainAlignment(boolean duplicate) throws Exception {
String seq1Probs = new String("0.7,0.0,0.3,0.0; 0.0,0.3,0.0,0.7; 0.0,0.0,0.0,1.0;");
String seq2Probs = new String("0.7,0.0,0.3,0.0; 0.0,0.3,0.0,0.7; 0.0,1.0,0.0,0.0;");
String seq3Probs = new String("0.4,0.0,0.6,0.0; 0.0,0.6,0.0,0.4; 0.0,1.0,0.0,0.0;");
if (duplicate) {
seq1Probs += seq1Probs;
seq2Probs += seq2Probs;
seq3Probs += seq3Probs;
}
Sequence seq1 = new Sequence();
seq1.initByName("taxon", "seq1", "value", seq1Probs, "uncertain", true);
Sequence seq2 = new Sequence();
seq2.initByName("taxon", "seq2", "value", seq2Probs, "uncertain", true);
Sequence seq3 = new Sequence();
seq3.initByName("taxon", "seq3", "value", seq3Probs, "uncertain", true);
Alignment data = new Alignment();
data.initByName("sequence", seq1, "sequence", seq2, "sequence", seq3, "dataType", "nucleotide");
DataType dataType = data.getDataType();
System.out.println("Most probable sequences:");
for (List<Integer> seq : data.getCounts()) {
System.out.println(dataType.state2string(seq));
}
return data;
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class TreeLikelihoodTest method aminoacidModelTestI.
void aminoacidModelTestI(SubstitutionModel substModel, double expectedValue) throws Exception {
Alignment data = BEASTTestCase.getAminoAcidAlignment();
Tree tree = BEASTTestCase.getAminoAcidTree(data);
SiteModel siteModel = new SiteModel();
siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", substModel, "proportionInvariant", "0.2");
TreeLikelihood likelihood = newTreeLikelihood();
likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
double logP = 0;
logP = likelihood.calculateLogP();
assertEquals(expectedValue, logP, BEASTTestCase.PRECISION);
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class TreeLikelihoodTest method testHKY85ILikelihood.
@Test
public void testHKY85ILikelihood() throws Exception {
// Set up HKY85+I model: estimated freqs, kappa = 38.564672, 0 gamma categories, prop invariant = 0.701211
Alignment data = BEASTTestCase.getAlignment();
Tree tree = BEASTTestCase.getTree(data);
Frequencies freqs = new Frequencies();
freqs.initByName("data", data);
HKY hky = new HKY();
hky.initByName("kappa", "38.564672", "frequencies", freqs);
SiteModel siteModel = new SiteModel();
siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "shape", "0.137064", "proportionInvariant", "0.701211", "substModel", hky);
TreeLikelihood likelihood = newTreeLikelihood();
likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
double logP = 0;
logP = likelihood.calculateLogP();
assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);
likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
logP = likelihood.calculateLogP();
assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);
}
use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.
the class TreeLikelihoodTest method aminoacidModelTestIG.
void aminoacidModelTestIG(SubstitutionModel substModel, double expectedValue) throws Exception {
Alignment data = BEASTTestCase.getAminoAcidAlignment();
Tree tree = BEASTTestCase.getAminoAcidTree(data);
SiteModel siteModel = new SiteModel();
siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", substModel, "gammaCategoryCount", 4, "shape", "0.15", "proportionInvariant", "0.2");
TreeLikelihood likelihood = newTreeLikelihood();
likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
double logP = 0;
logP = likelihood.calculateLogP();
assertEquals(expectedValue, logP, BEASTTestCase.PRECISION);
}
Aggregations