From: kjvdheide Date: Sat, 28 Oct 2017 20:50:28 +0000 (+0100) Subject: Changed more concrete DistanceMatrix references to reference interface X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=09a8c723e9ab220999f25c6be635282f18186be7;p=jalview.git Changed more concrete DistanceMatrix references to reference interface --- diff --git a/forester/java/src/org/forester/application/nj.java b/forester/java/src/org/forester/application/nj.java index dca5d08..f210058 100644 --- a/forester/java/src/org/forester/application/nj.java +++ b/forester/java/src/org/forester/application/nj.java @@ -33,7 +33,6 @@ import java.util.Date; import java.util.List; import org.forester.evoinference.distance.NeighborJoining; -import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.io.parsers.SymmetricalDistanceMatrixParser; import org.forester.io.writers.PhylogenyWriter; @@ -122,7 +121,7 @@ public class nj { final NeighborJoining nj = NeighborJoining.createInstance( verbose, 6 ); final long start_time = new Date().getTime(); for( final DistanceMatrix matrix : matrices ) { - ps.add( nj.execute( ( BasicSymmetricalDistanceMatrix ) matrix ) ); + ps.add( nj.execute( ( DistanceMatrix ) matrix ) ); } final long end_time = new Date().getTime(); final PhylogenyWriter w = new PhylogenyWriter(); diff --git a/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java b/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java index 1e8f3fc..cc62751 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/PhylogeneticInferrer.java @@ -37,6 +37,7 @@ import org.forester.archaeopteryx.MainFrameApplication; import org.forester.evoinference.distance.NeighborJoiningF; import org.forester.evoinference.distance.PairwiseDistanceCalculator; import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; +import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.evoinference.tools.BootstrapResampler; import org.forester.msa.BasicMsa; import org.forester.msa.Mafft; @@ -116,7 +117,7 @@ public class PhylogeneticInferrer extends RunnableProcess { } private Phylogeny inferPhylogeny( final Msa msa ) { - BasicSymmetricalDistanceMatrix m = null; + DistanceMatrix m = null; switch ( _options.getPwdDistanceMethod() ) { case KIMURA_DISTANCE: m = PairwiseDistanceCalculator.calcKimuraDistances( msa ); @@ -274,7 +275,7 @@ public class PhylogeneticInferrer extends RunnableProcess { return msa; } - private void writeToFiles( final BasicSymmetricalDistanceMatrix m ) { + private void writeToFiles( final DistanceMatrix m ) { if ( !ForesterUtil.isEmpty( _options.getIntermediateFilesBase() ) ) { try { final BufferedWriter msa_writer = new BufferedWriter( new FileWriter( _options.getIntermediateFilesBase() diff --git a/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java b/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java index 5b7b99c..a9c16e9 100644 --- a/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java +++ b/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java @@ -439,7 +439,7 @@ public class TestPhylogenyReconstruction { try { final Msa msa0 = GeneralMsaParser.parseMsa( new FileInputStream( test_dir + ForesterUtil.FILE_SEPARATOR + "bcl.aln" ) ); - final BasicSymmetricalDistanceMatrix pwd0 = PairwiseDistanceCalculator.calcKimuraDistances( msa0 ); + final DistanceMatrix pwd0 = PairwiseDistanceCalculator.calcKimuraDistances( msa0 ); if ( pwd0.getSize() != 120 ) { return false; } diff --git a/forester/java/src/org/forester/evoinference/distance/NeighborJoiningF.java b/forester/java/src/org/forester/evoinference/distance/NeighborJoiningF.java index f13e520..2f10c40 100644 --- a/forester/java/src/org/forester/evoinference/distance/NeighborJoiningF.java +++ b/forester/java/src/org/forester/evoinference/distance/NeighborJoiningF.java @@ -29,7 +29,6 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; -import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; @@ -118,9 +117,9 @@ public final class NeighborJoiningF { return phylogeny; } - public final List execute( final List distances_list ) { + public final List execute( final List distances_list ) { final List pl = new ArrayList(); - for( final BasicSymmetricalDistanceMatrix distances : distances_list ) { + for( final DistanceMatrix distances : distances_list ) { pl.add( execute( distances ) ); } return pl; diff --git a/forester/java/src/org/forester/evoinference/distance/PairwiseDistanceCalculator.java b/forester/java/src/org/forester/evoinference/distance/PairwiseDistanceCalculator.java index 39a446f..2e1dbbc 100644 --- a/forester/java/src/org/forester/evoinference/distance/PairwiseDistanceCalculator.java +++ b/forester/java/src/org/forester/evoinference/distance/PairwiseDistanceCalculator.java @@ -26,6 +26,8 @@ package org.forester.evoinference.distance; import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; +import org.forester.evoinference.matrix.distance.DistanceMatrix; +import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.msa.Msa; public final class PairwiseDistanceCalculator { @@ -82,31 +84,31 @@ public final class PairwiseDistanceCalculator { return -Math.log( dp ); } - private BasicSymmetricalDistanceMatrix calcKimuraDistances() { + private DistanceMatrix calcKimuraDistances() { final int s = _msa.getNumberOfSequences(); - final BasicSymmetricalDistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); + final DistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); copyIdentifiers( s, d ); calcKimuraDistances( s, d ); return d; } - private BasicSymmetricalDistanceMatrix calcPoissonDistances() { + private DistanceMatrix calcPoissonDistances() { final int s = _msa.getNumberOfSequences(); - final BasicSymmetricalDistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); + final DistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); copyIdentifiers( s, d ); calcPoissonDistances( s, d ); return d; } - private BasicSymmetricalDistanceMatrix calcFractionalDissimilarities() { + private DistanceMatrix calcFractionalDissimilarities() { final int s = _msa.getNumberOfSequences(); - final BasicSymmetricalDistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); + final DistanceMatrix d = new BasicSymmetricalDistanceMatrix( s ); copyIdentifiers( s, d ); calcFractionalDissimilarities( s, d ); return d; } - private void calcKimuraDistances( final int s, final BasicSymmetricalDistanceMatrix d ) { + private void calcKimuraDistances( final int s, final DistanceMatrix d ) { for( int i = 1; i < s; i++ ) { for( int j = 0; j < i; j++ ) { d.setValue( i, j, calcKimuraDistance( i, j ) ); @@ -114,7 +116,7 @@ public final class PairwiseDistanceCalculator { } } - private void calcPoissonDistances( final int s, final BasicSymmetricalDistanceMatrix d ) { + private void calcPoissonDistances( final int s, final DistanceMatrix d ) { for( int i = 1; i < s; i++ ) { for( int j = 0; j < i; j++ ) { d.setValue( i, j, calcPoissonDistance( i, j ) ); @@ -122,7 +124,7 @@ public final class PairwiseDistanceCalculator { } } - private void calcFractionalDissimilarities( final int s, final BasicSymmetricalDistanceMatrix d ) { + private void calcFractionalDissimilarities( final int s, final DistanceMatrix d ) { for( int i = 1; i < s; i++ ) { for( int j = 0; j < i; j++ ) { d.setValue( i, j, calcFractionalDissimilarity( i, j ) ); @@ -135,28 +137,28 @@ public final class PairwiseDistanceCalculator { throw new CloneNotSupportedException(); } - private void copyIdentifiers( final int s, final BasicSymmetricalDistanceMatrix d ) { + private void copyIdentifiers( final int s, final DistanceMatrix d ) { for( int i = 0; i < s; i++ ) { d.setIdentifier( i, _msa.getIdentifier( i ) ); } } - public static BasicSymmetricalDistanceMatrix calcFractionalDissimilarities( final Msa msa ) { + public static DistanceMatrix calcFractionalDissimilarities( final Msa msa ) { return new PairwiseDistanceCalculator( msa, DEFAULT_VALUE_FOR_TOO_LARGE_DISTANCE_FOR_KIMURA_FORMULA ) .calcFractionalDissimilarities(); } - public static BasicSymmetricalDistanceMatrix calcPoissonDistances( final Msa msa ) { + public static DistanceMatrix calcPoissonDistances( final Msa msa ) { return new PairwiseDistanceCalculator( msa, DEFAULT_VALUE_FOR_TOO_LARGE_DISTANCE_FOR_KIMURA_FORMULA ) .calcPoissonDistances(); } - public static BasicSymmetricalDistanceMatrix calcKimuraDistances( final Msa msa ) { + public static DistanceMatrix calcKimuraDistances( final Msa msa ) { return new PairwiseDistanceCalculator( msa, DEFAULT_VALUE_FOR_TOO_LARGE_DISTANCE_FOR_KIMURA_FORMULA ) .calcKimuraDistances(); } - public static BasicSymmetricalDistanceMatrix calcKimuraDistances( final Msa msa, + public static DistanceMatrix calcKimuraDistances( final Msa msa, final double value_for_too_large_distance_for_kimura_formula ) { return new PairwiseDistanceCalculator( msa, value_for_too_large_distance_for_kimura_formula ) .calcKimuraDistances(); diff --git a/forester/java/src/org/forester/evoinference/distance/Sset.java b/forester/java/src/org/forester/evoinference/distance/Sset.java index c8f912f..9af6ea0 100644 --- a/forester/java/src/org/forester/evoinference/distance/Sset.java +++ b/forester/java/src/org/forester/evoinference/distance/Sset.java @@ -10,7 +10,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; +import org.forester.evoinference.matrix.distance.DistanceMatrix; public final class Sset { @@ -38,7 +38,7 @@ public final class Sset { return getS( j ).get( key ); } - final public void initialize( final BasicSymmetricalDistanceMatrix d ) { + final public void initialize( final DistanceMatrix d ) { for( int j = 0; j < d.getSize(); ++j ) { final TreeMap> map = new TreeMap>(); _data.add( map ); diff --git a/forester/java/src/org/forester/msa_compactor/MsaCompactor.java b/forester/java/src/org/forester/msa_compactor/MsaCompactor.java index 8a13b5c..950d8cb 100644 --- a/forester/java/src/org/forester/msa_compactor/MsaCompactor.java +++ b/forester/java/src/org/forester/msa_compactor/MsaCompactor.java @@ -43,6 +43,7 @@ import org.forester.evoinference.distance.NeighborJoiningF; import org.forester.evoinference.distance.PairwiseDistanceCalculator; import org.forester.evoinference.distance.PairwiseDistanceCalculator.PWD_DISTANCE_METHOD; import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; +import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.evoinference.tools.BootstrapResampler; import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION; import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; @@ -601,7 +602,7 @@ public class MsaCompactor { } private final Phylogeny collapse( final Msa msa, final int threshold ) { - final BasicSymmetricalDistanceMatrix m = PairwiseDistanceCalculator.calcFractionalDissimilarities( msa ); + final DistanceMatrix m = PairwiseDistanceCalculator.calcFractionalDissimilarities( msa ); //TODO return null; } @@ -610,7 +611,7 @@ public class MsaCompactor { final Msa msa, final boolean write_matrix, final String matrix_name ) { - BasicSymmetricalDistanceMatrix m = null; + DistanceMatrix m = null; switch ( pwd_distance_method ) { case KIMURA_DISTANCE: m = PairwiseDistanceCalculator.calcKimuraDistances( msa ); diff --git a/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java b/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java index b23f82b..ed4eae7 100644 --- a/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java +++ b/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java @@ -96,9 +96,9 @@ public class PairwiseGenomeComparator { final boolean calc_similarity_scores, final Phylogeny phy ) { init(); - final BasicSymmetricalDistanceMatrix domain_distance_scores_means = new BasicSymmetricalDistanceMatrix( number_of_genomes ); - final BasicSymmetricalDistanceMatrix shared_domains_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); - final BasicSymmetricalDistanceMatrix shared_binary_combinations_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); + final DistanceMatrix domain_distance_scores_means = new BasicSymmetricalDistanceMatrix( number_of_genomes ); + final DistanceMatrix shared_domains_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); + final DistanceMatrix shared_binary_combinations_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); if ( verbose ) { System.out.println(); System.out.println( "Pairwise genome distances:" ); @@ -264,8 +264,8 @@ public class PairwiseGenomeComparator { final SortedSet domain_ids_to_ignore = randomlyPickDomainIds( all_unique_domain_ids, jacknife_ratio, generator ); - final BasicSymmetricalDistanceMatrix shared_domains_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); - final BasicSymmetricalDistanceMatrix shared_binary_combinations_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); + final DistanceMatrix shared_domains_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); + final DistanceMatrix shared_binary_combinations_based_distances = new BasicSymmetricalDistanceMatrix( number_of_genomes ); for( int i = 0; i < number_of_genomes; ++i ) { final String species_i = species[ i ].getSpeciesId(); shared_domains_based_distances.setIdentifier( i, species_i ); diff --git a/forester/java/src/org/forester/surfacing/SurfacingUtil.java b/forester/java/src/org/forester/surfacing/SurfacingUtil.java index 3b52234..05a9101 100644 --- a/forester/java/src/org/forester/surfacing/SurfacingUtil.java +++ b/forester/java/src/org/forester/surfacing/SurfacingUtil.java @@ -60,7 +60,6 @@ import org.forester.evoinference.matrix.character.CharacterStateMatrix; import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates; import org.forester.evoinference.matrix.character.CharacterStateMatrix.Format; import org.forester.evoinference.matrix.character.CharacterStateMatrix.GainLossStates; -import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix; import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.go.GoId; import org.forester.go.GoNameSpace; @@ -246,7 +245,7 @@ public final class SurfacingUtil { final DistanceMatrix distance ) { checkForOutputFileWriteability( nj_tree_outfile ); final NeighborJoining nj = NeighborJoining.createInstance(); - final Phylogeny phylogeny = nj.execute( ( BasicSymmetricalDistanceMatrix ) distance ); + final Phylogeny phylogeny = nj.execute( ( DistanceMatrix ) distance ); phylogeny.setName( nj_tree_outfile.getName() ); writePhylogenyToFile( phylogeny, nj_tree_outfile.toString() ); return phylogeny;