X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FNJTree.java;h=944354fda0f67cbe87a8ff1662876e3a39acbc3b;hb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;hp=c053cb38743681188e4080b0edfa299d4eb38d28;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java old mode 100755 new mode 100644 index c053cb3..944354f --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -1,19 +1,20 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.analysis; @@ -237,7 +238,7 @@ public class NJTree { if (ResidueProperties.getScoreMatrix(pwtype) == null) { - type = "BLOSUM62"; + pwtype = "BLOSUM62"; } } @@ -267,25 +268,26 @@ public class NJTree } /** - * DOCUMENT ME! + * Generate a string representation of the Tree * - * @return DOCUMENT ME! + * @return Newick File with all tree data available */ public String toString() { jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); - return fout.print(false, true); // distances only + return fout.print(isHasBootstrap(), isHasDistances(), + isHasRootDistance()); // output all data available for tree } /** * * used when the alignment associated to a tree has changed. * - * @param alignment - * Vector + * @param list + * Sequence set to be associated with tree nodes */ - public void UpdatePlaceHolders(Vector alignment) + public void UpdatePlaceHolders(List list) { Vector leaves = new Vector(); findLeaves(top, leaves); @@ -298,7 +300,7 @@ public class NJTree { SequenceNode leaf = (SequenceNode) leaves.elementAt(i++); - if (alignment.contains(leaf.element())) + if (list.contains(leaf.element())) { leaf.setPlaceholder(false); } @@ -307,11 +309,11 @@ public class NJTree if (seqmatcher == null) { // Only create this the first time we need it - SequenceI[] seqs = new SequenceI[alignment.size()]; + SequenceI[] seqs = new SequenceI[list.size()]; for (int j = 0; j < seqs.length; j++) { - seqs[j] = (SequenceI) alignment.elementAt(j); + seqs[j] = (SequenceI) list.get(j); } seqmatcher = new SequenceIdMatcher(seqs); @@ -347,6 +349,28 @@ public class NJTree } /** + * rename any nodes according to their associated sequence. This will modify + * the tree's metadata! (ie the original NewickFile or newly generated + * BinaryTree's label data) + */ + public void renameAssociatedNodes() + { + applyToNodes(new NodeTransformI() + { + + @Override + public void transform(BinaryNode node) + { + Object el = node.element(); + if (el != null && el instanceof SequenceI) + { + node.setName(((SequenceI) el).getName()); + } + } + }); + } + + /** * DOCUMENT ME! */ public void cluster() @@ -740,8 +764,9 @@ public class NJTree { try { - score += pwmatrix.getPairwiseScore(sequenceString[i] - .charAt(k), sequenceString[j].charAt(k)); + score += pwmatrix.getPairwiseScore( + sequenceString[i].charAt(k), + sequenceString[j].charAt(k)); } catch (Exception ex) { System.err.println("err creating BLOSUM62 tree");