proof of concept for passing tree data to archaeopteryx
authorkjvanderheide <kjvanderheide@ls29711.dyn.lifesci.dundee.ac.uk>
Wed, 27 Sep 2017 11:01:50 +0000 (12:01 +0100)
committerkjvanderheide <kjvanderheide@ls29711.dyn.lifesci.dundee.ac.uk>
Wed, 27 Sep 2017 11:03:37 +0000 (12:03 +0100)
.classpath
.project
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.ui.prefs
src/jalview/analysis/TreeModel.java
src/jalview/appletgui/TreePanel.java
src/jalview/gui/TreePanel.java
src/jalview/io/NewickFile.java
test/jalview/io/NewickFileTests.java

index c4a2832..42e9500 100644 (file)
@@ -69,5 +69,6 @@
        <classpathentry kind="lib" path="lib/biojava-core-4.1.0.jar"/>
        <classpathentry kind="lib" path="lib/biojava-ontology-4.1.0.jar"/>
        <classpathentry kind="lib" path="lib/groovy-all-2.4.6-indy.jar"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/forester"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
index d0dfc7e..b24880a 100644 (file)
--- a/.project
+++ b/.project
@@ -3,6 +3,7 @@
        <name>Jalview Release 2.7</name>
        <comment></comment>
        <projects>
+               <project>forester</project>
        </projects>
        <buildSpec>
                <buildCommand>
index 8a5e7a7..64e4e60 100644 (file)
@@ -10,6 +10,7 @@ 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.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
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52
@@ -23,8 +24,10 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
@@ -34,6 +37,8 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration
 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
 org.eclipse.jdt.core.formatter.blank_lines_after_package=1
@@ -60,6 +65,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
 org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
 org.eclipse.jdt.core.formatter.comment.format_block_comments=false
 org.eclipse.jdt.core.formatter.comment.format_header=false
 org.eclipse.jdt.core.formatter.comment.format_html=true
@@ -92,6 +98,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
 org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
@@ -286,11 +293,24 @@ org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
 org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
 org.eclipse.jdt.core.formatter.tabulation.char=space
 org.eclipse.jdt.core.formatter.tabulation.size=2
 org.eclipse.jdt.core.formatter.use_on_off_tags=true
 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
 org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
 org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
 org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
index 30e76be..699fd4a 100644 (file)
@@ -1,7 +1,7 @@
 eclipse.preferences.version=1
 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
 formatter_profile=_Jalview
-formatter_settings_version=12
+formatter_settings_version=13
 org.eclipse.jdt.ui.ignorelowercasenames=true
 org.eclipse.jdt.ui.importorder=jalview;java;javax;org;com;
 org.eclipse.jdt.ui.ondemandthreshold=99
index a50634e..6ad181d 100644 (file)
@@ -80,8 +80,8 @@ public class TreeModel
   public TreeModel(SequenceI[] seqs, AlignmentView odata,
           NewickFile treefile)
   {
-    this(seqs, treefile.getTree(), treefile.HasDistances(),
-            treefile.HasBootstrap(), treefile.HasRootDistance());
+    this(seqs, treefile.getTree(), treefile.hasDistances(),
+            treefile.hasBootstrap(), treefile.hasRootDistance());
     seqData = odata;
 
     associateLeavesToSequences(seqs);
index b5e3342..f6bc265 100644 (file)
@@ -207,12 +207,12 @@ public class TreePanel extends EmbmenuFrame
       {
         // Set default view, paying lip service to any overriding tree view
         // parameter settings
-        boolean showDist = newtree.HasDistances()
+        boolean showDist = newtree.hasDistances()
                 && av.applet.getDefaultParameter("showTreeDistances",
-                        newtree.HasDistances());
-        boolean showBoots = newtree.HasBootstrap()
+                        newtree.hasDistances());
+        boolean showBoots = newtree.hasBootstrap()
                 && av.applet.getDefaultParameter("showTreeBootstraps",
-                        newtree.HasBootstrap());
+                        newtree.hasBootstrap());
         distanceMenu.setState(showDist);
         bootstrapMenu.setState(showBoots);
         treeCanvas.setShowBootstrap(showBoots);
index 5e14fce..3af174a 100755 (executable)
@@ -41,6 +41,7 @@ import jalview.datamodel.NodeTransformI;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequenceNode;
+import jalview.ext.archaeopteryx.Testo;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.io.NewickFile;
@@ -55,7 +56,9 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.image.BufferedImage;
 import java.beans.PropertyChangeEvent;
+import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -170,6 +173,7 @@ public class TreePanel extends GTreePanel
       }
     });
 
+
     TreeLoader tl = new TreeLoader(newTree, inputData);
     tl.start();
 
@@ -256,9 +260,11 @@ public class TreePanel extends GTreePanel
       {
         // Must be outside run(), as Jalview2XML tries to
         // update distance/bootstrap visibility at the same time
-        showBootstrap(newickFile.HasBootstrap());
-        showDistances(newickFile.HasDistances());
+        showBootstrap(newickFile.hasBootstrap());
+        showDistances(newickFile.hasDistances());
+
       }
