From 05bbd2836374874e53dae8eefb0f6ede64a54bc1 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Tue, 5 Dec 2017 15:25:02 +0000 Subject: [PATCH] JAL-2794 associate leaves now iterates through ALL nodes (also internal) --- .../LoadedTreeSequenceAssociation.java | 35 +++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java b/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java index 1bc71b4..86f27d1 100644 --- a/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java +++ b/src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java @@ -7,11 +7,11 @@ import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI; import jalview.util.MappingUtils; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; +import org.forester.phylogeny.iterators.PhylogenyNodeIterator; public class LoadedTreeSequenceAssociation implements ExternalLoadedTreeAssociationI @@ -51,32 +51,35 @@ public class LoadedTreeSequenceAssociation { SequenceIdMatcher algnIds = new SequenceIdMatcher(alignSequences); - - List leaves = tree.getExternalNodes(); SequenceI nodeSequence; String nodeSequenceName; - for (PhylogenyNode treeNode : leaves) + if (!tree.isEmpty()) { - nodeSequenceName = treeNode.getName(); - - nodeSequence = algnIds.findIdMatch(nodeSequenceName); - if (nodeSequence != null) + for (final PhylogenyNodeIterator iter = tree.iteratorPreorder(); iter + .hasNext();) { - org.forester.phylogeny.data.Sequence foresterNodeSeq = DataConversions - .createForesterSequence(nodeSequence, true); - treeNode.getNodeData().setSequence(foresterNodeSeq); + PhylogenyNode treeNode = iter.next(); + nodeSequenceName = treeNode.getName(); - MappingUtils.putWithDuplicationCheck(alignmentWithNodes, - nodeSequence, treeNode); - MappingUtils.putWithDuplicationCheck(nodesWithAlignment, - treeNode, nodeSequence); + nodeSequence = algnIds.findIdMatch(nodeSequenceName); + if (nodeSequence != null) + { + org.forester.phylogeny.data.Sequence foresterNodeSeq = DataConversions + .createForesterSequence(nodeSequence, true); + treeNode.getNodeData().setSequence(foresterNodeSeq); + MappingUtils.putWithDuplicationCheck(alignmentWithNodes, + nodeSequence, treeNode); + MappingUtils.putWithDuplicationCheck(nodesWithAlignment, treeNode, + nodeSequence); - } + + } } + } } -- 1.7.10.2