def extract_sequence(reference, sequence_name, output):
    """

    Extract sequence takes in a <reference>, <sequence_name> and <output>
    The <reference> is a fasta file, which must be indexed. (have a .fai) file
    It looks up in the .fai file to find the <sequence_name>.
    If the name is present it reads the sequences from the <reference>,
    and saves it as <output>

    """
    inputs = [reference]
    outputs = [output]
    options = {
        'cores': 1,
        'memory': '4g',
        'account': 'NChain',
        'walltime': '01:00:00'
    }

    directory = "/".join(output.split("/")[:-1])

    spec = '''

    mkdir -p {dirc}

    python extract_sequence.py {ref} {seq} > {out}
    '''.format(ref=reference, seq=sequence_name, dirc=directory, out=output)

    return inputs, outputs, options, spec