/**
 * This function checks if a given gene sequence is valid.
 *
 * A valid gene sequence:
 * - Must start with a start codon "ATG"
 * - Must end with a stop codon "TAA", "TAG", or "TGA"
 * - Must have a length greater than or equal to 9
 *
 * @param sequence The gene sequence to be validated
 * @return True if the sequence is valid, False otherwise.
 */
fun checkGeneSequence(sequence: String): Boolean {

    // Check if the sequence is too short
    if (sequence.length < 9) {
        return false
    }

    // Check if the sequence starts with the start codon
    if (sequence.substring(0, 3) != "ATG") {
        return false
    }

    // Check if the sequence ends with any stop codon
    if (!setOf("TAA", "TAG", "TGA").contains(sequence.substring(sequence.length - 3))) {
        return false
    }

    // Check if the sequence contains any invalid characters
    val validChars = setOf('A', 'T', 'G', 'C')

    for (base in sequence) {
        if (base !in validChars) {
            return false
        }
    }

    return true
}
/**
 * This function checks if a given gene sequence is valid.
 *
 * A valid gene sequence:
 * - Must start with a start codon "ATG"
 * - Must end with a stop codon "TAA", "TAG", or "TGA"
 * - Must have a length greater than or equal to 9
 *
 * @param sequence The gene sequence to be validated
 * @return True if the sequence is valid, False otherwise.
 */
fun checkGeneSequence(sequence: String): Boolean {
/**
 * This function checks if a given gene sequence is valid.
 *
 * A valid gene sequence:
 * - Must start with a start codon "ATG"
 * - Must end with a stop codon "TAA", "TAG", or "TGA"
 * - Must have a length greater than or equal to 9
 *
 * @param sequence The gene sequence to be validated
 * @return True if the sequence is valid, False otherwise.
 */
fun checkGeneSequence(sequence: String): Boolean {

    // Check if the sequence is too short
    if (sequence.length < 9) {
        return false
    }

    // Check if the sequence starts with the start codon
    if (sequence.substring(0, 3) != "ATG") {
        return false
    }

    // Check if the sequence ends with any stop codon
    if (!setOf("TAA", "TAG", "TGA").contains(sequence.substring(sequence.length - 3))) {
        return false
    }

    // Check if the sequence contains any invalid characters
    val validChars = setOf('A', 'T', 'G', 'C')

    for (base in sequence) {
        if (base !in validChars) {
            return false
        }
    }

    return true
}