Search in sources :

Example 16 with Date

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);
        }
    }
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter) Date(dr.evolution.util.Date)

Example 17 with Date

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();
}
Also used : Units(dr.evolution.util.Units) Date(dr.evolution.util.Date)

Example 18 with Date

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;
}
Also used : SimpleAlignment(dr.evolution.alignment.SimpleAlignment) Taxon(dr.evolution.util.Taxon) Sequence(dr.evolution.sequence.Sequence) Date(dr.evolution.util.Date)

Example 19 with Date

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);
        }
    }
}
Also used : Parameter(dr.inference.model.Parameter) Date(dr.evolution.util.Date)

Example 20 with Date

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);
        }
    }
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter) Date(dr.evolution.util.Date)

Aggregations

Date (dr.evolution.util.Date)39 Taxon (dr.evolution.util.Taxon)19 Taxa (dr.evolution.util.Taxa)5 TimeScale (dr.evolution.util.TimeScale)5 Parameter (dr.inference.model.Parameter)5 java.util (java.util)5 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)4 Sequence (dr.evolution.sequence.Sequence)4 NodeRef (dr.evolution.tree.NodeRef)4 dr.evolution.util (dr.evolution.util)4 Units (dr.evolution.util.Units)3 CompoundParameter (dr.inference.model.CompoundParameter)3 ArrayList (java.util.ArrayList)3 Tree (dr.evolution.tree.Tree)2 TaxonList (dr.evolution.util.TaxonList)2 Attribute (dr.util.Attribute)2 NexusExporter (dr.app.tools.NexusExporter)1 CoalescentSimulator (dr.evolution.coalescent.CoalescentSimulator)1 PiecewiseLinearPopulation (dr.evolution.coalescent.PiecewiseLinearPopulation)1 SimpleNode (dr.evolution.tree.SimpleNode)1