@@ -123,33 +123,37 @@ double chi2prob (int deg, double chi2)
123123} /* chi2prob */
124124
125125
126- int Alignment::checkAbsentStates (string msg) {
127- double *state_freq = new double [num_states];
128- computeStateFreq (state_freq);
129- string absent_states, rare_states;
130- int count = 0 ;
131- // Skip check for PoMo.
126+ void Alignment::checkAbsentStates (string msg) {
127+ // skip checking for PoMo
132128 if (seq_type == SEQ_POMO)
133- return 0 ;
134- for (int i = 0 ; i < num_states; i++)
135- if (state_freq[i] == 0.0 ) {
129+ return ;
130+ string absent_states, rare_states;
131+ int absent_cnt = 0 ;
132+ double *state_freqs = new double [num_states];
133+ computeStateFreq (state_freqs);
134+ for (int x = 0 ; x < num_states; ++x) {
135+ if (state_freqs[x] == 0.0 ) {
136136 if (!absent_states.empty ())
137137 absent_states += " , " ;
138- absent_states += convertStateBackStr (i );
139- count ++;
140- } else if (state_freq[i ] <= Params::getInstance ().min_state_freq ) {
138+ absent_states += convertStateBackStr (x );
139+ absent_cnt ++;
140+ } else if (state_freqs[x ] <= Params::getInstance ().min_state_freq ) {
141141 if (!rare_states.empty ())
142142 rare_states += " , " ;
143- rare_states += convertStateBackStr (i );
143+ rare_states += convertStateBackStr (x );
144144 }
145- if (count >= num_states-1 && Params::getInstance ().fixed_branch_length != BRLEN_FIX)
146- outError (" Only one state is observed in " + msg);
145+ }
146+ delete [] state_freqs;
147+ if (absent_cnt == num_states)
148+ outError (" Only gaps observed in " + msg);
149+ if (absent_cnt == num_states - 1 )
150+ outWarning (" Only one state observed in " + msg);
151+ if (absent_cnt > 0 )
152+ outWarning (convertIntToString (absent_cnt) + " states (see below) not observed in " + msg);
147153 if (!absent_states.empty ())
148- cout << " NOTE: State(s) " << absent_states << " not present in " << msg << " and thus removed from Markov process to prevent numerical problems" << endl ;
154+ outWarning ( " State(s) " + absent_states + " not present in " + msg + " and may cause numerical problems" ) ;
149155 if (!rare_states.empty ())
150- cout << " WARNING: States(s) " << rare_states << " rarely appear in " << msg << " and may cause numerical problems" << endl;
151- delete[] state_freq;
152- return count;
156+ outWarning (" State(s) " + rare_states + " rarely appear in " + msg + " and may cause numerical problems" );
153157}
154158
155159void Alignment::checkSeqName () {
0 commit comments