1 class SampleKey(object):
2 """Identifier for a sample in a particular 'location' on a flowcell.
4 def __init__(self, lane=None, read=None, sample=None):
5 self.lane = int(lane) if lane is not None else None
6 self.read = int(read) if read is not None else None
10 return self.lane is None or \
11 self.read is None or \
13 iswild = property(_iswild)
15 def matches(self, other):
16 """Test non-None attributes
18 if not (self.lane is None or other.lane is None):
19 if self.lane != other.lane: return False
20 if not (self.read is None or other.read is None):
21 if self.read != other.read: return False
22 if not (self.sample is None or other.sample is None):
23 if self.sample != other.sample: return False
26 def __eq__(self, other):
27 return (self.lane == other.lane) and \
28 (self.read == other.read) and \
29 (self.sample == other.sample)
31 def __ne__(self, other):
32 return (self.lane != other.lane) or \
33 (self.read != other.read) or \
34 (self.sample != other.sample)
36 def __lt__(self, other):
37 if self.lane < other.lane:
39 elif self.lane > other.lane:
41 elif self.sample < other.sample:
43 elif self.sample > other.sample:
45 elif self.read < other.read:
47 elif self.read > other.read:
53 def __le__(self, other):
54 if self == other: return True
55 else: return self < other
57 def __gt__(self, other):
58 return not self <= other
60 def __ge__(self, other):
61 return not self < other
64 return hash((self.sample, self.lane, self.read))
69 name.append('L%s' % (self.lane,))
70 name.append('R%s' % (self.read,))
71 name.append('S%s' % (self.sample,))
73 return '<SampleKey(' + ",".join(name) + ')>'