Implement a function that calculates the minimum number of operations required to transform any 4-character substring of a given DNA string into a sequence that matches the pattern "ACTG". The transformation involves changing characters with the least number of operations, considering the circular nature of the alphabet where 'A' follows 'Z'.
Input/Output Requirements
Function Signature:def min_operations_to_genome(s: str, n: int = None) -> int:
Input:
A string s consisting of uppercase letters (the DNA sequence).
An optional integer n representing the length of the string. If n is not provided, it should default to the length of s.
Output:
The function should return an integer representing the minimum number of operations required to transform any 4-character substring of s into "ACTG".
Constraints:
If the length of s is less than 4, raise a ValueError with the message "The length of the string must be at least 4."
Implementation
You need to implement the above functionality in a Python file named /app/solution.py. Ensure that the code is well-structured, and consider edge cases where the input string is valid or invalid.