X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fanalysis%2FTreeBuilder.java;h=c4a94eb87763acc47f216fc860f8f82a1fcd99cf;hb=98b3b695032b6af0c35443044b6d3d00390b3c22;hp=b290428de2fb630c8322f9fc75925cf5f5d7a03a;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git diff --git a/src/jalview/analysis/TreeBuilder.java b/src/jalview/analysis/TreeBuilder.java index b290428..c4a94eb 100644 --- a/src/jalview/analysis/TreeBuilder.java +++ b/src/jalview/analysis/TreeBuilder.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ 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; import jalview.api.analysis.ScoreModelI; @@ -47,13 +67,19 @@ public abstract class TreeBuilder double maxDistValue; - double maxheight; + double maxHeight; int ycount; Vector node; - private AlignmentView seqStrings; + protected ScoreModelI scoreModel; + + protected SimilarityParamsI scoreParams; + + private AlignmentViewport avport; + + private AlignmentView seqStrings; // redundant? (see seqData) /** * Constructor @@ -66,6 +92,7 @@ public abstract class TreeBuilder SimilarityParamsI scoreParameters) { int start, end; + avport = av; boolean selview = av.getSelectionGroup() != null && av.getSelectionGroup().getSize() > 1; seqStrings = av.getAlignmentView(selview); @@ -105,20 +132,20 @@ public abstract class TreeBuilder { if (nd == null) { - return maxheight; + return maxHeight; } if ((nd.left() == null) && (nd.right() == null)) { nd.height = ((SequenceNode) nd.parent()).height + nd.dist; - if (nd.height > maxheight) + if (nd.height > maxHeight) { return nd.height; } else { - return maxheight; + return maxHeight; } } else @@ -129,15 +156,15 @@ public abstract class TreeBuilder } else { - maxheight = 0; + maxHeight = 0; nd.height = (float) 0.0; } - maxheight = findHeight((SequenceNode) (nd.left())); - maxheight = findHeight((SequenceNode) (nd.right())); + maxHeight = findHeight((SequenceNode) (nd.left())); + maxHeight = findHeight((SequenceNode) (nd.right())); } - return maxheight; + return maxHeight; } /** @@ -275,7 +302,11 @@ public abstract class TreeBuilder */ protected void computeTree(ScoreModelI sm, SimilarityParamsI scoreOptions) { - distances = sm.findDistances(seqData, scoreOptions); + + this.scoreModel = sm; + this.scoreParams = scoreOptions; + + distances = scoreModel.findDistances(seqData, scoreParams); makeLeaves(); @@ -344,7 +375,7 @@ public abstract class TreeBuilder protected void init(AlignmentView seqView, int start, int end) { - this.node = new Vector(); + this.node = new Vector<>(); if (seqView != null) { this.seqData = seqView; @@ -438,7 +469,7 @@ public abstract class TreeBuilder */ void makeLeaves() { - clusters = new Vector(); + clusters = new Vector<>(); for (int i = 0; i < noseqs; i++) { @@ -447,6 +478,7 @@ public abstract class TreeBuilder sn.setElement(sequences[i]); sn.setName(sequences[i].getName()); node.addElement(sn); + BitSet bs = new BitSet(); bs.set(i); clusters.addElement(bs); @@ -458,4 +490,24 @@ public abstract class TreeBuilder return seqStrings; } + public MatrixI getDistances() + { + return distances; + } + + public ScoreModelI getScoreModel() + { + return scoreModel; + } + + public SimilarityParamsI getScoreParams() + { + return scoreParams; + } + + public AlignmentViewport getAvport() + { + return avport; + } + }