X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FTreeModel.java;h=a50634ecf6178632561e498458857b969fe19a46;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=2f8d7883f40d2fe37f1b875eb7026b8da517af8a;hpb=be27d7b3cadbfb5c488066034c48b1735799b429;p=jalview.git diff --git a/src/jalview/analysis/TreeModel.java b/src/jalview/analysis/TreeModel.java index 2f8d788..a50634e 100644 --- a/src/jalview/analysis/TreeModel.java +++ b/src/jalview/analysis/TreeModel.java @@ -46,7 +46,7 @@ public class TreeModel * SequenceData is a string representation of what the user * sees. The display may contain hidden columns. */ - public AlignmentView seqData; + private AlignmentView seqData; int noseqs; @@ -68,7 +68,7 @@ public class TreeModel /** * Create a new TreeModel object with leaves associated with sequences in - * seqs, and original alignment data represented by Cigar strings + * seqs, and (optionally) original alignment data represented by Cigar strings * * @param seqs * SequenceI[] @@ -77,24 +77,12 @@ public class TreeModel * @param treefile * NewickFile */ - public TreeModel(SequenceI[] seqs, AlignmentView odata, NewickFile treefile) + public TreeModel(SequenceI[] seqs, AlignmentView odata, + NewickFile treefile) { - this(seqs, treefile); + this(seqs, treefile.getTree(), treefile.HasDistances(), + treefile.HasBootstrap(), treefile.HasRootDistance()); seqData = odata; - } - - /** - * Creates a new TreeModel object from a tree from an external source - * - * @param seqs - * SequenceI which should be associated with leafs of treefile - * @param treefile - * A parsed tree - */ - public TreeModel(SequenceI[] seqs, NewickFile treefile) - { - this(seqs, treefile.getTree(), treefile.HasDistances(), treefile - .HasBootstrap(), treefile.HasRootDistance()); associateLeavesToSequences(seqs); } @@ -106,8 +94,9 @@ public class TreeModel */ public TreeModel(TreeBuilder tree) { - this(tree.getSequences(), tree.getTopNode(), tree.hasDistances(), tree - .hasBootstrap(), tree.hasRootDistance()); + this(tree.getSequences(), tree.getTopNode(), tree.hasDistances(), + tree.hasBootstrap(), tree.hasRootDistance()); + seqData = tree.getOriginalData(); } /** @@ -199,8 +188,12 @@ public class TreeModel { NewickFile fout = new NewickFile(getTopNode()); - return fout.print(hasBootstrap(), hasDistances(), - hasRootDistance()); // output all data available for tree + return fout.print(hasBootstrap(), hasDistances(), hasRootDistance()); // output + // all + // data + // available + // for + // tree } /** @@ -260,8 +253,8 @@ public class TreeModel if (!leaf.isPlaceholder()) { // Construct a new placeholder sequence object for this leaf - leaf.setElement(new Sequence(leaf.getName(), - "THISISAPLACEHLDER")); + leaf.setElement( + new Sequence(leaf.getName(), "THISISAPLACEHLDER")); } leaf.setPlaceholder(true); @@ -468,39 +461,6 @@ public class TreeModel } /** - * - * @return true if original sequence data can be recovered - */ - public boolean hasOriginalSequenceData() - { - return seqData != null; - } - - /** - * Returns original alignment data used for calculation - or null where not - * available. - * - * @return null or cut'n'pasteable alignment - */ - public String printOriginalSequenceData(char gapChar) - { - if (seqData == null) - { - return null; - } - - StringBuffer sb = new StringBuffer(); - String[] seqdatas = seqData.getSequenceStrings(gapChar); - for (int i = 0; i < seqdatas.length; i++) - { - sb.append(new jalview.util.Format("%-" + 15 + "s").form(sequences[i] - .getName())); - sb.append(" " + seqdatas[i] + "\n"); - } - return sb.toString(); - } - - /** * DOCUMENT ME! * * @param nd @@ -523,8 +483,8 @@ public class TreeModel System.out.println(" name = " + ((SequenceI) nd.element()).getName()); } - System.out.println(" dist = " + nd.dist + " " + nd.count + " " - + nd.height); + System.out.println( + " dist = " + nd.dist + " " + nd.count + " " + nd.height); } /** @@ -553,7 +513,8 @@ public class TreeModel { // if (_lycount<_lylimit) // { - // System.err.println("Warning: depth of _recount greater than number of nodes."); + // System.err.println("Warning: depth of _recount greater than number of + // nodes."); // } if (nd == null) { @@ -704,10 +665,15 @@ public class TreeModel public void applyToNodes(NodeTransformI nodeTransformI) { for (Enumeration nodes = node.elements(); nodes - .hasMoreElements(); nodeTransformI.transform(nodes - .nextElement())) + .hasMoreElements(); nodeTransformI + .transform(nodes.nextElement())) { ; } } + + public AlignmentView getOriginalData() + { + return seqData; + } }