git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into patch/JAL-4110_stdout_for_tests
[jalview.git]
/
src
/
jalview
/
datamodel
/
GroupSet.java
diff --git
a/src/jalview/datamodel/GroupSet.java
b/src/jalview/datamodel/GroupSet.java
index
c7a73b7
..
db38e7b
100644
(file)
--- a/
src/jalview/datamodel/GroupSet.java
+++ b/
src/jalview/datamodel/GroupSet.java
@@
-145,30
+145,59
@@
public class GroupSet implements GroupSetI
return treeType;
}
return treeType;
}
- public static GroupSet makeGroups(ContactMatrixI matrix, float thresh,
+ public static GroupSet makeGroups(ContactMatrixI matrix, boolean autoCut)
+ {
+ return makeGroups(matrix, autoCut, 0, autoCut);
+ }
+ public static GroupSet makeGroups(ContactMatrixI matrix, boolean auto, float thresh,
boolean abs)
{
AverageDistanceEngine clusterer = new AverageDistanceEngine(null, null,
boolean abs)
{
AverageDistanceEngine clusterer = new AverageDistanceEngine(null, null,
- matrix);
+ matrix, true);
double height = clusterer.findHeight(clusterer.getTopNode());
double height = clusterer.findHeight(clusterer.getTopNode());
+ Console.debug("Column tree height: " + height);
String newick = new jalview.io.NewickFile(clusterer.getTopNode(), false,
true).print();
String treeType = "UPGMA";
Console.trace("Newick string\n" + newick);
List<BinaryNode> nodegroups;
String newick = new jalview.io.NewickFile(clusterer.getTopNode(), false,
true).print();
String treeType = "UPGMA";
Console.trace("Newick string\n" + newick);
List<BinaryNode> nodegroups;
- if (abs ? height > thresh : 0 < thresh && thresh < 1)
+ float cut = -1f;
+ if (auto)
{
{
- float cut = abs ? (float) (thresh / height) : thresh;
- Console.debug("Threshold " + cut + " for height=" + height);
-
- nodegroups = clusterer.groupNodes(cut);
+ double rootw = 0;
+ int p = 2;
+ BinaryNode bn = clusterer.getTopNode();
+ while (p-- > 0 & bn.left() != null)
+ {
+ if (bn.left() != null)
+ {
+ bn = bn.left();
+ }
+ if (bn.left() != null)
+ {
+ rootw = bn.height;
+ }
+ }
+ thresh = Math.max((float) (rootw / height) - 0.01f, 0);
+ cut = thresh;
+ nodegroups = clusterer.groupNodes(thresh);
}
else
{
}
else
{
- nodegroups = new ArrayList<BinaryNode>();
- nodegroups.add(clusterer.getTopNode());
+ if (abs ? (height > thresh) : (0 < thresh && thresh < 1))
+ {
+ cut = abs ? thresh : (float) (thresh * height);
+ Console.debug("Threshold " + cut + " for height=" + height);
+ nodegroups = clusterer.groupNodes(cut);
+ }
+ else
+ {
+ nodegroups = new ArrayList<BinaryNode>();
+ nodegroups.add(clusterer.getTopNode());
+ }
}
}
+
List<BitSet> groups = new ArrayList<>();
for (BinaryNode root : nodegroups)
{
List<BitSet> groups = new ArrayList<>();
for (BinaryNode root : nodegroups)
{
@@
-179,7
+208,8
@@
public class GroupSet implements GroupSetI
}
groups.add(gpset);
}
}
groups.add(gpset);
}
- GroupSet grps = new GroupSet(abs, thresh, groups, treeType, newick);
+ GroupSet grps = new GroupSet(abs, (cut == -1f) ? thresh : cut, groups,
+ treeType, newick);
return grps;
}
return grps;
}