All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lphy.base.function.tree.TreeLength Maven / Gradle / Ivy

Go to download

The standard library of LPhy, which contains the required generative distributions and basic functions.

The newest version!
package lphy.base.function.tree;

import lphy.base.evolution.tree.TimeTree;
import lphy.core.model.DeterministicFunction;
import lphy.core.model.Value;
import lphy.core.model.annotation.GeneratorCategory;
import lphy.core.model.annotation.GeneratorInfo;
import lphy.core.model.annotation.ParameterInfo;
import lphy.core.model.datatype.DoubleValue;

/**
 * use {@link TimeTree#treeLength()}
 */
@Deprecated
public class TreeLength extends DeterministicFunction {

    final String paramName;

    public TreeLength(@ParameterInfo(name = "tree", description = "the tree.") Value x) {
        paramName = getParamName(0);
        setParam(paramName, x);
    }

    @GeneratorInfo(name="treeLength",
            category = GeneratorCategory.TREE, examples = {"simpleCalibratedYule.lphy","simpleExtantBirthDeath.lphy"},
            description = "The sum of all the branch lengths in the tree.")
    public Value apply() {
        Value v = (Value)getParams().get(paramName);
        return new DoubleValue(v.value().treeLength(), this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy