@Override public final int getIndex( final String identifier ) { for( int i = 0; i < _identifiers.length; i++ ) { if ( getIdentifier( i ).equals( identifier ) ) { return i; } } throw new IllegalArgumentException( "identifier [" + identifier + "] not found in distance matrix" ); }
private final void initExternalNodes() { _external_nodes = new PhylogenyNode[ _n ]; String id; for( int i = 0; i < _n; ++i ) { _external_nodes[ i ] = new PhylogenyNode(); id = _d.getIdentifier( i ); if ( id != null ) { _external_nodes[ i ].setName( id ); } else { _external_nodes[ i ].setName( Integer.toString( i ) ); } _mappings[ i ] = i; } }
private final void initExternalNodes() { _external_nodes = new PhylogenyNode[ _n ]; String id; for( int i = 0; i < _n; ++i ) { _external_nodes[ i ] = new PhylogenyNode(); id = _d.getIdentifier( i ); if ( id != null ) { _external_nodes[ i ].setName( id ); } else { _external_nodes[ i ].setName( Integer.toString( i ) ); } _mappings[ i ] = i; } }
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 final void initExternalNodes() { _external_nodes = new PhylogenyNode[ _n ]; String id; for( int i = 0; i < _n; ++i ) { _external_nodes[ i ] = new PhylogenyNode(); id = _d.getIdentifier( i ); if ( id != null ) { _external_nodes[ i ].setName( id ); } else { _external_nodes[ i ].setName( Integer.toString( i ) ); } _mappings[ i ] = i; _rev_mappings[ i ] = i; } }
sb.append( ForesterUtil.LINE_SEPARATOR ); for( int row = 0; row < getSize(); ++row ) { if ( !ForesterUtil.isEmpty( getIdentifier( row ) ) ) { sb.append( ForesterUtil.pad( getIdentifier( row ), 10, ' ', false ) ); sb.append( ' ' ); sb.append( ' ' );
/** * 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; }