special domain coloring
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 1 Oct 2014 18:29:05 +0000 (18:29 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 1 Oct 2014 18:29:05 +0000 (18:29 +0000)
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java
forester/java/src/org/forester/ws/seqdb/UniProtEntry.java

index 5f1168e..df7306b 100644 (file)
@@ -255,6 +255,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     private float                        _y_distance                                        = 0.0f;
     private int                          _length_of_longest_text;
     private int                          _longest_domain;
+    public final static boolean          SPECIAL_DOMAIN_COLORING                            = true;
     //  private Image                           offscreenImage;
     //  private Graphics                        offscreenGraphics;
     //  private Dimension                       offscreenDimension;
@@ -1096,7 +1097,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                     && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
                 RenderableDomainArchitecture rds = null;
                 if ( !( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
-                    rds = new RenderableDomainArchitecture( node.getNodeData().getSequence().getDomainArchitecture() );
+                    if ( SPECIAL_DOMAIN_COLORING ) {
+                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
+                                .getDomainArchitecture(), node.getName() );
+                    }
+                    else {
+                        rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
+                                .getDomainArchitecture() );
+                    }
                     node.getNodeData().getSequence().setDomainArchitecture( rds );
                 }
                 else {
index 1fe52bc..5b66db8 100644 (file)
@@ -48,6 +48,7 @@ import org.forester.util.ForesterUtil;
 
 public final class RenderableDomainArchitecture extends DomainArchitecture implements RenderablePhylogenyData {
 
+    final static private String       SPECIAL_DOMAIN                = "RRMa";
     final static private int          BRIGHTEN_COLOR_BY             = 200;
     final static private int          E_VALUE_THRESHOLD_EXP_DEFAULT = 0;
     final static private BasicStroke  STROKE_1                      = new BasicStroke( 1f );
@@ -57,11 +58,17 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
     private final Rectangle2D         _rectangle                    = new Rectangle2D.Float();
     private float                     _rendering_factor_width       = 1;
     private float                     _rendering_height             = 0;
+    private String                    _node_name;
 
     public RenderableDomainArchitecture( final DomainArchitecture domain_structure ) {
         _domain_structure = domain_structure;
     }
 
+    public RenderableDomainArchitecture( final DomainArchitecture domain_structure, final String node_name ) {
+        _domain_structure = domain_structure;
+        _node_name = node_name;
+    }
+
     public static void setColorMap( final Map<String, Color> domain_colors ) {
         _domain_colors = domain_colors;
     }
@@ -103,6 +110,28 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         }
     }
 
+    private final void drawDomainGrey( final double x,
+                                       final double y,
+                                       final double width,
+                                       final double heigth,
+                                       final String name,
+                                       final Graphics2D g,
+                                       final boolean to_pdf ) {
+        final double h2 = heigth / 2.0;
+        final Color color_one = Color.GRAY;
+        final Color color_two = getColorTwo( color_one );
+        double step = 1;
+        if ( to_pdf ) {
+            step = 0.05;
+        }
+        for( double i = 0; i < heigth; i += step ) {
+            g.setColor( org.forester.util.ForesterUtil
+                    .calcColor( i >= h2 ? heigth - i : i, 0, h2, color_one, color_two ) );
+            _rectangle.setFrame( x, i + y, width, step );
+            g.fill( _rectangle );
+        }
+    }
+
     private final Color getColorOne( final String name ) {
         Color c = _domain_colors.get( name );
         if ( c == null ) {
@@ -186,9 +215,15 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         }
         _rectangle.setFrame( start, y - 0.5, _domain_structure.getTotalLength() * f, 1 );
         g.fill( _rectangle );
+        short special_domain_count = 0;
         for( int i = 0; i < _domain_structure.getDomains().size(); ++i ) {
             final ProteinDomain d = _domain_structure.getDomain( i );
-            if ( d.getConfidence() <= Math.pow( 10, _e_value_threshold_exp ) ) {
+            if ( ( d.getConfidence() <= Math.pow( 10, _e_value_threshold_exp ) )
+                    || ( TreePanel.SPECIAL_DOMAIN_COLORING && ( d.getName().equals( SPECIAL_DOMAIN ) ) && ( ( d
+                            .getConfidence() <= 1 ) ) ) ) {
+                if ( TreePanel.SPECIAL_DOMAIN_COLORING && ( d.getName().equals( SPECIAL_DOMAIN ) ) ) {
+                    special_domain_count++;
+                }
                 final float xa = start + ( d.getFrom() * f );
                 final float xb = xa + ( d.getLength() * f );
                 if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels()
@@ -204,7 +239,14 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
                             + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent()
                             + _rendering_height );
                 }
-                drawDomain( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
+                if ( TreePanel.SPECIAL_DOMAIN_COLORING && ( _node_name.indexOf( "~" ) > 1 )
+                        && ( d.getName().equals( SPECIAL_DOMAIN ) )
+                        && ( _node_name.indexOf( "~" + special_domain_count + "-" ) < 1 ) ) {
+                    drawDomainGrey( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
+                }
+                else {
+                    drawDomain( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
+                }
             }
         }
         g.setStroke( s );
index d6b2aa8..77ebe4e 100644 (file)
@@ -54,7 +54,6 @@ public final class UniProtEntry implements SequenceDatabaseEntry {
     public final static Pattern  PharmGKB_PATTERN  = Pattern.compile( "PharmGKB;\\s+([0-9A-Z]+);" );
     public final static Pattern  Reactome_PATTERN  = Pattern.compile( "Reactome;\\s+([0-9A-Z]+);\\s+([^\\.]+)" );
     public final static Pattern  HGNC_PATTERN      = Pattern.compile( "HGNC;\\s+HGNC:(\\d+);" );
-    
     private String               _ac;
     private SortedSet<Accession> _cross_references;
     private String               _gene_name;