phylotastic hackathon at NESCENT 120608
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 8 Jun 2012 15:36:28 +0000 (15:36 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 8 Jun 2012 15:36:28 +0000 (15:36 +0000)
forester/java/src/org/forester/application/gsdi.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/sdi/GSDI.java

index 708b734..e97b504 100644 (file)
@@ -31,7 +31,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
-import org.forester.archaeopteryx.Archaeopteryx;
+
 import org.forester.io.parsers.PhylogenyParser;
 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
 import org.forester.io.parsers.util.ParserUtils;
@@ -56,8 +56,8 @@ public final class gsdi {
     final static private String HELP_OPTION_2                = "h";
     final static private String DEFAULT_OUTFILE              = "gsdi_out.phylo.xml";
     final static private String PRG_NAME                     = "gsdi";
-    final static private String PRG_VERSION                  = "0.4";
-    final static private String PRG_DATE                     = "120607";
+    final static private String PRG_VERSION                  = "0.5";
+    final static private String PRG_DATE                     = "120608";
     final static private String PRG_DESC                     = "general speciation duplication inference";
     final static private String E_MAIL                       = "phylosoft@gmail.com";
     final static private String WWW                          = "www.phylosoft.org/forester";
@@ -208,7 +208,7 @@ public final class gsdi {
                 System.out.println( "Using GSDI algorithm" );
                 System.out.println();
                 System.out.println( "Use most parsimonous duplication model: " + most_parsimonous_duplication_model );
-                sdi = new GSDI( gene_tree, species_tree, most_parsimonous_duplication_model );
+                sdi = new GSDI( gene_tree, species_tree, most_parsimonous_duplication_model, true );
             }
         }
         catch ( final Exception e ) {
@@ -256,7 +256,7 @@ public final class gsdi {
         System.out.println( "     phyloXML (Newick, NHX, Nexus)" );
         System.out.println();
         System.out.println( "Species tree:" );
-        System.out.println( " In phyloXML format (unless option " + gsdi.GUESS_FORMAT_OF_SPECIES_TREE
+        System.out.println( " In phyloXML format (unless option -" + gsdi.GUESS_FORMAT_OF_SPECIES_TREE
                 + " is used), with taxonomy data in appropriate fields" );
         System.out.println();
         System.out.println( "Gene tree:" );
index 9a7619b..16189da 100644 (file)
@@ -1212,7 +1212,7 @@ public final class MainFrameApplication extends MainFrame {
         GSDI gsdi = null;
         int duplications = -1;
         try {
-            gsdi = new GSDI( gene_tree, _species_tree.copy(), true );
+            gsdi = new GSDI( gene_tree, _species_tree.copy(), true, true );
             duplications = gsdi.getDuplicationsSum();
         }
         catch ( final Exception e ) {
index 5bd03f3..fa7484f 100644 (file)
@@ -4546,7 +4546,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
         }
         if ( getMainPanel().getOptions().isAntialiasScreen() ) {
-            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) {
+            if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR 
+            && !getMainPanel().getOptions().isShowDefaultNodeShapes()       
+            && ( getControlPanel() != null && !getControlPanel().isShowDomainArchitectures() )
+            
+            ) {
                 _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
             }
             else {
index 58f79fa..46453e2 100644 (file)
@@ -26,6 +26,8 @@
 package org.forester.sdi;
 
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
@@ -60,6 +62,7 @@ public final class GSDI extends SDI {
 
     private final HashMap<PhylogenyNode, Integer> _transversal_counts;
     private final boolean                         _most_parsimonious_duplication_model;
+    private final boolean                         _strip_gene_tree;
     private int                                   _speciation_or_duplication_events_sum;
     private int                                   _speciations_sum;
 
@@ -91,18 +94,26 @@ public final class GSDI extends SDI {
      */
     public GSDI( final Phylogeny gene_tree,
                  final Phylogeny species_tree,
-                 final boolean most_parsimonious_duplication_model ) {
+                 final boolean most_parsimonious_duplication_model,
+                 final boolean strip_gene_tree ) {
         super( gene_tree, species_tree );
         _speciation_or_duplication_events_sum = 0;
         _speciations_sum = 0;
         _most_parsimonious_duplication_model = most_parsimonious_duplication_model;
         _transversal_counts = new HashMap<PhylogenyNode, Integer>();
         _duplications_sum = 0;
+        _strip_gene_tree = strip_gene_tree;
         getSpeciesTree().preOrderReId();
         linkNodesOfG();
         geneTreePostOrderTraversal( getGeneTree().getRoot() );
     }
 
+    public GSDI( final Phylogeny gene_tree,
+                 final Phylogeny species_tree,
+                 final boolean most_parsimonious_duplication_model ) {
+        this( gene_tree, species_tree, most_parsimonious_duplication_model, false );
+    }
+
     private final Event createDuplicationEvent() {
         final Event event = Event.createSingleDuplicationEvent();
         ++_duplications_sum;
@@ -250,7 +261,7 @@ public final class GSDI extends SDI {
      * 
      */
     @Override
-    final  void linkNodesOfG() {
+    final void linkNodesOfG() {
         final HashMap<Taxonomy, PhylogenyNode> speciestree_ext_nodes = new HashMap<Taxonomy, PhylogenyNode>();
         for( final PhylogenyNodeIterator iter = _species_tree.iteratorLevelOrder(); iter.hasNext(); ) {
             final PhylogenyNode n = iter.next();
@@ -262,8 +273,26 @@ public final class GSDI extends SDI {
                 speciestree_ext_nodes.put( n.getNodeData().getTaxonomy(), n );
             }
         }
-        // Retrieve the reference to the PhylogenyNode with a matching species
-        // name.
+        if ( _strip_gene_tree ) {
+            final Set<PhylogenyNode> to_delete = new HashSet<PhylogenyNode>();
+            for( final PhylogenyNodeIterator iter = _gene_tree.iteratorExternalForward(); iter.hasNext(); ) {
+                final PhylogenyNode g = iter.next();
+                if ( !g.getNodeData().isHasTaxonomy() ) {
+                    throw new IllegalArgumentException( "gene tree node " + g + " has no taxonomic data" );
+                }
+                final PhylogenyNode s = speciestree_ext_nodes.get( g.getNodeData().getTaxonomy() );
+                if ( s == null ) {
+                    // throw new IllegalArgumentException( "species " + g.getNodeData().getTaxonomy()
+                    //         + " not present in species tree" );
+                    to_delete.add( g );
+                }
+            }
+            for( final PhylogenyNode n : to_delete ) {
+                _gene_tree.deleteSubtree( n, true );
+                System.out.println( "deleted" + n );
+            }
+        }
+        // Retrieve the reference to the PhylogenyNode with a matching species.
         for( final PhylogenyNodeIterator iter = _gene_tree.iteratorExternalForward(); iter.hasNext(); ) {
             final PhylogenyNode g = iter.next();
             if ( !g.getNodeData().isHasTaxonomy() ) {
@@ -274,8 +303,6 @@ public final class GSDI extends SDI {
                 throw new IllegalArgumentException( "species " + g.getNodeData().getTaxonomy()
                         + " not present in species tree" );
             }
-          
-          
             g.setLink( s );
         }
     }