<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_header(in_bam, rgnames, ref_file, config):
 """Ensure passed in BAM header matches reference file and read groups names. """

    _check_bam_contigs(in_bam, ref_file, config)
    _check_sample(in_bam, rgnames)