Exemplo n.º 1
0
def test_gc_blocks_invalid_amino_acid():
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.gc_blocks('B', 1)
    excinfo.match("B is not a valid nucleotide.")

    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.gc_blocks('ATGACTBCGT', 4)
    excinfo.match("B is not a valid nucleotide.")
Exemplo n.º 2
0
def test_gc_blocks_for_empty_seq():
    """Perform unit tests on gc_blocks for empty seq"""
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.gc_blocks('', 1) == ()
    excinfo.match("Block size is longer than sequence.")
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.gc_blocks('', 50) == ()
    excinfo.match("Block size is longer than sequence.")
Exemplo n.º 3
0
def gc_map(seq, block_size, gc_thresh):
    """Divides a sequence into blocks and capitalizes blocks with GC content greater than or equal to the threshold."""

    blocks = gc_blocks.make_blocks(seq, block_size)

    block_gc_content = gc_blocks.gc_blocks(seq, block_size)

    # Initialize final sequence
    seq_analyzed = ''

    for i, val in enumerate(block_gc_content):
        if val >= gc_thresh:
            seq_analyzed += blocks[i].upper()
        else:
            seq_analyzed += blocks[i].lower()

    return seq_analyzed
Exemplo n.º 4
0
def test_gc_blocks_lowercase():
    """Perform unit tests on number_negative for lowercase"""
    assert gc_blocks.gc_blocks('atgactacgt', 4) == (
        0.25, 0.5)  # We want the function to be agnostic to case
Exemplo n.º 5
0
def test_gc_blocks_for_long_block():
    """Perform unit tests on gc_blocks for when the block size is longer than the sequence"""
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.gc_blocks('ATGACTAGCTAGC', 20)
    excinfo.match("Block size is longer than sequence.")
Exemplo n.º 6
0
def test_gc_blocks_short_sequences():
    """Perform unit tests on gc_blocks for short sequence"""
    assert gc_blocks.gc_blocks('ATGACTACGT', 4) == (0.25, 0.5)
Exemplo n.º 7
0
def test_gc_blocks_single_nucleotide():
    """Perform unit tests on gc_blocks for single nucleotide"""
    assert gc_blocks.gc_blocks('C', 1) == (1 / 1, )
    assert gc_blocks.gc_blocks('G', 1) == (1 / 1, )
    assert gc_blocks.gc_blocks('A', 1) == (0, )
    assert gc_blocks.gc_blocks('T', 1) == (0, )