Skip to content

Commit ff4d7ec

Browse files
committed
add sanity check to make sure datatype and frequencies match #28
1 parent d6f0f30 commit ff4d7ec

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/beast/base/evolution/sitemodel/SiteModelInterface.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ public void addCondition(final Input<? extends StateNode> stateNode) {
190190
@Override
191191
public void setDataType(final DataType dataType) {
192192
m_dataType = dataType;
193+
194+
// sanity check: make sure the number of states from dataType matches that of the substitution model
195+
if (m_dataType != null) {
196+
int nrOfStatesInData = m_dataType.getStateCount();
197+
if (nrOfStatesInData >= 0) {
198+
int nrOfFrequencies = substModelInput.get().getFrequencies().length;
199+
if (nrOfStatesInData != nrOfFrequencies) {
200+
throw new IllegalArgumentException("Number of states in data (" + nrOfStatesInData + ") differs from number of frequencies (" + nrOfFrequencies +")");
201+
}
202+
}
203+
}
193204
}
194205

195206
public double getProportionInvariant() {

0 commit comments

Comments
 (0)