1 """This module deals with CAPS markers.
2
3 A CAPS marker is a location a DifferentialCutsite as described below and a
4 set of primers that can be used to visualize this. More information can
5 be found in the paper located at:
6
7 http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=8106085&dopt=Abstract
8
9 Copyright Jonathan Taylor 2005
10 """
11
13 """A differential cutsite is a location in an alignment where an enzyme cuts
14 at least one sequence and also cannot cut at least one other sequence.
15
16 Members:
17 start Where it lives in the alignment.
18 enzyme The enzyme that causes this.
19 cuts_in A list of sequences (as indexes into the alignment) the
20 enzyme cuts in.
21 blocked_in A list of sequences (as indexes into the alignment) the
22 enzyme is blocked in.
23
24 """
25
27 """Initialize a DifferentialCutsite.
28
29 Each member (as listed in the class description) should be included as a
30 keyword.
31 """
32
33 self.start = int(kwds["start"])
34 self.enzyme = kwds["enzyme"]
35 self.cuts_in = kwds["cuts_in"]
36 self.blocked_in = kwds["blocked_in"]
37
40
42 """A map of an alignment showing all possible dcuts.
43
44 Members:
45 alignment The alignment that is mapped.
46 dcuts A list of possible CAPS markers in the form of
47 DifferentialCutsites.
48 """
49
50 - def __init__(self, alignment, enzymes = []):
72
74 cuts = {}
75 all = []
76
77
78 for seq in self.sequences:
79
80
81 cuts[seq] = [cut - enzyme.fst5 for cut in enzyme.search(seq)]
82
83
84 all.extend(cuts[seq])
85
86
87 all.sort()
88
89 last = -999
90 new = []
91 for cut in all:
92 if cut != last:
93 new.append(cut)
94 last = cut
95
96 all = new
97
98
99 for cut in all:
100
101
102 cuts_in = []
103 blocked_in = []
104
105 for i in range(0, self.size):
106 seq = self.sequences[i]
107 if cut in cuts[seq]:
108 cuts_in.append(i)
109 else:
110 blocked_in.append(i)
111
112 if cuts_in != [] and blocked_in != []:
113 self.dcuts.append(DifferentialCutsite(start = cut, enzyme = enzyme, cuts_in = cuts_in, blocked_in = blocked_in))
114
116 self.dcuts = []
117
118 for enzyme in self.enzymes:
119 self._digest_with(enzyme)
120