本文整理汇总了Java中beast.evolution.branchratemodel.BranchRateModel类的典型用法代码示例。如果您正苦于以下问题:Java BranchRateModel类的具体用法?Java BranchRateModel怎么用?Java BranchRateModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BranchRateModel类属于beast.evolution.branchratemodel包,在下文中一共展示了BranchRateModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: log
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的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(";");
}
开发者ID:genomescale,项目名称:starbeast2,代码行数:21,代码来源:SpeciesTreeLogger.java
示例2: log
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的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(";");
}
开发者ID:CompEvol,项目名称:beast2,代码行数:19,代码来源:TreeWithMetaDataLogger.java
示例3: log
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
@Override
public void log(int nSample, 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_" + nSample + " = ");
tree.getRoot().sort();
if(scaler != null){
scaleFactor = scaler.getScaleFactor();
}else{
scaleFactor = scaleParameter.getValue();
}
out.print(toNewick(tree.getRoot(), metadata, branchRateModel, scaleFactor));
//out.print(tree.getRoot().toShortNewick(false));
out.print(";");
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:23,代码来源:ScaledTreeWithMetaDataLogger.java
示例4: NewWVTreeLikelihood
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public NewWVTreeLikelihood(int[] patternWeights,
Alignment data,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel){
this.patternWeights = patternWeights;
storedPatternWeights = new int[patternWeights.length];
this.data = data;
this.tree = tree;
this.useAmbiguities = useAmbiguities;
m_siteModel = siteModel;
this.branchRateModel = branchRateModel;
this.substitutionModel = (SubstitutionModel.Base)m_siteModel.getSubstitutionModel();
setup();
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:17,代码来源:NewWVTreeLikelihood.java
示例5: testSequenceSimulator
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public void testSequenceSimulator() throws Exception {
Alignment dummyAlg = getDummyAlignment(taxa);
SiteModel siteModel = getSiteModel(dummyAlg);
BranchRateModel branchRateModel = getBranchModel(clockRate);
SequenceSimulator sequenceSimulator = new SequenceSimulator(); // sequence length default 1000
sequenceSimulator.initByName("data", dummyAlg, "tree", tree, "siteModel", siteModel,
"branchRateModel", branchRateModel, "sequencelength", sequenceLength);
Alignment simAlg = sequenceSimulator.simulate();
for (Sequence seq : simAlg.sequenceInput.get()) {
System.out.println(">" + seq.taxonInput.get());
System.out.println(seq.dataInput.get());
}
// ClusterTree upgma = new ClusterTree();
// upgma.initByName("clusterType", "upgma", "taxa", simAlg,
//// "distance", , // default Jukes Cantor
// "clock.rate", Double.toString(clockRate));
// System.out.println(upgma.getRoot().toNewick(false));
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:23,代码来源:SequenceSimulatorTest.java
示例6: log
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的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");
}
开发者ID:nicfel,项目名称:Mascot,代码行数:32,代码来源:StructuredTreeLoggerCollaps.java
示例7: log
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的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");
}
开发者ID:nicfel,项目名称:Mascot,代码行数:37,代码来源:StructuredTreeLogger.java
示例8: getClockModel
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
BranchRateModel getClockModel(String partition) {
int k = 0;
for (Alignment data : alignments) {
if (data.getID().equals(partition)) {
return clockModels.get(k);
}
k++;
}
return null;
}
开发者ID:CompEvol,项目名称:beast2,代码行数:11,代码来源:BeautiDoc.java
示例9: TempSiteTreeLikelihood
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public TempSiteTreeLikelihood(Alignment data,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel){
super(data,tree,useAmbiguities,siteModel,branchRateModel);
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:9,代码来源:TempSiteTreeLikelihood.java
示例10: QuietTreeLikelihood
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public QuietTreeLikelihood(Alignment data,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel){
this.data = data;
this.tree = tree;
this.useAmbiguities = useAmbiguities;
m_siteModel = siteModel;
this.branchRateModel = branchRateModel;
substitutionModel = m_siteModel.getSubstitutionModel();
setup();
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:15,代码来源:QuietTreeLikelihood.java
示例11: TempWVTreeLikelihood
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public TempWVTreeLikelihood(int[] patternWeights,
Alignment data,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel){
super(patternWeights, data, tree, useAmbiguities, siteModel, branchRateModel);
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:9,代码来源:TempWVTreeLikelihood.java
示例12: SepTempTreeLikelihood
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public SepTempTreeLikelihood(Alignment alignment,
Tree tree,
boolean useAmbiguities,
SiteModel siteModel,
BranchRateModel.Base branchRateModel,
DPNtdRateSepSiteModel dpNtdRateSepSiteModel){
super(alignment, tree, useAmbiguities, siteModel, branchRateModel);
this.dpNtdRateSepSiteModel = dpNtdRateSepSiteModel;
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:11,代码来源:SepTempTreeLikelihood.java
示例13: getSimulatedAlignment
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public Alignment getSimulatedAlignment(Alignment dummyAlg, Tree tree, SiteModel siteModel, BranchRateModel branchRateModel) throws Exception {
// feed to sequence simulator and generate leaves
SequenceSimulator sequenceSimulator = new SequenceSimulator(); // sequence length default 1000
sequenceSimulator.init(dummyAlg, tree, siteModel, branchRateModel);
return sequenceSimulator.simulate();
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:8,代码来源:TreeSeqSimulatorCustomized.java
示例14: getSimulatedAlignment
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public Alignment getSimulatedAlignment(Alignment dummyAlg, Tree tree, SiteModel siteModel,
BranchRateModel branchRateModel, int sequenceLength) throws Exception {
// feed to sequence simulator and generate leaves
SequenceSimulator sequenceSimulator = new SequenceSimulator(); // sequence length default 1000
sequenceSimulator.initByName("data", dummyAlg, "tree", tree, "siteModel", siteModel,
"branchRateModel", branchRateModel, "sequencelength", sequenceLength);
return sequenceSimulator.simulate();
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:10,代码来源:TreeSeqSimulator.java
示例15: main
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) {
try {
// parse arguments
if (args.length < 2) {
printUsageAndExit();
}
String fileName = args[0];
int replications = Integer.parseInt(args[1]);
PrintStream out = System.out;
if (args.length == 3) {
File file = new File(args[2]);
out = new PrintStream(file);
}
// grab the file
String xml = "";
BufferedReader fin = new BufferedReader(new FileReader(fileName));
while (fin.ready()) {
xml += fin.readLine();
}
fin.close();
// parse the xml
XMLParser parser = new XMLParser();
BEASTInterface beastObject = parser.parseFragment(xml, true);
// find relevant objects from the model
TreeLikelihood treeLikelihood = getTreeLikelihood(beastObject);
if (treeLikelihood == null) {
throw new IllegalArgumentException("No treelikelihood found in file. Giving up now.");
}
Alignment data = ((Input<Alignment>) treeLikelihood.getInput("data")).get();
Tree tree = ((Input<Tree>) treeLikelihood.getInput("tree")).get();
SiteModel pSiteModel = ((Input<SiteModel>) treeLikelihood.getInput("siteModel")).get();
BranchRateModel pBranchRateModel = ((Input<BranchRateModel>) treeLikelihood.getInput("branchRateModel")).get();
// feed to sequence simulator and generate leaves
SequenceSimulator treeSimulator = new SequenceSimulator();
treeSimulator.init(data, tree, pSiteModel, pBranchRateModel, replications);
XMLProducer producer = new XMLProducer();
Alignment alignment = treeSimulator.simulate();
xml = producer.toRawXML(alignment);
out.println("<beast version='2.0'>");
out.println(xml);
out.println("</beast>");
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:52,代码来源:SequenceSimulator.java
示例16: setUpOperator
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
/** set up relative weights and parameter input **/
private void setUpOperator() {
String weights = "";
List<RealParameter> parameters = operator.parameterInput.get();
parameters.clear();
double commonClockRate = -1;
boolean isAllClocksAreEqual = true;
try {
for (int i = 0; i < doc.alignments.size(); i++) {
Alignment data = doc.alignments.get(i);
int weight = data.getSiteCount();
BranchRateModel.Base clockModel = (BranchRateModel.Base) doc.clockModels.get(i);
RealParameter clockRate = clockModel.meanRateInput.get();
//clockRate.m_bIsEstimated.setValue(true, clockRate);
if (clockRate.isEstimatedInput.get()) {
if (commonClockRate < 0) {
commonClockRate = clockRate.valuesInput.get().get(0);
} else {
if (Math.abs(commonClockRate - clockRate.valuesInput.get().get(0)) > 1e-10) {
isAllClocksAreEqual = false;
}
}
weights += weight + " ";
parameters.add(clockRate);
}
//doc.autoSetClockRate = false;
}
if (!fixMeanRatesCheckBox.isSelected()) {
fixMeanRatesValidateLabel.setVisible(false);
return;
}
if (parameters.size() == 0) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.red;
fixMeanRatesValidateLabel.setToolTipText("The model is invalid: At least one clock rate should be estimated.");
return;
}
IntegerParameter weightParameter = new IntegerParameter(weights);
weightParameter.setID("weightparameter");
weightParameter.isEstimatedInput.setValue(false, weightParameter);
operator.parameterWeightsInput.setValue(weightParameter, operator);
if (!isAllClocksAreEqual) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("Not all clocks are equal. Are you sure this is what you want?");
} else if (parameters.size() == 1) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("At least 2 clock models should have their rate estimated");
} else if (parameters.size() < doc.alignments.size()) {
fixMeanRatesValidateLabel.setVisible(true);
fixMeanRatesValidateLabel.m_circleColor = Color.orange;
fixMeanRatesValidateLabel.setToolTipText("Not all partitions have their rate estimated");
} else {
fixMeanRatesValidateLabel.setVisible(false);
}
repaint();
//doc.autoSetClockRate = true;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:65,代码来源:ClockModelListInputEditor.java
示例17: toNewick
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
String toNewick(Node node, List<Function> metadataList, BranchRateModel.Base branchRateModel, double scaleFactor) {
StringBuffer buf = new StringBuffer();
if (node.getLeft() != null) {
buf.append("(");
buf.append(toNewick(node.getLeft(), metadataList, branchRateModel, scaleFactor));
if (node.getRight() != null) {
buf.append(',');
buf.append(toNewick(node.getRight(), metadataList, branchRateModel, scaleFactor));
}
buf.append(")");
} else {
buf.append(node.labelNr + 1);
}
if (someMetaDataNeedsLogging) {
buf.append("[&");
if (metadataList.size() > 0) {
for (Function metadata : metadataList) {
buf.append(((BEASTObject)metadata).getID());
buf.append('=');
if (metadata instanceof Parameter<?>) {
Parameter<?> p = (Parameter<?>) metadata;
int dim = p.getMinorDimension1();
if (dim > 1) {
buf.append('{');
for (int i = 0; i < dim; i++) {
buf.append(p.getMatrixValue(node.labelNr, i));
if (i < dim - 1) {
buf.append(',');
}
}
buf.append('}');
} else {
buf.append(metadata.getArrayValue(node.labelNr));
}
} else {
buf.append(metadata.getArrayValue(node.labelNr));
}
if (metadataList.indexOf(metadata) < metadataList.size() - 1) {
buf.append(",");
}
}
if (branchRateModel != null) {
buf.append(",");
}
}
if (branchRateModel != null) {
buf.append("rate=");
appendDouble(buf, branchRateModel.getRateForBranch(node));
}
buf.append(']');
}
buf.append(":");
if (substitutions) {
appendDouble(buf, node.getLength() * branchRateModel.getRateForBranch(node));
} else {
appendDouble(buf, node.getLength());
}
return buf.toString();
}
开发者ID:jessiewu,项目名称:substBMA,代码行数:61,代码来源:ScaledTreeWithMetaDataLogger.java
示例18: getBranchModel
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
public BranchRateModel getBranchModel(double clockRate) throws Exception {
StrictClockModel strictClockModel = new StrictClockModel();
strictClockModel.initByName("clock.rate", Double.toString(clockRate));
return strictClockModel;
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:7,代码来源:TreeSeqSimulatorCustomized.java
示例19: getBranchModel
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
protected BranchRateModel getBranchModel(double clockRate) throws Exception {
StrictClockModel strictClockModel = new StrictClockModel();
strictClockModel.initByName("clock.rate", Double.toString(clockRate));
return strictClockModel;
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:7,代码来源:SequenceSimulatorTest.java
示例20: toNewick
import beast.evolution.branchratemodel.BranchRateModel; //导入依赖的package包/类
String toNewick(Node node, List<Function> metadataList, BranchRateModel branchRateModel, PopulationModel populationModel) {
StringBuffer buf = new StringBuffer();
if (node.getLeft() != null) {
buf.append("(");
buf.append(toNewick(node.getLeft(), metadataList, branchRateModel, populationModel));
if (node.getRight() != null) {
buf.append(',');
buf.append(toNewick(node.getRight(), metadataList, branchRateModel, populationModel));
}
buf.append(")");
} else {
buf.append(node.getNr() + 1);
}
if (someMetaDataNeedsLogging) {
buf.append("[&");
if (metadataList.size() > 0) {
for (Function metadata : metadataList) {
buf.append(((BEASTObject)metadata).getID());
buf.append('=');
if (metadata instanceof Parameter<?>) {
Parameter<?> p = (Parameter<?>) metadata;
int dim = p.getMinorDimension1();
if (dim > 1) {
buf.append('{');
for (int i = 0; i < dim; i++) {
buf.append(p.getMatrixValue(node.getNr(), i));
if (i < dim - 1) {
buf.append(',');
}
}
buf.append('}');
} else {
buf.append(metadata.getArrayValue(node.getNr()));
}
} else {
buf.append(metadata.getArrayValue(node.getNr()));
}
if (metadataList.indexOf(metadata) < metadataList.size() - 1) {
buf.append(",");
}
}
if (branchRateModel != null || populationModel != null) {
buf.append(",");
}
}
if (branchRateModel != null) {
buf.append("rate=");
appendDouble(buf, branchRateModel.getRateForBranch(node));
if (populationModel != null) {
buf.append(",");
}
}
if (populationModel != null) {
populationModel.serialize(node, buf, df);
}
buf.append(']');
}
buf.append(":");
double nodeLength;
if (node.isRoot()) {
nodeLength = getTreeHeight() - node.getHeight();
} else {
nodeLength = node.getLength();
}
if (substitutions) {
appendDouble(buf, nodeLength * branchRateModel.getRateForBranch(node));
} else {
appendDouble(buf, nodeLength);
}
return buf.toString();
}
开发者ID:genomescale,项目名称:starbeast2,代码行数:76,代码来源:SpeciesTreeLogger.java
注:本文中的beast.evolution.branchratemodel.BranchRateModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论