首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

运用PAL创建 NeighbourJoining tree 以及 从Unrooted tree 到 rootedTree

2012-07-19 
使用PAL创建 NeighbourJoining tree 以及 从Unrooted tree 到 rootedTreeOverview:The PAL project is a c

使用PAL创建 NeighbourJoining tree 以及 从Unrooted tree 到 rootedTree


Overview:

The PAL project is a collaborative effort to provide ahigh quality Java libraryfor use in molecular evolution and phylogenetics.Updates of PAL are released in regular intervals.At present (version 1.4) PAL consists of approximately 200 publicclasses/interfaces in 16 packageswith a total of more than35,000 lines of Java code. Please refer to theAPI documentation (available in source archives) for a detailed descriptionof all classes and methods available, and to therelease history for an overviewof 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 stubreturn identifiers.length;}/* Returns the ith identifier. * @see pal.misc.IdGroup#getIdentifier(int) */public Identifier getIdentifier(int index) {// TODO Auto-generated method stubreturn 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 stubidentifiers[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.

?



?

热点排行