def check_chemistry_def(chemistry):
    """ Validate a chemistry definition dict. Return (ok, error_msg) """
    required_keys = [
        'description',
        'barcode_read_type', 'barcode_read_offset', 'barcode_read_length',
        'rna_read_type', 'rna_read_offset', 'rna_read_length',
        'rna_read2_type', 'rna_read2_offset', 'rna_read2_length',
        'umi_read_type', 'umi_read_offset', 'umi_read_length',
        'si_read_type', 'si_read_offset', 'si_read_length',
        'read_type_to_bcl_processor_filename',
        'read_type_to_bcl2fastq_filename',
        'strandedness',
    ]

    if 'name' not in chemistry:
        return (False, "Chemistry definition is missing a 'name' key")

    missing_keys = set(required_keys) - set(chemistry.keys())
    if len(missing_keys) > 0:
        return (False, "Keys missing from chemistry definition %s: %s" % (chemistry['name'], ','.join(sorted(list(missing_keys)))))

    return True, None