def get_sample_name_from_vcf_header_lines(header_lines):
<EOL>for line in reversed(header_lines):<EOL><INDENT>if line.startswith('<STR_LIT>'):<EOL><INDENT>fields = line.rstrip().split('<STR_LIT:\t>')<EOL>required_cols = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if fields[:len(required_cols)] != required_cols:<EOL><INDENT>raise Error('<STR_LIT>' + '<STR_LIT:U+002CU+0020>'.join(required_cols) + '<STR_LIT>' + line)<EOL><DEDENT>if len(fields) == len(required_cols):<EOL><INDENT>return None<EOL><DEDENT>required_cols.append('<STR_LIT>')<EOL>format_column = fields[len(required_cols) - <NUM_LIT:1>]<EOL>if format_column != required_cols[-<NUM_LIT:1>]:<EOL><INDENT>raise Error('<STR_LIT>' + format_column + '<STR_LIT>' + line)<EOL><DEDENT>if len(fields) == len(required_cols):<EOL><INDENT>logging.warning('<STR_LIT>' + line.rstrip())<EOL>return None<EOL><DEDENT>sample = fields[len(required_cols)]<EOL>if len(fields) > len(required_cols) + <NUM_LIT:1>:<EOL><INDENT>logging.warning('<STR_LIT>' + sample + '<STR_LIT>' + line.rstrip())<EOL><DEDENT>return sample<EOL><DEDENT><DEDENT>return None<EOL>
Given a list of header lines (made by either
    vcf_file_to_dict() or vcf_file_to_list()),
    returns the sample name. Assumes only one sample
    in the file.
    Raises error if badly formatted #CHROM line.
    Returns None if no #CHROM line found