def process_alignment_dict(self):
<EOL>nseq = len(self.aln)<EOL>inv_map = defaultdict(list)<EOL>for k,v in self.aln.items():<EOL><INDENT>for pos, bs in v.items():<EOL><INDENT>inv_map[pos].append(bs)<EOL><DEDENT><DEDENT>self.nonref_positions = np.sort(list(inv_map.keys()))<EOL>self.inferred_const_sites = []<EOL>ambiguous_char = self.gtr.ambiguous<EOL>nonref_const = []<EOL>nonref_alleles = []<EOL>ambiguous_const = []<EOL>variable_pos = []<EOL>for pos, bs in inv_map.items(): <EOL><INDENT>bases = "<STR_LIT>".join(np.unique(bs))<EOL>if len(bs) == nseq:<EOL><INDENT>if (len(bases)<=<NUM_LIT:2> and ambiguous_char in bases) or len(bases)==<NUM_LIT:1>:<EOL><INDENT>nonref_const.append(pos)<EOL>nonref_alleles.append(bases.replace(ambiguous_char, '<STR_LIT>'))<EOL>if ambiguous_char in bases: <EOL><INDENT>self.inferred_const_sites.append(pos)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>variable_pos.append(pos)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if bases==ambiguous_char:<EOL><INDENT>ambiguous_const.append(pos)<EOL>self.inferred_const_sites.append(pos) <EOL><DEDENT>else:<EOL><INDENT>variable_pos.append(pos)<EOL><DEDENT><DEDENT><DEDENT>refMod = np.array(list(self.ref))<EOL>refMod[nonref_const] = nonref_alleles<EOL>states = self.gtr.alphabet<EOL>refMod[variable_pos] = '<STR_LIT:.>'<EOL>reduced_alignment_const = []<EOL>alignment_patterns_const = {}<EOL>for base in states:<EOL><INDENT>p = base*nseq<EOL>pos = list(np.where(refMod==base)[<NUM_LIT:0>])<EOL>if len(pos):<EOL><INDENT>alignment_patterns_const[p] = [len(reduced_alignment_const), pos]<EOL>reduced_alignment_const.append(list(p))<EOL><DEDENT><DEDENT>return reduced_alignment_const, alignment_patterns_const, variable_pos<EOL>
prepare the dictionary specifying differences from a reference sequence
to construct the reduced alignment with variable sites only. NOTE:
    - sites can be constant but different from the reference
    - sites can be constant plus a ambiguous sites

assigns
-------
- self.nonref_positions: at least one sequence is different from ref

Returns
-------
reduced_alignment_const
    reduced alignment accounting for non-variable postitions

alignment_patterns_const
    dict pattern -> (pos in reduced alignment, list of pos in full alignment)

ariable_positions
    list of variable positions needed to construct remaining