本文整理汇总了Java中beast.evolution.tree.TraitSet类的典型用法代码示例。如果您正苦于以下问题:Java TraitSet类的具体用法?Java TraitSet怎么用?Java TraitSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TraitSet类属于beast.evolution.tree包,在下文中一共展示了TraitSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTraitSet
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
/**
* assigns trait to first available tree *
*/
void addTraitSet(TraitSet trait) {
if (trait != null) {
CompoundDistribution likelihood = (CompoundDistribution) pluginmap.get("likelihood");
for (Distribution d : likelihood.pDistributions.get()) {
if (d instanceof GenericTreeLikelihood) {
try {
// TODO: this might not be a valid type conversion from TreeInterface to Tree
Tree tree = (Tree) ((GenericTreeLikelihood) d).treeInput.get();
tree.m_traitList.setValue(trait, tree);
} catch (Exception e) {
e.printStackTrace();
}
scrubAll(true, false);
return;
}
}
}
}
示例2: getTypeTrait
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
/**
* @return TraitSet with same name as typeLabel.
*/
public TraitSet getTypeTrait() {
if (!traitsProcessed)
processTraits(m_traitList.get());
return typeTraitSet;
}
示例3: setTypeTrait
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
/**
* Specifically set the type trait set for this tree. A null value simply
* removes the existing trait set.
*
* @param traitSet
*/
public void setTypeTrait(TraitSet traitSet) {
if (hasTypeTrait()) {
m_traitList.get().remove(typeTraitSet);
}
if (traitSet != null) {
//m_traitList.setValue(traitSet, this);
typeTraitInput.setValue(traitSet, this);
}
typeTraitSet = traitSet;
}
示例4: initValues
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
public void initValues() {
// if t1 has t1 Input - do nothing
// Set t1 to Tree's height
//System.out.print("interval duration: "+intervals.getTotalDuration());
if (!popModel.hasEndTime()) {
if (tree.getDateTrait()==null) {
//System.out.println(" NO date trait, setting t1 = "+intervals.getTotalDuration());
popModel.setEndTime( intervals.getTotalDuration() );
} else {
if (tree.getDateTrait().getTraitName().equals( TraitSet.DATE_BACKWARD_TRAIT)) {
//System.out.println(" backward date trait, setting t1 = "+intervals.getTotalDuration());
popModel.setEndTime( intervals.getTotalDuration());
} else {
//System.out.println(" Date trait, setting t1 = "+ tree.getDateTrait().getDate(0) );
popModel.setEndTime( tree.getDateTrait().getDate(0));
}
}
} else {
//System.out.println(" Using t1 = "+popModel.getEndTime());
}
nrSamples = intervals.getSampleCount();
sp = new DoubleMatrix[nrSamples];
nrSamples++;
// Extant Lineages and state probabilities
stateProbabilities.init(tree.getNodeCount(), numStates);
}
示例5: findPriorityBeastObjects
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
private void findPriorityBeastObjects(BEASTInterface beastObject, List<BEASTInterface> priorityBeastObjects) throws IllegalArgumentException, IllegalAccessException {
if (beastObject.getClass().equals(Alignment.class)) {
priorityBeastObjects.add(beastObject);
}
if (beastObject instanceof TraitSet) {
priorityBeastObjects.add(beastObject);
}
for (BEASTInterface beastObject2 : beastObject.listActiveBEASTObjects()) {
findPriorityBeastObjects(beastObject2, priorityBeastObjects);
}
}
示例6: testDateBackward
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Test
public void testDateBackward() {
int Nleaves = 2;
TraitSet timeTrait = new TraitSet();
timeTrait.initByName(
"traitname", "date-backward",
"taxa", taxonSet(Nleaves),
"value", "t0=0, t1=10");
// The trait actually represents the age of the taxa relative to
// each other with arbitrary zero, so we test it like this.
assertEquals(-10.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
示例7: testDateForward
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Test
public void testDateForward() {
int Nleaves = 2;
TraitSet timeTrait = new TraitSet();
timeTrait.initByName(
"traitname", "date-forward",
"taxa", taxonSet(Nleaves),
"value", "t0=0, t1=10");
// The trait actually represents the age of the taxa relative to
// each other with arbitrary zero, so we test it like this.
assertEquals(10.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
示例8: testDateForwardUnspecified
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Test
public void testDateForwardUnspecified() {
int Nleaves = 2;
TraitSet timeTrait = new TraitSet();
timeTrait.initByName(
"traitname", "date-forward",
"taxa", taxonSet(Nleaves),
"value", "t1=10");
// The trait actually represents the age of the taxa relative to
// each other with arbitrary zero, so we test it like this.
assertEquals(0.0, timeTrait.getValue("t0")-timeTrait.getValue("t1"), 1e-7);
}
示例9: getDates
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
static public TraitSet getDates(TaxonSet taxa) throws Exception {
TraitSet timeTrait = new TraitSet();
String trait = String.join(",", (Iterable<String>) IntStream.range(0, 16).mapToObj(i -> taxa.getTaxonId(i) + "=" + i / 3.0)::iterator);
timeTrait.initByName(
"traitname", "date-forward",
"taxa", taxa,
"value", trait);
return timeTrait;
}
示例10: getTree
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
static public Tree getTree(TaxonSet taxa) throws Exception {
Tree tree = new RandomTree();
TraitSet dates = getDates(taxa);
ConstantPopulation constant = new ConstantPopulation();
constant.initByName("popSize", new RealParameter("5.0"));
tree.initByName(
"taxonset", taxa,
"populationModel", constant,
"trait", dates);
return tree;
}
示例11: getRandomTree
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
public Tree getRandomTree(double popSize, Alignment dummyAlg, String[] taxa, int[] dates) throws Exception {
TaxonSet taxonSet = new TaxonSet(dummyAlg);
StringBuilder traitSB = new StringBuilder();
for (int i=0; i<taxa.length; i++) {
if (i>0)
traitSB.append(",");
traitSB.append(taxa[i]).append("=").append(dates[i]);
}
// out.println(traitSB.toString());
TraitSet timeTrait = new TraitSet();
timeTrait.initByName(
"traitname", "date-backward",
"taxa", taxonSet,
"value", traitSB.toString());
ConstantPopulation popFunc = new ConstantPopulation();
popFunc.initByName("popSize", new RealParameter(Double.toString(popSize)));
// Create RandomTree and TreeInterval instances
RandomTree tree = new RandomTree();
// TreeIntervals intervals = new TreeIntervals();
tree.initByName(
"taxa", dummyAlg,
"populationModel", popFunc,
"trait", timeTrait);
// intervals.initByName("tree", tree);
return tree;
}
示例12: getRandomTree
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
public Tree getRandomTree(double popSize, Alignment dummyAlg, String[] taxa, int[] dates) throws Exception {
TaxonSet taxonSet = new TaxonSet(dummyAlg);
traitSB = new StringBuilder();
for (int i=0; i<taxa.length; i++) {
if (i>0)
traitSB.append(",");
traitSB.append(taxa[i]).append("=").append(dates[i]);
}
// out.println(traitSB.toString());
TraitSet timeTrait = new TraitSet();
timeTrait.initByName(
"traitname", traitName,
"taxa", taxonSet,
"value", traitSB.toString());
ConstantPopulation popFunc = new ConstantPopulation();
popFunc.initByName("popSize", new RealParameter(Double.toString(popSize)));
// Create RandomTree and TreeInterval instances
RandomTree tree = new RandomTree();
// TreeIntervals intervals = new TreeIntervals();
tree.initByName(
"taxa", dummyAlg,
"populationModel", popFunc,
"trait", timeTrait);
// intervals.initByName("tree", tree);
return tree;
}
示例13: type
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Override
public Class<?> type() {
return TraitSet.class;
}
示例14: TypeTraitTableModel
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
public TypeTraitTableModel(TraitSet typeTraitSet) {
this.typeTraitSet = typeTraitSet;
}
示例15: processTraits
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Override
protected void processTraits(List<TraitSet> traitList) {
super.processTraits(traitList);
// Record trait set associated with leaf types.
for (TraitSet traitSet : traitList) {
if (traitSet.getTraitName().equals(typeLabel)) {
typeTraitSet = traitSet;
break;
}
}
// Use explicitly-identified type trait set if available.
// Seems dumb, but needed for BEAUti as ListInputEditors
// muck things up...
if (typeTraitInput.get() != null)
typeTraitSet = typeTraitInput.get();
// Construct type list.
if (typeTraitSet == null) {
if (getTaxonset() != null) {
TraitSet dummyTraitSet = new TraitSet();
StringBuilder sb = new StringBuilder();
for (int i=0; i<getTaxonset().getTaxonCount(); i++) {
if (i>0)
sb.append(",\n");
sb.append(getTaxonset().getTaxonId(i)).append("=NOT_SET");
}
try {
dummyTraitSet.initByName(
"traitname", "type",
"taxa", getTaxonset(),
"value", sb.toString());
dummyTraitSet.setID("typeTraitSet.t:"
+ BeautiDoc.parsePartition(getID()));
setTypeTrait(dummyTraitSet);
} catch (Exception ex) {
System.out.println("Error setting default type trait.");
}
}
}
if (typeTraitSet != null) {
Set<String> typeSet = new HashSet<>();
int nTaxa = typeTraitSet.taxaInput.get().asStringList().size();
for (int i = 0; i < nTaxa; i++)
typeSet.add(typeTraitSet.getStringValue(i));
// Include any addittional trait values in type list
if (typeTraitValuesInput.get() != null) {
for (String typeName : typeTraitValuesInput.get().split(","))
typeSet.add(typeName);
}
typeList = Lists.newArrayList(typeSet);
Collections.sort(typeList);
System.out.println("Type trait with the following types detected:");
for (int i = 0; i < typeList.size(); i++)
System.out.println(typeList.get(i) + " (" + i + ")");
}
}