// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// All rights reserved
// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// All rights reserved
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
* This can read full, lower triangular, and upper triangular distance matrices.
* In the case of a full matrix, the lower triangular values are used. Format
* (by example): id1 0 id2 0.3 0 id3 0.4 0.4 0
* This can read full, lower triangular, and upper triangular distance matrices.
* In the case of a full matrix, the lower triangular values are used. Format
* (by example): id1 0 id2 0.3 0 id3 0.4 0.4 0
* @author Christian M Zmasek
*/
public class SymmetricalDistanceMatrixParser {
private final static InputMatrixType INPUT_MATRIX_TYPE_DEFAULT = InputMatrixType.LOWER_TRIANGLE;
private final static String COMMENT = "#";
* @author Christian M Zmasek
*/
public class SymmetricalDistanceMatrixParser {
private final static InputMatrixType INPUT_MATRIX_TYPE_DEFAULT = InputMatrixType.LOWER_TRIANGLE;
private final static String COMMENT = "#";
}
catch ( final NumberFormatException e ) {
throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( i - 1 ) + ", " + row
}
catch ( final NumberFormatException e ) {
throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( i - 1 ) + ", " + row
}
if ( !ForesterUtil.isEqual( 0.0, d ) ) {
throw new IOException( "attempt to use non-zero diagonal value [" + table_value + "] at [" + ( i - 1 )
}
if ( !ForesterUtil.isEqual( 0.0, d ) ) {
throw new IOException( "attempt to use non-zero diagonal value [" + table_value + "] at [" + ( i - 1 )
- final List<BasicTable<String>> tables = BasicTableParser.parse( source, VALUE_SEPARATOR, false, COMMENT, true );
+ final List<BasicTable<String>> tables = BasicTableParser.parse( source,
+ VALUE_SEPARATOR,
+ false,
+ false,
+ COMMENT,
+ true );
final DistanceMatrix[] distance_matrices = new DistanceMatrix[ tables.size() ];
int i = 0;
for( final BasicTable<String> table : tables ) {
final DistanceMatrix[] distance_matrices = new DistanceMatrix[ tables.size() ];
int i = 0;
for( final BasicTable<String> table : tables ) {
}
catch ( final NumberFormatException e ) {
throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( col - 1 ) + ", " + row
}
catch ( final NumberFormatException e ) {
throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( col - 1 ) + ", " + row
throw new IllegalArgumentException( "attempt to create distance matrix with illegal dimensions [columns: "
+ table.getNumberOfColumns() + ", rows: " + table.getNumberOfRows() + "]" );
}
throw new IllegalArgumentException( "attempt to create distance matrix with illegal dimensions [columns: "
+ table.getNumberOfColumns() + ", rows: " + table.getNumberOfRows() + "]" );
}
distance_matrix.setIdentifier( row, table.getValue( 0, row + start_row ) );
switch ( getInputMatrixType() ) {
case LOWER_TRIANGLE:
distance_matrix.setIdentifier( row, table.getValue( 0, row + start_row ) );
switch ( getInputMatrixType() ) {
case LOWER_TRIANGLE: