/** * Returns the distance matrix used to construct this guide tree. The scores have been normalized. * * @return the distance matrix used to construct this guide tree */ public double[][] getDistanceMatrix() { double[][] matrix = new double[distances.getSize()][distances.getSize()]; for (int i = 0; i < matrix.length; i++) { for (int j = i+1; j < matrix.length; j++) { matrix[i][j] = matrix[j][i] = distances.getValue(i, j); } } return matrix; }
/** * Returns the distance matrix used to construct this guide tree. The scores have been normalized. * * @return the distance matrix used to construct this guide tree */ public double[][] getDistanceMatrix() { double[][] matrix = new double[distances.getSize()][distances.getSize()]; for (int i = 0; i < matrix.length; i++) { for (int j = i+1; j < matrix.length; j++) { matrix[i][j] = matrix[j][i] = distances.getValue(i, j); } } return matrix; }
sb.append( PHYLIP_FORMATTER.format( getValue( col, row ) ) ); if ( col < ( getSize() - 1 ) ) { sb.append( ' ' );
public final void write( final Writer w ) throws IOException { w.write( " " ); w.write( getSize() + "" ); w.write( ForesterUtil.LINE_SEPARATOR ); for( int row = 0; row < getSize(); ++row ) { if ( !ForesterUtil.isEmpty( getIdentifier( row ) ) ) { w.write( ForesterUtil.pad( getIdentifier( row ), 10, ' ', false ).toString() ); w.write( ' ' ); w.write( ' ' ); } else { throw new IllegalFormatUseException( "Phylip format does not allow empty identifiers" ); } for( int col = 0; col < getSize(); ++col ) { w.write( PHYLIP_FORMATTER.format( getValue( col, row ) ) ); if ( col < ( getSize() - 1 ) ) { w.write( ' ' ); w.write( ' ' ); } } if ( row < ( getSize() - 1 ) ) { w.write( ForesterUtil.LINE_SEPARATOR ); } } }
private static boolean testDistanceCalculationMethods( final File test_dir ) { try { final Msa msa0 = GeneralMsaParser.parse( new FileInputStream( test_dir + ForesterUtil.FILE_SEPARATOR + "bcl.aln" ) ); final BasicSymmetricalDistanceMatrix pwd0 = PairwiseDistanceCalculator.calcKimuraDistances( msa0 ); if ( pwd0.getSize() != 120 ) { return false; } for( int i = 0; i < pwd0.getSize(); ++i ) { if ( !isEqual( pwd0.getValue( i, i ), 0.0 ) ) { return false; } } } catch ( final Exception e ) { e.printStackTrace( System.out ); return false; } return true; }
private final void reset( final BasicSymmetricalDistanceMatrix distances ) { _n = distances.getSize(); _d = distances; _r = new float[ _n ]; _mappings = new int[ _n ]; _d_values = new float[ distances.getSize() ][ distances.getSize() ]; for( int i = 0; i < distances.getSize(); ++i ) { for( int j = 0; j < distances.getSize(); ++j ) { _d_values[ i ][ j ] = ( float ) distances.getValue( i, j ); } } initExternalNodes(); }
/** * Helper function to clone a forester symmetrical DistanceMatrix. * * @param distM * forester symmetrical DistanceMatrix * @return identical copy of the forester symmetrical DistanceMatrix */ public static BasicSymmetricalDistanceMatrix cloneDM( BasicSymmetricalDistanceMatrix distM) { int n = distM.getSize(); BasicSymmetricalDistanceMatrix cloneDM = new BasicSymmetricalDistanceMatrix(n); for (int i = 0; i < n; i++) { cloneDM.setIdentifier(i, distM.getIdentifier(i)); for (int j = i + 1; j < n; j++) { cloneDM.setValue(i, j, distM.getValue(i, j)); } } return cloneDM; }
/** * Helper function to clone a forester symmetrical DistanceMatrix. * * @param distM * forester symmetrical DistanceMatrix * @return identical copy of the forester symmetrical DistanceMatrix */ public static BasicSymmetricalDistanceMatrix cloneDM( BasicSymmetricalDistanceMatrix distM) { int n = distM.getSize(); BasicSymmetricalDistanceMatrix cloneDM = new BasicSymmetricalDistanceMatrix(n); for (int i = 0; i < n; i++) { cloneDM.setIdentifier(i, distM.getIdentifier(i)); for (int j = i + 1; j < n; j++) { cloneDM.setValue(i, j, distM.getValue(i, j)); } } return cloneDM; }
/** * Helper function to clone a forester symmetrical DistanceMatrix. * * @param distM * forester symmetrical DistanceMatrix * @return identical copy of the forester symmetrical DistanceMatrix */ public static BasicSymmetricalDistanceMatrix cloneDM( BasicSymmetricalDistanceMatrix distM) { int n = distM.getSize(); BasicSymmetricalDistanceMatrix cloneDM = new BasicSymmetricalDistanceMatrix(n); for (int i = 0; i < n; i++) { cloneDM.setIdentifier(i, distM.getIdentifier(i)); for (int j = i + 1; j < n; j++) { cloneDM.setValue(i, j, distM.getValue(i, j)); } } return cloneDM; }