X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fanalysis%2FNJTree.java;h=099400e546004c7e8abd22e0e5258617b8e98878;hb=e07fc11d5aaf4d1237d83e5f7ea0909dea09902e;hp=4a5f7628ab046200d8688fe7986b0d09b02ff1b8;hpb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;p=jalview.git
diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java
index 4a5f762..099400e 100644
--- a/src/jalview/analysis/NJTree.java
+++ b/src/jalview/analysis/NJTree.java
@@ -1,30 +1,40 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
* 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.
+ * 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 .
+ * 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 java.util.*;
-
import jalview.api.analysis.ScoreModelI;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.schemes.*;
-import jalview.util.*;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.BinaryNode;
+import jalview.datamodel.CigarArray;
+import jalview.datamodel.NodeTransformI;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.SequenceNode;
+import jalview.io.NewickFile;
+import jalview.schemes.ResidueProperties;
+
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
/**
* DOCUMENT ME!
@@ -208,7 +218,7 @@ public class NJTree
* DOCUMENT ME!
*/
public NJTree(SequenceI[] sequence, AlignmentView seqData, String type,
- String pwtype, int start, int end)
+ String pwtype, ScoreModelI sm, int start, int end)
{
this.sequence = sequence;
this.node = new Vector();
@@ -235,7 +245,7 @@ public class NJTree
type = "AV";
}
- if (!(pwtype.equals("PID")))
+ if (sm == null && !(pwtype.equals("PID")))
{
if (ResidueProperties.getScoreMatrix(pwtype) == null)
{
@@ -255,7 +265,7 @@ public class NJTree
noseqs = i++;
- distance = findDistances();
+ distance = findDistances(sm);
// System.err.println("Made distances");// dbg
makeLeaves();
// System.err.println("Made leaves");// dbg
@@ -313,7 +323,7 @@ public class NJTree
for (int j = 0; j < seqs.length; j++)
{
- seqs[j] = (SequenceI) list.get(j);
+ seqs[j] = list.get(j);
}
seqmatcher = new SequenceIdMatcher(seqs);
@@ -720,21 +730,22 @@ public class NJTree
*
* @return similarity matrix used to compute tree
*/
- public float[][] findDistances()
+ public float[][] findDistances(ScoreModelI _pwmatrix)
{
-
- float[][] distance = new float[noseqs][noseqs];
- // Pairwise substitution score (with no gap penalties)
- ScoreModelI _pwmatrix = ResidueProperties.getScoreModel(pwtype);
+ float[][] distance = new float[noseqs][noseqs];
+ if (_pwmatrix == null)
+ {
+ // Resolve substitution model
+ _pwmatrix = ResidueProperties.getScoreModel(pwtype);
if (_pwmatrix == null)
{
_pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
}
- distance = _pwmatrix.findDistances(seqData);
+ }
+ distance = _pwmatrix.findDistances(seqData);
return distance;
-
}
/**
@@ -856,12 +867,12 @@ public class NJTree
{
System.out
.println("Leaf = " + ((SequenceI) node.element()).getName());
- System.out.println("Dist " + ((SequenceNode) node).dist);
+ System.out.println("Dist " + node.dist);
System.out.println("Boot " + node.getBootstrap());
}
else
{
- System.out.println("Dist " + ((SequenceNode) node).dist);
+ System.out.println("Dist " + node.dist);
printNode((SequenceNode) node.left());
printNode((SequenceNode) node.right());
}
@@ -882,11 +893,11 @@ public class NJTree
if ((node.left() == null) && (node.right() == null))
{
- float dist = ((SequenceNode) node).dist;
+ float dist = node.dist;
if (dist > maxDistValue)
{
- maxdist = (SequenceNode) node;
+ maxdist = node;
maxDistValue = dist;
}
}
@@ -1088,9 +1099,9 @@ public class NJTree
+ ((SequenceI) node.element()).getName());
}
- System.out.println(" dist = " + ((SequenceNode) node).dist + " "
- + ((SequenceNode) node).count + " "
- + ((SequenceNode) node).height);
+ System.out.println(" dist = " + node.dist + " "
+ + node.count + " "
+ + node.height);
}
/**
@@ -1136,13 +1147,13 @@ public class NJTree
SequenceNode l = (SequenceNode) node.left();
SequenceNode r = (SequenceNode) node.right();
- ((SequenceNode) node).count = l.count + r.count;
- ((SequenceNode) node).ycount = (l.ycount + r.ycount) / 2;
+ node.count = l.count + r.count;
+ node.ycount = (l.ycount + r.ycount) / 2;
}
else
{
- ((SequenceNode) node).count = 1;
- ((SequenceNode) node).ycount = ycount++;
+ node.count = 1;
+ node.ycount = ycount++;
}
_lycount--;
}
@@ -1281,7 +1292,9 @@ public class NJTree
{
for (Enumeration nodes = node.elements(); nodes.hasMoreElements(); nodeTransformI
.transform((BinaryNode) nodes.nextElement()))
+ {
;
+ }
}
}