rio, lca, refactoring
authorcmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sun, 25 Nov 2012 01:45:45 +0000 (01:45 +0000)
committercmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sun, 25 Nov 2012 01:45:45 +0000 (01:45 +0000)
58 files changed:
forester/java/src/org/forester/analysis/AncestralTaxonomyInference.java
forester/java/src/org/forester/application/aa.java
forester/java/src/org/forester/application/confadd.java
forester/java/src/org/forester/application/decorator.java
forester/java/src/org/forester/application/goac.java
forester/java/src/org/forester/application/mcc.java
forester/java/src/org/forester/application/pfam2go_extractor.java
forester/java/src/org/forester/application/rio.java
forester/java/src/org/forester/application/sdi_dir.java
forester/java/src/org/forester/application/strip.java
forester/java/src/org/forester/application/surfacing.java
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/NodePanel.java
forester/java/src/org/forester/archaeopteryx/TreeColorSet.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java
forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableVector.java
forester/java/src/org/forester/datastructures/IntMatrix.java
forester/java/src/org/forester/development/DevelopmentTools.java
forester/java/src/org/forester/development/MsaRenderer.java
forester/java/src/org/forester/development/ResidueRenderer.java
forester/java/src/org/forester/development/neTest.java
forester/java/src/org/forester/evoinference/distance/NeighborJoining.java
forester/java/src/org/forester/evoinference/matrix/character/BasicCharacterStateMatrix.java
forester/java/src/org/forester/evoinference/matrix/distance/BasicSymmetricalDistanceMatrix.java
forester/java/src/org/forester/io/parsers/SymmetricalDistanceMatrixParser.java
forester/java/src/org/forester/msa/MsaCompactor.java
forester/java/src/org/forester/pccx/TestPccx.java
forester/java/src/org/forester/phylogeny/Phylogeny.java
forester/java/src/org/forester/phylogeny/PhylogenyBranch.java
forester/java/src/org/forester/phylogeny/PhylogenyMethods.java
forester/java/src/org/forester/phylogeny/PhylogenyNode.java
forester/java/src/org/forester/phylogeny/data/NodeData.java
forester/java/src/org/forester/phylogeny/data/ProteinDomain.java
forester/java/src/org/forester/phylogeny/data/Taxonomy.java
forester/java/src/org/forester/phylogeny/iterators/PreorderTreeIterator.java
forester/java/src/org/forester/protein/BasicDomain.java
forester/java/src/org/forester/sdi/GSDI.java
forester/java/src/org/forester/sdi/ORcount.java
forester/java/src/org/forester/sdi/RIO.java
forester/java/src/org/forester/sdi/SDI.java
forester/java/src/org/forester/sdi/SDIse.java
forester/java/src/org/forester/sdi/TestGSDI.java
forester/java/src/org/forester/sequence/BasicSequence.java
forester/java/src/org/forester/surfacing/CountsBasedPairwiseDomainSimilarity.java
forester/java/src/org/forester/surfacing/DomainCountsDifferenceUtil.java
forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDomainSimilariyData.java
forester/java/src/org/forester/surfacing/SurfacingUtil.java
forester/java/src/org/forester/surfacing/TestSurfacing.java
forester/java/src/org/forester/test/Test.java
forester/java/src/org/forester/tools/PhylogenyDecorator.java
forester/java/src/org/forester/tools/TreeSplitMatrix.java
forester/java/src/org/forester/util/AsciiHistogram.java
forester/java/src/org/forester/util/BasicTable.java
forester/java/src/org/forester/util/BasicTableParser.java
forester/java/src/org/forester/util/CommandLineArguments.java
forester/java/src/org/forester/util/ForesterUtil.java

index 5a6a32a..2fbdb92 100644 (file)
@@ -65,7 +65,7 @@ public final class AncestralTaxonomyInference {
                             || !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getScientificName() )
                             || !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getLineage() )
                             || !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getTaxonomyCode() ) || !ForesterUtil
