From: cmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd> Date: Tue, 10 Apr 2012 02:21:35 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f6de7e66f71bf840d3d68ed70dda9946ad2e0faa;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/archaeopteryx/Constants.java b/forester/java/src/org/forester/archaeopteryx/Constants.java index 8832d0b..f53c94e 100644 --- a/forester/java/src/org/forester/archaeopteryx/Constants.java +++ b/forester/java/src/org/forester/archaeopteryx/Constants.java @@ -43,7 +43,7 @@ public final class Constants { public final static boolean ALLOW_DDBJ_BLAST = false; public final static String PRG_NAME = "Archaeopteryx"; final static String VERSION = "0.971 9M"; - final static String PRG_DATE = "2012.03.29"; + final static String PRG_DATE = "2012.04.09"; final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file"; final static String[] DEFAULT_FONT_CHOICES = { "Verdana", "Tahoma", "Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" }; diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index adb02a6..b58411b 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -1715,7 +1715,8 @@ final class ControlPanel extends JPanel implements ActionListener { if ( _mainpanel.getCurrentScrollPane() == null ) { return; } - displayedPhylogenyMightHaveChanged( false ); + getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + displayedPhylogenyMightHaveChanged( true ); _mainpanel.getCurrentTreePanel().updateOvSettings(); _mainpanel.getCurrentTreePanel().validate(); _mainpanel.validate(); @@ -1815,7 +1816,7 @@ final class ControlPanel extends JPanel implements ActionListener { node.setCollapse( false ); } tp.resetNodeIdToDistToLeafMap(); - tp.updateSetOfCollapsedExternalNodes( t ); + tp.updateSetOfCollapsedExternalNodes(); t.recalculateNumberOfExternalDescendants( false ); tp.setNodeInPreorderToNull(); t.hashIDs(); diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index b1688a3..287a690 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1113,7 +1113,7 @@ public final class MainFrameApplication extends MainFrame { phy.hashIDs(); phy.recalculateNumberOfExternalDescendants( true ); getCurrentTreePanel().resetNodeIdToDistToLeafMap(); - getCurrentTreePanel().updateSetOfCollapsedExternalNodes( phy ); + getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); getCurrentTreePanel().calculateLongestExtNodeInfo(); getCurrentTreePanel().setNodeInPreorderToNull(); getCurrentTreePanel().recalculateMaxDistanceToRoot(); diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 18d4089..c64a820 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -707,7 +707,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( !node.isExternal() && !node.isRoot() ) { final boolean collapse = !node.isCollapse(); AptxUtil.collapseSubtree( node, collapse ); - updateSetOfCollapsedExternalNodes( _phylogeny ); + updateSetOfCollapsedExternalNodes(); _phylogeny.recalculateNumberOfExternalDescendants( true ); resetNodeIdToDistToLeafMap(); calculateLongestExtNodeInfo(); @@ -726,7 +726,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } setWaitCursor(); AptxUtil.collapseSpeciesSpecificSubtrees( _phylogeny ); - updateSetOfCollapsedExternalNodes( _phylogeny ); + updateSetOfCollapsedExternalNodes(); _phylogeny.recalculateNumberOfExternalDescendants( true ); resetNodeIdToDistToLeafMap(); calculateLongestExtNodeInfo(); @@ -2532,17 +2532,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee paintNodeBox( _root.getXcoord(), _root.getYcoord(), _root, g, to_pdf, to_graphics_file, isInFoundNodes( _root ) ); } - void updateSetOfCollapsedExternalNodes( final Phylogeny phy ) { + void updateSetOfCollapsedExternalNodes() { + final Phylogeny phy = getPhylogeny(); _collapsed_external_nodeid_set.clear(); - E: for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) { - final PhylogenyNode ext_node = it.next(); - PhylogenyNode n = ext_node; - while ( !n.isRoot() ) { - if ( n.isCollapse() ) { - _collapsed_external_nodeid_set.add( ext_node.getId() ); - continue E; - } - n = n.getParent(); + if ( phy != null ) { + E: for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) { + final PhylogenyNode ext_node = it.next(); + PhylogenyNode n = ext_node; + while ( !n.isRoot() ) { + if ( n.isCollapse() ) { + _collapsed_external_nodeid_set.add( ext_node.getId() ); + ext_node.setCollapse( true ); + continue E; + } + n = n.getParent(); + } } } } diff --git a/forester/java/src/org/forester/io/parsers/nhx/NHXtags.java b/forester/java/src/org/forester/io/parsers/nhx/NHXtags.java index c6a16f9..3a524bb 100644 --- a/forester/java/src/org/forester/io/parsers/nhx/NHXtags.java +++ b/forester/java/src/org/forester/io/parsers/nhx/NHXtags.java @@ -27,29 +27,21 @@ package org.forester.io.parsers.nhx; public final class NHXtags { - public static final String CUSTOM_DATA_ON_NODE = "XN="; - public static final String COLOR = "C="; - public static final String PARENT_BRANCH_WIDTH = "W="; - public static final String SUBTREE_NEIGHBORS = "SNn="; - public static final String SUPER_ORTHOLOGOUS = "SOn="; - public static final String ORTHOLOGOUS = "On="; - public static final String TAXONOMY_ID = "T="; - public static final String SUPPORT = "B="; - public static final String IS_DUPLICATION = "D="; - public static final String ANNOTATION = "AN="; //TODO fix on website NHXv2 - public static final String SPECIES_NAME = "S="; - public static final String DOMAIN_STRUCTURE = "DS="; - public static final String GENE_NAME = "GN="; - public static final String GENE_NAME_SYNONYM = "G="; - public static final String SEQUENCE_ACCESSION = "AC="; - public static final String NODE_IDENTIFIER = "ID="; //TODO fix on website NHXv2 - public static final Object BRANCH_WIDTH = "W="; - @Deprecated - public static final String BINARY_DOMAIN_COMBINATIONS = "GDC="; - @Deprecated - public static final String DOMAINS_SEPARATOR = "\\|"; - @Deprecated - public static final String DOMAINS = "GD="; - @Deprecated - public static final String EC_NUMBER = "E="; + public static final String CUSTOM_DATA_ON_NODE = "XN="; + public static final String COLOR = "C="; + public static final String PARENT_BRANCH_WIDTH = "W="; + public static final String SUBTREE_NEIGHBORS = "SNn="; + public static final String SUPER_ORTHOLOGOUS = "SOn="; + public static final String ORTHOLOGOUS = "On="; + public static final String TAXONOMY_ID = "T="; + public static final String SUPPORT = "B="; + public static final String IS_DUPLICATION = "D="; + public static final String ANNOTATION = "AN="; + public static final String SPECIES_NAME = "S="; + public static final String DOMAIN_STRUCTURE = "DS="; + public static final String GENE_NAME = "GN="; + public static final String GENE_NAME_SYNONYM = "G="; + public static final String SEQUENCE_ACCESSION = "AC="; + public static final String NODE_IDENTIFIER = "ID="; + public static final Object BRANCH_WIDTH = "W="; } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java index 851398a..c4c5be2 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java @@ -257,6 +257,12 @@ public final class PhyloXmlHandler extends DefaultHandler { } node.setDistanceToParent( d ); } + if ( xml_element.isHasAttribute( PhyloXmlMapping.NODE_COLLAPSE ) ) { + final String collapse_str = xml_element.getAttribute( PhyloXmlMapping.NODE_COLLAPSE ); + if ( !ForesterUtil.isEmpty( collapse_str ) && collapse_str.trim().equalsIgnoreCase( "true" ) ) { + node.setCollapse( true ); + } + } for( int i = 0; i < xml_element.getNumberOfChildElements(); ++i ) { final XmlElement element = xml_element.getChildElement( i ); final String qualified_name = element.getQualifiedName(); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlMapping.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlMapping.java index 2a8d971..4659fc2 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlMapping.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlMapping.java @@ -42,6 +42,7 @@ public final class PhyloXmlMapping { public static final String PHYLOGENY_TYPE_ATTR = "type"; public static final String CLADE = "clade"; public static final String NODE_NAME = "name"; + public static final String NODE_COLLAPSE = "collapse"; public static final String SEQUENCE = "sequence"; public static final String SEQUENCE_NAME = "name"; public static final String SEQUENCE_SYMBOL = "symbol"; diff --git a/forester/java/src/org/forester/io/writers/PhyloXmlNodeWriter.java b/forester/java/src/org/forester/io/writers/PhyloXmlNodeWriter.java index 5860cac..67d38d4 100644 --- a/forester/java/src/org/forester/io/writers/PhyloXmlNodeWriter.java +++ b/forester/java/src/org/forester/io/writers/PhyloXmlNodeWriter.java @@ -39,7 +39,7 @@ public class PhyloXmlNodeWriter { public static void toPhyloXml( final Writer w, final PhylogenyNode node, final int level, final String indentation ) throws IOException { String ind = ""; - if ( indentation.length() > 0 ) { + if ( ( indentation != null ) && ( indentation.length() > 0 ) ) { ind = indentation + PhylogenyWriter.PHYLO_XML_INTENDATION_BASE; } if ( !ForesterUtil.isEmpty( node.getName() ) ) { diff --git a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java index b41d8d7..36dfda4 100644 --- a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java +++ b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java @@ -552,12 +552,10 @@ public final class PhylogenyWriter { } PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE ); } - if ( indentation != null ) { - PhyloXmlNodeWriter.toPhyloXml( getWriter(), node, getPhyloXmlLevel(), indentation.toString() ); - } - else { - PhyloXmlNodeWriter.toPhyloXml( getWriter(), node, getPhyloXmlLevel(), "" ); - } + PhyloXmlNodeWriter.toPhyloXml( getWriter(), + node, + getPhyloXmlLevel(), + indentation != null ? indentation.toString() : "" ); if ( node.isExternal() ) { getWriter().write( ForesterUtil.LINE_SEPARATOR ); if ( indentation != null ) { @@ -594,7 +592,15 @@ public final class PhylogenyWriter { if ( isIndentPhyloxml() ) { getWriter().write( createIndentation().toString() ); } - PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE ); + if ( node.isCollapse() ) { + PhylogenyDataUtil.appendOpen( getWriter(), + PhyloXmlMapping.CLADE, + PhyloXmlMapping.NODE_COLLAPSE, + "true" ); + } + else { + PhylogenyDataUtil.appendOpen( getWriter(), PhyloXmlMapping.CLADE ); + } } else if ( ( getOutputFormt() == FORMAT.NHX ) || ( getOutputFormt() == FORMAT.NH ) ) { getBuffer().append( "(" );