// 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
// 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
import org.forester.util.ForesterUtil;
/**
- *
+ *
* IN PROGRESS!
* DO NOT USE!
- *
- *
+ *
+ *
* @param <STATE_TYPE>
*/
public class SankoffParsimony<STATE_TYPE> {
/**
* Returns a view of the internal states prior to trace-back.
- *
+ *
* @return
*/
public CharacterStateMatrix<List<STATE_TYPE>> getInternalStatesMatrixPriorToTraceback() {
final PhylogenyNode node_child = node.getChildNode( i );
if ( !states.containsKey( node_child ) ) {
throw new AssertionError( "this should not have happened: node [" + node_child.getName()
- + "] not found in node state map" );
+ + "] not found in node state map" );
}
if ( i == 0 ) {
states_in_child_nodes.addAll( states.get( node_child ) );
final STATE_TYPE state = matrix.getState( indentifier_index, character_index );
if ( state == null ) {
throw new IllegalArgumentException( "value at [" + indentifier_index + ", " + character_index
- + "] is null" );
+ + "] is null" );
}
final SortedSet<STATE_TYPE> l = new TreeSet<STATE_TYPE>();
l.add( state );
private Map<PhylogenyNode, STATE_TYPE> getStatesForCharacterForTraceback( final Phylogeny p,
final CharacterStateMatrix<STATE_TYPE> matrix,
final int character_index ) {
- final Map<PhylogenyNode, STATE_TYPE> states = new HashMap<PhylogenyNode, STATE_TYPE>( matrix
- .getNumberOfIdentifiers() );
+ final Map<PhylogenyNode, STATE_TYPE> states = new HashMap<PhylogenyNode, STATE_TYPE>( matrix.getNumberOfIdentifiers() );
for( int indentifier_index = 0; indentifier_index < matrix.getNumberOfIdentifiers(); ++indentifier_index ) {
final STATE_TYPE state = matrix.getState( indentifier_index, character_index );
if ( state == null ) {
throw new IllegalArgumentException( "value at [" + indentifier_index + ", " + character_index
- + "] is null" );
+ + "] is null" );
}
states.put( p.getNode( matrix.getIdentifier( indentifier_index ) ), state );
}
final PhylogenyNode node_child = node.getChildNode( i );
if ( !states.containsKey( node_child ) ) {
throw new AssertionError( "this should not have happened: node [" + node_child.getName()
- + "] not found in node state map" );
+ + "] not found in node state map" );
}
states_in_child_nodes.addAll( states.get( node_child ) );
}
nodes.add( postorder.next() );
}
setGainLossMatrix( new BasicCharacterStateMatrix<CharacterStateMatrix.GainLossStates>( nodes.size(),
- external_node_states_matrix
- .getNumberOfCharacters() ) );
+ external_node_states_matrix
+ .getNumberOfCharacters() ) );
int identifier_index = 0;
for( final PhylogenyNode node : nodes ) {
getGainLossMatrix().setIdentifier( identifier_index++,
}
}
setInternalStatesMatrixPriorToTraceback( new BasicCharacterStateMatrix<List<STATE_TYPE>>( internal_nodes.size(),
- external_node_states_matrix
- .getNumberOfCharacters() ) );
+ external_node_states_matrix
+ .getNumberOfCharacters() ) );
setInternalStatesMatrixTraceback( new BasicCharacterStateMatrix<STATE_TYPE>( internal_nodes.size(),
- external_node_states_matrix
- .getNumberOfCharacters() ) );
+ external_node_states_matrix
+ .getNumberOfCharacters() ) );
int identifier_index = 0;
for( final PhylogenyNode node : internal_nodes ) {
getInternalStatesMatrix().setIdentifier( identifier_index,
.getName() );
getInternalStatesMatrixPriorToTraceback().setIdentifier( identifier_index,
ForesterUtil.isEmpty( node.getName() ) ? node
- .getId()
- + "" : node.getName() );
+ .getId() + "" : node.getName() );
++identifier_index;
}
for( int character_index = 0; character_index < external_node_states_matrix.getNumberOfCharacters(); ++character_index ) {
external_node_states_matrix.getCharacter( character_index ) );
getInternalStatesMatrixPriorToTraceback().setCharacter( character_index,
external_node_states_matrix
- .getCharacter( character_index ) );
+ .getCharacter( character_index ) );
}
}
final PhylogenyNode node,
final GainLossStates state ) {
getGainLossMatrix().setState( ForesterUtil.isEmpty( node.getName() ) ? node.getId() + "" : node.getName(),
- character_state_column,
- state );
+ character_state_column,
+ state );
}
private void setInternalNodeState( final Map<PhylogenyNode, STATE_TYPE> states,
final int character_state_column,
final PhylogenyNode node ) {
getInternalStatesMatrix()
- .setState( ForesterUtil.isEmpty( node.getName() ) ? node.getId() + "" : node.getName(),
- character_state_column,
- states.get( node ) );
+ .setState( ForesterUtil.isEmpty( node.getName() ) ? node.getId() + "" : node.getName(),
+ character_state_column,
+ states.get( node ) );
}
private void setInternalNodeStatePriorToTraceback( final Map<PhylogenyNode, SortedSet<STATE_TYPE>> states,
final int character_state_column,
final PhylogenyNode node ) {
getInternalStatesMatrixPriorToTraceback().setState( ForesterUtil.isEmpty( node.getName() ) ? node.getId() + ""
- : node.getName(),
- character_state_column,
- toListSorted( states.get( node ) ) );
+ : node.getName(),
+ character_state_column,
+ toListSorted( states.get( node ) ) );
}
private void setInternalStatesMatrixPriorToTraceback( final CharacterStateMatrix<List<STATE_TYPE>> internal_states_matrix_prior_to_traceback ) {
* This sets whether to use the first or last state in the sorted
* states at the undecided internal nodes.
* For randomized choices set randomize to true (and this to false).
- *
+ *
* Note. It might be advisable to set this to false
* for BinaryStates if absence at the root is preferred
- * (given the enum BinaryStates sorts in the following order:
+ * (given the enum BinaryStates sorts in the following order:
* ABSENT, UNKNOWN, PRESENT).
- *
- *
+ *
+ *
* @param use_last
*/
public void setUseLast( final boolean use_last ) {