import re


def extract_seq(fasta, start, length):
    """
    Extract sequence from fasta according to given position

    Parameters
    -----
    fasta : str
        file name of fasta
    start : int
        offset of chrosome
    length : int
        length of chromsome sequence

    Returns
    -----
    str
        sequence from start to start + length

    """
    with open(fasta, 'r') as f:
        f.seek(start, 0)
        seq = f.read(length)
        seq = re.sub('\n', '', seq)
    return seq