def test_DeletionMutator_mutate_sequence_del_length_2():
    mutator = genome_mutator.DeletionMutator(5, 2)
    original_seq = "1234567890ABCDEF"
    sequence = pyfastaq.sequences.Fasta("name", original_seq)
    got_mutations, got_sequence = mutator.mutate_sequence(sequence)
    assert sequence.seq == original_seq
    assert got_sequence == "12347890CDEF"
    expect_mutations = [
        genome_mutator.Mutation(3, 3, "456", "4"),
        genome_mutator.Mutation(9, 7, "0AB", "0"),
    ]
    assert got_mutations == expect_mutations
def test_InsertionMutator_mutate_sequence():
    mutator = genome_mutator.InsertionMutator(4, 1, seed=43)
    original_seq = "0123456789XYZ"
    sequence = pyfastaq.sequences.Fasta("name", original_seq)
    got_mutations, got_sequence = mutator.mutate_sequence(sequence)
    assert sequence.seq == original_seq
    assert got_sequence == "0123A4567G89XYZ"
    expect_mutations = [
        genome_mutator.Mutation(3, 3, "3", "3A"),
        genome_mutator.Mutation(7, 8, "7", "7G"),
    ]
    assert got_mutations == expect_mutations
def test_ComplexMutator_mutate_sequence():
    mutator = genome_mutator.ComplexMutator(20, 10, 2, 2, 1, 1, seed=42)
    original_seq = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh"
    sequence = pyfastaq.sequences.Fasta("name", original_seq)
    got_mutations, got_sequence = mutator.mutate_sequence(sequence)
    print(got_sequence)
    assert sequence.seq == original_seq
    assert got_sequence == "abcdefghijklmnopqrstAuwAyabTdefghijklmnTqCtTuvwxyzabcdefgh"
    expect_mutations = [
        genome_mutator.Mutation(19, 19, "tuvwxyzabc", "tAuwAyabT"),
        genome_mutator.Mutation(39, 38, "nopqrstuvw", "nTqCtTuvw"),
    ]
    assert got_mutations == expect_mutations
def test_DeletionMutator_mutate_sequence_del_length_1():
    mutator = genome_mutator.DeletionMutator(3, 1)
    original_seq = "1234567890ABCDE"
    sequence = pyfastaq.sequences.Fasta("name", original_seq)
    got_mutations, got_sequence = mutator.mutate_sequence(sequence)
    assert sequence.seq == original_seq
    assert got_sequence == "1245780ACDE"
    expect_mutations = [
        genome_mutator.Mutation(1, 1, "23", "2"),
        genome_mutator.Mutation(4, 3, "56", "5"),
        genome_mutator.Mutation(7, 5, "89", "8"),
        genome_mutator.Mutation(10, 7, "AB", "A"),
    ]
    assert got_mutations == expect_mutations
def test_SnpMutator_mutate_sequence():
    # Set the seed so that the random mutations will be the same every time
    # the test runs
    mutator = genome_mutator.SnpMutator(3, seed=42)
    original_seq = "AGTAGGCAG"
    sequence = pyfastaq.sequences.Fasta("name", original_seq)
    got_mutations, got_sequence = mutator.mutate_sequence(sequence)
    assert sequence.seq == original_seq
    assert got_sequence == "AGGAGACAG"
    expect_mutations = [
        genome_mutator.Mutation(2, 2, "T", "G"),
        genome_mutator.Mutation(5, 5, "G", "A"),
    ]
    assert got_mutations == expect_mutations