@classmethod
def _chunk_end_indexes_from_vcf_record_list(cls, record_list, start_index,
    flank_length, total_sites=None, total_alleles=None):
    """Returns tuple of:
           1. last index of VCF record that we want to use for variant calling
           2. index of last variant in the chunk, which can't be used for variant calling
              but should end up in the gramtools graph"""
    assert total_sites != total_alleles and (total_sites is not None or 
        total_alleles is not None)
    file_start_index = start_index
    while file_start_index > 0:
        distance_to_previous_variant = record_list[start_index
            ].POS - record_list[file_start_index - 1].ref_end_pos()
        if distance_to_previous_variant > flank_length:
            break
        file_start_index -= 1
    if total_sites is not None:
        use_vcf_end_index = min(start_index + total_sites - 1, len(
            record_list) - 1)
    else:
        use_vcf_end_index = start_index
        alleles = 1 + len(record_list[start_index].ALT)
        while use_vcf_end_index < len(record_list
            ) - 1 and alleles <= total_alleles:
            use_vcf_end_index += 1
            alleles += 1 + len(record_list[use_vcf_end_index].ALT)
        use_vcf_end_index = max(start_index, use_vcf_end_index - 1)
    if use_vcf_end_index == len(record_list) - 1:
        return file_start_index, use_vcf_end_index, use_vcf_end_index
    file_end_index = use_vcf_end_index
    while file_end_index < len(record_list) - 1:
        distance_to_next_variant = record_list[file_end_index + 1
            ].POS - record_list[use_vcf_end_index].ref_end_pos()
        if distance_to_next_variant > flank_length:
            break
        file_end_index += 1
    return file_start_index, use_vcf_end_index, min(file_end_index, len(
        record_list) - 1)
