1 from htsworkflow.pipelines import LANE_LIST
3 class SampleKey(object):
4 """Identifier for a sample in a particular 'location' on a flowcell.
6 def __init__(self, lane=None, read=None, sample=None):
7 self.lane = int(lane) if lane is not None else None
8 self.read = int(read) if read is not None else None
12 return self.lane is None or \
13 self.read is None or \
15 iswild = property(_iswild)
17 def matches(self, other):
18 """Test non-None attributes
20 if not (self.lane is None or other.lane is None):
21 if self.lane != other.lane: return False
22 if not (self.read is None or other.read is None):
23 if self.read != other.read: return False
24 if not (self.sample is None or other.sample is None):
25 if self.sample != other.sample: return False
28 def __eq__(self, other):
29 return (self.lane == other.lane) and \
30 (self.read == other.read) and \
31 (self.sample == other.sample)
33 def __ne__(self, other):
34 return (self.lane != other.lane) or \
35 (self.read != other.read) or \
36 (self.sample != other.sample)
38 def __lt__(self, other):
39 if self.lane < other.lane:
41 elif self.lane > other.lane:
43 elif self.sample < other.sample:
45 elif self.sample > other.sample:
47 elif self.read < other.read:
49 elif self.read > other.read:
55 def __le__(self, other):
56 if self == other: return True
57 else: return self < other
59 def __gt__(self, other):
60 return not self <= other
62 def __ge__(self, other):
63 return not self < other
66 return hash((self.sample, self.lane, self.read))
71 name.append('L%s' % (self.lane,))
72 name.append('R%s' % (self.read,))
73 name.append('S%s' % (self.sample,))
75 return '<SampleKey(' + ",".join(name) + ')>'
77 LANE_SAMPLE_KEYS = [ SampleKey(lane=l) for l in LANE_LIST ]