本文整理汇总了Java中beast.evolution.tree.TraitSet类的典型用法代码示例。如果您正苦于以下问题:Java TraitSet类的具体用法?Java TraitSet怎么用?Java TraitSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TraitSet类属于beast.evolution.tree包,在下文中一共展示了TraitSet类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:22,代码来源:BeautiDoc.java
示例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;
}
开发者ID:nicfel,项目名称:Mascot,代码行数:10,代码来源:TreeWithTrait.java
示例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;
}
开发者ID:nicfel,项目名称:Mascot,代码行数:19,代码来源:TreeWithTrait.java
示例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);
}
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:29,代码来源:STreeLikelihood.java
示例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);
}
}
开发者ID:CompEvol,项目名称:beast2,代码行数:12,代码来源:JSONProducer.java
示例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);
}
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java
示例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);
}
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java
示例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);
}
开发者ID:CompEvol,项目名称:beast2,代码行数:14,代码来源:TraitSetTest.java
示例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;
}
开发者ID:CompEvol,项目名称:beast2,代码行数:10,代码来源:UnorderedAlignmentsTest.java
示例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;
}
开发者ID:CompEvol,项目名称:beast2,代码行数:12,代码来源:UnorderedAlignmentsTest.java
示例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;
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:33,代码来源:TreeSeqSimulatorCustomized.java
示例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;
}
开发者ID:CompEvol,项目名称:NZGOT,代码行数:33,代码来源:TreeSeqSimulator.java
示例13: type
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Override
public Class<?> type() {
return TraitSet.class;
}
开发者ID:nicfel,项目名称:Mascot,代码行数:5,代码来源:TypeTraitSetInputEditor.java
示例14: TypeTraitTableModel
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
public TypeTraitTableModel(TraitSet typeTraitSet) {
this.typeTraitSet = typeTraitSet;
}
开发者ID:nicfel,项目名称:Mascot,代码行数:4,代码来源:TypeTraitSetInputEditor.java
示例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 + ")");
}
}
开发者ID:nicfel,项目名称:Mascot,代码行数:67,代码来源:TreeWithTrait.java
示例16: testMascotStructured
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Test
public void testMascotStructured(){
//build alignment
Sequence sequence1 = new Sequence();
Sequence sequence2 = new Sequence();
Sequence sequence3 = new Sequence();
Sequence sequence4 = new Sequence();
Sequence sequence5 = new Sequence();
sequence1.initByName("taxon", "a1", "value", "???");
sequence2.initByName("taxon", "a2", "value", "???");
sequence3.initByName("taxon", "a3", "value", "???");
sequence4.initByName("taxon", "b1", "value", "???");
sequence5.initByName("taxon", "b2", "value", "???");
Alignment alignment = new Alignment();
alignment.initByName("sequence", sequence1,"sequence", sequence2,"sequence", sequence3,"sequence", sequence4, "sequence", sequence5);
TaxonSet taxa = new TaxonSet();
taxa.initByName("alignment", alignment);
//build trait set
TraitSet traitSet = new TraitSet();
traitSet.initByName("value", "a1=a,a2=a,a3=a,b1=b,b2=b", "traitname", "type", "taxa", taxa);
Tree tree = new TreeParser("(((a1:1,a2:2):1,(b1:1,b2:1.5):2):1,a3:1)");
Tree traitTree = new Tree();
tree.initByName("taxonset", taxa, "trait", traitSet);
StructuredTreeIntervals st = new StructuredTreeIntervals();
st.initByName("tree",tree);
// build constant dynamics
RealParameter Ne = new RealParameter("1 2");
RealParameter backwardsMigration = new RealParameter("0.3 2");
int dim = 2;
Constant constant = new Constant();
constant.initByName("backwardsMigration", backwardsMigration, "Ne", Ne, "dimension", dim, "typeTrait", traitSet);
Mascot mascot = new Mascot();
mascot.initByName("structuredTreeIntervals", st, "dynamics", constant);
Assert.assertTrue(mascot.calculateLogP()==-6.870390751933608);
}
开发者ID:nicfel,项目名称:Mascot,代码行数:50,代码来源:MascotTest.java
示例17: testMascotUnstructured
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
@Test
public void testMascotUnstructured(){
//build alignment
Sequence sequence1 = new Sequence();
Sequence sequence2 = new Sequence();
Sequence sequence3 = new Sequence();
Sequence sequence4 = new Sequence();
Sequence sequence5 = new Sequence();
sequence1.initByName("taxon", "a1", "value", "???");
sequence2.initByName("taxon", "a2", "value", "???");
sequence3.initByName("taxon", "a3", "value", "???");
sequence4.initByName("taxon", "b1", "value", "???");
sequence5.initByName("taxon", "b2", "value", "???");
Alignment alignment = new Alignment();
alignment.initByName("sequence", sequence1,"sequence", sequence2,"sequence", sequence3,"sequence", sequence4, "sequence", sequence5);
TaxonSet taxa = new TaxonSet();
taxa.initByName("alignment", alignment);
//build trait set
TraitSet traitSet = new TraitSet();
traitSet.initByName("value", "a1=a,a2=a,a3=a,b1=a,b2=a", "traitname", "type", "taxa", taxa);
Tree tree = new TreeParser("(((a1:1,a2:2):1,(b1:1,b2:1.5):2):1,a3:1)");
Tree traitTree = new Tree();
tree.initByName("taxonset", taxa, "trait", traitSet);
StructuredTreeIntervals st = new StructuredTreeIntervals();
st.initByName("tree",tree);
// build constant dynamics
RealParameter Ne = new RealParameter("1.5 2");
RealParameter backwardsMigration = new RealParameter("0 0");
int dim = 2;
Constant constant = new Constant();
constant.initByName("backwardsMigration", backwardsMigration, "Ne", Ne, "dimension", dim, "typeTrait", traitSet);
Mascot mascot = new Mascot();
mascot.initByName("structuredTreeIntervals", st, "dynamics", constant);
// also set up the constant coalescent
TreeIntervals ti = new TreeIntervals();
ti.initByName("tree",tree);
RealParameter Nec = new RealParameter("1.5");
ConstantPopulation cp = new ConstantPopulation();
cp.initByName("popSize", Nec);
Coalescent coalescent = new Coalescent();
coalescent.initByName("populationModel", cp, "treeIntervals", ti);
Assert.assertTrue(Math.abs(mascot.calculateLogP()-coalescent.calculateLogP())<0.000000001);
}
开发者ID:nicfel,项目名称:Mascot,代码行数:61,代码来源:MascotTest.java
示例18: convertTraitToTableData
import beast.evolution.tree.TraitSet; //导入依赖的package包/类
private void convertTraitToTableData() {
for (int i = 0; i < tableData.length; i++) {
tableData[i][0] = taxa.get(i);
tableData[i][1] = "0";
tableData[i][2] = "0";
}
String[] traits = traitSet.traitsInput.get().split(",");
for (String trait : traits) {
trait = trait.replaceAll("\\s+", " ");
String[] strs = trait.split("=");
if (strs.length != 2) {
break;
//throw new Exception("could not parse trait: " + trait);
}
String taxonID = normalize(strs[0]);
int taxonIndex = taxa.indexOf(taxonID);
// if (taxonIndex < 0) {
// throw new Exception("Trait (" + taxonID + ") is not a known taxon. Spelling error perhaps?");
// }
if (taxonIndex >= 0) {
tableData[taxonIndex][1] = normalize(strs[1]);
tableData[taxonIndex][0] = taxonID;
} else {
Log.warning.println("WARNING: File contains taxon " + taxonID + " that cannot be found in alignment");
}
}
if (traitSet.traitNameInput.get().equals(TraitSet.DATE_BACKWARD_TRAIT)) {
Double minDate = Double.MAX_VALUE;
for (int i = 0; i < tableData.length; i++) {
minDate = Math.min(minDate, parseDate((String) tableData[i][1]));
}
for (int i = 0; i < tableData.length; i++) {
tableData[i][2] = parseDate((String) tableData[i][1]) - minDate;
}
} else {
Double maxDate = 0.0;
for (int i = 0; i < tableData.length; i++) {
maxDate = Math.max(maxDate, parseDate((String) tableData[i][1]));
}
for (int i = 0; i < tableData.length; i++) {
tableData[i][2] = maxDate - parseDate((String) tableData[i][1]);
}
}
if (table != null) {
for (int i = 0; i < tableData.length; i++) {
table.setValueAt(tableData[i][1], i, 1);
table.setValueAt(tableData[i][2], i, 2);
}
}
}
开发者ID:genomescale,项目名称:starbeast2,代码行数:52,代码来源:StarBeastTipDatesInputEditor.java
注:本文中的beast.evolution.tree.TraitSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论