def test_make_blocks_for_negative_block_size():
    """Perform unit tests on make_blocks for noninteger block_size"""
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.make_blocks('ACTGCTAGA', -3.6)
    excinfo.match("block_size is not a positive integer.")

    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.make_blocks('ACTGCTAGA', -5)
    excinfo.match("block_size is not a positive integer.")
def test_make_blocks_for_empty_seq():
    """Perform unit tests on make_blocks for empty seq"""
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.make_blocks('', 1) == ()
    excinfo.match("Block size is longer than sequence.")

    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.make_blocks('', 7) == ()
    excinfo.match("Block size is longer than sequence.")
Exemple #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
def test_make_blocks_for_long_block():
    """Perform unit tests on make_blocks for when the block size is longer than the sequence"""
    with pytest.raises(RuntimeError) as excinfo:
        gc_blocks.make_blocks('ATGACTAGCTAGC', 20)
    excinfo.match("Block size is longer than sequence.")
def test_make_blocks_for_short_sequences():
    """Perform unit tests on make_blocks for short sequences"""
    assert gc_blocks.make_blocks('atgactacgt', 4) == ('ATGA', 'CTAC')
def test_make_blocks_for_single_nucleotide():
    """Perform unit tests on make_blocks for empty seq"""
    assert gc_blocks.make_blocks('C', 1) == ('C', )
    assert gc_blocks.make_blocks('A', 1) == ('A', )