JAL-2795 Forester now NJ-clusters the DistanceMatrix from Jalview
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 2 Nov 2017 16:58:50 +0000 (16:58 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 2 Nov 2017 16:58:50 +0000 (16:58 +0000)
.settings/org.eclipse.jdt.core.prefs
src/jalview/analysis/TreeBuilder.java
src/jalview/ext/archaeopteryx/ArchaeopteryxTreeConverter.java

index 64e4e60..12c11f0 100644 (file)
@@ -1,15 +1,15 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
 org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
index 0cd340e..30b83b3 100644 (file)
@@ -53,6 +53,8 @@ public abstract class TreeBuilder
 
   protected MatrixI distances;
 
+  public MatrixI testDistances;
+
   protected int mini;
 
   protected int minj;
@@ -303,8 +305,8 @@ public abstract class TreeBuilder
     this.scoreModel = sm;
     this.scoreParams = scoreOptions;
 
+    testDistances = scoreModel.findDistances(seqData, scoreParams);
     distances = scoreModel.findDistances(seqData, scoreParams);
-
     makeLeaves();
 
     noClus = clusters.size();
index 9542397..ce603f5 100644 (file)
@@ -2,77 +2,68 @@ package jalview.ext.archaeopteryx;
 
 import jalview.analysis.TreeBuilder;
 import jalview.datamodel.SequenceI;
+import jalview.ext.forester.ForesterMatrix;
 import jalview.util.MessageManager;
 
+import org.forester.evoinference.distance.NeighborJoiningF;
 import org.forester.evoinference.matrix.distance.DistanceMatrix;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 
 public class ArchaeopteryxTreeConverter
 {
-  protected SequenceI[] sequences;
+  protected final SequenceI[] sequences;
 
   private Phylogeny aptxTree;
 
   private PhylogenyNode rootNode;
 
-  protected DistanceMatrix distances;
+  protected final DistanceMatrix distances;
   
-  protected TreeBuilder jalviewTree;
+  protected final TreeBuilder jalviewTree;
   
   public String treeTitle;
 
 
 
-  public ArchaeopteryxTreeConverter(TreeBuilder calculatedTree)
+  public ArchaeopteryxTreeConverter(final TreeBuilder calculatedTree)
   {
-    this.jalviewTree = calculatedTree;
-    this.sequences = jalviewTree.getSequences();
-    this.distances = MatrixConverter.convertJalviewToForester(
-            jalviewTree.getDistances(), jalviewTree.getSequences());
+    jalviewTree = calculatedTree;
+    sequences = jalviewTree.getSequences();
+    distances = ForesterMatrix.convertJalviewToForester(
+            jalviewTree.testDistances, sequences);
+    aptxTree = new Phylogeny();
+    rootNode = new PhylogenyNode();
 
   }
 
-  public Phylogeny buildAptxTree()
+  public Phylogeny buildAptxTree(final PhylogenyNode treeRoot)
   {
-    this.rootNode = new PhylogenyNode();
-
-    return buildAptxTree(rootNode);
 
-  }
+    rootNode = treeRoot;
 
-  public Phylogeny buildAptxTree(PhylogenyNode treeRoot)
-  {
+    buildAptxTree();
 
-    this.rootNode = treeRoot;
 
-    this.aptxTree = new Phylogeny();
+    return aptxTree;
 
-    this.treeTitle = generateTreeName();
-    this.aptxTree.setName(treeTitle);
+  }
 
-    // final NeighborJoiningF nj = NeighborJoiningF.createInstance(false, 5);
+  public Phylogeny buildAptxTree()
+  {
 
-    //
-    // final Phylogeny phy = nj.execute(JalviewMatrixToForesterMatrix
-    // .convertJalviewToForester(distances));
+    NeighborJoiningF foresterClustering = NeighborJoiningF
+            .createInstance();
+    aptxTree = foresterClustering.execute(distances);
+    treeTitle = generateTreeName();
+    aptxTree.setName(treeTitle);
 
-    return buildAptxTree(sequences);
+    return aptxTree;
 
   }
 
-  // testing method to be removed
-  public Phylogeny buildAptxTree(SequenceI[] sequences)
+  private Phylogeny clusterNodes()
   {
-
-    for (SequenceI sequence : sequences)
-    {
-      PhylogenyNode treeNode = new PhylogenyNode(sequence.getName());
-      rootNode.addAsChild(treeNode);
-
-    }
-
-    aptxTree.setRoot(rootNode);
     return aptxTree;
 
   }