From: <rv...@us...> - 2012-01-31 20:53:41
|
Revision: 1024 http://treebase.svn.sourceforge.net/treebase/?rev=1024&view=rev Author: rvos Date: 2012-01-31 20:53:32 +0000 (Tue, 31 Jan 2012) Log Message: ----------- This should result in the correct identifiers being set for each state, and all states other than missing being added to the set of possible states within the missing state set. This includes the gap character. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2012-01-31 20:21:36 UTC (rev 1023) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2012-01-31 20:53:32 UTC (rev 1024) @@ -82,20 +82,28 @@ // then create the single state set out of the map, assigning all non-missing characters to missing Set<CharacterState> xmlMissingStates = new HashSet<CharacterState>(); + UncertainCharacterState missing = null; for ( Character symbol : stateForSymbol.keySet() ) { - if ( symbol.charValue() != '?' && symbol.charValue() != '-' ) { - CharacterState xmlState = xmlStateSet.createCharacterState(symbol.toString()); - DiscreteCharState tbState = stateForSymbol.get(symbol); - xmlState.setLabel(tbState.getLabel()); - attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); + char sym = symbol.charValue(); + CharacterState xmlState = null; + String symString = symbol.toString(); + if ( sym == '-' ) { + xmlState = xmlStateSet.createUncertainCharacterState(symString, new HashSet<CharacterState>()); xmlMissingStates.add(xmlState); } - } - UncertainCharacterState gap = xmlStateSet.createUncertainCharacterState("-", new HashSet<CharacterState>()); - xmlMissingStates.add(gap); - UncertainCharacterState missing = xmlStateSet.createUncertainCharacterState("?", xmlMissingStates); - missing.setLabel("?"); - gap.setLabel("-"); + else if ( sym == '?' ) { + xmlState = xmlStateSet.createUncertainCharacterState(symString, new HashSet<CharacterState>()); + missing = (UncertainCharacterState) xmlState; + } + else { + xmlState = xmlStateSet.createCharacterState(symString); + xmlMissingStates.add(xmlState); + } + DiscreteCharState tbState = stateForSymbol.get(symbol); + xmlState.setLabel(symString); + attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); + } + missing.setStates(xmlMissingStates); // then create the XML characters, assigning them all the same state set List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |