当前位置: 首页>>代码示例>>Java>>正文


Java Tree.getExternalNodes方法代码示例

本文整理汇总了Java中beast.evolution.tree.Tree.getExternalNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getExternalNodes方法的具体用法?Java Tree.getExternalNodes怎么用?Java Tree.getExternalNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在beast.evolution.tree.Tree的用法示例。


在下文中一共展示了Tree.getExternalNodes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TreeSDBorrowingTest

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void TreeSDBorrowingTest(String seq) throws Exception {
	seq = "";
	for (int j = 0; j < 5; j++) {
		seq += '1';
	}
	Sequence l = new Sequence("", seq);

	ExplicitBinaryStochasticDollo sd_mod = new ExplicitBinaryStochasticDollo(0.1, 0.2, 0.0, 0.0,
			false);

	System.out.println("Tree SD Borrowing Test");
	Tree tree = randomYuleTree(2, 0.01);
	tree.getRoot().setMetaData("lang", l);
	sd_mod.mutateOverTreeBorrowing(tree);
	for (Node n : tree.getExternalNodes()) {
		Sequence l2 = (Sequence) n.getMetaData("lang");
		System.out.println(l2.getData());
	}
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:20,代码来源:BeastBorrowingPluginTest.java

示例2: NoEmptyTraitTest

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void NoEmptyTraitTest() throws Exception {
	for (int i = 0; i < 1; i++) {
		System.out.println(i);
		Sequence l = new Sequence("", "00000000000001");
		Tree tree = randomYuleTree(3, 0.06);
		tree.getRoot().setMetaData("lang", l);
		ExplicitBinaryStochasticDollo sd_mod = new ExplicitBinaryStochasticDollo(0.0, 0.5, 0.0, 0.0, true);
		tree = sd_mod.mutateOverTree(tree);

		for (Node n : tree.getExternalNodes()) {
			Sequence l2 = (Sequence) n.getMetaData("lang");
			System.out.println(l2.getData());
		}

	}
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:17,代码来源:BeastBorrowingPluginTest.java

示例3: GTRTreeValidation

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void GTRTreeValidation() throws Exception {
	ArrayList<Integer> births = new ArrayList<Integer>();
	for (int i = 0; i < 10000; i++) {
		System.out.println(i);
		ExplicitBinaryGTR gtr_mod = new ExplicitBinaryGTR(0.5, 0.0, 0.0, false);
		String seq = "";
		for (int j = 0; j < 20; j++) {
			seq += Integer.toString(Randomizer.nextInt(2));
		}
		Sequence l = new Sequence("", seq);
		Tree tree = randomYuleTree(8, 0.001);
		tree.getRoot().setMetaData("lang", l);
		tree = gtr_mod.mutateOverTree(tree);
		for (Node n : tree.getExternalNodes()) {
			Sequence l2 = (Sequence) n.getMetaData("lang");
			births.add(LanguageSubsitutionModel.getBirths(l2));
		}

	}
	listToCSV(births, "Utilities/Thesis Graph Generation/gtrtree.csv");
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:22,代码来源:BeastBorrowingPluginTest.java

示例4: SDTreeValidation

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void SDTreeValidation() throws Exception {
	ArrayList<Integer> births = new ArrayList<Integer>();

	for (int i = 0; i < 10000; i++) {
		System.out.println(i);
		ExplicitBinaryStochasticDollo sd_mod = new ExplicitBinaryStochasticDollo(0.5, 0.5, 0.0, 0.0, false);
		String seq = "";
		Sequence l = new Sequence("", seq);
		Tree tree = randomYuleTree(8, 0.01);
		tree.getRoot().setMetaData("lang", l);
		tree = sd_mod.mutateOverTreeBorrowing(tree);
		for (Node n : tree.getExternalNodes()) {
			Sequence l2 = (Sequence) n.getMetaData("lang");
			births.add(LanguageSubsitutionModel.getBirths(l2));
		}
	}
	listToCSV(births, "Utilities/Thesis Graph Generation/sdtree.csv");
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:19,代码来源:BeastBorrowingPluginTest.java

示例5: TreeGenTest

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void TreeGenTest(String seq) throws Exception {
	Sequence l = new Sequence("", seq);
	ExplicitBinaryStochasticDollo sd_mod = new ExplicitBinaryStochasticDollo(0.5, 0.5, 0.0, 0.0, false);

	System.out.println("Tree generation test");
	Tree tree = randomYuleTree(4, 0.6);
	tree.getRoot().setMetaData("lang", l);
	sd_mod.mutateOverTree(tree);
	for (Node n : tree.getExternalNodes()) {
		Sequence l2 = (Sequence) n.getMetaData("lang");
		System.out.println(l2.getData());
	}
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:14,代码来源:BeastBorrowingPluginTest.java

示例6: TreeGTRBorrowingTest

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void TreeGTRBorrowingTest(String seq) throws Exception {
	Sequence l = new Sequence("", seq);
	ExplicitBinaryGTR gtr_mod = new ExplicitBinaryGTR(0.5, 1.2, 0.0, false);

	System.out.println("Tree GTR Borrowing Test");
	Tree tree = randomYuleTree(2, 0.01);
	tree.getRoot().setMetaData("lang", l);
	gtr_mod.mutateOverTreeBorrowing(tree);
	for (Node n : tree.getExternalNodes()) {
		Sequence l2 = (Sequence) n.getMetaData("lang");
		System.out.println(l2.getData());
	}
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:14,代码来源:BeastBorrowingPluginTest.java

示例7: getRank

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public int getRank(Tree tree, Node node) {
    ArrayList<Node> nodes = new ArrayList<Node>(tree.getExternalNodes());
    Comparator<Node> comp = new NodeComparator();

    Collections.sort(nodes, comp);
    return nodes.size() - nodes.indexOf(node);
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:8,代码来源:SATreeTraceAnalysis.java

示例8: GTRTreeBorrowingValidationThreeLanguages

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private static void GTRTreeBorrowingValidationThreeLanguages() throws Exception {
	Tree tree = null;
	ArrayList<Integer> zeroZeroZero = new ArrayList<Integer>();
	ArrayList<Integer> oneZeroZero = new ArrayList<Integer>();
	ArrayList<Integer> zeroOneZero = new ArrayList<Integer>();
	ArrayList<Integer> zeroZeroOne = new ArrayList<Integer>();
	ArrayList<Integer> oneOneZero = new ArrayList<Integer>();
	ArrayList<Integer> oneZeroOne = new ArrayList<Integer>();
	ArrayList<Integer> zeroOneOne = new ArrayList<Integer>();
	ArrayList<Integer> oneOneOne = new ArrayList<Integer>();
	for (int i = 0; i < 10000; i++) {
		System.out.println(i);
		ExplicitBinaryGTR gtr_mod = new ExplicitBinaryGTR(0.5, 0.5, 0.0, false);
		String seq = "";
		for (int j = 0; j < 20; j++) {
			seq += Integer.toString(Randomizer.nextInt(2));
		}
		Sequence l = new Sequence("", seq);
		tree = randomYuleTree3Branch(3, 0.01);
		tree.getRoot().setMetaData("lang", l);
		tree = gtr_mod.mutateOverTreeBorrowing(tree);
		List<Node> ext = tree.getExternalNodes();
		String l1 = ((Sequence) ext.get(0).getMetaData("lang")).getData();
		String l2 = ((Sequence) ext.get(1).getMetaData("lang")).getData();
		String l3 = ((Sequence) ext.get(2).getMetaData("lang")).getData();
		Integer zeroZeroZeroInt = 0;
		Integer oneZeroZeroInt = 0;
		Integer zeroOneZeroInt = 0;
		Integer zeroZeroOneInt = 0;
		Integer oneOneZeroInt = 0;
		Integer oneZeroOneInt = 0;
		Integer zeroOneOneInt = 0;
		Integer oneOneOneInt = 0;
		for (int j = 0; j < 20; j++) {
			if (l1.charAt(j) == '0' && l2.charAt(j) == '0' && l3.charAt(j) == '0') {
				zeroZeroZeroInt += 1;
			} else if (l1.charAt(j) == '1' && l2.charAt(j) == '0' && l3.charAt(j) == '0') {
				oneZeroZeroInt += 1;
			} else if (l1.charAt(j) == '0' && l2.charAt(j) == '1' && l3.charAt(j) == '0') {
				zeroOneZeroInt += 1;
			} else if (l1.charAt(j) == '0' && l2.charAt(j) == '0' && l3.charAt(j) == '1') {
				zeroZeroOneInt += 1;
			} else if (l1.charAt(j) == '1' && l2.charAt(j) == '1' && l3.charAt(j) == '0') {
				oneOneZeroInt += 1;
			} else if (l1.charAt(j) == '1' && l2.charAt(j) == '0' && l3.charAt(j) == '1') {
				oneZeroOneInt += 1;
			} else if (l1.charAt(j) == '0' && l2.charAt(j) == '1' && l3.charAt(j) == '1') {
				zeroOneOneInt += 1;
			} else if (l1.charAt(j) == '1' && l2.charAt(j) == '1' && l3.charAt(j) == '1') {
				oneOneOneInt += 1;
			}
		}
		zeroZeroZero.add(zeroZeroZeroInt);
		oneZeroZero.add(oneZeroZeroInt);
		zeroOneZero.add(zeroOneZeroInt);
		zeroZeroOne.add(zeroZeroOneInt);
		oneOneZero.add(oneOneZeroInt);
		oneZeroOne.add(oneZeroOneInt);
		zeroOneOne.add(zeroOneOneInt);
		oneOneOne.add(oneOneOneInt);
	}

	listToCSV(zeroZeroZero, "Utilities/Thesis Graph Generation/gtr000.csv");
	listToCSV(oneZeroZero, "Utilities/Thesis Graph Generation/gtr100.csv");
	listToCSV(zeroOneZero, "Utilities/Thesis Graph Generation/gtr010.csv");
	listToCSV(zeroZeroOne, "Utilities/Thesis Graph Generation/gtr001.csv");
	listToCSV(oneOneZero, "Utilities/Thesis Graph Generation/gtr110.csv");
	listToCSV(oneZeroOne, "Utilities/Thesis Graph Generation/gtr101.csv");
	listToCSV(zeroOneOne, "Utilities/Thesis Graph Generation/gtr011.csv");
	listToCSV(oneOneOne, "Utilities/Thesis Graph Generation/gtr111.csv");
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:72,代码来源:BeastBorrowingPluginTest.java

示例9: sample

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * Sampling only implemented for no-origin case currently.
 */
@Override
public void sample(State state, Random random) {

    if (sampledFlag)
        return;

    sampledFlag = true;

    // Cause conditional parameters to be sampled

    sampleConditions(state, random);

    Tree tree = (Tree) treeInput.get();
    RealParameter birthRate = birthDiffRateParameterInput.get();

    // Simulate tree conditional on new parameters

    List<Node> activeLineages = new ArrayList<>();
    for (Node oldLeaf : tree.getExternalNodes()) {
        Node newLeaf = new Node(oldLeaf.getID());
        newLeaf.setNr(oldLeaf.getNr());
        newLeaf.setHeight(0.0);
        activeLineages.add(newLeaf);
    }

    int nextNr = activeLineages.size();

    double t = 0.0;
    while (activeLineages.size() > 1) {
        int k = activeLineages.size();
        double a = birthRate.getValue() * k;

        t += -Math.log(random.nextDouble())/a;

        Node node1 = activeLineages.get(random.nextInt(k));
        Node node2;
        do {
            node2 = activeLineages.get(random.nextInt(k));
        } while (node2.equals(node1));

        Node newParent = new Node();
        newParent.setNr(nextNr++);
        newParent.setHeight(t);
        newParent.addChild(node1);
        newParent.addChild(node2);

        activeLineages.remove(node1);
        activeLineages.remove(node2);
        activeLineages.add(newParent);
    }

    tree.assignFromWithoutID(new Tree(activeLineages.get(0)));
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:57,代码来源:YuleModel.java


注:本文中的beast.evolution.tree.Tree.getExternalNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。