private static boolean testBasicSymmetricalDistanceMatrix() { try { final DistanceMatrix matrix_0 = new BasicSymmetricalDistanceMatrix( 4 ); matrix_0.setIdentifier( 0, "A" ); matrix_0.setIdentifier( 1, "B" ); matrix_0.setIdentifier( 2, "C" ); matrix_0.setIdentifier( 3, "0123456789012" ); matrix_0.setValue( 1, 0, 0.00001 ); matrix_0.setValue( 0, 2, 0.0000009 ); matrix_0.setValue( 3, 0, 3.0 ); matrix_0.setValue( 1, 2, 4.0 ); matrix_0.setValue( 3, 1, 5.0 ); matrix_0.setValue( 2, 3, 6.0 ); if ( !matrix_0.getIdentifier( 0 ).equals( "A" ) ) { return false; if ( !matrix_0.getIdentifier( 1 ).equals( "B" ) ) { return false; if ( !matrix_0.getIdentifier( 2 ).equals( "C" ) ) { return false; if ( !matrix_0.getIdentifier( 3 ).equals( "0123456789012" ) ) { return false; if ( matrix_0.getSize() != 4 ) { return false; if ( !isEqual( matrix_0.getValue( 0, 0 ), 0.0 ) ) { return false;
logger.info("{}:{}", "Determining Distances", (loopcount * 100) / totalloopcount); distance.setIdentifier(i, msa.getAlignedSequence(i + 1) .getAccession().getID()); loopcount++; if (j == i) { distance.setValue(i, j, 0); } else { distance.setValue(i, j, 100 - Comparison.PID( sequenceString[i], sequenceString[j])); distance.setValue(j, i, distance.getValue(i, j));
int numSequences = matrix.getSize(); List<PhylogenyNode> externalNodes = tree.getExternalNodes(); HashMap<String, PhylogenyNode> externalNodesHashMap = new HashMap<String, PhylogenyNode>(); double averageTreeErrorDistance = 0.0; for (int row = 0; row < numSequences - 1; row++) { String nodeName1 = matrix.getIdentifier(row); PhylogenyNode node1 = externalNodesHashMap.get(nodeName1); markPathToRoot(node1, path); for (int col = row + 1; col < numSequences; col++) { count++; String nodeName2 = matrix.getIdentifier(col); PhylogenyNode node2 = externalNodesHashMap.get(nodeName2); double distance = matrix.getValue(col, row); averageMatrixDistance = averageMatrixDistance + distance; PhylogenyNode commonParent = findCommonParent(node2, path);
distance_matrix.setIdentifier( row, table.getValue( 0, row + start_row ) ); switch ( getInputMatrixType() ) { case LOWER_TRIANGLE: setMatrixSize( distance_matrix.getSize() ); else if ( getMatrixSize() != distance_matrix.getSize() ) { throw new IOException( "attempt to use matrices of unequal size: [" + getMatrixSize() + "] vs [" + distance_matrix.getSize() + "]" );
if ( !isEqual( ma0[ 0 ].getValue( 0, 0 ), 0 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 1, 0 ), 1 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 2, 0 ), 2 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 3, 0 ), 3 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 0, 1 ), 1 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 1, 1 ), 0 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 2, 1 ), 4 ) ) { return false; if ( !isEqual( ma0[ 0 ].getValue( 3, 1 ), 5 ) ) { return false; if ( !isEqual( ma0[ 1 ].getValue( 0, 0 ), 0 ) ) { return false; if ( !isEqual( ma0[ 1 ].getValue( 1, 0 ), 11 ) ) { return false;
+ matrices[ 0 ].getSize() );
public static void writeMatrixToFile( final File matrix_outfile, final List<DistanceMatrix> matrices ) { checkForOutputFileWriteability( matrix_outfile ); try { final BufferedWriter out = new BufferedWriter( new FileWriter( matrix_outfile ) ); for( final DistanceMatrix distance_matrix : matrices ) { out.write( distance_matrix.toStringBuffer( DistanceMatrix.Format.PHYLIP ).toString() ); out.write( ForesterUtil.LINE_SEPARATOR ); out.flush(); } out.close(); } catch ( final IOException e ) { ForesterUtil.fatalError( surfacing.PRG_NAME, e.getMessage() ); } ForesterUtil.programMessage( surfacing.PRG_NAME, "Wrote distance matrices to \"" + matrix_outfile + "\"" ); }
logger.info("{}:{}", "Determining Distances", (loopcount * 100) / totalloopcount); distance.setIdentifier(i, msa.getAlignedSequence(i + 1) .getAccession().getID()); loopcount++; if (j == i) { distance.setValue(i, j, 0); } else { distance.setValue(i, j, 100 - Comparison.PID( sequenceString[i], sequenceString[j])); distance.setValue(j, i, distance.getValue(i, j));
int numSequences = matrix.getSize(); List<PhylogenyNode> externalNodes = tree.getExternalNodes(); HashMap<String, PhylogenyNode> externalNodesHashMap = new HashMap<String, PhylogenyNode>(); double averageTreeErrorDistance = 0.0; for (int row = 0; row < numSequences - 1; row++) { String nodeName1 = matrix.getIdentifier(row); PhylogenyNode node1 = externalNodesHashMap.get(nodeName1); markPathToRoot(node1, path); for (int col = row + 1; col < numSequences; col++) { count++; String nodeName2 = matrix.getIdentifier(col); PhylogenyNode node2 = externalNodesHashMap.get(nodeName2); double distance = matrix.getValue(col, row); averageMatrixDistance = averageMatrixDistance + distance; PhylogenyNode commonParent = findCommonParent(node2, path);
logger.info("{}:{}", "Determining Distances", (loopcount * 100) / totalloopcount); distance.setIdentifier(i, msa.getAlignedSequence(i + 1) .getAccession().getID()); loopcount++; if (j == i) { distance.setValue(i, j, 0); } else { distance.setValue(i, j, 100 - Comparison.PID( sequenceString[i], sequenceString[j])); distance.setValue(j, i, distance.getValue(i, j));
int numSequences = matrix.getSize(); List<PhylogenyNode> externalNodes = tree.getExternalNodes(); HashMap<String, PhylogenyNode> externalNodesHashMap = new HashMap<String, PhylogenyNode>(); double averageTreeErrorDistance = 0.0; for (int row = 0; row < numSequences - 1; row++) { String nodeName1 = matrix.getIdentifier(row); PhylogenyNode node1 = externalNodesHashMap.get(nodeName1); markPathToRoot(node1, path); for (int col = row + 1; col < numSequences; col++) { count++; String nodeName2 = matrix.getIdentifier(col); PhylogenyNode node2 = externalNodesHashMap.get(nodeName2); double distance = matrix.getValue(col, row); averageMatrixDistance = averageMatrixDistance + distance; PhylogenyNode commonParent = findCommonParent(node2, path);
private void transferValue( final BasicTable<String> table, final DistanceMatrix distance_matrix, final int row, final int col, final int start_row, final int col_offset ) throws IOException { double d = 0.0; final String table_value = table.getValue( col, row + start_row ); if ( ForesterUtil.isEmpty( table_value ) ) { throw new IOException( "value is null or empty at [" + ( col - 1 ) + ", " + row + "]" ); } try { d = Double.parseDouble( table_value ); } catch ( final NumberFormatException e ) { throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( col - 1 ) + ", " + row + "]" ); } distance_matrix.setValue( ( col - 1 ) + col_offset, row, d ); }