本文整理汇总了Java中beast.core.StateNode类的典型用法代码示例。如果您正苦于以下问题:Java StateNode类的具体用法?Java StateNode怎么用?Java StateNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StateNode类属于beast.core包,在下文中一共展示了StateNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void log(int nSample, PrintStream out) {
// make sure we get the current version of the inputs
SpeciesTreeInterface speciesTree = speciesTreeInput.get();
SpeciesTreeInterface tree = (SpeciesTreeInterface) speciesTree.getCurrent();
List<Function> metadata = parameterInput.get();
for (int i = 0; i < metadata.size(); i++) {
if (metadata.get(i) instanceof StateNode) {
metadata.set(i, ((StateNode) metadata.get(i)).getCurrent());
}
}
BranchRateModel branchRateModel = clockModelInput.get();
PopulationModel populationModel = populationModelInput.get();
// write out the log tree with meta data
out.print("tree STATE_" + nSample + " = ");
tree.getRoot().sort();
out.print(toNewick(tree.getRoot(), metadata, branchRateModel, populationModel));
//out.print(tree.getRoot().toShortNewick(false));
out.print(";");
}
示例2: log
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void log(int sample, PrintStream out) {
// make sure we get the current version of the inputs
Tree tree = (Tree) treeInput.get().getCurrent();
List<Function> metadata = parameterInput.get();
for (int i = 0; i < metadata.size(); i++) {
if (metadata.get(i) instanceof StateNode) {
metadata.set(i, ((StateNode) metadata.get(i)).getCurrent());
}
}
BranchRateModel.Base branchRateModel = clockModelInput.get();
// write out the log tree with meta data
out.print("tree STATE_" + sample + " = ");
tree.getRoot().sort();
out.print(toNewick(tree.getRoot(), metadata, branchRateModel));
//out.print(tree.getRoot().toShortNewick(false));
out.print(";");
}
示例3: assignTo
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void assignTo(StateNode other) {
if (!(other instanceof GeneralParameterList))
throw new RuntimeException("Incompatible statenodes in assignTo "
+ "call.");
@SuppressWarnings("unchecked")
GeneralParameterList<T> otherParamList = (GeneralParameterList<T>)other;
otherParamList.pList.clear();
for (QuietParameter param : pList)
otherParamList.pList.add(param.copy());
otherParamList.dimension = dimension;
otherParamList.minorDimension = minorDimension;
otherParamList.lowerBound = lowerBound;
otherParamList.upperBound = upperBound;
otherParamList.deallocatedKeys = new TreeSet<>(deallocatedKeys);
otherParamList.nextUnallocatedKey = nextUnallocatedKey;
}
示例4: assignFrom
import beast.core.StateNode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void assignFrom(StateNode other) {
if (!(other instanceof GeneralParameterList))
throw new RuntimeException("Incompatible statenodes in assignFrom "
+ "call.");
GeneralParameterList<T> otherParamList = (GeneralParameterList<T>)other;
pList.clear();
for (Object paramObj : otherParamList.pList)
pList.add((QuietParameter) paramObj);
dimension = otherParamList.dimension;
minorDimension = otherParamList.minorDimension;
lowerBound = otherParamList.lowerBound;
upperBound = otherParamList.upperBound;
deallocatedKeys = new TreeSet<>(otherParamList.deallocatedKeys);
nextUnallocatedKey = otherParamList.nextUnallocatedKey;
}
示例5: log
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void log(int nSample, PrintStream out) {
states = mascotInput.get().dynamicsInput.get().getDimension();
// make sure we get the current version of the inputs
// Tree tree = (Tree) mascotInput.get().treeIntervalsInput.get().treeInput.get().getCurrent();
//calculate the state of each node
calculateNodeStates();
used = new boolean[stateProbabilities.length];
report = false;
List<Function> metadata = parameterInput.get();
for (int i = 0; i < metadata.size(); i++) {
if (metadata.get(i) instanceof StateNode) {
metadata.set(i, ((StateNode) metadata.get(i)).getCurrent());
}
}
BranchRateModel.Base branchRateModel = clockModelInput.get();
// write out the log tree with meta data
out.print("tree STATE_" + nSample + " = ");
mascotInput.get().treeIntervalsInput.get().treeInput.get().getRoot().sort();
root = mascotInput.get().treeIntervalsInput.get().treeInput.get().getRoot();
out.print(toNewick(root, metadata, branchRateModel));
out.print(";");
for (int i = 0; i < used.length; i++)
if(!used[i])
System.err.println("not all nodes used");
if (report)
System.err.println("error in node numbers");
}
示例6: log
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void log(int nSample, PrintStream out) {
states = mascotInput.get().dynamicsInput.get().getDimension();
// make sure we get the current version of the inputs
// Tree tree = (Tree) mascotInput.get().treeIntervalsInput.get().treeInput.get().getCurrent();
//calculate the state of each node
try {
CalculateNodeStates();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
used = new boolean[stateProbabilities.length];
report = false;
List<Function> metadata = parameterInput.get();
for (int i = 0; i < metadata.size(); i++) {
if (metadata.get(i) instanceof StateNode) {
metadata.set(i, ((StateNode) metadata.get(i)).getCurrent());
}
}
BranchRateModel.Base branchRateModel = clockModelInput.get();
// write out the log tree with meta data
out.print("tree STATE_" + nSample + " = ");
mascotInput.get().treeIntervalsInput.get().treeInput.get().getRoot().sort();
root = mascotInput.get().treeIntervalsInput.get().treeInput.get().getRoot();
out.print(toNewick(root, metadata, branchRateModel));
out.print(";");
for (int i = 0; i < used.length; i++)
if(!used[i])
System.err.println("not all nodes used");
if (report)
System.err.println("error in node numbers");
}
示例7: testUniformity
import beast.core.StateNode; //导入依赖的package包/类
public void testUniformity() throws Exception {
Double[] m_parameters = new Double[length];
Integer[] m_indices = new Integer[length];
Integer[] m_sizes = new Integer[length];
for (int i = 0; i < length; ++i) {
m_parameters[i] = 1.;
m_indices[i] = i;
m_sizes[i] = 1;
}
StateNode parameters = new RealParameter(m_parameters);
StateNode indices = new IntegerParameter(m_indices);
StateNode sizes = new IntegerParameter(m_sizes);
State state = new State();
state.initByName("stateNode", parameters, "stateNode", indices,
"stateNode", sizes);
RescaledDirichlet rescaledDirichlet = new RescaledDirichlet();
rescaledDirichlet.initByName("sizes", sizes);
Distribution prior = new Prior();
prior.initByName("x", parameters, "distr", rescaledDirichlet);
Operator merger = new MergeOperator();
merger.initByName("parameters", parameters, "groupings", indices,
"sizes", sizes, "weight", 1.);
Operator splitter = new SplitOperator();
splitter.initByName("parameters", parameters, "groupings", indices,
"sizes", sizes, "weight", 1.);
// It would be nice to have a logger that could just write the results
// into a list, so we can easily check the likelihood that this does
// indeed form a uniform prior, and show how to analyse results.
MCMC mcmc = new MCMC();
mcmc.initByName("chainLength", 100000, "preBurnin", 1, "state", state,
"distribution", prior, "operator", merger, "operator", splitter);
mcmc.run();
throw new RuntimeException("The core of this test remains unimplemented");
}
示例8: getInitialisedStateNodes
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void getInitialisedStateNodes(final List<StateNode> stateNodes) {
stateNodes.add(speciesTreeInput.get());
for (final Tree g : genes.get()) {
stateNodes.add(g);
}
final RealParameter brate = birthRate.get();
if (brate != null) {
stateNodes.add(brate) ;
}
}
示例9: addCondition
import beast.core.StateNode; //导入依赖的package包/类
/**
* add item to the list *
* @param stateNode
*/
public void addCondition(final Input<? extends StateNode> stateNode) {
if (stateNode.get() == null) return;
if (conditions == null) conditions = new ArrayList<>();
conditions.add(stateNode.get().getID());
}
示例10: listStateNodes
import beast.core.StateNode; //导入依赖的package包/类
@Override
public List<StateNode> listStateNodes() {
List<StateNode> stateNodeList = new ArrayList<>();
for (Operator op : operatorsInput.get())
stateNodeList.addAll(op.listStateNodes());
return stateNodeList;
}
示例11: outsideBounds
import beast.core.StateNode; //导入依赖的package包/类
private boolean outsideBounds(final StateNode node) {
if (node instanceof Parameter<?>) {
final Parameter<?> p = (Parameter<?>) node;
final Double lower = (Double) p.getLower();
final Double upper = (Double) p.getUpper();
final Double value = (Double) p.getValue();
if (value < lower || value > upper) {
return true;
}
}
return false;
}
示例12: log
import beast.core.StateNode; //导入依赖的package包/类
@Override
public void log(final int sample, final PrintStream out) {
// make sure we get the current version of the inputs
final Tree tree = (Tree) treeInput.get().getCurrent();
Function metadata = parameterInput.get();
if (metadata instanceof StateNode) {
metadata = ((StateNode) metadata).getCurrent();
}
Function metadataTop = parameterTopInput.get();
if (metadataTop != null && metadataTop instanceof StateNode) {
metadataTop = ((StateNode) metadataTop).getCurrent();
}
List<Function> metadataList = metadataInput.get();
for (int i = 0; i < metadataList.size(); i++) {
if (metadataList.get(i) instanceof StateNode) {
metadataList.set(i, ((StateNode) metadataList.get(i)).getCurrent());
}
}
// write out the log tree with meta data
out.print("tree STATE_" + sample + " = ");
tree.getRoot().sort();
out.print(toNewick(tree.getRoot(), metadata, metadataTop, metadataList));
//out.print(tree.getRoot().toShortNewick(false));
out.print(";");
}
示例13: createDistribution
import beast.core.StateNode; //导入依赖的package包/类
@Override
public List<Distribution> createDistribution(BeautiDoc doc) {
MRCAPrior prior = new MRCAPrior();
try {
List<Tree> trees = new ArrayList<>();
getDoc().scrubAll(true, false);
State state = (State) doc.pluginmap.get("state");
for (StateNode node : state.stateNodeInput.get()) {
if (node instanceof Tree) { // && ((Tree) node).m_initial.get() != null) {
trees.add((Tree) node);
}
}
int treeIndex = 0;
if (trees.size() > 1) {
String[] treeIDs = new String[trees.size()];
for (int j = 0; j < treeIDs.length; j++) {
treeIDs[j] = trees.get(j).getID();
}
treeIndex = JOptionPane.showOptionDialog(null, "Select a tree", "MRCA selector",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
treeIDs, trees.get(0));
}
if (treeIndex < 0) {
return null;
}
prior.treeInput.setValue(trees.get(treeIndex), prior);
TaxonSet taxonSet = new TaxonSet();
TaxonSetDialog dlg = new TaxonSetDialog(taxonSet, getTaxonCandidates(prior), doc);
if (!dlg.showDialog() || dlg.taxonSet.getID() == null || dlg.taxonSet.getID().trim().equals("")) {
return null;
}
taxonSet = dlg.taxonSet;
if (taxonSet.taxonsetInput.get().size() == 0) {
JOptionPane.showMessageDialog(doc.beauti, "At least one taxon should be included in the taxon set",
"Error specifying taxon set", JOptionPane.ERROR_MESSAGE);
return null;
}
int i = 1;
String id = taxonSet.getID();
while (doc.pluginmap.containsKey(taxonSet.getID()) && doc.pluginmap.get(taxonSet.getID()) != taxonSet) {
taxonSet.setID(id + i);
i++;
}
BEASTObjectPanel.addPluginToMap(taxonSet, doc);
prior.taxonsetInput.setValue(taxonSet, prior);
prior.setID(taxonSet.getID() + ".prior");
// this sets up the type
prior.distInput.setValue(new OneOnX(), prior);
// this removes the parametric distribution
prior.distInput.setValue(null, prior);
Logger logger = (Logger) doc.pluginmap.get("tracelog");
logger.loggersInput.setValue(prior, logger);
} catch (Exception e) {
// TODO: handle exception
}
List<Distribution> selectedPlugins = new ArrayList<>();
selectedPlugins.add(prior);
g_collapsedIDs.add(prior.getID());
return selectedPlugins;
}
示例14: getLabel
import beast.core.StateNode; //导入依赖的package包/类
String getLabel(Operator operator) {
String name = operator.getClass().getName();
name = name.substring(name.lastIndexOf('.') + 1);
name = name.replaceAll("Operator", "");
if (name.matches(".*[A-Z].*")) {
name = name.replaceAll("(.)([A-Z])", "$1 $2");
}
name += ": ";
try {
for (BEASTInterface beastObject2 : operator.listActiveBEASTObjects()) {
if (beastObject2 instanceof StateNode && ((StateNode) beastObject2).isEstimatedInput.get()) {
name += beastObject2.getID() + " ";
}
// issue https://github.com/CompEvol/beast2/issues/661
if (name.length() > 100) {
name += "... ";
break;
}
}
} catch (Exception e) {
// ignore
}
String tipText = getDoc().tipTextMap.get(operator.getID());
if (tipText != null) {
name += " " + tipText;
}
return name;
}
示例15: recompute
import beast.core.StateNode; //导入依赖的package包/类
/**
* collect values of the compounds into an array *
*/
private void recompute() {
int k = 0;
for (BEASTObject beastObject : m_values.get()) {
Function valuable = (Function) beastObject;
if (beastObject instanceof StateNode) {
valuable = ((StateNode) beastObject).getCurrent();
}
int dimension = valuable.getDimension();
for (int i = 0; i < dimension; i++) {
m_fValues[k++] = valuable.getArrayValue(i);
}
}
m_bRecompute = false;
}