use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class TreeModelParser method setPrecisionBounds.
private void setPrecisionBounds(Parameter newParameter, Taxon taxon) {
Date date = taxon.getDate();
if (date != null) {
double precision = date.getPrecision();
if (precision > 0.0) {
// taxon date not specified to exact value so add appropriate bounds
double upper = Taxon.getHeightFromDate(date);
double lower = Taxon.getHeightFromDate(date);
if (date.isBackwards()) {
upper += precision;
} else {
lower -= precision;
}
// set the bounds for the given precision
newParameter.addBounds(new Parameter.DefaultBounds(upper, lower, 1));
// set the initial value to be mid-point
newParameter.setParameterValue(0, (upper + lower) / 2);
}
}
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class SamplesPanel method timeScaleChanged.
public final void timeScaleChanged() {
Units.Type units = Units.Type.YEARS;
switch(unitsCombo.getSelectedIndex()) {
case 0:
units = Units.Type.YEARS;
break;
case 1:
units = Units.Type.MONTHS;
break;
case 2:
units = Units.Type.DAYS;
break;
}
boolean backwards = directionCombo.getSelectedIndex() == 1;
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
Date date = taxonList.getTaxon(i).getDate();
double d = date.getTimeValue();
Date newDate = createDate(d, units, backwards, 0.0);
newDate.setPrecision(date.getPrecision());
taxonList.getTaxon(i).setDate(newDate);
}
calculateHeights();
dataTableModel.fireTableDataChanged();
frame.timeScaleChanged();
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class DataLikelihoodTester2 method createAlignment.
private static SimpleAlignment createAlignment(Object[][] taxa_sequence, DataType dataType) {
SimpleAlignment alignment = new SimpleAlignment();
alignment.setDataType(dataType);
// alignment.setDataType(Nucleotides.INSTANCE);
// 6, 17
Taxon[] taxa = new Taxon[taxa_sequence[0].length];
System.out.println("Taxon len = " + taxa_sequence[0].length);
System.out.println("Alignment len = " + taxa_sequence[1].length);
if (taxa_sequence.length > 2)
System.out.println("Date len = " + taxa_sequence[2].length);
for (int i = 0; i < taxa_sequence[0].length; i++) {
taxa[i] = new Taxon(taxa_sequence[0][i].toString());
if (taxa_sequence.length > 2) {
Date date = new Date((Double) taxa_sequence[2][i], Units.Type.YEARS, (Boolean) taxa_sequence[3][0]);
taxa[i].setDate(date);
}
// taxonList.addTaxon(taxon);
Sequence sequence = new Sequence(taxa_sequence[1][i].toString());
sequence.setTaxon(taxa[i]);
sequence.setDataType(dataType);
alignment.addSequence(sequence);
}
return alignment;
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class BigFastTreeModelParser method setUncertaintyBounds.
private void setUncertaintyBounds(Parameter newParameter, Taxon taxon) {
Date date = taxon.getDate();
if (date != null) {
double uncertainty = date.getUncertainty();
if (uncertainty > 0.0) {
// taxon date not specified to exact value so add appropriate bounds
double upper = Taxon.getHeightFromDate(date);
double lower = Taxon.getHeightFromDate(date);
if (date.isBackwards()) {
upper += uncertainty;
} else {
lower -= uncertainty;
}
// set the bounds for the given precision
newParameter.addBounds(new Parameter.DefaultBounds(upper, lower, 1));
// set the initial value to be mid-point
newParameter.setParameterValue(0, (upper + lower) / 2);
}
}
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class TreeModelParser method setUncertaintyBounds.
private void setUncertaintyBounds(Parameter newParameter, Taxon taxon) {
Date date = taxon.getDate();
if (date != null) {
double uncertainty = date.getUncertainty();
if (uncertainty > 0.0) {
// taxon date not specified to exact value so add appropriate bounds
double upper = Taxon.getHeightFromDate(date);
double lower = Taxon.getHeightFromDate(date);
if (date.isBackwards()) {
upper += uncertainty;
} else {
lower -= uncertainty;
}
// set the bounds for the given precision
newParameter.addBounds(new Parameter.DefaultBounds(upper, lower, 1));
// set the initial value to be mid-point
newParameter.setParameterValue(0, (upper + lower) / 2);
}
}
}
Aggregations