+
     }
 
     @Override
@@ -289,6 +295,19 @@ public class TreePanel extends GTreePanel
       tree.findHeight(tree.getTopNode());
       treeCanvas.setTree(tree);
       treeCanvas.repaint();
+
+      Testo test = new Testo();
+      NewickFile newickTree = test.treeToNewick(tree);
+      File newickAsFile = test.newickToArchaeopteryx(newickTree);
+      try
+      {
+        String[] archaeCommandlineArgs = {
+            "-open", newickAsFile.getCanonicalPath() };
+        test.startArchaeopteryx(archaeCommandlineArgs);
+      } catch (IOException e)
+      {
+        e.printStackTrace();
+      }
       av.setCurrentTree(tree);
       if (av.getSortByTree())
       {
@@ -493,7 +512,7 @@ public class TreePanel extends GTreePanel
 
     if (treeCanvas.applyToAllViews)
     {
-      final ArrayList<CommandI> commands = new ArrayList<CommandI>();
+      final ArrayList<CommandI> commands = new ArrayList<>();
       for (AlignmentPanel ap : PaintRefresher
               .getAssociatedPanels(av.getSequenceSetId()))
       {
index c414145..7444b5f 100755 (executable)
@@ -76,14 +76,14 @@ public class NewickFile extends FileParse
 {
   SequenceNode root;
 
-  private boolean HasBootstrap = false;
+  private boolean hasBootstrap = false;
 
-  private boolean HasDistances = false;
+  private boolean hasDistances = false;
 
-  private boolean RootHasDistance = false;
+  private boolean rootHasDistance = false;
 
   // File IO Flags
-  boolean ReplaceUnderscores = false;
+  boolean replaceUnderscores = false;
 
   boolean printRootInfo = true;
 
@@ -156,7 +156,7 @@ public class NewickFile extends FileParse
    */
   public NewickFile(SequenceNode newtree, boolean bootstrap)
   {
-    HasBootstrap = bootstrap;
+    hasBootstrap = bootstrap;
     root = newtree;
   }
 
@@ -174,8 +174,8 @@ public class NewickFile extends FileParse
           boolean distances)
   {
     root = newtree;
-    HasBootstrap = bootstrap;
-    HasDistances = distances;
+    hasBootstrap = bootstrap;
+    hasDistances = distances;
   }
 
   /**
@@ -194,9 +194,9 @@ public class NewickFile extends FileParse
           boolean distances, boolean rootdistance)
   {
     root = newtree;
-    HasBootstrap = bootstrap;
-    HasDistances = distances;
-    RootHasDistance = rootdistance;
+    hasBootstrap = bootstrap;
+    hasDistances = distances;
+    rootHasDistance = rootdistance;
   }
 
   /**
@@ -226,9 +226,9 @@ public class NewickFile extends FileParse
 
   // @tree annotations
   // These are set automatically by the reader
-  public boolean HasBootstrap()
+  public boolean hasBootstrap()
   {
-    return HasBootstrap;
+    return hasBootstrap;
   }
 
   /**
@@ -236,14 +236,14 @@ public class NewickFile extends FileParse
    * 
    * @return DOCUMENT ME!
    */
-  public boolean HasDistances()
+  public boolean hasDistances()
   {
-    return HasDistances;
+    return hasDistances;
   }
 
-  public boolean HasRootDistance()
+  public boolean hasRootDistance()
   {
-    return RootHasDistance;
+    return rootHasDistance;
   }
 
   /**
@@ -446,7 +446,7 @@ public class NewickFile extends FileParse
         {
           if (nodename == null)
           {
-            if (ReplaceUnderscores)
+            if (replaceUnderscores)
             {
               nodename = uqnodename.stringMatched(1).replace('_', ' ');
             }
@@ -479,7 +479,7 @@ public class NewickFile extends FileParse
             {
               bootstrap = (new Integer(nbootstrap.stringMatched(1)))
                       .intValue();
-              HasBootstrap = true;
+              hasBootstrap = true;
             } catch (Exception e)
             {
               Error = ErrorStringrange(Error, "Can't parse bootstrap value",
@@ -495,7 +495,7 @@ public class NewickFile extends FileParse
           try
           {
             distance = (new Float(ndist.stringMatched(1))).floatValue();
-            HasDistances = true;
+            hasDistances = true;
             nodehasdistance = true;
           } catch (Exception e)
           {
@@ -510,12 +510,12 @@ public class NewickFile extends FileParse
           // Write node info here
           c.setName(nodename);
           // Trees without distances still need a render distance
-          c.dist = (HasDistances) ? distance : DefDistance;
+          c.dist = (hasDistances) ? distance : DefDistance;
           // be consistent for internal bootstrap defaults too
-          c.setBootstrap((HasBootstrap) ? bootstrap : DefBootstrap);
+          c.setBootstrap((hasBootstrap) ? bootstrap : DefBootstrap);
           if (c == realroot)
           {
-            RootHasDistance = nodehasdistance; // JBPNote This is really
+            rootHasDistance = nodehasdistance; // JBPNote This is really
             // UGLY!!! Ensure root node gets
             // its given distance
           }
@@ -526,8 +526,8 @@ public class NewickFile extends FileParse
         {
           // Find a place to put the leaf
           SequenceNode newnode = new SequenceNode(null, c, nodename,
-                  (HasDistances) ? distance : DefDistance,
-                  (HasBootstrap) ? bootstrap : DefBootstrap, false);
+                  (hasDistances) ? distance : DefDistance,
+                  (hasBootstrap) ? bootstrap : DefBootstrap, false);
           parseNHXNodeProps(c, commentString2);
           commentString2 = null;
 
@@ -546,7 +546,7 @@ public class NewickFile extends FileParse
               // Insert a dummy node for polytomy
               // dummy nodes have distances
               SequenceNode newdummy = new SequenceNode(null, c, null,
-                      (HasDistances ? 0 : DefDistance), 0, true);
+                      (hasDistances ? 0 : DefDistance), 0, true);
               newdummy.SetChildren(c.left(), newnode);
               c.setLeft(newdummy);
             }
@@ -624,9 +624,9 @@ public class NewickFile extends FileParse
     // (root.right()!=null && root.isDummy())
     root = (SequenceNode) root.right().detach(); // remove the imaginary root.
 
-    if (!RootHasDistance)
+    if (!rootHasDistance)
     {
-      root.dist = (HasDistances) ? 0 : DefDistance;
+      root.dist = (hasDistances) ? 0 : DefDistance;
     }
   }
 
@@ -665,7 +665,7 @@ public class NewickFile extends FileParse
               v = iv.intValue(); // jalview only does integer bootstraps
               // currently
               c.setBootstrap(v);
-              HasBootstrap = true;
+              hasBootstrap = true;
             }
             // more codes here.
           } catch (Exception e)
@@ -722,11 +722,11 @@ public class NewickFile extends FileParse
   {
     synchronized (this)
     {
-      boolean boots = this.HasBootstrap;
-      this.HasBootstrap = withbootstraps;
+      boolean boots = this.hasBootstrap;
+      this.hasBootstrap = withbootstraps;
 
       String rv = print();
-      this.HasBootstrap = boots;
+      this.hasBootstrap = boots;
 
       return rv;
     }
@@ -748,11 +748,11 @@ public class NewickFile extends FileParse
   {
     synchronized (this)
     {
-      boolean dists = this.HasDistances;
-      this.HasDistances = withdists;
+      boolean dists = this.hasDistances;
+      this.hasDistances = withdists;
 
       String rv = print(withbootstraps);
-      this.HasDistances = dists;
+      this.hasDistances = dists;
 
       return rv;
     }
@@ -842,10 +842,10 @@ public class NewickFile extends FileParse
   private String printNodeField(SequenceNode c)
   {
     return ((c.getName() == null) ? "" : nodeName(c.getName()))
-            + ((HasBootstrap) ? ((c.getBootstrap() > -1)
+            + ((hasBootstrap) ? ((c.getBootstrap() > -1)
                     ? ((c.getName() != null ? " " : "") + c.getBootstrap())
                     : "") : "")
-            + ((HasDistances) ? (":" + c.dist) : "");
+            + ((hasDistances) ? (":" + c.dist) : "");
   }
 
   /**
@@ -860,13 +860,13 @@ public class NewickFile extends FileParse
   {
     return (printRootInfo)
             ? (((root.getName() == null) ? "" : nodeName(root.getName()))
-                    + ((HasBootstrap)
+                    + ((hasBootstrap)
                             ? ((root.getBootstrap() > -1)
                                     ? ((root.getName() != null ? " " : "")
                                             + +root.getBootstrap())
                                     : "")
                             : "")
-                    + ((RootHasDistance) ? (":" + root.dist) : ""))
+                    + ((rootHasDistance) ? (":" + root.dist) : ""))
             : "";
   }
 
index a92f5fb..1cbe5ac 100644 (file)
@@ -109,8 +109,8 @@ public class NewickFileTests
       SequenceNode tree = nf.getTree();
       AssertJUnit.assertTrue(stage + "Null Tree", tree != null);
       stage = "Creating newick file from testTree " + treename;
-      String gentree = new NewickFile(tree).print(nf.HasBootstrap(),
-              nf.HasDistances());
+      String gentree = new NewickFile(tree).print(nf.hasBootstrap(),
+              nf.hasDistances());
       AssertJUnit.assertTrue(stage + "Empty string generated",
               gentree != null && gentree.trim().length() > 0);
       stage = "Parsing regenerated testTree " + treename;