That's great. However the method that you use to find the canonical representative [1] is quadratic (when the string has length N, there are N rotations and for each rotation you need to check N characters to determine whether this is earlier than the best on that you have found so far). For large strings you would probably want to switch to one of the linear minimal string rotation algorithms [2], for example Booth's Algorithm.
[1] https://github.com/Benjamin-Lee/viroiddb/blob/main/scripts/c...
[2] https://en.wikipedia.org/wiki/Lexicographically_minimal_stri...