def make_one_merged_vcf_record_for_gramtools(self, ref_seq, max_alleles=<NUM_LIT>):
if len(self) == <NUM_LIT:0>:<EOL><INDENT>return None<EOL><DEDENT>elif len(self) == <NUM_LIT:1>:<EOL><INDENT>record = copy.copy(self[<NUM_LIT:0>])<EOL>record.FILTER = {'<STR_LIT>'}<EOL>return record<EOL><DEDENT>logging.debug('<STR_LIT>' +  str(len(self)))<EOL>for record in self.vcf_records:<EOL><INDENT>logging.debug('<STR_LIT>' + str(record))<EOL><DEDENT>nucleotides = {'<STR_LIT:A>', '<STR_LIT:C>', '<STR_LIT>', '<STR_LIT:T>'}<EOL>snps = {} <EOL>non_snps = [] <EOL>chrom_names = set()<EOL>final_start = float('<STR_LIT>')<EOL>final_end = -<NUM_LIT:1><EOL>for record in self.vcf_records:<EOL><INDENT>final_start = min(final_start, record.POS)<EOL>final_end = max(final_end, record.ref_end_pos())<EOL>chrom_names.add(record.CHROM)<EOL>if record.REF in nucleotides:<EOL><INDENT>for alt in record.ALT:<EOL><INDENT>if alt in nucleotides:<EOL><INDENT>if record.POS not in snps:<EOL><INDENT>snps[record.POS] = {record.REF}<EOL><DEDENT>snps[record.POS].add(alt)<EOL><DEDENT>else:<EOL><INDENT>non_snps.append((record.POS, record.REF, alt))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for alt in record.ALT:<EOL><INDENT>non_snps.append((record.POS, record.REF, alt))<EOL><DEDENT><DEDENT><DEDENT>if len(chrom_names) != <NUM_LIT:1>:<EOL><INDENT>raise Error('<STR_LIT>' + str(chrom_names))<EOL><DEDENT>chrom_name = chrom_names.pop()<EOL>snp_positions = []<EOL>snp_nucleotides = []<EOL>for position in sorted(snps):<EOL><INDENT>snp_positions.append(position)<EOL>snp_nucleotides.append(sorted(list(snps[position])))<EOL><DEDENT>ref_seq_for_vcf = ref_seq[final_start:final_end+<NUM_LIT:1>]<EOL>alleles = set()<EOL>total_alleles_lower_bound = <NUM_LIT:1><EOL>for x in snp_nucleotides:<EOL><INDENT>total_alleles_lower_bound *= len(x)<EOL><DEDENT>total_alleles_lower_bound += len(non_snps)<EOL>if max_alleles is not None and total_alleles_lower_bound > max_alleles:<EOL><INDENT>return None<EOL><DEDENT>for combination in itertools.product(*snp_nucleotides):<EOL><INDENT>alt_seq = list(ref_seq_for_vcf)<EOL>for i, position in enumerate(snp_positions):<EOL><INDENT>if position < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>" % position)<EOL><DEDENT>alt_seq[position - final_start] = combination[i]<EOL><DEDENT>alleles.add('<STR_LIT>'.join(alt_seq))<EOL>for non_snp_pos, non_snp_ref, non_snp_alt in non_snps:<EOL><INDENT>start_pos = non_snp_pos - final_start<EOL>new_seq = alt_seq[:start_pos] + list(non_snp_alt) + alt_seq[start_pos + len(non_snp_ref):]<EOL>alleles.add('<STR_LIT>'.join(new_seq))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>alleles.remove(ref_seq_for_vcf)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if max_alleles is not None and len(alleles) > max_alleles:<EOL><INDENT>return None<EOL><DEDENT>alleles = sorted(list(alleles))<EOL>fields = [chrom_name, str(final_start + <NUM_LIT:1>), '<STR_LIT:.>', ref_seq_for_vcf,<EOL>'<STR_LIT:U+002C>'.join(alleles), '<STR_LIT:.>', '<STR_LIT>', '<STR_LIT>']<EOL>logging.debug('<STR_LIT>' + str(len(alleles)))<EOL>return vcf_record.VcfRecord('<STR_LIT:\t>'.join(fields))<EOL>
Returns one new VcfRecord that can be used as input to gramtools.
        It pads the reference if necessary, and lists all the variants
        (including all combinations of SNPs) in the ALT field of the
        VcfRecord.
        Note: gramtools needs PASS in the filter column, so the returned
        VcfRecord always has PASS.