Overview:
The PAL project is a collaborative effort to provide a
high quality Java library
for use in molecular evolution and phylogenetics.
Updates of PAL are released in regular intervals.
At present (version 1.4) PAL consists of approximately 200 public
classes/interfaces in 16 packages
with a total of more than
35,000 lines of Java code. Please refer to the
API documentation (available in source archives) for a detailed description
of all classes and methods available, and to the
release history for an overview
of the development history of PAL.
More info. please refer: http://www.cebl.auckland.ac.nz/pal-project/
Following, I'll illustrate how to use PAL to construct Neighbour Joinning (NJ) tree, according to the algorithm of NJ, the result tree is a unrooted tree, but, sometimes, we need rooted tree, then in this page, I'll also illustrate how to use PAL to convert an unrootd tree to rooted tree.
GOAL:
1. Using PAL to construct unrooted tree.
2. Using PAL to convert unrooted tree to rooted tree.
1. Using PAL to construct unrooted tree.
import pal.distance.DistanceMatrix;
import pal.tree.NeighborJoiningTree;
NeighborJoiningTree njTree = new NeighborJoiningTree(DistanceMatrix);
njTree.toString(); // Newick format representation of NJ tree.
In order to constract NJ tree, we need pal.distance.DistanceMatrix;
//new DistanceMatrix(double[][] distance, IdGroup idGroup).
DistanceMatrix distanceMatrix = new DistanceMatrix(distance, TaxaGroup );
While in PAL IdGroup is an interface, we need an implentation for it, here TaxaGroup is an implementation for it.
package picb.wavefancy.ReweightedTree;
import pal.misc.IdGroup;
import pal.misc.Identifier;
/**
* @author icorner
*
*/
public class TaxaGroup implements IdGroup {
private static final long serialVersionUID = -8639297673966439918L;
private Identifier[] identifiers;
private String[] taxaNames;
public TaxaGroup(String[] taxas){
identifiers = new Identifier[taxas.length];
for (int i = 0; i < taxas.length; i++) {
identifiers[i] = new Identifier(taxas[i]);
}
setTaxaNames(taxas);
}
public String[] getTaxaNames() {
return taxaNames;
}
public void setTaxaNames(String[] taxaNames) {
this.taxaNames = taxaNames;
}
/* Returns the number of identifiers in this group
* @see pal.misc.IdGroup#getIdCount()
*/
public int getIdCount() {
// TODO Auto-generated method stub
return identifiers.length;
}
/* Returns the ith identifier.
* @see pal.misc.IdGroup#getIdentifier(int)
*/
public Identifier getIdentifier(int index) {
// TODO Auto-generated method stub
return identifiers[index];
}
/* Sets the ith identifier.
* @see pal.misc.IdGroup#setIdentifier(int, pal.misc.Identifier)
*/
public void setIdentifier(int index, Identifier identifier) {
// TODO Auto-generated method stub
identifiers[index] = identifier;
}
/* returns the index of the identifier with the given name. return -1 if didn't find the target one.
* @see pal.misc.IdGroup#whichIdNumber(java.lang.String)
*/
public int whichIdNumber(String identifierName) {
for (int i = 0; i < identifiers.length; i++) {
if (identifiers[i].getName().equals(identifierName)) {
return i;
}
}
return -1;
}
}
2. Using PAL to convert unrooted tree to rooted tree.
The NeighborJoiningTree in PAL is a unrooted tree. We could use the toolset in PAL to convert an unrooted tree to rooted tree.
import pal.distance.DistanceMatrix;
import pal.tree.NeighborJoiningTree;
import pal.tree.Tree;
import pal.tree.TreeTool;
NeighborJoiningTree njTree = new NeighborJoiningTree(distanceMatrix);
String[] outGroupArr = new String[1]; //It's OK to specify several outgroup.More info. please refer PAL api.
Tree rootedTree = TreeTool.getRooted(njTree,outGroupArr);
rootedTree.toString(); // Newick format representation of a rooted tree.
分享到:
相关推荐
它处于测试阶段,因此仅当 (1) 您了解将存在错误 (2) 您准备报告完整错误报告时才使用(理想情况下,使用 bin/script 或 GooglePlay 的“终端 IDE”捕获完整的 shell 会话) , 文本格式) (3) 您有在 Gentoo Linux ...
这里我们将深入探讨这两个库以及它们在Java单元测试中的作用。 JUnit 4.12 是JUnit系列的一个版本,它引入了许多增强功能和改进,使得测试更加灵活和可扩展。JUnit 4 放弃了基于继承的测试结构,转而采用注解...
5. 树的种类和数量:系统发育推断涉及不同类型的树,包括有根双分支树(Rooted bifurcating trees)、无根双分支树(Unrooted bifurcating trees)和多分支树(Multifurcating trees)。不同的树形状代表了不同的...
魅族18全系列机型Fastboot模式保数据救砖教程+资源 如果你误操作导致手机进不去系统。系统里有重要数据不能丢失。 那么此资源适合你使用 详细的步骤按步骤操作即可 需要有基础的刷机常识的...希望我的资源可以帮到你
安装最新源从下载zip,将其解压缩到您的桌面。 [DESKTOP]将引用您的桌面目录转到Chrome并打开页面chrome:// extensions 选中“开发人员模式” 点击“加载解压后的扩展程序” 导航到[DESKTOP] / automoe / dev 按...
rectangleLayout()以产生一个“常规”系统发生树, radialLayout()以产生圆形系统发育,和unrooted()经由相等角度布局算法产生一个无根树。 例子 现在可以在Observable上查看一个快速教程: : 它遍历了三个树的布局...