Example #1
0
def hamming_distance(seq_1, seq_2, ignore_case):
    """Hamming distance between two sequences

    Calculate the Hamming distance between SEQ_1 and SEQ_2.
    """
    result = pb.hamming_distance(seq_1, seq_2, ignore_case=ignore_case)
    click.echo(result)
Example #2
0
def test_hamming_distance_ignore_case():
    expect = 0
    result = pb.hamming_distance("CAGATA", "cagata", ignore_case=True)
    assert result == expect
Example #3
0
def test_hamming_distance_different_case():
    expect = 6
    result = pb.hamming_distance("CAGATA", "cagata", ignore_case=False)
    assert result == expect
Example #4
0
def test_hamming_distance_error():
    with pytest.raises(ValueError):
        pb.hamming_distance("CAGATA", "CACACACA")
Example #5
0
def test_hamming_distance_many():
    expect = 6
    result = pb.hamming_distance("CAGATA", "GTCTAT")
    assert result == expect
Example #6
0
def test_mutate_sequence_aa_many(sample_aa_sequence):
    result = pb.mutate_sequence(sample_aa_sequence, mutations=10,
                                alphabet="aa")
    assert len(result) == len(sample_aa_sequence)
    assert set(result) == set(pb._AA_LIST)
    assert pb.hamming_distance(sample_aa_sequence, result) <= 10
Example #7
0
def test_mutate_sequence_nt_many(sample_nt_sequence):
    result = pb.mutate_sequence(sample_nt_sequence, mutations=10)
    assert len(result) == len(sample_nt_sequence)
    assert set(result) == set(pb._NT_LIST)
    assert pb.hamming_distance(sample_nt_sequence, result) <= 10
Example #8
0
def test_hamming_distance_one():
    expect = 1
    result = pb.hamming_distance("CAGATA", "CACATA")
    assert result == expect
Example #9
0
def test_hamming_distance_zero():
    expect = 0
    result = pb.hamming_distance("CAGATA", "CAGATA")
    assert result == expect