JAL-2794 associate leaves now iterates through ALL nodes (also internal)
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 5 Dec 2017 15:25:02 +0000 (15:25 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 5 Dec 2017 15:31:28 +0000 (15:31 +0000)
src/jalview/ext/archaeopteryx/LoadedTreeSequenceAssociation.java

index 1bc71b4..86f27d1 100644 (file)
@@ -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<PhylogenyNode> 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);
 
-      }
+
+        }
 
     }
 
+    }
   }