IQ-TREE icon indicating copy to clipboard operation
IQ-TREE copied to clipboard

Nicer errors when partition file has mistakes

Open roblanf opened this issue 2 years ago • 0 comments

At the moment our errors for partitioning mistakes are:

https://github.com/Cibiv/IQ-TREE/blob/6776a95f15a2eccda2aa330497291dc246575995/alignment/alignment.cpp#L3004-L3007

My suggestion is that we edit the errors as below, and also print out the offending line so users can quickly identify and fix it (and also so they won't have to post on the forums).

Here are my suggestions for making the errors better. But I don't know in C how to also print out the offending line, hence not making a pull request!

            if (upper >= aln->getNSite()) throw "The following line of your partition definitions includes a site with an ID that is larger than your alignment. All site ID's in your partition file must refer to a column number of the alignment between 1 and the length of the alignment. Please fix this and try again.";
            if (lower < 0) throw "The following line of your partition definitions includes a site with a negative ID, which is impossible. All site ID's in your partition file must refer to a column number of the alignment between 1 and the length of the alignment. Please fix this and try again.";
            if (lower > upper) throw "The following line of your partition definitions includes a range of sites where the lower end of the range (the number before dash) is higher than the upper end of the range (the number after the dash). Please fix this and try again.";
            if (step < 1) throw "The following line of your partition definitions includes a range of sites where the step size (the number after the \) is less than one. Step sizes have to be at least 1. Please fix this and try again.";

roblanf avatar Sep 26 '21 23:09 roblanf