1 ## klastorin.R (2003-05-26)
3 ## Klastorin's (1982) classifification method, applied to
4 ## phylogenetic trees as suggested by Misawa and Tajima (2000)
6 ## Copyright 2003 Gangolf Jobb
8 ## This file is part of the R-package `ape'.
9 ## See the file ../COPYING for licensing issues.
11 ########### PRIVATE ##############
13 getMisawaTajima <- function()
14 .C("getMisawaTajima", result = integer(klastorin_nTips()),
15 PACKAGE = "ape")$result
17 ### functions to set and extract phylo tree ###
19 buildTreeFromPhylo <- function(tree) {
20 lowerNodes <- tree$edge[,1]
21 upperNodes <- tree$edge[,2]
22 edgeLengths <- tree$edge.length
23 tipLabels <- tree$tip.label
24 .C("buildTreeFromPhylo", as.integer(lowerNodes),
25 as.integer(upperNodes), as.double(edgeLengths),
26 as.integer(length(edgeLengths)),
27 as.character(tipLabels),
28 as.integer(length(tipLabels)),
29 result = integer(1), PACKAGE = "ape"
33 destroyTree <- function()
34 .C("destroyTree", result = integer(1),
35 PACKAGE = "ape")$result
37 getError <- function()
38 .C("getError", result = integer(1),
39 PACKAGE = "ape")$result
41 klastorin_nTips <- function()
42 .C("nTips", result = integer(1),
43 PACKAGE = "ape")$result
45 ########### PUBLIC ##############
47 klastorin <- function(phy)
49 if (class(phy) != "phylo")
50 stop("object \"phy\" is not of class \"phylo\"")
51 ## added by EP for the new coding of "phylo" (2006-10-04):
52 phy <- new2old.phylo(phy)
54 buildTreeFromPhylo(phy)
55 if (getError() !=0) stop("Could not load \"phylo\" object")
56 tmp <- getMisawaTajima()