Make reduced alignment: made some dictionaries temporary objects instead of class attributes
@@ -176,8 +176,8 @@ class TreeAnc(object):
def make_reduced_alignment(self):
from collections import defaultdict
- self.alignment_patterns = {}
- self.position_to_pattern = {}
+ alignment_patterns = {}
+ position_to_pattern = {}
self.full_to_reduced_sequence_map = np.zeros(self.aln.get_alignment_length(), dtype=int)
self.reduced_to_full_sequence_map = {}
@@ -194,24 +194,24 @@ class TreeAnc(object):
other = [c for c in unique_letters if c!=self.gtr.ambiguous][0]
str_pat = str_pat.replace(self.gtr.ambiguous, other)
- if str_pat in self.alignment_patterns:
- self.alignment_patterns[str_pat][1].append(pi)
+ if str_pat in alignment_patterns:
+ alignment_patterns[str_pat][1].append(pi)
else:
- self.position_to_pattern[len(tmp)] = str_pat
- self.alignment_patterns[str_pat] = (len(tmp), [pi])
+ position_to_pattern[len(tmp)] = str_pat
+ alignment_patterns[str_pat] = (len(tmp), [pi])
tmp.append(pattern)
- self.multiplicity = np.zeros(len(self.alignment_patterns))
- for p, pos in self.alignment_patterns.values():
+ self.multiplicity = np.zeros(len(alignment_patterns))
+ for p, pos in alignment_patterns.values():
self.multiplicity[p]=len(pos)
self.reduced_alignment = np.array(tmp).T
- for p, pos in self.alignment_patterns.values():
+ for p, pos in alignment_patterns.values():
self.full_to_reduced_sequence_map[np.array(pos)]=p
- for p, val in self.alignment_patterns.iteritems():
- self.alignment_patterns[p]=(val[0], np.array(val[1], dtype=int))
+ for p, val in alignment_patterns.iteritems():
+ alignment_patterns[p]=(val[0], np.array(val[1], dtype=int))
self.reduced_to_full_sequence_map[val[0]]=np.array(val[1], dtype=int)
