def gt_aware_merge(self, other, reference_seq):
if self.CHROM != other.CHROM or self.intersects(other) or len(self.ALT) != <NUM_LIT:1> or len(other.ALT) != <NUM_LIT:1>:<EOL><INDENT>return None<EOL><DEDENT>ref_start = min(self.POS, other.POS)<EOL>ref_end = max(self.ref_end_pos(), other.ref_end_pos())<EOL>ref_seq_for_vcf = reference_seq[ref_start:ref_end + <NUM_LIT:1>]<EOL>sorted_records = sorted([self, other], key=operator.attrgetter('<STR_LIT>'))<EOL>alt_seq = []<EOL>all_alt_seq = []<EOL>gt_confs = []<EOL>current_ref_pos = ref_start<EOL>for record in sorted_records:<EOL><INDENT>assert record.REF != '<STR_LIT:.>' and record.ALT[<NUM_LIT:0>] != '<STR_LIT:.>'<EOL>alt_seq.append(reference_seq[current_ref_pos:record.POS])<EOL>all_alt_seq.append(reference_seq[current_ref_pos:record.POS])<EOL>if record.FORMAT is None or '<STR_LIT>' not in record.FORMAT:<EOL><INDENT>return None<EOL><DEDENT>called_alleles = list(set(record.FORMAT['<STR_LIT>'].split('<STR_LIT:/>')))<EOL>if len(called_alleles) != <NUM_LIT:1> or '<STR_LIT:.>' in called_alleles:<EOL><INDENT>return None<EOL><DEDENT>gt = int(called_alleles[<NUM_LIT:0>])<EOL>if gt > <NUM_LIT:0>:<EOL><INDENT>alt_seq.append(record.ALT[gt-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>alt_seq.append(record.REF)<EOL><DEDENT>all_alt_seq.append(record.ALT[<NUM_LIT:0>])<EOL>current_ref_pos += len(record.REF)<EOL>if record.FORMAT is not None and '<STR_LIT>' in record.FORMAT:<EOL><INDENT>gt_confs.append(record.FORMAT['<STR_LIT>'])<EOL><DEDENT><DEDENT>alt_seq_for_vcf = '<STR_LIT>'.join(alt_seq)<EOL>format = "<STR_LIT>"<EOL>gt_0 = '<STR_LIT>'<EOL>gt_1 = '<STR_LIT>'<EOL>if len(gt_confs) > <NUM_LIT:0>:<EOL><INDENT>gt_conf = min(gt_confs)<EOL>format = '<STR_LIT>'<EOL>gt_0 = '<STR_LIT>' + str(gt_conf)<EOL>gt_1 = '<STR_LIT>' + str(gt_conf)<EOL><DEDENT>if ref_seq_for_vcf == alt_seq_for_vcf:<EOL><INDENT>return VcfRecord('<STR_LIT:\t>'.join([<EOL>self.CHROM,<EOL>str(ref_start + <NUM_LIT:1>),<EOL>'<STR_LIT:.>',<EOL>ref_seq_for_vcf,<EOL>'<STR_LIT>'.join(all_alt_seq),<EOL>'<STR_LIT:.>', '<STR_LIT:.>', '<STR_LIT>',<EOL>format, gt_0,<EOL>]))<EOL><DEDENT>else:<EOL><INDENT>return VcfRecord('<STR_LIT:\t>'.join([<EOL>self.CHROM,<EOL>str(ref_start + <NUM_LIT:1>),<EOL>'<STR_LIT:.>',<EOL>ref_seq_for_vcf,<EOL>alt_seq_for_vcf,<EOL>'<STR_LIT:.>', '<STR_LIT:.>', '<STR_LIT>',<EOL>format, gt_1,<EOL>]))<EOL><DEDENT>
Tries to merge this VcfRecord with other VcfRecord always using called allele as alt.
        Simple example (working in 0-based coords):
        ref = ACGT
        var1 = SNP at position 1, C->G called alt
        var2 = SNP at position 3, T->A called ref
        then this returns new variant, position=1, REF=CGT, ALT=GGT.

        If there is any kind of conflict, eg two SNPs in same position, then
        returns None.
        Also assumes there is only one ALT, otherwise returns None.