use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class MsatFullLikelihoodTest method setUpExample2.
private void setUpExample2() throws Exception {
//taxa
ArrayList<Taxon> taxonList2 = new ArrayList<Taxon>();
Collections.addAll(taxonList2, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"), new Taxon("taxon4"), new Taxon("taxon5"));
Taxa taxa2 = new Taxa(taxonList2);
//msat datatype
Microsatellite msat = new Microsatellite(1, 3);
Patterns msatPatterns = new Patterns(msat, taxa2);
//pattern in the correct code form.
msatPatterns.addPattern(new int[] { 0, 1, 2, 1, 2 });
//create tree
NewickImporter importer = new NewickImporter("(((taxon1:1.5,taxon2:1.5):1.5,(taxon3:2.1,taxon4:2.1):0.9):0.7,taxon5:3.7);");
Tree tree = importer.importTree(null);
//treeModel
TreeModel treeModel = new TreeModel(tree);
//msatsubstModel
AsymmetricQuadraticModel aqm2 = new AsymmetricQuadraticModel(msat, null);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(aqm2);
//treeLikelihood
treeLikelihood2 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class MsatSamplingTreeLikelihoodTest method setUp.
public void setUp() throws Exception {
super.setUp();
//taxa
ArrayList<Taxon> taxonList3 = new ArrayList<Taxon>();
Collections.addAll(taxonList3, new Taxon("Taxon1"), new Taxon("Taxon2"), new Taxon("Taxon3"), new Taxon("Taxon4"), new Taxon("Taxon5"), new Taxon("Taxon6"), new Taxon("Taxon7"));
Taxa taxa3 = new Taxa(taxonList3);
//msat datatype
Microsatellite msat = new Microsatellite(1, 6);
Patterns msatPatterns = new Patterns(msat, taxa3);
//pattern in the correct code form.
msatPatterns.addPattern(new int[] { 0, 1, 3, 2, 4, 5, 1 });
//create tree
NewickImporter importer = new NewickImporter("(((Taxon1:0.3,Taxon2:0.3):0.6,Taxon3:0.9):0.9,((Taxon4:0.5,Taxon5:0.5):0.3,(Taxon6:0.7,Taxon7:0.7):0.1):1.0);");
Tree tree = importer.importTree(null);
//treeModel
TreeModel treeModel = new TreeModel(tree);
//msatsubstModel
AsymmetricQuadraticModel eu1 = new AsymmetricQuadraticModel(msat, null);
//create msatSamplerTreeModel
Parameter internalVal = new Parameter.Default(new double[] { 2, 3, 4, 2, 1, 5 });
int[] externalValues = msatPatterns.getPattern(0);
HashMap<String, Integer> taxaMap = new HashMap<String, Integer>(externalValues.length);
boolean internalValuesProvided = true;
for (int i = 0; i < externalValues.length; i++) {
taxaMap.put(msatPatterns.getTaxonId(i), i);
}
MicrosatelliteSamplerTreeModel msatTreeModel = new MicrosatelliteSamplerTreeModel("JUnitTestEx", treeModel, internalVal, msatPatterns, externalValues, taxaMap, internalValuesProvided);
//create msatSamplerTreeLikelihood
BranchRateModel branchRateModel = new StrictClockBranchRates(new Parameter.Default(1.0));
eu1Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, eu1, branchRateModel);
//eu2
TwoPhaseModel eu2 = new TwoPhaseModel(msat, null, eu1, new Parameter.Default(0.0), new Parameter.Default(0.4), null, false);
eu2Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, eu2, branchRateModel);
//ec1
LinearBiasModel ec1 = new LinearBiasModel(msat, null, eu1, new Parameter.Default(0.48), new Parameter.Default(0.0), false, false, false);
ec1Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, ec1, branchRateModel);
//ec2
TwoPhaseModel ec2 = new TwoPhaseModel(msat, null, ec1, new Parameter.Default(0.0), new Parameter.Default(0.4), null, false);
ec2Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, ec2, branchRateModel);
//el1
LinearBiasModel el1 = new LinearBiasModel(msat, null, eu1, new Parameter.Default(0.2), new Parameter.Default(-0.018), true, false, false);
el1Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, el1, branchRateModel);
AsymmetricQuadraticModel pu1 = new AsymmetricQuadraticModel(msat, null, new Parameter.Default(1.0), new Parameter.Default(0.015), new Parameter.Default(0.0), new Parameter.Default(1.0), new Parameter.Default(0.015), new Parameter.Default(0.0), false);
pu1Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, pu1, branchRateModel);
//ec2
TwoPhaseModel pu2 = new TwoPhaseModel(msat, null, pu1, new Parameter.Default(0.0), new Parameter.Default(0.4), null, false);
pu2Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, pu2, branchRateModel);
//ec1
LinearBiasModel pc1 = new LinearBiasModel(msat, null, pu1, new Parameter.Default(0.48), new Parameter.Default(0.0), false, false, false);
pc1Likelihood = new MicrosatelliteSamplerTreeLikelihood(msatTreeModel, pc1, branchRateModel);
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class SimpleTree method setTaxonId.
/**
* Sets the ID of the taxon of the ith external node. If it doesn't have
* a taxon, sets the ID of the node itself.
*/
public void setTaxonId(int taxonIndex, String id) {
Taxon taxon = getTaxon(taxonIndex);
if (taxon != null)
taxon.setId(id);
else
getExternalNode(taxonIndex).setId(id);
fireTreeChanged();
fireTaxaChanged();
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class TreeUtils method getLeafSet.
/**
* @param tree the tree to retrieve leaf set of
* @return a set of strings which are the taxa of the tree.
*/
public static Set<String> getLeafSet(Tree tree) {
HashSet<String> leafSet = new HashSet<String>();
int m = tree.getTaxonCount();
for (int i = 0; i < m; i++) {
Taxon taxon = tree.getTaxon(i);
leafSet.add(taxon.getId());
}
return leafSet;
}
use of dr.evolution.util.Taxon in project beast-mcmc by beast-dev.
the class BeagleSequenceSimulator method compileAlignment.
// END: SimulatePartitionCallable class
private SimpleAlignment compileAlignment() {
SimpleAlignment simpleAlignment = new SimpleAlignment();
simpleAlignment.setReportCountStatistics(false);
simpleAlignment.setDataType(dataType);
LinkedHashMap<Taxon, int[]> alignmentMap = new LinkedHashMap<Taxon, int[]>();
// compile the alignment
for (Partition partition : partitions) {
Map<Taxon, int[]> sequenceMap = partition.getTaxonSequencesMap();
Iterator<Entry<Taxon, int[]>> iterator = sequenceMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<Taxon, int[]> pairs = (Entry<Taxon, int[]>) iterator.next();
Taxon taxon = pairs.getKey();
int[] partitionSequence = pairs.getValue();
if (alignmentMap.containsKey(taxon)) {
int j = 0;
for (int i = partition.from; i <= partition.to; i += partition.every) {
alignmentMap.get(taxon)[i] = partitionSequence[j];
j++;
}
// END: i loop
} else {
int[] sequence = new int[siteCount];
// dirty solution for gaps when taxa between the tree
// topologies don't match
Arrays.fill(sequence, gapFlag);
int j = 0;
for (int i = partition.from; i <= partition.to; i += partition.every) {
sequence[i] = partitionSequence[j];
j++;
}
// END: i loop
alignmentMap.put(taxon, sequence);
}
// END: key check
}
// END: iterate seqMap
}
// END: partitions loop
Iterator<Entry<Taxon, int[]>> iterator = alignmentMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<Taxon, int[]> pairs = (Entry<Taxon, int[]>) iterator.next();
Taxon taxon = (Taxon) pairs.getKey();
int[] intSequence = (int[]) pairs.getValue();
Sequence sequence = //
Utils.intArray2Sequence(//
taxon, //
intSequence, //
gapFlag, dataType);
// sequence.setDataType(dataType);
simpleAlignment.addSequence(sequence);
iterator.remove();
}
return simpleAlignment;
}
Aggregations