From 33452f3abf6ec10c192f6a9d2ea9ae8c38423403 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Thu, 26 Oct 2017 21:57:16 +0100 Subject: [PATCH] Added proper title to aptx trees --- .../archaeopteryx/ArchaeopteryxTreeConverter.java | 88 ++++++++++---------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java index 780acee..689d5cd 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java @@ -3,6 +3,7 @@ package jalview.ext.archaeopteryx; import jalview.analysis.TreeBuilder; import jalview.datamodel.SequenceI; import jalview.math.MatrixI; +import jalview.util.MessageManager; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; @@ -16,36 +17,38 @@ public class ArchaeopteryxTreeConverter private PhylogenyNode rootNode; protected MatrixI distances; + + protected TreeBuilder jalviewTree; + + public String treeTitle; - { - this.aptxTree = new Phylogeny(); - } public ArchaeopteryxTreeConverter(TreeBuilder calculatedTree) { - this.sequences = calculatedTree.getSequences(); - this.distances = calculatedTree.getDistances(); - - this.rootNode = new PhylogenyNode(); - this.rootNode.setName("root"); + this.jalviewTree = calculatedTree; + this.sequences = jalviewTree.getSequences(); + this.distances = jalviewTree.getDistances(); } - public ArchaeopteryxTreeConverter(PhylogenyNode treeRoot, - TreeBuilder calculatedTree) + public Phylogeny buildAptxTree() { - this(calculatedTree); - this.rootNode = treeRoot; + this.rootNode = new PhylogenyNode(); + + return buildAptxTree(rootNode); } - public Phylogeny buildAptxTree() + public Phylogeny buildAptxTree(PhylogenyNode treeRoot) { + this.rootNode = treeRoot; + + this.aptxTree = new Phylogeny(); - this.aptxTree.setName( - "PLEASE FIX ME reheaheth35yheqhb3q5hyq3bt3q5u4jwqjwuh6"); + this.treeTitle = generateTreeName(); + this.aptxTree.setName(treeTitle); // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5); @@ -83,31 +86,32 @@ public class ArchaeopteryxTreeConverter * * @return */ - // public String getPanelTitle() - // { - // if (treeTitle != null) - // { - // return treeTitle; - // } - // else - // { - // /* - // * i18n description of Neighbour Joining or Average Distance method - // */ - // String treecalcnm = MessageManager - // .getString("label.tree_calc_" + treeType.toLowerCase()); - // - // /* - // * short score model name (long description can be too long) - // */ - // String smn = substitutionMatrix; - // - // /* - // * put them together as Using - // */ - // final String ttl = MessageManager - // .formatMessage("label.treecalc_title", treecalcnm, smn); - // return ttl; - // } - // } + public String generateTreeName() + { + if (treeTitle != null) // will currently never happen, loaded tree file will + // take a different path + { + return treeTitle; + } + else + { + /* + * i18n description of Neighbour Joining or Average Distance method + */ + String treecalcnm = MessageManager + .getString("label.tree_calc_" + jalviewTree.getClass() + .getSimpleName().substring(0, 2).toLowerCase()); + /* + * short score model name (long description can be too long) + */ + String smn = jalviewTree.getScoreModel().getName(); + + /* + * put them together as Using + */ + final String ttl = MessageManager + .formatMessage("label.treecalc_title", treecalcnm, smn); + return ttl; + } + } } -- 1.7.10.2