use of dr.evolution.alignment.Patterns in project beast-mcmc by beast-dev.
the class MicrosatelliteSamplerTreeModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel tree = (TreeModel) xo.getElementFirstChild(TREE);
Parameter internalVal = (Parameter) xo.getElementFirstChild(INTERNAL_VALUES);
Patterns microsatellitePattern = (Patterns) xo.getElementFirstChild(EXTERNAL_VALUES);
int[] externalValues = microsatellitePattern.getPattern(0);
HashMap<String, Integer> taxaMap = new HashMap<String, Integer>(externalValues.length);
boolean internalValuesProvided = false;
if (xo.hasAttribute(USE_PROVIDED_INTERNAL_VALUES)) {
internalValuesProvided = xo.getBooleanAttribute(USE_PROVIDED_INTERNAL_VALUES);
}
for (int i = 0; i < externalValues.length; i++) {
taxaMap.put(microsatellitePattern.getTaxonId(i), i);
}
String modelId = xo.getAttribute("id", "treeMicrosatelliteSamplerModel");
return new MicrosatelliteSamplerTreeModel(modelId, tree, internalVal, microsatellitePattern, externalValues, taxaMap, internalValuesProvided);
}
use of dr.evolution.alignment.Patterns in project beast-mcmc by beast-dev.
the class OldTreesPanel method createTree.
private void createTree() {
if (generateTreeDialog == null) {
generateTreeDialog = new GenerateTreeDialog(frame);
}
int result = generateTreeDialog.showDialog(options);
if (result != JOptionPane.CANCEL_OPTION) {
GenerateTreeDialog.MethodTypes methodType = generateTreeDialog.getMethodType();
PartitionData partition = generateTreeDialog.getDataPartition();
Patterns patterns = new Patterns(partition.getAlignment());
DistanceMatrix distances = new F84DistanceMatrix(patterns);
Tree tree;
TemporalRooting temporalRooting;
switch(methodType) {
case NJ:
tree = new NeighborJoiningTree(distances);
temporalRooting = new TemporalRooting(tree);
tree = temporalRooting.findRoot(tree, TemporalRooting.RootingFunction.CORRELATION);
break;
case UPGMA:
tree = new UPGMATree(distances);
temporalRooting = new TemporalRooting(tree);
break;
default:
throw new IllegalArgumentException("unknown method type");
}
tree.setId(generateTreeDialog.getName());
options.userTrees.add(tree);
treesTableModel.fireTableDataChanged();
int row = options.userTrees.size() - 1;
treesTable.getSelectionModel().setSelectionInterval(row, row);
}
fireTreePriorsChanged();
}
use of dr.evolution.alignment.Patterns in project beast-mcmc by beast-dev.
the class BEAUTiImporter method importMicroSatFile.
// micro-sat
private void importMicroSatFile(File file) throws IOException, ImportException {
try {
Reader reader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(reader);
MicroSatImporter importer = new MicroSatImporter(bufferedReader);
List<Patterns> microsatPatList = importer.importPatterns();
Taxa unionSetTaxonList = importer.getUnionSetTaxonList();
Microsatellite microsatellite = importer.getMicrosatellite();
// options.allowDifferentTaxa = importer.isHasDifferentTaxon();
bufferedReader.close();
PartitionSubstitutionModel substModel = new PartitionSubstitutionModel(options, microsatPatList.get(0).getId());
substModel.setMicrosatellite(microsatellite);
for (Patterns patterns : microsatPatList) {
setData(file.getName(), unionSetTaxonList, patterns, substModel, null);
}
// has to call after data is imported
options.microsatelliteOptions.initModelParametersAndOpererators();
} catch (ImportException e) {
throw new ImportException(e.getMessage());
} catch (IOException e) {
throw new IOException(e.getMessage());
}
}
use of dr.evolution.alignment.Patterns in project beast-mcmc by beast-dev.
the class MsatFullLikelihoodTest method setUp.
public void setUp() throws Exception {
super.setUp();
//taxa
ArrayList<Taxon> taxonList1 = new ArrayList<Taxon>();
Collections.addAll(taxonList1, new Taxon("taxon1"), new Taxon("taxon2"), new Taxon("taxon3"));
Taxa taxa1 = new Taxa(taxonList1);
//msat datatype
Microsatellite msat = new Microsatellite(1, 3);
Patterns msatPatterns = new Patterns(msat, taxa1);
//pattern in the correct code form.
msatPatterns.addPattern(new int[] { 0, 1, 2 });
//create tree
NewickImporter importer = new NewickImporter("(taxon1:7.5,(taxon2:5.3,taxon3:5.3):2.2);");
Tree tree = importer.importTree(null);
//treeModel
TreeModel treeModel = new TreeModel(tree);
//msatsubstModel
AsymmetricQuadraticModel aqm1 = new AsymmetricQuadraticModel(msat, null);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(aqm1);
//treeLikelihood
treeLikelihood1 = new TreeLikelihood(msatPatterns, treeModel, siteModel, null, null, false, false, true, false, false);
setUpExample2();
setUpExample3();
}
use of dr.evolution.alignment.Patterns 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);
}
Aggregations