本文整理汇总了Java中beast.evolution.alignment.TaxonSet类的典型用法代码示例。如果您正苦于以下问题:Java TaxonSet类的具体用法?Java TaxonSet怎么用?Java TaxonSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaxonSet类属于beast.evolution.alignment包,在下文中一共展示了TaxonSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
public TaxonSet generateSuperset() {
List<Taxon> superSetList = new ArrayList<>();
for (int i = 0; i < nSpecies; i++) {
final String speciesName = String.format("s%d", i);
List<Taxon> taxonList = new ArrayList<>();
for (int j = 0; j < individualsPerSpecies; j++) {
final String taxonName = String.format("s%d_tip%d", i, j);
taxonList.add(new Taxon(taxonName));
}
superSetList.add(new TaxonSet(speciesName, taxonList));
}
TaxonSet speciesSuperset = new TaxonSet(superSetList);
return speciesSuperset;
}
示例2: initialize
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private void initialize(TaxonSet speciesSuperset) throws Exception {
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
geneTrees.add(geneTree);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree);
geneTreeWrappers.add(geneTreeWrapper);
}
state.initByName("stateNode", alphaParameter);
state.initByName("stateNode", meanParameter);
msc = new MultispeciesCoalescent();
msc.initByName("populationShape", alphaParameter, "populationMean", meanParameter, "distribution", geneTreeWrappers);
for (GeneTree gt: geneTreeWrappers) gt.calculateLogP();
}
示例3: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
public TaxonSet generateSuperset() throws Exception {
List<Taxon> superSetList = new ArrayList<>();
for (int i = 0; i < nSpecies; i++) {
final String speciesName = String.format("s%d", i);
List<Taxon> taxonList = new ArrayList<>();
for (int j = 0; j < individualsPerSpecies; j++) {
final String taxonName = String.format("s%d_tip%d", i, j);
taxonList.add(new Taxon(taxonName));
}
superSetList.add(new TaxonSet(speciesName, taxonList));
}
TaxonSet speciesSuperSet = new TaxonSet(superSetList);
return speciesSuperSet;
}
示例4: testLogP
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
@Test
public void testLogP() throws Exception {
TaxonSet speciesSuperset = generateSuperset();
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
final int nBranches = nSpecies * 2 - 1;
popsizeParameter.initByName("value", String.valueOf(popSize), "dimension", String.valueOf(nBranches));
state.initByName("stateNode", popsizeParameter);
popModel = new ConstantPopulations();
popModel.initByName("populationSizes", popsizeParameter, "speciesTree", speciesTree);
double calculatedLogP = 0.0;
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree, "populationModel", popModel);
calculatedLogP += geneTreeWrapper.calculateLogP();
}
// System.out.println(String.format("expected %f, calculated %f", expectedLogP, calculatedLogP));
assertEquals(expectedLogP, calculatedLogP, allowedError);
}
示例5: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
public TaxonSet generateSuperset() {
List<Taxon> superSetList = new ArrayList<>();
for (int i = 0; i < nSpecies; i++) {
final String speciesName = String.format("T%d", i + 1);
List<Taxon> taxonList = new ArrayList<>();
for (int j = 0; j < individualsPerSpecies; j++) {
final String taxonName = String.format("T%d_%d", i + 1, j + 1);
taxonList.add(new Taxon(taxonName));
}
superSetList.add(new TaxonSet(speciesName, taxonList));
}
TaxonSet speciesSuperset = new TaxonSet(superSetList);
return speciesSuperset;
}
示例6: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private TaxonSet generateSuperset() {
List<Taxon> superSetList = new ArrayList<>();
for (int i = 0; i < nSpecies; i++) {
final String speciesName = String.format("s%d", i);
List<Taxon> taxonList = new ArrayList<>();
for (int j = 0; j < individualsPerSpecies; j++) {
final String taxonName = String.format("s%d_tip%d", i, j);
taxonList.add(new Taxon(taxonName));
}
superSetList.add(new TaxonSet(speciesName, taxonList));
}
TaxonSet speciesSuperset = new TaxonSet(superSetList);
return speciesSuperset;
}
示例7: initialize
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private void initialize(TaxonSet speciesSuperset) throws Exception {
speciesTree = new SpeciesTreeParser();
speciesTree.initByName("newick", newickSpeciesTree, "IsLabelledNewick", true, "taxonset", speciesSuperset);
for (String geneTreeNewick: newickGeneTrees) {
TreeParser geneTree = new TreeParser();
geneTree.initByName("newick", geneTreeNewick, "IsLabelledNewick", true);
geneTrees.add(geneTree);
GeneTree geneTreeWrapper = new GeneTree();
geneTreeWrapper.initByName("tree", geneTree, "ploidy", ploidy, "speciesTree", speciesTree);
geneTreeWrappers.add(geneTreeWrapper);
}
state.initByName("stateNode", alphaParameter);
state.initByName("stateNode", meanParameter);
msc = new MultispeciesCoalescent();
msc.initByName("populationShape", alphaParameter, "populationMean", meanParameter, "distribution", geneTreeWrappers);
}
示例8: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
public TaxonSet generateSuperset() throws Exception {
List<Taxon> superSetList = new ArrayList<>();
List<Taxon> taxonListA = new ArrayList<>();
List<Taxon> taxonListB = new ArrayList<>();
List<Taxon> taxonListC = new ArrayList<>();
taxonListA.add(new Taxon("A1"));
taxonListA.add(new Taxon("A2"));
taxonListB.add(new Taxon("B1"));
taxonListB.add(new Taxon("B2"));
taxonListC.add(new Taxon("C1"));
superSetList.add(new TaxonSet("A", taxonListA));
superSetList.add(new TaxonSet("B", taxonListB));
superSetList.add(new TaxonSet("C", taxonListC));
TaxonSet speciesSuperSet = new TaxonSet(superSetList);
return speciesSuperSet;
}
示例9: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private TaxonSet generateSuperset() throws Exception {
String speciesCodes = "abc";
List<Taxon> superSetList = new ArrayList<>();
for (int i = 0; i < nSpecies; i++) {
final String speciesName = speciesCodes.substring(i, i + 1);
List<Taxon> taxonList = new ArrayList<>();
for (int j = 0; j < individualsPerSpecies; j++) {
final String taxonName = String.format("%s%d", speciesName, j + 1);
taxonList.add(new Taxon(taxonName));
}
superSetList.add(new TaxonSet(speciesName, taxonList));
}
TaxonSet speciesSuperSet = new TaxonSet(superSetList);
return speciesSuperSet;
}
示例10: generateSuperset
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
public TaxonSet generateSuperset() throws Exception {
List<Taxon> superSetList = new ArrayList<>();
List<Taxon> taxonListA = new ArrayList<>();
List<Taxon> taxonListB = new ArrayList<>();
List<Taxon> taxonListC = new ArrayList<>();
taxonListA.add(new Taxon("A1"));
taxonListA.add(new Taxon("A2"));
taxonListB.add(new Taxon("B1"));
taxonListB.add(new Taxon("B2"));
taxonListC.add(new Taxon("C1"));
superSetList.add(new TaxonSet("A", taxonListA));
superSetList.add(new TaxonSet("B", taxonListB));
superSetList.add(new TaxonSet("C", taxonListC));
TaxonSet speciesSuperSet = new TaxonSet(superSetList);
return speciesSuperSet;
}
示例11: initAndValidate
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
@Override
public void initAndValidate() {
/** maps gene taxa names to species number **/
final Map<String, Integer> taxonMap = new HashMap<>();
final List<Taxon> list = taxonSetInput.get().taxonsetInput.get();
if (list.size() <= 1) {
Log.err.println("NodeReheight operator requires at least 2 taxa while the taxon set (id=" + taxonSetInput.get().getID() +") has only " + list.size() + " taxa. "
+ "If the XML file was set up in BEAUti, this probably means a taxon assignment needs to be set up in the taxonset panel.");
// assume we are in BEAUti, back off for now
return;
}
for (int i = 0; i < list.size(); i++) {
final Taxon taxa = list.get(i);
// cast should be ok if taxon-set is the set for the species tree
final TaxonSet set = (TaxonSet) taxa;
for (final Taxon taxon : set.taxonsetInput.get()) {
taxonMap.put(taxon.getID(), i);
}
}
/** build the taxon map for each gene tree **/
m_taxonMap = new ArrayList<>();
for (final Tree tree : geneTreesInput.get()) {
final Map<Integer, Integer> map = new HashMap<>();
setupTaxaMap(tree.getRoot(), map, taxonMap);
m_taxonMap.add(map);
}
nrOfGeneTrees = geneTreesInput.get().size();
nrOfSpecies = treeInput.get().getLeafNodeCount();
}
示例12: randomInit
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private void randomInit() {
double lam = 1;
final RealParameter lambda = birthRate.get();
if( lambda != null ) {
lam = lambda.getArrayValue();
}
final Tree stree = speciesTreeInput.get();
final TaxonSet species = stree.m_taxonset.get();
final int speciesCount = species.asStringList().size();
double s = 0;
for(int k = 2; k <= speciesCount; ++k) {
s += 1.0/k;
}
final double rootHeight = (1/lam) * s;
stree.scale(rootHeight/stree.getRoot().getHeight());
randomInitGeneTrees(rootHeight);
// final List<Tree> geneTrees = genes.get();
// for (final Tree gtree : geneTrees) {
// gtree.makeCaterpillar(rootHeight, rootHeight/gtree.getInternalNodeCount(), true);
// }
}
示例13: getTaxonCandidates
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
Set<Taxon> getTaxonCandidates(MRCAPrior prior) {
Set<Taxon> candidates = new HashSet<>();
Tree tree = prior.treeInput.get();
String [] taxa = null;
if (tree.m_taxonset.get() != null) {
try {
TaxonSet set = tree.m_taxonset.get();
set.initAndValidate();
taxa = set.asStringList().toArray(new String[0]);
} catch (Exception e) {
taxa = prior.treeInput.get().getTaxaNames();
}
} else {
taxa = prior.treeInput.get().getTaxaNames();
}
for (String taxon : taxa) {
candidates.add(doc.getTaxon(taxon));
}
return candidates;
}
示例14: enableTipSampling
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
private void enableTipSampling() {
// First, create/find the operator
TipDatesRandomWalker operator = null;
MRCAPrior prior = (MRCAPrior) m_beastObject;
TaxonSet taxonset = prior.taxonsetInput.get();
taxonset.initAndValidate();
// see if an old operator still hangs around -- happens when toggling the TipsOnly checkbox a few times
for (BEASTInterface o : taxonset.getOutputs()) {
if (o instanceof TipDatesRandomWalker) {
operator = (TipDatesRandomWalker) o;
}
}
if (operator == null) {
operator = new TipDatesRandomWalker();
operator.initByName("tree", prior.treeInput.get(), "taxonset", taxonset, "windowSize", 1.0, "weight", 1.0);
}
operator.setID("tipDatesSampler." + taxonset.getID());
doc.mcmc.get().setInputValue("operator", operator);
}
示例15: TreeParser
import beast.evolution.alignment.TaxonSet; //导入依赖的package包/类
/**
* Create a tree from the given newick format
*
* @param taxaNames a list of taxa names to use, or null.
* If null then IsLabelledNewick will be set to true
* @param newick the newick of the tree
* @param offset the offset to map node numbers in newick format to indices in taxaNames.
* so, name(node with nodeNumber) = taxaNames[nodeNumber-offset]
* @param adjustTipHeightsWhenMissingDateTraits
* true if tip heights should be adjusted to zero
*/
public TreeParser(final List<String> taxaNames,
final String newick,
final int offset,
final boolean adjustTipHeightsWhenMissingDateTraits) {
if (taxaNames == null) {
isLabelledNewickInput.setValue(true, this);
} else {
m_taxonset.setValue(new TaxonSet(Taxon.createTaxonList(taxaNames)), this);
}
newickInput.setValue(newick, this);
offsetInput.setValue(offset, this);
adjustTipHeightsInput.setValue(adjustTipHeightsWhenMissingDateTraits, this);
labels = taxaNames;
initAndValidate();
}