a b/singlecellmultiomics/modularDemultiplexer/demultiplexModules/NLAIII.py
1
from singlecellmultiomics.modularDemultiplexer.baseDemultiplexMethods import UmiBarcodeDemuxMethod, NonMultiplexable
2
3
# NLAIII, 96 well format with 3bp UMI
4
5
6
class NLAIII_96w_c8_u3(UmiBarcodeDemuxMethod):
7
    def __init__(self, barcodeFileParser, **kwargs):
8
        self.barcodeFileAlias = 'lennart96NLA'
9
        UmiBarcodeDemuxMethod.__init__(
10
            self,
11
            umiRead=0,
12
            umiStart=0,
13
            umiLength=3,
14
            random_primer_read=1,
15
            random_primer_length=6,
16
            barcodeRead=0,
17
            barcodeStart=3,
18
            barcodeLength=8,
19
            barcodeFileAlias=self.barcodeFileAlias,
20
            barcodeFileParser=barcodeFileParser,
21
            **kwargs)
22
        self.shortName = 'NLAIII96C8U3'
23
        self.longName = 'NLAIII, 96well CB: 8bp UMI: 3bp RP: 6bp'
24
        self.autoDetectable = True
25
        self.description = '96 well format. 3bp umi followed by 8bp barcode. R2 starts with a 6bp random primer'
26
27
28
# NLAIII, 384 well format with 3bp UMI
29
class NLAIII_384w_c8_u3(UmiBarcodeDemuxMethod):
30
    def __init__(self, barcodeFileParser, **kwargs):
31
        self.barcodeFileAlias = 'maya_384NLA'
32
        UmiBarcodeDemuxMethod.__init__(
33
            self,
34
            umiRead=0,
35
            umiStart=0,
36
            umiLength=3,
37
            barcodeRead=0,
38
            barcodeStart=3,
39
            barcodeLength=8,
40
            random_primer_read=1,
41
            random_primer_length=6,
42
            barcodeFileAlias=self.barcodeFileAlias,
43
            barcodeFileParser=barcodeFileParser,
44
            **kwargs)
45
        self.shortName = 'NLAIII384C8U3'
46
        self.longName = 'NLAIII, 384well CB: 8bp UMI: 3bp RP:6bp'
47
        self.autoDetectable = True
48
        self.description = '384 well format. 3bp umi followed by 8bp barcode. R2 starts with a 6bp random primer'
49
50
    def demultiplex(self, records, **kwargs):
51
        if kwargs.get('probe') and records[0].sequence[self.barcodeLength + \
52
                      self.umiLength: self.barcodeLength + self.umiLength + 4] != 'CATG':
53
            raise NonMultiplexable
54
55
        taggedRecords = UmiBarcodeDemuxMethod.demultiplex(
56
            self, records, **kwargs)
57
        return taggedRecords
58
59
60
61
# NLAIII, 384 well format with 3bp UMI, single end, because? Why? Lets make ourselves unable to deduplicate IVT
62
class NLAIII_384w_c8_u3_SINGLE_END(UmiBarcodeDemuxMethod):
63
    def __init__(self, barcodeFileParser, **kwargs):
64
        self.barcodeFileAlias = 'maya_384NLA'
65
        UmiBarcodeDemuxMethod.__init__(
66
            self,
67
            umiRead=0,
68
            umiStart=0,
69
            umiLength=3,
70
            barcodeRead=0,
71
            barcodeStart=3,
72
            barcodeLength=8,
73
            random_primer_read=None,
74
            random_primer_length=None,
75
            barcodeFileAlias=self.barcodeFileAlias,
76
            barcodeFileParser=barcodeFileParser,
77
            **kwargs)
78
        self.shortName = 'NLAIII384C8U3SE'
79
        self.longName = 'NLAIII, 384well CB: 8bp UMI: 3bp RP:6bp, single ended'
80
        self.autoDetectable = True
81
        self.description = '384 well format. 3bp umi followed by 8bp barcode. Single end: R2 is sadly missing'
82
83
    def demultiplex(self, records, **kwargs):
84
85
        if kwargs.get('probe') and records[0].sequence[self.barcodeLength + \
86
                      self.umiLength: self.barcodeLength + self.umiLength + 4] != 'CATG' or len(records)!=1:
87
            raise NonMultiplexable
88
89
        taggedRecords = UmiBarcodeDemuxMethod.demultiplex(
90
            self, records, **kwargs)
91
        return taggedRecords
92
93
94
class NLAIII_96w_c8_u3_SINGLE_END(UmiBarcodeDemuxMethod):
95
    def __init__(self, barcodeFileParser, **kwargs):
96
        self.barcodeFileAlias = 'lennart96NLA'
97
        UmiBarcodeDemuxMethod.__init__(
98
            self,
99
            umiRead=0,
100
            umiStart=0,
101
            umiLength=3,
102
            barcodeRead=0,
103
            barcodeStart=3,
104
            barcodeLength=8,
105
            random_primer_read=None,
106
            random_primer_length=None,
107
            barcodeFileAlias=self.barcodeFileAlias,
108
            barcodeFileParser=barcodeFileParser,
109
            **kwargs)
110
        self.shortName = 'NLAIII96C8U3SE'
111
        self.longName = 'NLAIII, 96 well CB: 8bp UMI: 3bp RP:6bp, single ended'
112
        self.autoDetectable = True
113
        self.description = '96 well format. 3bp umi followed by 8bp barcode. Single end: R2 is missing'
114
115
    def demultiplex(self, records, **kwargs):
116
117
        if kwargs.get('probe') and records[0].sequence[self.barcodeLength + \
118
                      self.umiLength: self.barcodeLength + self.umiLength + 4] != 'CATG' or len(records)!=1:
119
            raise NonMultiplexable
120
121
        taggedRecords = UmiBarcodeDemuxMethod.demultiplex(
122
            self, records, **kwargs)
123
        return taggedRecords