-                            .isEmpty( desc.getNodeData().getTaxonomy().getCommonName() ) ) ) {
+                                .isEmpty( desc.getNodeData().getTaxonomy().getCommonName() ) ) ) {
                 final UniProtTaxonomy up_tax = TaxonomyDataManager.obtainUniProtTaxonomy( desc.getNodeData()
                         .getTaxonomy(), null, null );
                 if ( ( up_tax == null ) && ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getLineage() ) ) {
index a71d3fe..cc8413b 100644 (file)
@@ -73,8 +73,8 @@ public class aa {
                 i++;
             }
             Arrays.sort( fasta_ary );
-            for( int j = 0; j < fasta_ary.length; ++j ) {
-                System.out.println( fasta_ary[ j ] );
+            for( final String element : fasta_ary ) {
+                System.out.println( element );
             }
             System.out.println( "DONE." );
         }
index fc4dd41..3fed60c 100644 (file)
@@ -204,7 +204,7 @@ public class confadd {
         }
         double value = 1;
         if ( norm > 0 ) {
-            value = norm / ( 1 + last - first );
+            value = norm / ( ( 1 + last ) - first );
         }
         ForesterUtil.programMessage( PRG_NAME, "first topology to use: " + first );
         String is_last = "";
@@ -212,7 +212,7 @@ public class confadd {
             is_last = " (corresponds to last topology in file)";
         }
         ForesterUtil.programMessage( PRG_NAME, "last topology to use : " + last + is_last );
-        ForesterUtil.programMessage( PRG_NAME, "sum of topologies used as evaluators: " + ( last - first + 1 ) );
+        ForesterUtil.programMessage( PRG_NAME, "sum of topologies used as evaluators: " + ( ( last - first ) + 1 ) );
         if ( norm > 0 ) {
             ForesterUtil.programMessage( PRG_NAME, "normalizer: " + norm + " (" + ForesterUtil.round( value, 6 ) + ")" );
         }
index f1b2fbc..18966af 100644 (file)
@@ -351,8 +351,8 @@ public final class decorator {
                 phylogenies[ 0 ].setIdentifier( new Identifier( s_ary[ 1 ], s_ary[ 0 ] ) );
             }
             if ( !ForesterUtil.isEmpty( tree_desc ) ) {
-                for( int i = 0; i < phylogenies.length; ++i ) {
-                    phylogenies[ i ].setDescription( tree_desc );
+                for( final Phylogeny phylogenie : phylogenies ) {
+                    phylogenie.setDescription( tree_desc );
                 }
             }
         }
index 3cdceb7..a753694 100644 (file)
@@ -174,7 +174,7 @@ public class goac {
                 final int counts = counts_id.get( id );
                 double percentage = 0.0;
                 if ( sum > 0 ) {
-                    percentage = 100.0 * counts / ( sum );
+                    percentage = ( 100.0 * counts ) / ( sum );
                 }
                 System.out.println( counts + "\t" + counts + "/" + sum + "\t" + percentage + "\t" + id + "\t"
                         + goid_to_term_map.get( id ).getName() );
index c0c72b0..70b520f 100644 (file)
@@ -129,15 +129,15 @@ public class mcc {
             step = 1;
         }
         final double id_ratios[] = new double[ msa.getLength() ];
-        for( int i = 0; i <= msa.getLength() - 1; ++i ) {
+        for( int i = 0; i <= ( msa.getLength() - 1 ); ++i ) {
             id_ratios[ i ] = MsaMethods.calculateIdentityRatio( msa, i );
         }
         String min_pos = "";
         String max_pos = "";
         double min = 1;
         double max = 0;
-        for( int i = 0; i <= msa.getLength() - 1; i += step ) {
-            int to = i + window - 1;
+        for( int i = 0; i <= ( msa.getLength() - 1 ); i += step ) {
+            int to = ( i + window ) - 1;
             if ( to > ( msa.getLength() - 1 ) ) {
                 to = msa.getLength() - 1;
             }
index 63b4320..edf1940 100644 (file)
@@ -83,8 +83,8 @@ public class pfam2go_extractor {
             final GoId go_id = pfam_to_go_mapping.getValue();
             final Set<GoId> supers = GoUtils.getAllSuperGoIds( go_id, goid_to_term_map );
             supers.add( go_id );
-            for( int i = 0; i < queries.length; ++i ) {
-                if ( supers.contains( queries[ i ] ) ) {
+            for( final GoId querie : queries ) {
+                if ( supers.contains( querie ) ) {
                     pfams.add( domain_id.toString() );
                 }
             }
index 789a412..de4ed75 100644 (file)
@@ -273,17 +273,17 @@ public class rio {
         else if ( ( args.length < 3 ) || ( args.length > 18 ) ) {
             errorInCommandLine();
         }
-        for( int i = 0; i < args.length; ++i ) {
-            if ( args[ i ].trim().charAt( 0 ) != 'p' ) {
-                if ( args[ i ].trim().length() < 3 ) {
+        for( final String arg2 : args ) {
+            if ( arg2.trim().charAt( 0 ) != 'p' ) {
+                if ( arg2.trim().length() < 3 ) {
                     errorInCommandLine();
                 }
                 else {
-                    arg = args[ i ].trim().substring( 2 );
+                    arg = arg2.trim().substring( 2 );
                 }
             }
             try {
-                switch ( args[ i ].trim().charAt( 0 ) ) {
+                switch ( arg2.trim().charAt( 0 ) ) {
                     case 'M':
                         multiple_trees_file = new File( arg );
                         break;
index f23a683..d1bcbce 100644 (file)
@@ -211,8 +211,8 @@ public class sdi_dir {
         suffix = suffix.trim();
         out = new PrintWriter( new FileWriter( outfile ), true );
         //nodecount0 = PhylogenyNode.getNodeCount();
-        for( int i = 0; i < filenames.length; ++i ) {
-            filename = filenames[ i ];
+        for( final String filename2 : filenames ) {
+            filename = filename2;
             if ( ( suffix.length() < 1 ) || filename.endsWith( suffix ) ) {
                 final File gene_tree_file = new File( indir.getPath(), filename );
                 if ( gene_tree_file.exists() && gene_tree_file.isFile() ) {
@@ -285,7 +285,7 @@ public class sdi_dir {
                         }
                         out.println();
                         if ( write_trees ) {
-                            outtree = new File( outdir, new File( filenames[ i ] ).getName() );
+                            outtree = new File( outdir, new File( filename2 ).getName() );
                             final PhylogenyWriter writer = new PhylogenyWriter();
                             writer.toPhyloXML( outtree, trees[ 0 ], 1 );
                         }
index 4d1c2ad..f374154 100644 (file)
@@ -84,7 +84,7 @@ public class strip {
         }
         else {
             names = new String[ args.length - 3 ];
-            for( int i = 0; i < args.length - 3; ++i ) {
+            for( int i = 0; i < ( args.length - 3 ); ++i ) {
                 names[ i ] = args[ i + 3 ];
             }
         }
index 99e946c..2218f40 100644 (file)
@@ -2024,12 +2024,13 @@ public class surfacing {
                                          "Average of proteins with a least one domain assigned: "
                                                  + ( 100 * protein_coverage_stats.arithmeticMean() ) + "% (+/-"
                                                  + ( 100 * protein_coverage_stats.sampleStandardDeviation() ) + "%)" );
-            ForesterUtil.programMessage( PRG_NAME, "Range of proteins with a least one domain assigned: " + 100
-                    * protein_coverage_stats.getMin() + "%-" + 100 * protein_coverage_stats.getMax() + "%" );
+            ForesterUtil.programMessage( PRG_NAME, "Range of proteins with a least one domain assigned: "
+                    + ( 100 * protein_coverage_stats.getMin() ) + "%-" + ( 100 * protein_coverage_stats.getMax() )
+                    + "%" );
             log( "Average of prot with a least one dom assigned  : " + ( 100 * protein_coverage_stats.arithmeticMean() )
                     + "% (+/-" + ( 100 * protein_coverage_stats.sampleStandardDeviation() ) + "%)", log_writer );
-            log( "Range of prot with a least one dom assigned    : " + 100 * protein_coverage_stats.getMin() + "%-"
-                    + 100 * protein_coverage_stats.getMax() + "%", log_writer );
+            log( "Range of prot with a least one dom assigned    : " + ( 100 * protein_coverage_stats.getMin() ) + "%-"
+                    + ( 100 * protein_coverage_stats.getMax() ) + "%", log_writer );
         }
         catch ( final IOException e2 ) {
             ForesterUtil.fatalError( surfacing.PRG_NAME, e2.getLocalizedMessage() );
@@ -2306,7 +2307,7 @@ public class surfacing {
                                 System.out.print( ", not mapped domains = " + mapping_results.getSumOfFailures() );
                                 if ( total_domains > 0 ) {
                                     System.out.println( ", mapped ratio = "
-                                            + ( 100 * mapping_results.getSumOfSuccesses() / total_domains ) + "%" );
+                                            + ( ( 100 * mapping_results.getSumOfSuccesses() ) / total_domains ) + "%" );
                                 }
                                 else {
                                     System.out.println( ", mapped ratio = n/a (total domains = 0 )" );
@@ -2440,7 +2441,7 @@ public class surfacing {
         for( final Entry<Integer, Integer> entry : all_genomes_domains_per_potein_histo.entrySet() ) {
             sum += entry.getValue();
         }
-        final double percentage = 100.0 * ( sum - all_genomes_domains_per_potein_histo.get( 1 ) ) / sum;
+        final double percentage = ( 100.0 * ( sum - all_genomes_domains_per_potein_histo.get( 1 ) ) ) / sum;
         ForesterUtil.programMessage( PRG_NAME, "Percentage of multidomain proteins: " + percentage + "%" );
         log( "Percentage of multidomain proteins:            : " + percentage + "%", log_writer );
     }
@@ -2488,12 +2489,12 @@ public class surfacing {
             }
             System.out.println( "--" );
         }
-        for( int i = 0; i < input_file_properties.length; ++i ) {
+        for( final String[] input_file_propertie : input_file_properties ) {
             try {
-                intree.getNode( input_file_properties[ i ][ 1 ] );
+                intree.getNode( input_file_propertie[ 1 ] );
             }
             catch ( final IllegalArgumentException e ) {
-                ForesterUtil.fatalError( surfacing.PRG_NAME, "node named [" + input_file_properties[ i ][ 1 ]
+                ForesterUtil.fatalError( surfacing.PRG_NAME, "node named [" + input_file_propertie[ 1 ]
                         + "] not present/not unique in input tree" );
             }
         }
index ab8bcf6..f10fabd 100644 (file)
@@ -328,7 +328,7 @@ public final class AptxUtil {
             if ( n.getNodeData().isHasTaxonomy()
                     && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() )
                             || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) || !ForesterUtil
-                            .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
+                                .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
                 if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
                         && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) {
                     final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData()
index 8d5a4e7..bd7f19f 100644 (file)
@@ -232,6 +232,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     /**
      * Action performed.
      */
+    @Override
     public void actionPerformed( final ActionEvent e ) {
         final Object o = e.getSource();
         boolean is_applet = false;
@@ -555,6 +556,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         // See "Swing's Threading Policy".
         SwingUtilities.invokeLater( new Runnable() {
 
+            @Override
             public void run() {
                 doUpdateProcessMenu();
             }
index bb050a5..00a09d7 100644 (file)
@@ -265,7 +265,7 @@ class NodePanel extends JPanel implements TreeSelectionListener {
             }
         }
         if ( !phylogeny_node.isRoot() ) {
-            addSubelement( category, "Depth", String.valueOf( phylogeny_node.calculateDepth()  ) );
+            addSubelement( category, "Depth", String.valueOf( phylogeny_node.calculateDepth() ) );
             final double d = phylogeny_node.calculateDistanceToRoot();
             if ( d > 0 ) {
                 addSubelement( category, "Distance to root", String.valueOf( ForesterUtil.FORMATTER_6.format( d ) ) );
index 2abad1d..9881efa 100644 (file)
@@ -273,7 +273,7 @@ public final class TreeColorSet {
     }
 
     void cycleColorScheme() {
-        if ( getCurrentColorScheme() >= _color_schemes.length - 1 ) {
+        if ( getCurrentColorScheme() >= ( _color_schemes.length - 1 ) ) {
             setColorSchema( 0 );
         }
         else {
index db6b22e..924eae9 100644 (file)
@@ -347,6 +347,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
+    @Override
     final public void actionPerformed( final ActionEvent e ) {
         boolean done = false;
         final JMenuItem node_popup_menu_item = ( JMenuItem ) e.getSource();
@@ -1098,7 +1099,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return null;
         }
-        final int half_box_size_plus_wiggle = getOptions().getDefaultNodeShapeSize() / 2 + WIGGLE;
+        final int half_box_size_plus_wiggle = ( getOptions().getDefaultNodeShapeSize() / 2 ) + WIGGLE;
         for( final PhylogenyNodeIterator iter = _phylogeny.iteratorPostorder(); iter.hasNext(); ) {
             final PhylogenyNode node = iter.next();
             if ( ( _phylogeny.isRooted() || !node.isRoot() || ( node.getNumberOfDescendants() > 2 ) )
@@ -1490,9 +1491,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     final private void increaseOvSize() {
-        if ( ( getOvMaxWidth() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 )
-                && ( getOvMaxHeight() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
-                        .getHeight() / 2 ) ) {
+        if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
+                && ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
+                        .getHeight() / 2 ) ) ) {
             setOvMaxWidth( getOvMaxWidth() + 5 );
             setOvMaxHeight( getOvMaxHeight() + 5 );
             updateOvSettings();
@@ -1519,7 +1520,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         setTreeFile( null );
         setEdited( false );
         initializeOvSettings();
-        setStartingAngle( TWO_PI * 3 / 4 );
+        setStartingAngle( ( TWO_PI * 3 ) / 4 );
         final ImageLoader il = new ImageLoader( this );
         new Thread( il ).start();
     }
@@ -1569,24 +1570,24 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     final boolean inOv( final MouseEvent e ) {
-        return ( ( e.getX() > getVisibleRect().x + getOvXPosition() + 1 )
-                && ( e.getX() < getVisibleRect().x + getOvXPosition() + getOvMaxWidth() - 1 )
-                && ( e.getY() > getVisibleRect().y + getOvYPosition() + 1 ) && ( e.getY() < getVisibleRect().y
-                + getOvYPosition() + getOvMaxHeight() - 1 ) );
+        return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
+                && ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
+                && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
+                + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
     }
 
     final boolean inOvRectangle( final MouseEvent e ) {
-        return ( ( e.getX() >= getOvRectangle().getX() - 1 )
-                && ( e.getX() <= getOvRectangle().getX() + getOvRectangle().getWidth() + 1 )
-                && ( e.getY() >= getOvRectangle().getY() - 1 ) && ( e.getY() <= getOvRectangle().getY()
-                + getOvRectangle().getHeight() + 1 ) );
+        return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
+                && ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
+                && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
+                + getOvRectangle().getHeight() + 1 ) ) );
     }
 
     final private boolean inOvVirtualRectangle( final int x, final int y ) {
-        return ( ( x >= getOvVirtualRectangle().x - 1 )
-                && ( x <= getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 )
-                && ( y >= getOvVirtualRectangle().y - 1 ) && ( y <= getOvVirtualRectangle().y
-                + getOvVirtualRectangle().height + 1 ) );
+        return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
+                && ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
+                && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
+                + getOvVirtualRectangle().height + 1 ) ) );
     }
 
     final private boolean inOvVirtualRectangle( final MouseEvent e ) {
@@ -1691,16 +1692,16 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( getControlPanel().isShowTaxonomyImages() ) {
             y_dist = 40 + ( int ) getYdistance();
         }
-        return ( ( node.getYcoord() < getVisibleRect().getMinY() - y_dist )
-                || ( node.getYcoord() > getVisibleRect().getMaxY() + y_dist ) || ( ( node.getParent() != null ) && ( node
+        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
+                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
                 .getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
     }
 
     final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
-        return ( ( node.getYcoord() < getVisibleRect().getMinY() - 20 )
-                || ( node.getYcoord() > getVisibleRect().getMaxY() + 20 )
-                || ( node.getXcoord() < getVisibleRect().getMinX() - 20 ) || ( node.getXcoord() > getVisibleRect()
-                .getMaxX() + 20 ) );
+        return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
+                || ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
+                || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
+                .getMaxX() + 20 ) ) );
     }
 
     final private boolean isNonLinedUpCladogram() {
@@ -1982,9 +1983,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( getOptions().isShowOverview() && isOvOn() && isInOv() ) {
             final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
             final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
-            double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - getOvRectangle().getWidth() / 2.0 )
+            double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - ( getOvRectangle().getWidth() / 2.0 ) )
                     * w_ratio;
-            double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - getOvRectangle().getHeight() / 2.0 )
+            double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - ( getOvRectangle().getHeight() / 2.0 ) )
                     * h_ratio;
             if ( x < 0 ) {
                 x = 0;
@@ -2081,8 +2082,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
         final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
         final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
-        double dx = ( w_ratio * e.getX() - w_ratio * getLastDragPointX() );
-        double dy = ( h_ratio * e.getY() - h_ratio * getLastDragPointY() );
+        double dx = ( ( w_ratio * e.getX() ) - ( w_ratio * getLastDragPointX() ) );
+        double dy = ( ( h_ratio * e.getY() ) - ( h_ratio * getLastDragPointY() ) );
         scroll_position.x = ForesterUtil.roundToInt( scroll_position.x + dx );
         scroll_position.y = ForesterUtil.roundToInt( scroll_position.y + dy );
         if ( scroll_position.x <= 0 ) {
@@ -2174,6 +2175,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         setCursor( ARROW_CURSOR );
     }
 
+    @Override
     final public void mouseWheelMoved( final MouseWheelEvent e ) {
         final int notches = e.getWheelRotation();
         if ( inOvVirtualRectangle( e ) ) {
@@ -2401,7 +2403,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         final double root_y = _root.getYcoord();
         final double dx = root_x - p.getXcoord();
         final double dy = root_y - p.getYcoord();
-        final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
         final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
         assignGraphicsForBranchWithColorForParentBranch( c, false, g, to_pdf, to_graphics_file );
         if ( ( c.isFirstChildNode() || c.isLastChildNode() )
@@ -2418,7 +2420,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( c.isExternal() ) {
             final boolean is_in_found_nodes = isInFoundNodes( c );
             if ( ( _dynamic_hiding_factor > 1 ) && !is_in_found_nodes
-                    && ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor != 1 ) ) {
+                    && ( ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor ) != 1 ) ) {
                 return;
             }
             paintNodeDataUnrootedCirc( g, c, to_pdf, to_graphics_file, radial_labels, 0, is_in_found_nodes );
@@ -2432,7 +2434,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         final double dx = root_x - p.getXSecondary();
         final double dy = root_y - p.getYSecondary();
         final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
-        final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+        final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
         g.setColor( getTreeColorSet().getOvColor() );
         if ( ( c.isFirstChildNode() || c.isLastChildNode() ) && ( Math.abs( arc ) > 0.02 ) ) {
             final double r2 = 2.0 * parent_radius;
@@ -2549,8 +2551,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                     || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
                 if ( !to_graphics_file
                         && !to_pdf
-                        && ( ( ( y2 < getVisibleRect().getMinY() - 20 ) && ( y1 < getVisibleRect().getMinY() - 20 ) ) || ( ( y2 > getVisibleRect()
-                                .getMaxY() + 20 ) && ( y1 > getVisibleRect().getMaxY() + 20 ) ) ) ) {
+                        && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
+                                .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
                     // Do nothing.
                 }
                 else {
@@ -2584,7 +2586,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
             // draw the horizontal line
             if ( !to_graphics_file && !to_pdf
-                    && ( ( y2 < getVisibleRect().getMinY() - 20 ) || ( y2 > getVisibleRect().getMaxY() + 20 ) ) ) {
+                    && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
                 return;
             }
             float x1_r = 0;
@@ -2708,8 +2710,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         double current_angle = starting_angle;
         for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
             final PhylogenyNode n = it.next();
-            n.setXSecondary( ( float ) ( center_x + radius * Math.cos( current_angle ) ) );
-            n.setYSecondary( ( float ) ( center_y + radius * Math.sin( current_angle ) ) );
+            n.setXSecondary( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
+            n.setYSecondary( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
             _urt_nodeid_angle_map.put( n.getId(), current_angle );
             current_angle += ( TWO_PI / circ_num_ext_nodes );
         }
@@ -2747,11 +2749,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
             double r = 0;
             if ( !n.isRoot() ) {
-                r = 1 - ( ( ( double ) _circ_max_depth -  n.calculateDepth() ) / _circ_max_depth );
+                r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
             }
             final double theta = sum / descs.size();
-            n.setXcoord( ( float ) ( center_x + r * radius * Math.cos( theta ) ) );
-            n.setYcoord( ( float ) ( center_y + r * radius * Math.sin( theta ) ) );
+            n.setXcoord( ( float ) ( center_x + ( r * radius * Math.cos( theta ) ) ) );
+            n.setYcoord( ( float ) ( center_y + ( r * radius * Math.sin( theta ) ) ) );
             _urt_nodeid_angle_map.put( n.getId(), theta );
             for( final PhylogenyNode desc : descs ) {
                 paintBranchCircular( n, desc, g, radial_labels, to_pdf, to_graphics_file );
@@ -2776,11 +2778,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
             float r = 0;
             if ( !n.isRoot() ) {
-                r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth()  ) / _circ_max_depth );
+                r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
             }
             final double theta = _urt_nodeid_angle_map.get( n.getId() );
-            n.setXSecondary( ( float ) ( center_x + radius * r * Math.cos( theta ) ) );
-            n.setYSecondary( ( float ) ( center_y + radius * r * Math.sin( theta ) ) );
+            n.setXSecondary( ( float ) ( center_x + ( radius * r * Math.cos( theta ) ) ) );
+            n.setYSecondary( ( float ) ( center_y + ( radius * r * Math.sin( theta ) ) ) );
             for( final PhylogenyNode desc : descs ) {
                 paintBranchCircularLite( n, desc, g );
             }
@@ -3237,7 +3239,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                 x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
                             }
                         }
-                        if ( x + nodeTextBoundsWidth > 0 ) /* we only underline if there is something displayed */
+                        if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
                         {
                             if ( nodeTextBoundsWidth == 0 ) {
                                 nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
@@ -3370,11 +3372,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                         }
                         // y = y - ( 0.9 * getYdistance() );
                         final double hs = bi.getHeight() * scaling_factor;
-                        double ws = bi.getWidth() * scaling_factor + offset;
+                        double ws = ( bi.getWidth() * scaling_factor ) + offset;
                         final double my_y = y - ( 0.5 * hs );
                         final int x_w = ( int ) ( x + ws + 0.5 );
                         final int y_h = ( int ) ( my_y + hs + 0.5 );
-                        if ( ( x_w - x > 7 ) && ( y_h - my_y > 7 ) ) {
+                        if ( ( ( x_w - x ) > 7 ) && ( ( y_h - my_y ) > 7 ) ) {
                             g.drawImage( bi,
                                          ( int ) ( x + 0.5 + offset ),
                                          ( int ) ( my_y + 0.5 ),
@@ -3671,8 +3673,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         if ( dynamically_hide
                 && !is_in_found_nodes
-                && ( ( node.isExternal() && ( _external_node_index % dynamic_hiding_factor != 1 ) ) || ( !node
-                        .isExternal() && ( ( new_x_min < 20 ) || ( _y_distance * node.getNumberOfExternalNodes() < getTreeFontSet()._fm_large
+                && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
+                        .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getTreeFontSet()._fm_large
                         .getHeight() ) ) ) ) ) {
             return;
         }
@@ -3779,8 +3781,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         final float y_ratio = ( float ) getHeight() / getVisibleRect().y;
         final float width = getOvMaxWidth() / w_ratio;
         final float height = getOvMaxHeight() / h_ratio;
-        final float x = getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / x_ratio;
-        final float y = getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / y_ratio;
+        final float x = getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / x_ratio );
+        final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio );
         g.setColor( getTreeColorSet().getFoundColor() );
         getOvRectangle().setRect( x, y, width, height );
         if ( ( width < 6 ) && ( height < 6 ) ) {
@@ -3891,8 +3893,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             //    paintNodeRectangular( g, it.next(), to_pdf, getControlPanel().isDynamicallyHideData()
             //            && ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file );
             //}
-            for( int i = 0; i < _nodes_in_preorder.length; ++i ) {
-                paintNodeRectangular( g, _nodes_in_preorder[ i ], to_pdf, getControlPanel().isDynamicallyHideData()
+            for( final PhylogenyNode element : _nodes_in_preorder ) {
+                paintNodeRectangular( g, element, to_pdf, getControlPanel().isDynamicallyHideData()
                         && ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file );
             }
             if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) {
@@ -3932,7 +3934,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
             paintUnrooted( _phylogeny.getRoot(),
                            angle,
-                           ( float ) ( angle + 2 * Math.PI ),
+                           ( float ) ( angle + ( 2 * Math.PI ) ),
                            radial_labels,
                            g,
                            to_pdf,
@@ -3953,7 +3955,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 g.setColor( getTreeColorSet().getOvColor() );
                 paintUnrootedLite( _phylogeny.getRoot(),
                                    angle,
-                                   angle + 2 * Math.PI,
+                                   angle + ( 2 * Math.PI ),
                                    g,
                                    ( getUrtFactorOv() / ( getVisibleRect().width / getOvMaxWidth() ) ) );
                 paintOvRectangle( g );
@@ -4017,8 +4019,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         //for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) {
         //    paintNodeLite( g, it.next() );
         //}
-        for( int i = 0; i < _nodes_in_preorder.length; ++i ) {
-            paintNodeLite( g, _nodes_in_preorder[ i ] );
+        for( final PhylogenyNode element : _nodes_in_preorder ) {
+            paintNodeLite( g, element );
         }
         paintOvRectangle( g );
     }
@@ -4253,9 +4255,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             else {
                 length = getUrtFactor();
             }
-            final double mid_angle = current_angle + arc_size / 2;
-            final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
-            final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+            final double mid_angle = current_angle + ( arc_size / 2 );
+            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
             desc.setXcoord( new_x );
             desc.setYcoord( new_y );
             paintUnrooted( desc, current_angle, current_angle + arc_size, radial_labels, g, to_pdf, to_graphics_file );
@@ -4275,8 +4277,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                           final Graphics2D g,
                                           final float urt_ov_factor ) {
         if ( n.isRoot() ) {
-            final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / 2 );
-            final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / 2 );
+            final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / 2 ) );
+            final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / 2 ) );
             n.setXSecondary( x_pos );
             n.setYSecondary( y_pos );
         }
@@ -4303,9 +4305,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             else {
                 length = urt_ov_factor;
             }
-            final double mid_angle = current_angle + arc_size / 2;
-            final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
-            final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+            final double mid_angle = current_angle + ( arc_size / 2 );
+            final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+            final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
             desc.setXSecondary( new_x );
             desc.setYSecondary( new_y );
             if ( isInFoundNodes( desc ) ) {
@@ -4350,7 +4352,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         final Phylogeny buffer_phy = getCutOrCopiedTree().copy();
         buffer_phy.setAllNodesToNotCollapse();
-        buffer_phy.preOrderReId();
+        PhylogenyMethods.preOrderReId( buffer_phy );
         buffer_phy.setRooted( true );
         boolean need_to_show_whole = false;
         if ( paste_as_sibling ) {
@@ -4394,6 +4396,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         repaint();
     }
 
+    @Override
     final public int print( final Graphics g, final PageFormat page_format, final int page_index )
             throws PrinterException {
         if ( page_index > 0 ) {
@@ -4433,7 +4436,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         _node_frame_index--;
         _node_frames[ i ] = null;
         if ( i < _node_frame_index ) {
-            for( int j = 0; j < _node_frame_index - 1; j++ ) {
+            for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
                 _node_frames[ j ] = _node_frames[ j + 1 ];
             }
             _node_frames[ _node_frame_index ] = null;
@@ -5230,7 +5233,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     final void updateOvSizes() {
-        if ( ( getWidth() > 1.05 * getVisibleRect().width ) || ( getHeight() > 1.05 * getVisibleRect().height ) ) {
+        if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
             setOvOn( true );
             float l = getLongestExtNodeInfo();
             final float w_ratio = getOvMaxWidth() / getWidth();
index 539dd65..ca0d111 100644 (file)
@@ -190,8 +190,8 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple
         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 ) ) {
-                final double xa = start + d.getFrom() * f;
-                final double xb = xa + d.getLength() * f;
+                final double xa = start + ( d.getFrom() * f );
+                final double xb = xa + ( d.getLength() * f );
                 if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels() ) {
                     g.setFont( tree_panel.getMainPanel().getTreeFontSet().getSmallFont() );
                     g.setColor( getConfiguration().getDomainStructureFontColor() );
index 2785daf..eb99a35 100644 (file)
@@ -113,7 +113,7 @@ public final class RenderableVector implements RenderablePhylogenyData {
         final double width = ( double ) DEFAULT_WIDTH / _values.size();
         for( int i = 0; i < _values.size(); ++i ) {
             g.setColor( calculateColor( _values.get( i ) ) );
-            _rectangle.setFrame( start + i * width, y - 0.5, width, getRenderingHeight() );
+            _rectangle.setFrame( start + ( i * width ), y - 0.5, width, getRenderingHeight() );
             g.fill( _rectangle );
         }
     }
index 70415b9..f23c5e9 100644 (file)
@@ -49,7 +49,7 @@ public final class IntMatrix {
 
     @Override
     public String toString() {
-        StringBuilder sb = new StringBuilder();
+        final StringBuilder sb = new StringBuilder();
         for( int x = 0; x < size(); ++x ) {
             if ( getLabel( x ) != null ) {
                 sb.append( getLabel( x ) );
index 8cc0cc5..5a6a8db 100644 (file)
@@ -182,7 +182,7 @@ public final class DevelopmentTools {
         final Random r = new Random();
         PhylogenyNode n = t.getFirstExternalNode();
         while ( n != null ) {
-            final String code = ( ( Math.abs( r.nextInt() ) % ( ma - mi + 1 ) ) + mi ) + "";
+            final String code = ( ( Math.abs( r.nextInt() ) % ( ( ma - mi ) + 1 ) ) + mi ) + "";
             try {
                 PhylogenyMethods.setTaxonomyCode( n, code );
             }
index 4ad1323..3f7b5a3 100644 (file)
@@ -150,7 +150,7 @@ public class MsaRenderer extends JComponent {
     @Override
     public Dimension getPreferredSize() {
         final int width = ( getWellSize() + 1 ) * ( getColumns() + 1 );
-        final int hight = ( getWellSize() + 1 ) * ( getRows() + 1 ) + 30;
+        final int hight = ( ( getWellSize() + 1 ) * ( getRows() + 1 ) ) + 30;
         return new Dimension( width, hight );
     }
 
@@ -168,7 +168,7 @@ public class MsaRenderer extends JComponent {
     private void initializeWells() {
         _wells = new AbstractRenderer[ getRows() + 1 ][ getColumns() + 1 ];
         for( int row = 0; row < getRows(); row++ ) {
-            for( int col = 0; col < getColumns() + 1; col++ ) {
+            for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
                 AbstractRenderer r;
                 if ( col == getColumns() ) {
                     //  r = new LabelRenderer( PlateData.ALPHABET[ row % PlateData.ALPHABET.length ] + "", this );
@@ -183,7 +183,7 @@ public class MsaRenderer extends JComponent {
                 //  setAbstractRenderer( r, row, col );
             }
         }
-        for( int col = 0; col < getColumns() + 1; col++ ) {
+        for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
             //  AbstractRenderer r;
             if ( col == getColumns() ) {
                 //      r = new LabelRenderer( "", this );
@@ -221,8 +221,8 @@ public class MsaRenderer extends JComponent {
         // g
         //         .drawString( "Number:" + getPlateData().getName() + " Replicate:"
         //                 + ( getPlateData().getReplicateNumber() + 1 ), 10, 20 );
-        for( int row = 0; row < getRows() + 1; row++ ) {
-            for( int col = 0; col < getColumns() + 1; col++ ) {
+        for( int row = 0; row < ( getRows() + 1 ); row++ ) {
+            for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
                 getAbstractRenderer( row, col ).paint( g );
             }
         }
@@ -245,11 +245,11 @@ public class MsaRenderer extends JComponent {
     public void resetWellSize( final int well_size ) {
         setWellSize( well_size );
         final int factor = well_size + 0;
-        for( int row = 0; row < getRows() + 1; row++ ) {
-            for( int col = 0; col < getColumns() + 1; col++ ) {
+        for( int row = 0; row < ( getRows() + 1 ); row++ ) {
+            for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
                 final AbstractRenderer r = getAbstractRenderer( row, col );
-                r.setX( 10 + factor * col );
-                r.setY( factor * row + 30 );
+                r.setX( 10 + ( factor * col ) );
+                r.setY( ( factor * row ) + 30 );
                 r.setWellSize( well_size );
             }
         }
@@ -296,19 +296,19 @@ public class MsaRenderer extends JComponent {
     }
 
     private void setIsSelectedOfAll( final boolean isSelected ) {
-        for( int col = 0; col < getColumns() + 1; col++ ) {
+        for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
             setIsSelectedOfColumn( col, isSelected );
         }
     }
 
     private void setIsSelectedOfColumn( final int column, final boolean isSelected ) {
-        for( int row = 0; row < getRows() + 1; row++ ) {
+        for( int row = 0; row < ( getRows() + 1 ); row++ ) {
             getAbstractRenderer( row, column ).setIsSelected( isSelected );
         }
     }
 
     private void setIsSelectedOfRow( final int row, final boolean isSelected ) {
-        for( int col = 0; col < getColumns() + 1; col++ ) {
+        for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
             getAbstractRenderer( row, col ).setIsSelected( isSelected );
         }
     }
index 1d02267..1e5122a 100644 (file)
@@ -72,9 +72,9 @@ public class ResidueRenderer extends AbstractRenderer {
             value = max;
         }
         final double x = ( 255D * ( value - min ) ) / ( max - min );
-        final int red = ( int ) ( minColor.getRed() + x * calcFactor( minColor.getRed(), maxColor.getRed() ) );
-        final int green = ( int ) ( minColor.getGreen() + x * calcFactor( minColor.getGreen(), maxColor.getGreen() ) );
-        final int blue = ( int ) ( minColor.getBlue() + x * calcFactor( minColor.getBlue(), maxColor.getBlue() ) );
+        final int red = ( int ) ( minColor.getRed() + ( x * calcFactor( minColor.getRed(), maxColor.getRed() ) ) );
+        final int green = ( int ) ( minColor.getGreen() + ( x * calcFactor( minColor.getGreen(), maxColor.getGreen() ) ) );
+        final int blue = ( int ) ( minColor.getBlue() + ( x * calcFactor( minColor.getBlue(), maxColor.getBlue() ) ) );
         return new Color( red, green, blue );
     }
 
@@ -99,18 +99,18 @@ public class ResidueRenderer extends AbstractRenderer {
         }
         if ( value < mean ) {
             final double x = ( 255D * ( value - min ) ) / ( mean - min );
-            final int red = ( int ) ( minColor.getRed() + x * calcFactor( minColor.getRed(), meanColor.getRed() ) );
-            final int green = ( int ) ( minColor.getGreen() + x
-                    * calcFactor( minColor.getGreen(), meanColor.getGreen() ) );
-            final int blue = ( int ) ( minColor.getBlue() + x * calcFactor( minColor.getBlue(), meanColor.getBlue() ) );
+            final int red = ( int ) ( minColor.getRed() + ( x * calcFactor( minColor.getRed(), meanColor.getRed() ) ) );
+            final int green = ( int ) ( minColor.getGreen() + ( x * calcFactor( minColor.getGreen(),
+                                                                                meanColor.getGreen() ) ) );
+            final int blue = ( int ) ( minColor.getBlue() + ( x * calcFactor( minColor.getBlue(), meanColor.getBlue() ) ) );
             return new Color( red, green, blue );
         }
         if ( value > mean ) {
             final double x = ( 255D * ( value - mean ) ) / ( max - mean );
-            final int red = ( int ) ( meanColor.getRed() + x * calcFactor( meanColor.getRed(), maxColor.getRed() ) );
-            final int green = ( int ) ( meanColor.getGreen() + x
-                    * calcFactor( meanColor.getGreen(), maxColor.getGreen() ) );
-            final int blue = ( int ) ( meanColor.getBlue() + x * calcFactor( meanColor.getBlue(), maxColor.getBlue() ) );
+            final int red = ( int ) ( meanColor.getRed() + ( x * calcFactor( meanColor.getRed(), maxColor.getRed() ) ) );
+            final int green = ( int ) ( meanColor.getGreen() + ( x * calcFactor( meanColor.getGreen(),
+                                                                                 maxColor.getGreen() ) ) );
+            final int blue = ( int ) ( meanColor.getBlue() + ( x * calcFactor( meanColor.getBlue(), maxColor.getBlue() ) ) );
             return new Color( red, green, blue );
         }
         else {
index 61cb24c..9b02188 100644 (file)
@@ -37,7 +37,7 @@ public class neTest {
     //    }  /* coeffs */
     // compute cosine and sine of theta
     void coeffs( final double x, final double y, final DoublePointer c, final DoublePointer s, final double accuracy ) {
-        final double root = Math.sqrt( x * x + y * y );
+        final double root = Math.sqrt( ( x * x ) + ( y * y ) );
         if ( root < accuracy ) {
             c.setValue( 1.0 );
             s.setValue( 0.0 );
@@ -124,7 +124,7 @@ public class neTest {
             do {
                 TEMP = a[ i - 2 ][ i - 2 ] - a[ i - 1 ][ i - 1 ];
                 TEMP1 = a[ i - 1 ][ i - 2 ];
-                d = Math.sqrt( TEMP * TEMP + TEMP1 * TEMP1 );
+                d = Math.sqrt( ( TEMP * TEMP ) + ( TEMP1 * TEMP1 ) );
                 approx = a[ i - 2 ][ i - 2 ] + a[ i - 1 ][ i - 1 ];
                 if ( a[ i - 1 ][ i - 1 ] < a[ i - 2 ][ i - 2 ] ) {
                     approx = ( approx - d ) / 2.0;
@@ -181,13 +181,13 @@ public class neTest {
         double d;
         for( k = 0; k < n; k++ ) {
             if ( left ) {
-                d = ctheta * a[ i - 1 ][ k ] + stheta * a[ j - 1 ][ k ];
-                a[ j - 1 ][ k ] = ctheta * a[ j - 1 ][ k ] - stheta * a[ i - 1 ][ k ];
+                d = ( ctheta * a[ i - 1 ][ k ] ) + ( stheta * a[ j - 1 ][ k ] );
+                a[ j - 1 ][ k ] = ( ctheta * a[ j - 1 ][ k ] ) - ( stheta * a[ i - 1 ][ k ] );
                 a[ i - 1 ][ k ] = d;
             }
             else {
-                d = ctheta * a[ k ][ i - 1 ] + stheta * a[ k ][ j - 1 ];
-                a[ k ][ j - 1 ] = ctheta * a[ k ][ j - 1 ] - stheta * a[ k ][ i - 1 ];
+                d = ( ctheta * a[ k ][ i - 1 ] ) + ( stheta * a[ k ][ j - 1 ] );
+                a[ k ][ j - 1 ] = ( ctheta * a[ k ][ j - 1 ] ) - ( stheta * a[ k ][ i - 1 ] );
                 a[ k ][ i - 1 ] = d;
             }
         }
index 33f3f6e..1f74a2b 100644 (file)
@@ -60,7 +60,7 @@ public final class NeighborJoining {
             }
             //  _d_values[ _mappings[ otu1 ] ][ _mappings[ i ] ] = ( getValueFromD( otu1, i ) + getValueFromD( i, otu2 ) - d ) / 2;
             i_m = _mappings[ i ];
-            _d_values[ otu1_m ][ i_m ] = ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] - 2 ) / 2;
+            _d_values[ otu1_m ][ i_m ] = ( ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] ) - 2 ) / 2;
         }
     }
 
@@ -195,14 +195,14 @@ public final class NeighborJoining {
             j_m = _mappings[ j ];
             for( int i = 0; i < j; ++i ) {
                 //  _m_values[ i ][ j ] = getValueFromD( i, j ) - ( _r[ i ] + r_j ) / ( _n - 2 );
-                _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( _r[ i ] + r_j ) / ( _n_2 );
+                _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( ( _r[ i ] + r_j ) / ( _n_2 ) );
             }
         }
     }
 
     // otu2 will, in effect, be "deleted" from the matrix.
     private final void updateMappings( final int otu2 ) {
-        for( int i = otu2; i < _mappings.length - 1; ++i ) {
+        for( int i = otu2; i < ( _mappings.length - 1 ); ++i ) {
             _mappings[ i ] = _mappings[ i + 1 ];
         }
     }
index 30b5f9b..2d5e7c7 100644 (file)
@@ -326,7 +326,7 @@ public class BasicCharacterStateMatrix<S> implements CharacterStateMatrix<S> {
             final String c = getCharacter( character );
             writer.write( c != null ? ForesterUtil.pad( c, longest, ' ', false ).toString() : ForesterUtil
                     .pad( "", longest, ' ', false ).toString() );
-            if ( character < getNumberOfCharacters() - 1 ) {
+            if ( character < ( getNumberOfCharacters() - 1 ) ) {
                 writer.write( ' ' );
             }
         }
@@ -340,11 +340,11 @@ public class BasicCharacterStateMatrix<S> implements CharacterStateMatrix<S> {
                 final S state = getState( identifier, character );
                 writer.write( state != null ? ForesterUtil.pad( state.toString(), longest, ' ', false ).toString()
                         : ForesterUtil.pad( "", longest, ' ', false ).toString() );
-                if ( character < getNumberOfCharacters() - 1 ) {
+                if ( character < ( getNumberOfCharacters() - 1 ) ) {
                     writer.write( ' ' );
                 }
             }
-            if ( identifier < getNumberOfIdentifiers() - 1 ) {
+            if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
                 writer.write( ForesterUtil.LINE_SEPARATOR );
             }
         }
@@ -384,12 +384,12 @@ public class BasicCharacterStateMatrix<S> implements CharacterStateMatrix<S> {
                 final String state = getState( identifier, character ).toString();
                 writer.write( state != null ? ForesterUtil.pad( state, pad, ' ', false ).toString() : ForesterUtil
                         .pad( "", pad, ' ', false ).toString() );
-                if ( character < getNumberOfCharacters() - 1 ) {
+                if ( character < ( getNumberOfCharacters() - 1 ) ) {
                     writer.write( ' ' );
                     writer.write( ' ' );
                 }
             }
-            if ( identifier < getNumberOfIdentifiers() - 1 ) {
+            if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
                 writer.write( ForesterUtil.LINE_SEPARATOR );
             }
         }
@@ -472,7 +472,7 @@ public class BasicCharacterStateMatrix<S> implements CharacterStateMatrix<S> {
             w.write( "  " + ( i + 1 ) + " '" );
             w.write( getCharacter( i ) );
             w.write( "'" );
-            if ( i < getNumberOfCharacters() - 1 ) {
+            if ( i < ( getNumberOfCharacters() - 1 ) ) {
                 w.write( "," );
                 w.write( ForesterUtil.LINE_SEPARATOR );
             }
@@ -505,7 +505,7 @@ public class BasicCharacterStateMatrix<S> implements CharacterStateMatrix<S> {
                 }
                 w.write( state.toString() );
             }
-            if ( identifier < getNumberOfIdentifiers() - 1 ) {
+            if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
                 w.write( ForesterUtil.LINE_SEPARATOR );
             }
         }
index d7eaed5..d45ecda 100644 (file)
@@ -134,12 +134,12 @@ public final class BasicSymmetricalDistanceMatrix implements DistanceMatrix {
             }
             for( int col = 0; col < getSize(); ++col ) {
                 w.write( PHYLIP_FORMATTER.format( getValue( col, row ) ) );
-                if ( col < getSize() - 1 ) {
+                if ( col < ( getSize() - 1 ) ) {
                     w.write( ' ' );
                     w.write( ' ' );
                 }
             }
-            if ( row < getSize() - 1 ) {
+            if ( row < ( getSize() - 1 ) ) {
                 w.write( ForesterUtil.LINE_SEPARATOR );
             }
         }
@@ -165,12 +165,12 @@ public final class BasicSymmetricalDistanceMatrix implements DistanceMatrix {
             //sb.append( "" );
             for( int col = 0; col < getSize(); ++col ) {
                 sb.append( PHYLIP_FORMATTER.format( getValue( col, row ) ) );
-                if ( col < getSize() - 1 ) {
+                if ( col < ( getSize() - 1 ) ) {
                     sb.append( ' ' );
                     sb.append( ' ' );
                 }
             }
-            if ( row < getSize() - 1 ) {
+            if ( row < ( getSize() - 1 ) ) {
                 sb.append( ForesterUtil.LINE_SEPARATOR );
             }
         }
index 538257c..03f66df 100644 (file)
@@ -142,7 +142,7 @@ public class SymmetricalDistanceMatrixParser {
             throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( col - 1 ) + ", " + row
                     + "]" );
         }
-        distance_matrix.setValue( col - 1 + col_offset, row, d );
+        distance_matrix.setValue( ( col - 1 ) + col_offset, row, d );
     }
 
     private DistanceMatrix transform( final BasicTable<String> table ) throws IllegalArgumentException, IOException {
@@ -154,7 +154,7 @@ public class SymmetricalDistanceMatrixParser {
         if ( table.getNumberOfColumns() == table.getNumberOfRows() ) {
             first_line_is_size = true;
         }
-        else if ( table.getNumberOfColumns() != table.getNumberOfRows() + 1 ) {
+        else if ( table.getNumberOfColumns() != ( table.getNumberOfRows() + 1 ) ) {
             throw new IllegalArgumentException( "attempt to create distance matrix with illegal dimensions [columns: "
                     + table.getNumberOfColumns() + ", rows: " + table.getNumberOfRows() + "]" );
         }
@@ -163,7 +163,7 @@ public class SymmetricalDistanceMatrixParser {
         if ( first_line_is_size ) {
             start_row = 1;
         }
-        for( int row = 0; row < table.getNumberOfRows() - start_row; row++ ) {
+        for( int row = 0; row < ( table.getNumberOfRows() - start_row ); row++ ) {
             distance_matrix.setIdentifier( row, table.getValue( 0, row + start_row ) );
             switch ( getInputMatrixType() ) {
                 case LOWER_TRIANGLE:
index 64c6957..73f0c63 100644 (file)
@@ -188,19 +188,7 @@ public class MsaCompactor {
     final private DescriptiveStatistics[] calcStats() {
         final DescriptiveStatistics stats[] = calc();
         sort( stats );
-        for( int i = 0; i < stats.length; ++i ) {
-            final DescriptiveStatistics s = stats[ i ];
-            //            System.out.print( s.getDescription() );
-            //            System.out.print( "\t" );
-            //            System.out.print( s.arithmeticMean() );
-            //            System.out.print( "\t(" );
-            //            System.out.print( s.arithmeticMean() );
-            //            System.out.print( ")" );
-            //            System.out.print( "\t" );
-            //            System.out.print( s.getMin() );
-            //            System.out.print( "\t" );
-            //            System.out.print( s.getMax() );
-            //            System.out.println();
+        for( final DescriptiveStatistics s : stats ) {
         }
         return stats;
     }
index 9cb772f..642d919 100644 (file)
@@ -65,53 +65,53 @@ public class TestPccx {
             final CoverageCalculator cc = CoverageCalculator.getInstance( new ExternalNodeBasedCoverageMethod(),
                                                                           options );
             Coverage cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 / 2 + 1.0 / 3 + 1.0 / 4 + 1.0 / 7 + 1.0 / 7 + 1.0 / 7
-                    + 1.0 / 7 + 1.0 / 5 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + ( 1.0 / 2 ) + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 7 )
+                    + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 5 ) ) / 9 ) ) {
                 return false;
             }
             names.add( "B" );
             names.add( "B" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 / 7 + 1.0 / 7 + 1.0 / 7 + 1.0
-                    / 7 + 1.0 / 5 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 7 ) + ( 1.0 / 7 )
+                    + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 5 ) ) / 9 ) ) {
                 return false;
             }
             names.add( "G" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx
-                    .isEqual( cov.getScore(),
-                              ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 / 4 + 1.0 / 4 + 1.0 + 1.0 / 2 + 1.0 / 4 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 4 ) + ( 1.0 / 4 )
+                    + 1.0 + ( 1.0 / 2 ) + ( 1.0 / 4 ) ) / 9 ) ) {
                 return false;
             }
             names.add( "E" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(),
-                                    ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 / 4 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+                    + ( 1.0 / 2 ) + ( 1.0 / 4 ) ) / 9 ) ) {
                 return false;
             }
             names.add( "X" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(),
-                                    ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 3 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 3 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+                    + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
                 return false;
             }
             names.add( "C" );
             names.add( "C" );
             names.add( "C" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(),
-                                    ( 1.0 + 1.0 + 1.0 + 1.0 / 3 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + ( 1.0 / 3 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+                    + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
                 return false;
             }
             names.add( "D" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx
-                    .isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+            if ( !TestPccx.isEqual( cov.getScore(),
+                                    ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + ( 1.0 / 2 ) + 1.0 + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
                 return false;
             }
             names.add( "F" );
             cov = cc.calculateCoverage( phylogenies, names, false );
-            if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+            if ( !TestPccx
+                    .isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
                 return false;
             }
             names.add( "H" );
@@ -195,23 +195,27 @@ public class TestPccx {
             final CoverageCalculator cc2 = CoverageCalculator.getInstance( new ExternalNodeBasedCoverageMethod(),
                                                                            options2 );
             Coverage cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
-            final double nf = 1 / ( 1 / 0.1 + 1 / 0.7 + 1 / 1.0 + 1 / 1.7 + 1 / 0.3 + 1 / 0.4 + 1 / 0.5 + 1 / 0.6 + 1 / 2.0 );
-            if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.3 + 1
-                    / 4.0 + 1 / 6.4 + 1 / 6.5 + 1 / 6.7 + 1 / 6.8 + 1 / 5.6 )
+            final double nf = 1 / ( ( 1 / 0.1 ) + ( 1 / 0.7 ) + ( 1 / 1.0 ) + ( 1 / 1.7 ) + ( 1 / 0.3 ) + ( 1 / 0.4 )
+                    + ( 1 / 0.5 ) + ( 1 / 0.6 ) + ( 1 / 2.0 ) );
+            if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+                    + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.3 ) + ( 1 / 4.0 ) + ( 1 / 6.4 )
+                    + ( 1 / 6.5 ) + ( 1 / 6.7 ) + ( 1 / 6.8 ) + ( 1 / 5.6 ) )
                     * nf ) ) {
                 return false;
             }
             names2.add( "C" );
             cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
-            if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.0 + 1
-                    / 4.0 + 1 / 6.4 + 1 / 6.5 + 1 / 6.7 + 1 / 6.8 + 1 / 5.6 )
+            if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+                    + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.0 ) + ( 1 / 4.0 ) + ( 1 / 6.4 )
+                    + ( 1 / 6.5 ) + ( 1 / 6.7 ) + ( 1 / 6.8 ) + ( 1 / 5.6 ) )
                     * nf ) ) {
                 return false;
             }
             names2.add( "E" );
             cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
-            if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.0 + +1
-                    / 4.0 + 1 / 0.3 + 1 / 0.7 + 1 / 3.1 + 1 / 3.2 + 1 / 4.8 )
+            if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+                    + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.0 ) + ( +1 / 4.0 ) + ( 1 / 0.3 )
+                    + ( 1 / 0.7 ) + ( 1 / 3.1 ) + ( 1 / 3.2 ) + ( 1 / 4.8 ) )
                     * nf ) ) {
                 return false;
             }
index a4102d2..8c7cf82 100644 (file)
@@ -853,18 +853,6 @@ public class Phylogeny {
         PhylogenyNode.setNodeCount( max + 1 );
     }
 
-    public void preOrderReId() {
-        if ( isEmpty() ) {
-            return;
-        }
-        setIdToNodeMap( null );
-        int i = PhylogenyNode.getNodeCount();
-        for( final PhylogenyNodeIterator it = iteratorPreorder(); it.hasNext(); ) {
-            it.next().setId( i++ );
-        }
-        PhylogenyNode.setNodeCount( i );
-    }
-
     /**
      * Prints descriptions of all external Nodes of this Phylogeny to
      * System.out.
@@ -1152,7 +1140,7 @@ public class Phylogeny {
         _identifier = identifier;
     }
 
-    private void setIdToNodeMap( final HashMap<Integer, PhylogenyNode> idhash ) {
+    public void setIdToNodeMap( final HashMap<Integer, PhylogenyNode> idhash ) {
         _id_to_node_map = idhash;
     }
 
index c427c25..4a4f7fb 100644 (file)
@@ -132,10 +132,10 @@ public class PhylogenyBranch implements Edge {
                 hc_2 = node_2_hc;
             }
         }
-        result = PRIME * result + ( ( _data == null ) ? 0 : _data.hashCode() );
-        result = PRIME * result + ( _is_directed ? 1231 : 1237 );
-        result = PRIME * result + hc_1;
-        result = PRIME * result + hc_2;
+        result = ( PRIME * result ) + ( ( _data == null ) ? 0 : _data.hashCode() );
+        result = ( PRIME * result ) + ( _is_directed ? 1231 : 1237 );
+        result = ( PRIME * result ) + hc_1;
+        result = ( PRIME * result ) + hc_2;
         return result;
     }
 
index 052b23f..e64d72a 100644 (file)
@@ -79,7 +79,7 @@ public class PhylogenyMethods {
      * @return distance between node1 and node2
      */
     public double calculateDistance( final PhylogenyNode node1, final PhylogenyNode node2 ) {
-        final PhylogenyNode lca =calculateLCA( node1, node2 );
+        final PhylogenyNode lca = calculateLCA( node1, node2 );
         final PhylogenyNode n1 = node1;
         final PhylogenyNode n2 = node2;
         return ( PhylogenyMethods.getDistance( n1, lca ) + PhylogenyMethods.getDistance( n2, lca ) );
@@ -161,11 +161,11 @@ public class PhylogenyMethods {
         if ( node1 == node2 ) {
             return node1;
         }
-        if (( node1.getParent() == node2.getParent() ) /*&& node1.getParent() != null */ ) {
+        if ( ( node1.getParent() == node2.getParent() ) ) {
             return node1.getParent();
         }
-        int depth1 = node1.calculateDepth() ;
-        int depth2 = node2.calculateDepth() ;
+        int depth1 = node1.calculateDepth();
+        int depth2 = node2.calculateDepth();
         while ( ( depth1 > -1 ) && ( depth2 > -1 ) ) {
             if ( depth1 > depth2 ) {
                 node1 = node1.getParent();
@@ -188,6 +188,39 @@ public class PhylogenyMethods {
         throw new IllegalArgumentException( "illegal attempt to calculate LCA of two nodes which do not share a common root" );
     }
 
+    public static final void preOrderReId( final Phylogeny phy ) {
+        if ( phy.isEmpty() ) {
+            return;
+        }
+        phy.setIdToNodeMap( null );
+        int i = PhylogenyNode.getNodeCount();
+        for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
+            it.next().setId( i++ );
+        }
+        PhylogenyNode.setNodeCount( i );
+    }
+
+    /**
+     * Returns the LCA of PhylogenyNodes node1 and node2.
+     * Precondition: ids are in pre-order (or level-order).
+     * 
+     * 
+     * @param node1
+     * @param node2
+     * @return LCA of node1 and node2
+     */
+    public final static PhylogenyNode calculateLCAonTreeWithIdsInPreOrder( PhylogenyNode node1, PhylogenyNode node2 ) {
+        while ( node1 != node2 ) {
+            if ( node1.getId() > node2.getId() ) {
+                node1 = node1.getParent();
+            }
+            else {
+                node2 = node2.getParent();
+            }
+        }
+        return node1;
+    }
+
     /**
      * Returns all orthologs of the external PhylogenyNode n of this Phylogeny.
      * Orthologs are returned as List of node references.
@@ -202,22 +235,19 @@ public class PhylogenyMethods {
      *         of this Phylogeny, null if this Phylogeny is empty or if n is
      *         internal
      */
-    public List<PhylogenyNode> getOrthologousNodes( final Phylogeny phy, final PhylogenyNode node ) {
+    public final static List<PhylogenyNode> getOrthologousNodes( final Phylogeny phy, final PhylogenyNode node ) {
         final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
+        PhylogenyMethods.preOrderReId( phy );
         final PhylogenyNodeIterator it = phy.iteratorExternalForward();
         while ( it.hasNext() ) {
             final PhylogenyNode temp_node = it.next();
-            if ( ( temp_node != node ) && isAreOrthologous( node, temp_node ) ) {
+            if ( ( temp_node != node ) && !calculateLCAonTreeWithIdsInPreOrder( node, temp_node ).isDuplication() ) {
                 nodes.add( temp_node );
             }
         }
         return nodes;
     }
 
-    public static boolean isAreOrthologous( final PhylogenyNode node1, final PhylogenyNode node2 ) {
-        return !calculateLCA( node1, node2 ).isDuplication();
-    }
-
     public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
         final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
         final Phylogeny[] trees = factory.create( file, parser );
index df13f64..b41da60 100644 (file)
@@ -461,7 +461,7 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable<Phylogeny
             previous_node = current_node;
             current_node = current_node.getParent();
         }
-        if ( index < current_node.getNumberOfDescendants() - 1 ) {
+        if ( index < ( current_node.getNumberOfDescendants() - 1 ) ) {
             current_node = current_node.getChildNode( index + 1 );
         }
         while ( current_node.isInternal() && !current_node.isCollapse() ) {
@@ -744,7 +744,7 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable<Phylogeny
         }
         return steps;
     }
-    
+
     public final double calculateDistanceToRoot() {
         PhylogenyNode n = this;
         double d = 0.0;
@@ -757,8 +757,6 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable<Phylogeny
         return d;
     }
 
-    
-    
     /**
      * Checks whether this PhylogenyNode is a root.
      * 
index bc7e8b9..e0d74a2 100644 (file)
@@ -273,7 +273,7 @@ public class NodeData implements PhylogenyData {
         return ( getDate() != null )
                 && ( !ForesterUtil.isEmpty( getDate().getDesc() ) || !ForesterUtil.isNull( getDate().getMax() )
                         || !ForesterUtil.isNull( getDate().getMin() ) || !ForesterUtil.isNull( getDate().getValue() ) || !ForesterUtil
-                        .isEmpty( getDate().getUnit() ) );
+                            .isEmpty( getDate().getUnit() ) );
     }
 
     public boolean isHasDistribution() {
index 5bb947a..5964f47 100644 (file)
@@ -107,7 +107,7 @@ public class ProteinDomain implements PhylogenyData {
     }
 
     public int getLength() {
-        return ( getTo() - getFrom() + 1 );
+        return ( ( getTo() - getFrom() ) + 1 );
     }
 
     public String getName() {
index 544522b..1396cf8 100644 (file)
@@ -251,7 +251,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
                 && ForesterUtil.isEmpty( getCommonName() ) && ForesterUtil.isEmpty( getScientificName() )
                 && ForesterUtil.isEmpty( getRank() ) && ForesterUtil.isEmpty( _uris )
                 && ForesterUtil.isEmpty( getAuthority() ) && ForesterUtil.isEmpty( _synonyms ) && ForesterUtil
-                .isEmpty( _lineage ) );
+                    .isEmpty( _lineage ) );
     }
 
     /**
index c01434b..c4e06f0 100644 (file)
@@ -31,14 +31,7 @@ import java.util.Stack;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 
-// import java.util.Iterator; TODO should implement this, not some iterator of
-// this package.
-/*
- * @author Christian M. Zmasek
- * 
- * @version 1.020 -- last modified: 10/10/05
- */
-public class PreorderTreeIterator implements PhylogenyNodeIterator {
+public final class PreorderTreeIterator implements PhylogenyNodeIterator {
 
     final private Phylogeny            _tree;
     final private Stack<PhylogenyNode> _stack;
@@ -62,58 +55,50 @@ public class PreorderTreeIterator implements PhylogenyNodeIterator {
         reset( node );
     }
 
-    private Stack<PhylogenyNode> getStack() {
-        return _stack;
-    }
-
-    private Phylogeny getTree() {
-        return _tree;
-    }
-
     /*
      * (non-Javadoc)
      * 
      * @see java.util.Iterator#hasNext()
      */
     @Override
-    public boolean hasNext() {
-        return !getStack().isEmpty();
+    public final boolean hasNext() {
+        return !_stack.isEmpty();
     }
 
     /**
      * Advances the Iterator by one.
      */
     @Override
-    public PhylogenyNode next() throws NoSuchElementException {
+    public final PhylogenyNode next() throws NoSuchElementException {
         if ( !hasNext() ) {
             throw new NoSuchElementException( "Attempt to call \"next()\" on iterator which has no more next elements." );
         }
-        final PhylogenyNode node = getStack().pop();
+        final PhylogenyNode node = _stack.pop();
         if ( !node.isExternal() ) {
             for( int i = node.getNumberOfDescendants() - 1; i >= 0; --i ) {
-                getStack().push( node.getChildNode( i ) );
+                _stack.push( node.getChildNode( i ) );
             }
         }
         return node;
-    } // next()
+    }
 
     /**
      * Not supported.
      * 
      */
     @Override
-    public void remove() {
+    public final void remove() {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void reset() {
-        getStack().clear();
-        getStack().push( getTree().getRoot() );
+    public final void reset() {
+        _stack.clear();
+        _stack.push( _tree.getRoot() );
     }
 
-    private void reset( final PhylogenyNode node ) {
-        getStack().clear();
-        getStack().push( node );
+    private final void reset( final PhylogenyNode node ) {
+        _stack.clear();
+        _stack.push( node );
     }
-} // End of class PreorderTreeIterator.
+}
index 68fb60f..c6c5288 100644 (file)
@@ -214,6 +214,6 @@ public class BasicDomain implements Domain {
 
     @Override
     public int getLength() {
-        return 1 + getTo() - getFrom();
+        return ( 1 + getTo() ) - getFrom();
     }
 }
index 8629acb..2419d13 100644 (file)
@@ -35,6 +35,7 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Event;
 import org.forester.phylogeny.data.Taxonomy;
@@ -93,7 +94,7 @@ public final class GSDI extends SDI {
         _mapped_species_tree_nodes = new HashSet<PhylogenyNode>();
         _scientific_names_mapped_to_reduced_specificity = new TreeSet<String>();
         linkNodesOfG();
-        getSpeciesTree().preOrderReId();
+        PhylogenyMethods.preOrderReId( getSpeciesTree() );
         geneTreePostOrderTraversal();
     }
 
index 567a67c..5a9fa39 100644 (file)
@@ -162,8 +162,8 @@ public class ORcount {
                 final String all_j = ORcount.all_species[ j ].trim().toUpperCase();
                 final String[] a = { all_i };
                 final String[] b = { all_j };
-                for( int k = 0; k < trees.length; ++k ) {
-                    countSharedAncestralClades( trees[ k ], bootstrap_threshold, a, b );
+                for( final Phylogeny tree : trees ) {
+                    countSharedAncestralClades( tree, bootstrap_threshold, a, b );
                 }
             }
         }
@@ -171,8 +171,8 @@ public class ORcount {
         if ( ( ORcount.group_1 != null ) && ( ORcount.group_2 != null ) && ( ORcount.group_1.length > 0 )
                 && ( ORcount.group_2.length > 0 ) ) {
             setGroup1Vs2Counter( 0 );
-            for( int k = 0; k < trees.length; ++k ) {
-                countSharedAncestralClades( trees[ k ], bootstrap_threshold, ORcount.group_1, ORcount.group_2 );
+            for( final Phylogeny tree : trees ) {
+                countSharedAncestralClades( tree, bootstrap_threshold, ORcount.group_1, ORcount.group_2 );
             }
             System.out.println( "\nCount [(" + ForesterUtil.stringArrayToString( ORcount.group_1 ) + ") vs ("
                     + ForesterUtil.stringArrayToString( ORcount.group_2 ) + ")] = " + getGroup1Vs2Counter() );
@@ -181,8 +181,8 @@ public class ORcount {
 
     public void countSuperOrthologousRelations( final int bootstrap_threshold ) {
         reset();
-        for( int i = 0; i < _trees.length; ++i ) {
-            countSuperOrthologousRelations( _trees[ i ], bootstrap_threshold );
+        for( final Phylogeny _tree : _trees ) {
+            countSuperOrthologousRelations( _tree, bootstrap_threshold );
         }
     }
 
@@ -269,7 +269,7 @@ public class ORcount {
         }
         final Object[] species_array = _species.keySet().toArray();
         final int s = species_array.length;
-        for( int i = 0; i < s - 1; ++i ) {
+        for( int i = 0; i < ( s - 1 ); ++i ) {
             final String species = ( String ) species_array[ i ];
             System.out.println();
             System.out.println( species + ":" );
index 47a88b8..da0ba6e 100644 (file)
@@ -77,11 +77,11 @@ public final class RIO {
         reset();
     }
 
-    public IntMatrix calculateOrthologTable( Phylogeny[] gene_trees ) {
-        List<String> labels = new ArrayList<String>();
-        Set<String> labels_set = new HashSet<String>();
+    public IntMatrix calculateOrthologTable( final Phylogeny[] gene_trees ) {
+        final List<String> labels = new ArrayList<String>();
+        final Set<String> labels_set = new HashSet<String>();
         String label;
-        for( PhylogenyNode n : gene_trees[ 0 ].getExternalNodes() ) {
+        for( final PhylogenyNode n : gene_trees[ 0 ].getExternalNodes() ) {
             if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
                 label = n.getNodeData().getSequence().getName();
             }
@@ -101,16 +101,17 @@ public final class RIO {
             labels_set.add( label );
             labels.add( label );
         }
-        IntMatrix m = new IntMatrix( labels );
+        final IntMatrix m = new IntMatrix( labels );
         int counter = 0;
-        for( Phylogeny gt : gene_trees ) {
+        for( final Phylogeny gt : gene_trees ) {
             System.out.println( counter );
             counter++;
+            PhylogenyMethods.preOrderReId( gt );
             for( int x = 0; x < m.size(); ++x ) {
-                PhylogenyNode nx = gt.getNode( m.getLabel( x ) );
+                final PhylogenyNode nx = gt.getNode( m.getLabel( x ) );
                 for( int y = 0; y < m.size(); ++y ) {
-                    PhylogenyNode ny = gt.getNode( m.getLabel( y ) );
-                    if ( PhylogenyMethods.isAreOrthologous( nx, ny ) ) {
+                    final PhylogenyNode ny = gt.getNode( m.getLabel( y ) );
+                    if ( !PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( nx, ny ).isDuplication() ) {
                         m.set( x, y, m.get( x, y ) + 1 );
                         //System.out.println( x + " " + y );
                     }
@@ -137,7 +138,7 @@ public final class RIO {
             return 0.0;
         }
         final int i = h.get( name );
-        return ( i * 100.0 / getBootstraps() );
+        return ( ( i * 100.0 ) / getBootstraps() );
     }
 
     /**
@@ -314,7 +315,7 @@ public final class RIO {
         _sn_hash_maps.put( query, new HashMap<String, Integer>( _seq_names.size() ) );
         // Go through all gene trees in the file.
         final Phylogeny[] gene_trees = factory.create( gene_trees_file, p );
-        Phylogeny[] assigned_trees = new Phylogeny[ gene_trees.length ];
+        final Phylogeny[] assigned_trees = new Phylogeny[ gene_trees.length ];
         int c = 0;
         for( final Phylogeny gt : gene_trees ) {
             bs++;
@@ -323,7 +324,7 @@ public final class RIO {
             assigned_trees[ c++ ] = inferOrthologsHelper( gt, species_tree, query );
             // System.out.println( bs );
         }
-        IntMatrix m = calculateOrthologTable( assigned_trees );
+        final IntMatrix m = calculateOrthologTable( assigned_trees );
         System.out.println( m.toString() );
         setBootstraps( bs );
         if ( RIO.TIME ) {
@@ -372,8 +373,7 @@ public final class RIO {
             throw new IllegalArgumentException( "no node containing a sequence named [" + query + "] found" );
         }
         final PhylogenyNode query_node = nodes.get( 0 );
-        final PhylogenyMethods methods = PhylogenyMethods.getInstance();
-        orthologs = methods.getOrthologousNodes( assigned_tree, query_node );
+        orthologs = PhylogenyMethods.getOrthologousNodes( assigned_tree, query_node );
         updateHash( _o_hash_maps, query, orthologs );
         super_orthologs = PhylogenyMethods.getSuperOrthologousNodes( query_node );
         updateHash( _so_hash_maps, query, super_orthologs );
@@ -616,12 +616,12 @@ public final class RIO {
                     nv_array[ j ] = nv.get( j );
                 }
                 Arrays.sort( nv_array );
-                for( int i = 0; i < nv_array.length; ++i ) {
-                    name = nv_array[ i ].getKey();
-                    value1 = nv_array[ i ].getValue1();
-                    value2 = nv_array[ i ].getValue2();
-                    value3 = nv_array[ i ].getValue3();
-                    value4 = nv_array[ i ].getValue4();
+                for( final Tuplet element : nv_array ) {
+                    name = element.getKey();
+                    value1 = element.getValue1();
+                    value2 = element.getValue2();
+                    value3 = element.getValue3();
+                    value4 = element.getValue4();
                     orthologs.append( addNameAndValues( name, value1, value2, value3, value4, sort ) );
                 }
             }
@@ -708,10 +708,10 @@ public final class RIO {
                 else {
                     sort = 90;
                 }
-                for( int i = 0; i < nv_array.length; ++i ) {
-                    name = nv_array[ i ].getKey();
-                    value1 = nv_array[ i ].getValue1();
-                    value2 = nv_array[ i ].getValue2();
+                for( final Tuplet element : nv_array ) {
+                    name = element.getKey();
+                    value1 = element.getValue1();
+                    value2 = element.getValue2();
                     ultra_paralogs += addNameAndValues( name, value1, value2, 0.0, 0.0, sort );
                 }
             }
index b1258f0..1f1e163 100644 (file)
@@ -94,14 +94,14 @@ public abstract class SDI {
             computeMappingCostHelper( g.getChildNode1() );
             computeMappingCostHelper( g.getChildNode2() );
             if ( ( g.getLink() != g.getChildNode1().getLink() ) && ( g.getLink() != g.getChildNode2().getLink() ) ) {
-                _mapping_cost += ( g.getChildNode1().getLink().getId() + g.getChildNode2().getLink().getId()
+                _mapping_cost += ( ( g.getChildNode1().getLink().getId() + g.getChildNode2().getLink().getId() )
                         - ( 2 * g.getLink().getId() ) - 2 );
             }
             else if ( ( g.getLink() != g.getChildNode1().getLink() ) && ( g.getLink() == g.getChildNode2().getLink() ) ) {
-                _mapping_cost += ( g.getChildNode1().getLink().getId() - g.getLink().getId() + 1 );
+                _mapping_cost += ( ( g.getChildNode1().getLink().getId() - g.getLink().getId() ) + 1 );
             }
             else if ( ( g.getLink() == g.getChildNode1().getLink() ) && ( g.getLink() != g.getChildNode2().getLink() ) ) {
-                _mapping_cost += ( g.getChildNode2().getLink().getId() - g.getLink().getId() + 1 );
+                _mapping_cost += ( ( g.getChildNode2().getLink().getId() - g.getLink().getId() ) + 1 );
             }
             else {
                 _mapping_cost++;
index 7efd6a7..bf06a41 100644 (file)
@@ -28,6 +28,7 @@
 package org.forester.sdi;
 
 import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Event;
 
@@ -84,7 +85,7 @@ public class SDIse extends SDI {
     public SDIse( final Phylogeny gene_tree, final Phylogeny species_tree ) throws SDIException {
         super( gene_tree, species_tree );
         _duplications_sum = 0;
-        getSpeciesTree().preOrderReId();
+        PhylogenyMethods.preOrderReId( getSpeciesTree() );
         linkNodesOfG();
         geneTreePostOrderTraversal( getGeneTree().getRoot() );
     }
index 2be6dee..6480281 100644 (file)
@@ -128,17 +128,20 @@ public final class TestGSDI {
             if ( sdi1.getDuplicationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+            if ( !PhylogenyMethods.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
                     .isSpeciationOrDuplication() ) {
                 return false;
             }
-            if ( !( pm.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isDuplication() ) ) {
+            if ( !( PhylogenyMethods.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+                    .isDuplication() ) ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2 = TestGSDI
@@ -147,17 +150,20 @@ public final class TestGSDI {
             if ( sdi2.getDuplicationsSum() != 0 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
+            if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
                     .isSpeciationOrDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g3 = TestGSDI
@@ -166,17 +172,20 @@ public final class TestGSDI {
             if ( sdi3.getDuplicationsSum() != 0 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
+            if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
                     .isSpeciationOrDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g4 = TestGSDI
@@ -185,13 +194,16 @@ public final class TestGSDI {
             if ( sdi4.getDuplicationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent().isDuplication() ) {
+            if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent()
+                    .isDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g5 = TestGSDI
@@ -200,19 +212,24 @@ public final class TestGSDI {
             if ( sdi5.getDuplicationsSum() != 3 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent().isDuplication() ) {
+            if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent()
+                    .isDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent().isDuplication() ) {
+            if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent()
+                    .isDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent().isDuplication() ) {
+            if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
+                    .isDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny species7 = TestGSDI.createPhylogeny( "(((((((([&&NHX:S=a1],[&&NHX:S=a2]),"
@@ -265,7 +282,8 @@ public final class TestGSDI {
             if ( sdi2_0.getSpeciationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_1 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],h2[&&NHX:S=h2])" );
@@ -279,7 +297,8 @@ public final class TestGSDI {
             if ( sdi2_1.getSpeciationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_2 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],p4[&&NHX:S=p4])" );
@@ -293,7 +312,8 @@ public final class TestGSDI {
             if ( sdi2_2.getSpeciationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_3 = TestGSDI.createPhylogeny( "(e2a[&&NHX:S=e2],e2b[&&NHX:S=e2])" );
@@ -307,7 +327,8 @@ public final class TestGSDI {
             if ( sdi2_3.getSpeciationsSum() != 0 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData().getEvent().isDuplication() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData()
+                    .getEvent().isDuplication() ) {
                 return false;
             }
             final Phylogeny g2_4 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),i3[&&NHX:S=i3])" );
@@ -321,10 +342,12 @@ public final class TestGSDI {
             if ( sdi2_4.getSpeciationsSum() != 2 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_5 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),f3[&&NHX:S=f3])" );
@@ -338,10 +361,12 @@ public final class TestGSDI {
             if ( sdi2_5.getSpeciationsSum() != 2 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_6 = TestGSDI.createPhylogeny( "((j3[&&NHX:S=j3],i4[&&NHX:S=i4]),f3[&&NHX:S=f3])" );
@@ -355,10 +380,12 @@ public final class TestGSDI {
             if ( sdi2_6.getSpeciationsSum() != 2 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_7 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k1[&&NHX:S=k1]),i1[&&NHX:S=i1])" );
@@ -372,10 +399,11 @@ public final class TestGSDI {
             if ( sdi2_7.getSpeciationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
+            if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
                     .isSpeciationOrDuplication() ) {
                 return false;
             }
@@ -390,11 +418,12 @@ public final class TestGSDI {
             if ( sdi2_8.getSpeciationsSum() != 1 ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
+            if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
                     .isSpeciationOrDuplication() ) {
                 return false;
             }
-            if ( !pm.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent().isSpeciation() ) {
+            if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent()
+                    .isSpeciation() ) {
                 return false;
             }
             final Phylogeny g2_9 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
index 60828bd..6b76f92 100644 (file)
@@ -87,8 +87,8 @@ public class BasicSequence implements Sequence {
     @Override
     public int getNumberOfGapResidues() {
         int gaps = 0;
-        for( int i = 0; i < _mol_sequence.length; ++i ) {
-            if ( _mol_sequence[ i ] == GAP ) {
+        for( final char element : _mol_sequence ) {
+            if ( element == GAP ) {
                 ++gaps;
             }
         }
index 4de0d28..a037ed5 100644 (file)
@@ -48,7 +48,7 @@ public class CountsBasedPairwiseDomainSimilarity implements PairwiseDomainSimila
         if ( abs_copy_number_difference > counts_sum ) {
             throw new IllegalArgumentException( "attempt to use absolute copy number difference larger than copy number sum" );
         }
-        _score = 1.0 - ( double ) abs_copy_number_difference / counts_sum;
+        _score = 1.0 - ( ( double ) abs_copy_number_difference / counts_sum );
     }
 
     /**
index c3691bf..1a742fd 100644 (file)
@@ -556,7 +556,7 @@ public final class DomainCountsDifferenceUtil {
         for( final BinaryDomainCombination bdc : all_bdcs ) {
             if ( ( high_copy_base_values.get( bdc ) > 0 ) && ( high_copy_target_values.get( bdc ) > 0 )
                     && ( high_copy_base_values.get( bdc ) >= low_copy_values.get( bdc ) ) ) {
-                if ( high_copy_target_values.get( bdc ) >= min_diff + ( factor * low_copy_values.get( bdc ) ) ) {
+                if ( high_copy_target_values.get( bdc ) >= ( min_diff + ( factor * low_copy_values.get( bdc ) ) ) ) {
                     if ( low_copy_values.get( bdc ) <= 0.0 ) {
                         ++total_absense_counter;
                     }
@@ -680,8 +680,8 @@ public final class DomainCountsDifferenceUtil {
         for( final DomainId domain_id : all_domains ) {
             if ( ( high_copy_base_values.get( domain_id ) > 0 ) && ( high_copy_target_values.get( domain_id ) > 0 )
                     && ( high_copy_base_values.get( domain_id ) >= low_copy_values.get( domain_id ) ) ) {
-                if ( high_copy_target_values.get( domain_id ) >= min_diff
-                        + ( factor * low_copy_values.get( domain_id ) ) ) {
+                if ( high_copy_target_values.get( domain_id ) >= ( min_diff + ( factor * low_copy_values
+                        .get( domain_id ) ) ) ) {
                     if ( low_copy_values.get( domain_id ) <= 0.0 ) {
                         ++total_absense_counter;
                     }
index 81c6dbf..7317338 100644 (file)
@@ -137,7 +137,7 @@ class PrintableSpeciesSpecificDomainSimilariyData implements SpeciesSpecificDoma
                 sb.append( ":" );
                 sb.append( getCombinableDomainIdToCountsMap().get( domain_id ) );
             }
-            if ( i < ids.size() - 1 ) {
+            if ( i < ( ids.size() - 1 ) ) {
                 sb.append( "," );
             }
         }
index b7590aa..6b3639f 100644 (file)
@@ -372,7 +372,7 @@ public final class SurfacingUtil {
                         nodes.add( n );
                     }
                 }
-                for( int i = 0; i < nodes.size() - 1; ++i ) {
+                for( int i = 0; i < ( nodes.size() - 1 ); ++i ) {
                     for( int j = i + 1; j < nodes.size(); ++j ) {
                         final PhylogenyNode lca = PhylogenyMethods.calculateLCA( nodes.get( i ), nodes.get( j ) );
                         String rank = "unknown";
@@ -1621,58 +1621,50 @@ public final class SurfacingUtil {
                     + all_pfams_encountered.size() );
             ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams without a mapping                 : "
                     + pfams_without_mappings_counter + " ["
-                    + ( 100 * pfams_without_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * pfams_without_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
             ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams without mapping to proc. or func. : "
                     + pfams_without_mappings_to_bp_or_mf_counter + " ["
-                    + ( 100 * pfams_without_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
-            ForesterUtil.programMessage( surfacing.PRG_NAME,
-                                         "Pfams with a mapping                    : " + pfams_with_mappings_counter
-                                                 + " ["
-                                                 + ( 100 * pfams_with_mappings_counter / all_pfams_encountered.size() )
-                                                 + "%]" );
+                    + ( ( 100 * pfams_without_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
+            ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with a mapping                    : "
+                    + pfams_with_mappings_counter + " ["
+                    + ( ( 100 * pfams_with_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
             ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with a mapping to proc. or func.  : "
                     + pfams_with_mappings_to_bp_or_mf_counter + " ["
-                    + ( 100 * pfams_with_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
-            ForesterUtil.programMessage( surfacing.PRG_NAME,
-                                         "Pfams with mapping to biological process: " + biological_process_counter
-                                                 + " ["
-                                                 + ( 100 * biological_process_counter / all_pfams_encountered.size() )
-                                                 + "%]" );
-            ForesterUtil.programMessage( surfacing.PRG_NAME,
-                                         "Pfams with mapping to molecular function: " + molecular_function_counter
-                                                 + " ["
-                                                 + ( 100 * molecular_function_counter / all_pfams_encountered.size() )
-                                                 + "%]" );
-            ForesterUtil.programMessage( surfacing.PRG_NAME,
-                                         "Pfams with mapping to cellular component: " + cellular_component_counter
-                                                 + " ["
-                                                 + ( 100 * cellular_component_counter / all_pfams_encountered.size() )
-                                                 + "%]" );
+                    + ( ( 100 * pfams_with_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
+            ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to biological process: "
+                    + biological_process_counter + " ["
+                    + ( ( 100 * biological_process_counter ) / all_pfams_encountered.size() ) + "%]" );
+            ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to molecular function: "
+                    + molecular_function_counter + " ["
+                    + ( ( 100 * molecular_function_counter ) / all_pfams_encountered.size() ) + "%]" );
+            ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to cellular component: "
+                    + cellular_component_counter + " ["
+                    + ( ( 100 * cellular_component_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Sum of Pfams encountered                : " + all_pfams_encountered.size() );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams without a mapping                 : " + pfams_without_mappings_counter
-                    + " [" + ( 100 * pfams_without_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+                    + " [" + ( ( 100 * pfams_without_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams without mapping to proc. or func. : "
                     + pfams_without_mappings_to_bp_or_mf_counter + " ["
-                    + ( 100 * pfams_without_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * pfams_without_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams with a mapping                    : " + pfams_with_mappings_counter + " ["
-                    + ( 100 * pfams_with_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * pfams_with_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams with a mapping to proc. or func.  : "
                     + pfams_with_mappings_to_bp_or_mf_counter + " ["
-                    + ( 100 * pfams_with_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * pfams_with_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams with mapping to biological process: " + biological_process_counter + " ["
-                    + ( 100 * biological_process_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * biological_process_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams with mapping to molecular function: " + molecular_function_counter + " ["
-                    + ( 100 * molecular_function_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * molecular_function_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.write( "# Pfams with mapping to cellular component: " + cellular_component_counter + " ["
-                    + ( 100 * cellular_component_counter / all_pfams_encountered.size() ) + "%]" );
+                    + ( ( 100 * cellular_component_counter ) / all_pfams_encountered.size() ) + "%]" );
             summary_writer.write( ForesterUtil.LINE_SEPARATOR );
             summary_writer.close();
         }
index 44c9115..5cdd6eb 100644 (file)
@@ -442,8 +442,8 @@ public class TestSurfacing {
             if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(),
-                                         ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 5 + 1.0 / 2 + 2.0 / 7 ) / 6 ) ) {
+            if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 5 )
+                    + ( 1.0 / 2 ) + ( 2.0 / 7 ) ) / 6 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
@@ -514,7 +514,7 @@ public class TestSurfacing {
             if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( 2.0 / 5 + 2.0 / 3 + 1.0 / 2 ) / 3 ) ) {
+            if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + ( 2.0 / 3 ) + ( 1.0 / 2 ) ) / 3 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
@@ -592,8 +592,8 @@ public class TestSurfacing {
             if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(),
-                                         ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 6 + 1.0 / 2 + 2.0 / 8 ) / 6 ) ) {
+            if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 6 )
+                    + ( 1.0 / 2 ) + ( 2.0 / 8 ) ) / 6 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
@@ -736,14 +736,15 @@ public class TestSurfacing {
             if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa4_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
-                    + 1 - 11.0 / 13 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa4_d.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
                 return false;
             }
             if ( sa4_d.getN() != 6 ) {
@@ -777,14 +778,15 @@ public class TestSurfacing {
             if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa4_p.getMeanSimilarityScore(),
-                                         ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa4_p.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
                 return false;
             }
             if ( sa4_p.getN() != 6 ) {
@@ -851,14 +853,15 @@ public class TestSurfacing {
             if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa5_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
-                    + 1 - 11.0 / 13 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa5_d.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
                 return false;
             }
             if ( sa5_d.getN() != 6 ) {
@@ -901,14 +904,15 @@ public class TestSurfacing {
             if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa5_p.getMeanSimilarityScore(),
-                                         ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa5_p.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
                 return false;
             }
             if ( sa5_p.getN() != 6 ) {
@@ -984,14 +988,15 @@ public class TestSurfacing {
             if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa6_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
-                    + 1 - 11.0 / 13 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa6_d.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
                 return false;
             }
             if ( sa6_d.getN() != 6 ) {
@@ -1034,14 +1039,15 @@ public class TestSurfacing {
             if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa6_p.getMeanSimilarityScore(),
-                                         ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+            if ( !TestSurfacing
+                    .isEqual( sa6_p.getMeanSimilarityScore(),
+                              ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
                 return false;
             }
             if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
                 return false;
             }
-            if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+            if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
                 return false;
             }
             if ( sa6_p.getN() != 6 ) {
@@ -1996,7 +2002,7 @@ public class TestSurfacing {
             two.setKeyDomainCount( 3 );
             final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
             PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
-            if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 3 - 2.0 ) / ( 2 + 3 ) ) ) {
+            if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( ( 3 - 2.0 ) / ( 2 + 3 ) ) ) ) {
                 return false;
             }
             if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
@@ -2014,7 +2020,7 @@ public class TestSurfacing {
             one.setKeyDomainCount( 1 );
             two.setKeyDomainCount( 1000 );
             s1 = calc.calculateSimilarity( one, two );
-            if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - 999.0 / 1001 ) ) {
+            if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 999.0 / 1001 ) ) ) {
                 return false;
             }
             if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
@@ -3435,17 +3441,17 @@ public class TestSurfacing {
                 return false;
             }
             if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 25.0 - 5.0 ) / 25.0 ) ) {
+                           1.0 - ( ( 25.0 - 5.0 ) / 25.0 ) ) ) {
                 return false;
             }
             if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 22.0 - 3.0 ) / 22.0 ) ) {
+                           1.0 - ( ( 22.0 - 3.0 ) / 22.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
+            if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
+            if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
                 return false;
             }
             final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
@@ -3761,34 +3767,34 @@ public class TestSurfacing {
                 return false;
             }
             if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
+                           1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
+            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
                 return false;
             }
             calc_u.setAllowDomainsToBeIgnored( false );
             if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
+                           1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
+            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
                 return false;
             }
             calc_u.setAllowDomainsToBeIgnored( true );
             if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
+                           1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
+            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
                 return false;
             }
             calc_u.deleteAllDomainIdsToIgnore();
             if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
-                           1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
+                           1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
                 return false;
             }
-            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
+            if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
                 return false;
             }
         }
index 1808421..4592bdf 100644 (file)
@@ -136,7 +136,7 @@ public final class Test {
 
     private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
         final PhylogenyMethods pm = PhylogenyMethods.getInstance();
-        return pm.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
+        return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
     }
 
     public static boolean isEqual( final double a, final double b ) {
@@ -477,6 +477,15 @@ public final class Test {
             System.out.println( "failed." );
             failed++;
         }
+        System.out.print( "Finding of LCA 2: " );
+        if ( Test.testGetLCA2() ) {
+            System.out.println( "OK." );
+            succeeded++;
+        }
+        else {
+            System.out.println( "failed." );
+            failed++;
+        }
         System.out.print( "Calculation of distance between nodes: " );
         if ( Test.testGetDistance() ) {
             System.out.println( "OK." );
@@ -699,13 +708,13 @@ public final class Test {
         else {
             path = "/home/czmasek/bin/mafft";
         }
-        if ( !Mafft.isInstalled( path ) ) {
+        if ( !MsaInferrer.isInstalled( path ) ) {
             path = "mafft";
         }
-        if ( !Mafft.isInstalled( path ) ) {
+        if ( !MsaInferrer.isInstalled( path ) ) {
             path = "/usr/local/bin/mafft";
         }
-        if ( Mafft.isInstalled( path ) ) {
+        if ( MsaInferrer.isInstalled( path ) ) {
             System.out.print( "MAFFT (external program): " );
             if ( Test.testMafft( path ) ) {
                 System.out.println( "OK." );
@@ -3415,6 +3424,291 @@ public final class Test {
         return true;
     }
 
+    private static boolean testGetLCA2() {
+        try {
+            final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+            final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
+                                                 new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p1 );
+            final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                          p1.getNode( "A" ) );
+            if ( !A.getName().equals( "A" ) ) {
+                return false;
+            }
+            final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
+                                                                                           p1.getNode( "gh" ) );
+            if ( !gh.getName().equals( "gh" ) ) {
+                return false;
+            }
+            final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                           p1.getNode( "B" ) );
+            if ( !ab.getName().equals( "ab" ) ) {
+                return false;
+            }
+            final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
+                                                                                            p1.getNode( "A" ) );
+            if ( !ab2.getName().equals( "ab" ) ) {
+                return false;
+            }
+            final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
+                                                                                            p1.getNode( "G" ) );
+            if ( !gh2.getName().equals( "gh" ) ) {
+                return false;
+            }
+            final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
+                                                                                            p1.getNode( "H" ) );
+            if ( !gh3.getName().equals( "gh" ) ) {
+                return false;
+            }
+            final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
+                                                                                            p1.getNode( "A" ) );
+            if ( !abc.getName().equals( "abc" ) ) {
+                return false;
+            }
+            final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                             p1.getNode( "C" ) );
+            if ( !abc2.getName().equals( "abc" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                             p1.getNode( "D" ) );
+            if ( !abcd.getName().equals( "abcd" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
+                                                                                              p1.getNode( "A" ) );
+            if ( !abcd2.getName().equals( "abcd" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                               p1.getNode( "F" ) );
+            if ( !abcdef.getName().equals( "abcdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
+                                                                                                p1.getNode( "A" ) );
+            if ( !abcdef2.getName().equals( "abcdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
+                                                                                                p1.getNode( "F" ) );
+            if ( !abcdef3.getName().equals( "abcdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
+                                                                                                p1.getNode( "ab" ) );
+            if ( !abcdef4.getName().equals( "abcdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                              p1.getNode( "E" ) );
+            if ( !abcde.getName().equals( "abcde" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
+                                                                                               p1.getNode( "A" ) );
+            if ( !abcde2.getName().equals( "abcde" ) ) {
+                return false;
+            }
+            final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
+                                                                                          p1.getNode( "abcdefgh" ) );
+            if ( !r.getName().equals( "abcdefgh" ) ) {
+                return false;
+            }
+            final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+                                                                                           p1.getNode( "H" ) );
+            if ( !r2.getName().equals( "abcdefgh" ) ) {
+                return false;
+            }
+            final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
+                                                                                           p1.getNode( "A" ) );
+            if ( !r3.getName().equals( "abcdefgh" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
+                                                                                               p1.getNode( "abcde" ) );
+            if ( !abcde3.getName().equals( "abcde" ) ) {
+                return false;
+            }
+            final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
+                                                                                               p1.getNode( "E" ) );
+            if ( !abcde4.getName().equals( "abcde" ) ) {
+                return false;
+            }
+            final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
+                                                                                            p1.getNode( "B" ) );
+            if ( !ab3.getName().equals( "ab" ) ) {
+                return false;
+            }
+            final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
+                                                                                            p1.getNode( "ab" ) );
+            if ( !ab4.getName().equals( "ab" ) ) {
+                return false;
+            }
+            final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p2 );
+            final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+                                                                                           p2.getNode( "d" ) );
+            if ( !cd.getName().equals( "cd" ) ) {
+                return false;
+            }
+            final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
+                                                                                            p2.getNode( "c" ) );
+            if ( !cd2.getName().equals( "cd" ) ) {
+                return false;
+            }
+            final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+                                                                                            p2.getNode( "e" ) );
+            if ( !cde.getName().equals( "cde" ) ) {
+                return false;
+            }
+            final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
+                                                                                             p2.getNode( "c" ) );
+            if ( !cde2.getName().equals( "cde" ) ) {
+                return false;
+            }
+            final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+                                                                                             p2.getNode( "f" ) );
+            if ( !cdef.getName().equals( "cdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
+                                                                                              p2.getNode( "f" ) );
+            if ( !cdef2.getName().equals( "cdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
+                                                                                              p2.getNode( "d" ) );
+            if ( !cdef3.getName().equals( "cdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+                                                                                           p2.getNode( "a" ) );
+            if ( !rt.getName().equals( "r" ) ) {
+                return false;
+            }
+            final Phylogeny p3 = factory
+                    .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
+                             new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p3 );
+            final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
+                                                                                             p3.getNode( "c" ) );
+            if ( !bc_3.getName().equals( "bc" ) ) {
+                return false;
+            }
+            final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+                                                                                             p3.getNode( "c" ) );
+            if ( !ac_3.getName().equals( "abc" ) ) {
+                return false;
+            }
+            final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+                                                                                             p3.getNode( "d" ) );
+            if ( !ad_3.getName().equals( "abcde" ) ) {
+                return false;
+            }
+            final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+                                                                                             p3.getNode( "f" ) );
+            if ( !af_3.getName().equals( "abcdef" ) ) {
+                return false;
+            }
+            final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+                                                                                             p3.getNode( "g" ) );
+            if ( !ag_3.getName().equals( "" ) ) {
+                return false;
+            }
+            if ( !ag_3.isRoot() ) {
+                return false;
+            }
+            final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+                                                                                             p3.getNode( "l" ) );
+            if ( !al_3.getName().equals( "" ) ) {
+                return false;
+            }
+            if ( !al_3.isRoot() ) {
+                return false;
+            }
+            final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
+                                                                                             p3.getNode( "l" ) );
+            if ( !kl_3.getName().equals( "" ) ) {
+                return false;
+            }
+            if ( !kl_3.isRoot() ) {
+                return false;
+            }
+            final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
+                                                                                             p3.getNode( "l" ) );
+            if ( !fl_3.getName().equals( "" ) ) {
+                return false;
+            }
+            if ( !fl_3.isRoot() ) {
+                return false;
+            }
+            final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
+                                                                                             p3.getNode( "k" ) );
+            if ( !gk_3.getName().equals( "ghijk" ) ) {
+                return false;
+            }
+            final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p4 );
+            final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
+                                                                                            p4.getNode( "c" ) );
+            if ( !r_4.getName().equals( "r" ) ) {
+                return false;
+            }
+            final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p5 );
+            final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
+                                                                                            p5.getNode( "c" ) );
+            if ( !r_5.getName().equals( "root" ) ) {
+                return false;
+            }
+            final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p6 );
+            final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
+                                                                                            p6.getNode( "a" ) );
+            if ( !r_6.getName().equals( "rot" ) ) {
+                return false;
+            }
+            final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
+            PhylogenyMethods.preOrderReId( p7 );
+            final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
+                                                                                            p7.getNode( "e" ) );
+            if ( !r_7.getName().equals( "rott" ) ) {
+                return false;
+            }
+            final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+                                                                                             p7.getNode( "a" ) );
+            if ( !r_71.getName().equals( "rott" ) ) {
+                return false;
+            }
+            final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+                                                                                             p7.getNode( "rott" ) );
+            if ( !r_72.getName().equals( "rott" ) ) {
+                return false;
+            }
+            final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
+                                                                                             p7.getNode( "a" ) );
+            if ( !r_73.getName().equals( "rott" ) ) {
+                return false;
+            }
+            final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
+                                                                                             p7.getNode( "rott" ) );
+            if ( !r_74.getName().equals( "rott" ) ) {
+                return false;
+            }
+            final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+                                                                                             p7.getNode( "e" ) );
+            if ( !r_75.getName().equals( "e" ) ) {
+                return false;
+            }
+        }
+        catch ( final Exception e ) {
+            e.printStackTrace( System.out );
+            return false;
+        }
+        return true;
+    }
+
     private static boolean testHmmscanOutputParser() {
         final String test_dir = Test.PATH_TO_TEST_DATA;
         try {
@@ -5775,46 +6069,46 @@ public final class Test {
             if ( p.getNode( "r" ).getId() != count ) {
                 return false;
             }
-            if ( p.getNode( "A" ).getId() != count + 1 ) {
+            if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
                 return false;
             }
-            if ( p.getNode( "B" ).getId() != count + 1 ) {
+            if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
                 return false;
             }
-            if ( p.getNode( "C" ).getId() != count + 1 ) {
+            if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
                 return false;
             }
-            if ( p.getNode( "1" ).getId() != count + 2 ) {
+            if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "2" ).getId() != count + 2 ) {
+            if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "3" ).getId() != count + 2 ) {
+            if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "4" ).getId() != count + 2 ) {
+            if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "5" ).getId() != count + 2 ) {
+            if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "6" ).getId() != count + 2 ) {
+            if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
                 return false;
             }
-            if ( p.getNode( "a" ).getId() != count + 3 ) {
+            if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
                 return false;
             }
-            if ( p.getNode( "b" ).getId() != count + 3 ) {
+            if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
                 return false;
             }
-            if ( p.getNode( "X" ).getId() != count + 4 ) {
+            if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
                 return false;
             }
-            if ( p.getNode( "Y" ).getId() != count + 4 ) {
+            if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
                 return false;
             }
-            if ( p.getNode( "Z" ).getId() != count + 4 ) {
+            if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
                 return false;
             }
         }
index cf3d280..2bf5ad2 100644 (file)
@@ -372,11 +372,9 @@ public final class PhylogenyDecorator {
                                  final boolean picky,
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map )
             throws IllegalArgumentException, NHXFormatException, PhyloXmlDataFormatException {
-        for( int i = 0; i < phylogenies.length; ++i ) {
-            PhylogenyDecorator.decorate( phylogenies[ i ],
-                                         map,
-                                         picky,
-                                         numbers_of_chars_allowed_to_remove_if_not_found_in_map );
+        for( final Phylogeny phylogenie : phylogenies ) {
+            PhylogenyDecorator
+                    .decorate( phylogenie, map, picky, numbers_of_chars_allowed_to_remove_if_not_found_in_map );
         }
     }
 
@@ -392,8 +390,8 @@ public final class PhylogenyDecorator {
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
                                  final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
             PhyloXmlDataFormatException {
-        for( int i = 0; i < phylogenies.length; ++i ) {
-            PhylogenyDecorator.decorate( phylogenies[ i ],
+        for( final Phylogeny phylogenie : phylogenies ) {
+            PhylogenyDecorator.decorate( phylogenie,
                                          map,
                                          field,
                                          extract_bracketed_scientific_name,
@@ -420,8 +418,8 @@ public final class PhylogenyDecorator {
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
                                  final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
             PhyloXmlDataFormatException {
-        for( int i = 0; i < phylogenies.length; ++i ) {
-            PhylogenyDecorator.decorate( phylogenies[ i ],
+        for( final Phylogeny phylogenie : phylogenies ) {
+            PhylogenyDecorator.decorate( phylogenie,
                                          map,
                                          field,
                                          extract_bracketed_scientific_name,
index 29bd2dd..ebd8792 100644 (file)
@@ -150,7 +150,7 @@ public class TreeSplitMatrix {
         if ( q_counts != counts ) {
             positive_matches = false;
         }
-        if ( q_counts != keySet().size() - counts ) {
+        if ( q_counts != ( keySet().size() - counts ) ) {
             negative_matches = false;
         }
         if ( !positive_matches && !negative_matches ) {
index ea64f40..f9b0bb3 100644 (file)
@@ -68,7 +68,7 @@ public class AsciiHistogram {
         }
         for( int i = 0; i < bins.length; ++i ) {
             final int count = bins[ i ];
-            final double label = ForesterUtil.round( ( min + i * ( 1.0 / binning_factor ) ), digits );
+            final double label = ForesterUtil.round( ( min + ( i * ( 1.0 / binning_factor ) ) ), digits );
             if ( !ForesterUtil.isEmpty( indent ) ) {
                 sb.append( indent );
             }
index 6f6d0a8..2c7afc8 100644 (file)
@@ -107,7 +107,7 @@ public class BasicTable<E> {
     }
 
     public E getValue( final int col, final int row ) throws IllegalArgumentException {
-        if ( ( row > getNumberOfRows() - 1 ) || ( row < 0 ) ) {
+        if ( ( row > ( getNumberOfRows() - 1 ) ) || ( row < 0 ) ) {
             throw new IllegalArgumentException( "value for row (" + row + ") is out of range [number of rows: "
                     + getNumberOfRows() + "]" );
         }
@@ -151,10 +151,10 @@ public class BasicTable<E> {
         if ( ( row < 0 ) || ( col < 0 ) ) {
             throw new IllegalArgumentException( "attempt to use negative values for row or column" );
         }
-        if ( row > getNumberOfRows() - 1 ) {
+        if ( row > ( getNumberOfRows() - 1 ) ) {
             setMaxRow( row );
         }
-        if ( col > getNumberOfColumns() - 1 ) {
+        if ( col > ( getNumberOfColumns() - 1 ) ) {
             setMaxCol( col );
         }
         final String row_key = "" + row;
@@ -175,11 +175,11 @@ public class BasicTable<E> {
         for( int row = 0; row < getNumberOfRows(); ++row ) {
             for( int col = 0; col < getNumberOfColumns(); ++col ) {
                 sb.append( getValue( col, row ) );
-                if ( col < getNumberOfColumns() - 1 ) {
+                if ( col < ( getNumberOfColumns() - 1 ) ) {
                     sb.append( " " );
                 }
             }
-            if ( row < getNumberOfRows() - 1 ) {
+            if ( row < ( getNumberOfRows() - 1 ) ) {
                 sb.append( ForesterUtil.LINE_SEPARATOR );
             }
         }
index 63e7e13..2917a31 100644 (file)
@@ -95,7 +95,7 @@ public class BasicTableParser {
                 if ( use_last_separator_only ) {
                     final String e[] = line.split( column_delimiter );
                     final StringBuffer rest = new StringBuffer();
-                    for( int i = 0; i < e.length - 1; ++i ) {
+                    for( int i = 0; i < ( e.length - 1 ); ++i ) {
                         rest.append( e[ i ].trim() );
                     }
                     table.setValue( 0, row, rest.toString() );
index e3b9276..91f11bd 100644 (file)
@@ -182,7 +182,7 @@ public final class CommandLineArguments {
         for( int i = 0; i < args.length; ++i ) {
             final String arg = args[ i ].trim();
             _command_line_str += arg;
-            if ( i < args.length - 1 ) {
+            if ( i < ( args.length - 1 ) ) {
                 _command_line_str += " ";
             }
             if ( arg.startsWith( CommandLineArguments.EXTENDED_OPTIONS_PREFIX ) ) {
index eab885d..08c3b9e 100644 (file)
@@ -482,7 +482,7 @@ public final class ForesterUtil {
     }
 
     final public static boolean isEven( final int n ) {
-        return n % 2 == 0;
+        return ( n % 2 ) == 0;
     }
 
     /**
@@ -502,10 +502,9 @@ public final class ForesterUtil {
         if ( ( a.length < 1 ) || ( b.length < 1 ) ) {
             return false;
         }
-        for( int i = 0; i < a.length; ++i ) {
-            final String ai = a[ i ];
-            for( int j = 0; j < b.length; ++j ) {
-                if ( ( ai != null ) && ( b[ j ] != null ) && ai.equals( b[ j ] ) ) {
+        for( final String ai : a ) {
+            for( final String element : b ) {
+                if ( ( ai != null ) && ( element != null ) && ai.equals( element ) ) {
                     return true;
                 }
             }
@@ -808,7 +807,7 @@ public final class ForesterUtil {
      */
     final public static String removeWhiteSpace( String s ) {
         int i;
-        for( i = 0; i <= s.length() - 1; i++ ) {
+        for( i = 0; i <= ( s.length() - 1 ); i++ ) {
             if ( ( s.charAt( i ) == ' ' ) || ( s.charAt( i ) == '\t' ) || ( s.charAt( i ) == '\n' )
                     || ( s.charAt( i ) == '\r' ) ) {
                 s = s.substring( 0, i ) + s.substring( i + 1 );
@@ -874,7 +873,7 @@ public final class ForesterUtil {
     final public static String stringArrayToString( final String[] a, final String separator ) {
         final StringBuilder sb = new StringBuilder();
         if ( ( a != null ) && ( a.length > 0 ) ) {
-            for( int i = 0; i < a.length - 1; ++i ) {
+            for( int i = 0; i < ( a.length - 1 ); ++i ) {
                 sb.append( a[ i ] + separator );
             }
             sb.append( a[ a.length - 1 ] );
@@ -897,7 +896,7 @@ public final class ForesterUtil {
     final public static String stringListToString( final List<String> l, final String separator ) {
         final StringBuilder sb = new StringBuilder();
         if ( ( l != null ) && ( l.size() > 0 ) ) {
-            for( int i = 0; i < l.size() - 1; ++i ) {
+            for( int i = 0; i < ( l.size() - 1 ); ++i ) {
                 sb.append( l.get( i ) + separator );
             }
             sb.append( l.get( l.size() - 1 ) );
@@ -955,7 +954,7 @@ public final class ForesterUtil {
                 ls = -1;
                 start = i + 1;
             }
-            if ( i > start + width - 1 ) {
+            if ( i > ( ( start + width ) - 1 ) ) {
                 if ( ls != -1 ) {
                     sb.setCharAt( ls, '\n' );
                     start = ls + 1;