From: Rutger V. <R....@re...> - 2011-05-28 16:17:29
|
Hi Hilmar, you note that you are looking at a javascript snippet for determining the root in a nexml tree in preparation for displaying it in jsPhyloSVG, right? Anyway, the following *doesn't* work, targetCount for the root should be 0 or possibly 1 in the case where a rootedge is an element in the nexEdges array. The head revision shows this done correctly. I was trying to get jsPhyloSVG to play nice and this was just one of many things that weren't working properly so this ended up being committed in that revision without actually working. Rutger On Sat, May 28, 2011 at 4:43 PM, Hilmar Lapp <hl...@dr...> wrote: > Rutger - > > I'm curious and am probably missing something and therefore don't fully follow why the below works. Would you mind explaining? By edges pointing into a node, do you mean incoming (from ancestor) or outgoing (to descendant) edges? It sounds like outgoing (or otherwise there wouldn't be two, right), but why does NeXML then require a node with one outgoing edge at the root of the tree, artificial or not? Or do you mean outgoing plus incoming? > > So I'm obviously missing something, but can you point me to what it is? > > -hilmar > > Sent with a tap. > > On May 19, 2011, at 9:00 AM, rv...@us... wrote: > >> Revision: 873 >> http://treebase.svn.sourceforge.net/treebase/?rev=873&view=rev >> Author: rvos >> Date: 2011-05-19 13:00:28 +0000 (Thu, 19 May 2011) >> >> Log Message: >> ----------- >> Added additional loop to identify the root node based on the implicit topology (instead of by looking for the @root attribute). >> >> Modified Paths: >> -------------- >> trunk/treebase-web/src/main/webapp/scripts/jsphylosvg-min.js >> >> Modified: trunk/treebase-web/src/main/webapp/scripts/jsphylosvg-min.js >> =================================================================== >> --- trunk/treebase-web/src/main/webapp/scripts/jsphylosvg-min.js 2011-05-19 12:57:49 UTC (rev 872) >> +++ trunk/treebase-web/src/main/webapp/scripts/jsphylosvg-min.js 2011-05-19 13:00:28 UTC (rev 873) >> @@ -761,6 +761,27 @@ >> } >> } >> >> + // RAV: the root attribute is used to indicate whether an implicitly rooted >> + // topology should, from a biological p.o.v., be considered as such. However, >> + // valid NeXML tree structures are always rooted, even if they don't have >> + // the root attribute, in the sense that there's always going to be one node >> + // that doesn't have two edges pointing into it. It seems to me that we can >> + // still render these trees, we just have to find which node is the one that >> + // doesn't have two edges pointing in. This loop does that. >> + if (!root){ >> + for(i = 0; i < nexNodes.length; i++) { >> + var targetCount = 0; >> + for(j = 0; j < nexEdges.length; j++) { >> + if(nexEdges[j].target == nexNodes[i].id) { >> + targetCount++; >> + } >> + } >> + if ( targetCount < 2 ) { >> + root = nexNodes[i]; >> + } >> + } >> + } >> + >> if(root){ >> root = recursiveParse(root); >> >> >> >> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. >> >> ------------------------------------------------------------------------------ >> What Every C/C++ and Fortran developer Should Know! >> Read this article and learn how Intel has extended the reach of its >> next-generation tools to help Windows* and Linux* C/C++ and Fortran >> developers boost performance applications - including clusters. >> http://p.sf.net/sfu/intel-dev2devmay >> _______________________________________________ >> Treebase-guts mailing list >> Tre...@li... >> https://lists.sourceforge.net/lists/listinfo/treebase-guts > > ------------------------------------------------------------------------------ > vRanger cuts backup time in half-while increasing security. > With the market-leading solution for virtual backup and recovery, > you get blazing-fast, flexible, and affordable data protection. > Download your free trial now. > http://p.sf.net/sfu/quest-d2dcopy1 > _______________________________________________ > Treebase-devel mailing list > Tre...@li... > https://lists.sourceforge.net/lists/listinfo/treebase-devel > -- Dr. Rutger A. Vos School of Biological Sciences Philip Lyle Building, Level 4 University of Reading Reading, RG6 6BX, United Kingdom Tel: +44 (0) 118 378 7535 http://rutgervos.blogspot.com |