import jalview.analysis.TreeBuilder;
import jalview.datamodel.SequenceI;
+import jalview.ext.forester.ForesterConversions;
import jalview.ext.forester.ForesterMatrix;
import jalview.util.MessageManager;
+import java.util.HashMap;
+import java.util.Map;
+
import org.forester.evoinference.matrix.distance.DistanceMatrix;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.NodeData;
+import org.forester.phylogeny.data.Sequence;
-public class ArchaeopteryxTreeConverter
+public class ArchaeopteryxTreeConverter // implements PhylogenyFactory
{
protected final SequenceI[] sequences;
- private Phylogeny aptxTree;
-
- private PhylogenyNode rootNode;
-
protected final DistanceMatrix distances;
protected final TreeBuilder jalviewTree;
public String treeTitle;
+ private final Phylogeny aptxTree;
+
+ private PhylogenyNode rootNode;
+ private final Map<SequenceI, PhylogenyNode> alignmentBoundNodes;
public ArchaeopteryxTreeConverter(final TreeBuilder calculatedTree)
{
jalviewTree.getDistances(), sequences);
aptxTree = new Phylogeny();
rootNode = new PhylogenyNode();
+ alignmentBoundNodes = new HashMap<>(
+ distances.getSize());
+
}
public Phylogeny buildAptxTree(final PhylogenyNode treeRoot)
{
- rootNode = treeRoot;
+ if (treeRoot != null)
+ {
+ rootNode = treeRoot;
+ }
buildAptxTree();
}
+
public Phylogeny buildAptxTree()
{
- // test loop
+
for (SequenceI sequence : sequences)
{
+ Sequence seq = ForesterConversions
+ .createForesterSequence(sequence);
PhylogenyNode sequenceNode = new PhylogenyNode(sequence.getName());
+ NodeData nodeData = sequenceNode.getNodeData();
+ nodeData.setSequence(seq);
+
+ alignmentBoundNodes.put(sequence, sequenceNode);
rootNode.addAsChild(sequenceNode);
}
- aptxTree.setRoot(rootNode);
+ aptxTree.setRoot(rootNode);
+
treeTitle = generateTreeName();
aptxTree.setName(treeTitle);
}
+ public Map<SequenceI, PhylogenyNode> getAlignmentBoundNodes()
+ {
+ return alignmentBoundNodes;
+ }
+
private Phylogeny clusterNodes()
{
return aptxTree;
}
-
-
/**
* Formats a localised title for the tree panel, like
* <p>
*
* @return
*/
- public String generateTreeName()
+ public String generateTreeName() // Move this and add selection region to the
+ // title when applicable
{
if (treeTitle != null) // will currently never happen, loaded tree file will
// take a different path