Skip to content

Commit d3f76df

Browse files
committed
Handling of uncertainties and polymorphisms in categorical data read.
1 parent fe313f2 commit d3f76df

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/mesquite/nexml/InterpretNEXML/NexmlReaders/NexmlCharactersBlockReader.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.nexml.model.MolecularMatrix;
3131
import org.nexml.model.OTU;
3232
import org.nexml.model.OTUs;
33+
import org.nexml.model.UncertainCharacterState;
3334

3435
/**
3536
* @author rvosa
@@ -112,9 +113,25 @@ private FileElement readMatrix(String mesDataType,Matrix<?> xmlMatrix,MesquiteFi
112113
}
113114
org.nexml.model.CharacterState xmlState = (org.nexml.model.CharacterState)xmlCell.getValue();
114115
if ( xmlState != null ) {
115-
mesCS = new CategoricalState();
116116
String xmlSymbol = xmlState.getSymbol().toString();
117-
mesCS.setValue(xmlSymbol, mesMatrix);
117+
if (xmlMatrix instanceof CategoricalMatrix) {
118+
long stateValue = CategoricalState.emptySet();
119+
if (xmlState instanceof CompoundCharacterState) {
120+
for (org.nexml.model.CharacterState state : ((CompoundCharacterState)xmlState).getStates()) {
121+
int memberSymbol = Integer.parseInt(state.getSymbol().toString());
122+
stateValue = CategoricalState.addToSet(stateValue, memberSymbol);
123+
}
124+
if (xmlState instanceof UncertainCharacterState) {
125+
stateValue = CategoricalState.setUncertainty(stateValue, true);
126+
}
127+
} else {
128+
stateValue = CategoricalState.makeSet(Integer.parseInt(xmlSymbol));
129+
}
130+
mesCS = new CategoricalState(stateValue);
131+
} else {
132+
mesCS = new CategoricalState();
133+
mesCS.setValue(xmlSymbol, mesMatrix);
134+
}
118135
}
119136
}
120137
if ( mesCS != null ) {

0 commit comments

Comments
 (0)