Skip to content

Commit 62efdd5

Browse files
committed
Show an error if the root frequency of any state is zero
1 parent c60c0e7 commit 62efdd5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

model/modelbase.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ void cmaple::ModelBase::extractRootFreqs(const Alignment* aln) {
191191
// update root_freqs and root_log_freqs
192192
RealNumType inverse_seq_length = 1.0 / seq_length;
193193
for (StateType i = 0; i < num_states_; ++i) {
194+
// validate root_freqs[i]
195+
if (root_freqs[i] == 0)
196+
{
197+
// Get the seqtype
198+
const cmaple::SeqRegion::SeqType seqtype = getSeqType();
199+
std::string error_msg = "Root frequency of state ";
200+
error_msg += cmaple::Alignment::convertState2Char(i, seqtype);
201+
error_msg += " is zero!";
202+
throw std::logic_error(error_msg);
203+
}
194204
// root_freqs[i] /= seq_length;
195205
root_freqs[i] *= inverse_seq_length;
196206
inverse_root_freqs[i] = 1.0 / root_freqs[i];

0 commit comments

Comments
 (0)