def __init__(self,sample_sheet_file):
        """
        Create a new SampleSheetBarcodes instance

        Arguments:
          sample_sheet_file (str): path of a SampleSheet.csv
            file

        """
        self._sample_sheet = SampleSheet(sample_sheet_file)
        self._sample_lookup = {}
        self._barcode_lookup = {}
        self._lanes = []
        sample_id = self._sample_sheet.sample_id_column
        for line in self._sample_sheet.data:
            if self._sample_sheet.has_lanes:
                lane = line['Lane']
            else:
                lane = None
            if lane not in self._lanes:
                self._lanes.append(lane)
                self._sample_lookup[lane] = {}
                self._barcode_lookup[lane] = {}
            sample = line[sample_id]
            index_seq = normalise_barcode(samplesheet_index_sequence(line))
            self._sample_lookup[lane][index_seq] = sample
            self._barcode_lookup[lane][sample] = index_seq
    def count_barcode(self,barcode,lane=None,incr=1):
        """
        Increment count of a barcode sequence

        Arguments:
          barcode (str): barcode sequence to count
          lane (int): lane that the barcode appears
            in (None if unknown)
          incr (int): increment the count for the
            barcode in the lane by this amount
            (defaults to 1)

        """
        # Normalise barcode
        barcode = normalise_barcode(barcode)
        # Store by lane
        try:
            self._seqs[lane][barcode] += incr
        except KeyError:
            try:
                self._seqs[lane][barcode] = incr
            except KeyError:
                self._seqs[lane] = { barcode: incr }
        # Store overall
        try:
            self._seqs_all[barcode] += incr
        except KeyError:
            self._seqs_all[barcode] = incr
Пример #3
0
    def __init__(self,sample_sheet_file):
        """
        Create a new SampleSheetBarcodes instance

        Arguments:
          sample_sheet_file (str): path of a SampleSheet.csv
            file

        """
        self._sample_sheet = SampleSheet(sample_sheet_file)
        self._sample_lookup = {}
        self._barcode_lookup = {}
        self._lanes = []
        sample_id = self._sample_sheet.sample_id_column
        for line in self._sample_sheet.data:
            if self._sample_sheet.has_lanes:
                lane = line['Lane']
            else:
                lane = None
            if lane not in self._lanes:
                self._lanes.append(lane)
                self._sample_lookup[lane] = {}
                self._barcode_lookup[lane] = {}
            sample = line[sample_id]
            index_seq = normalise_barcode(samplesheet_index_sequence(line))
            self._sample_lookup[lane][index_seq] = sample
            self._barcode_lookup[lane][sample] = index_seq
Пример #4
0
    def count_barcode(self,barcode,lane=None,incr=1):
        """
        Increment count of a barcode sequence

        Arguments:
          barcode (str): barcode sequence to count
          lane (int): lane that the barcode appears
            in (None if unknown)
          incr (int): increment the count for the
            barcode in the lane by this amount
            (defaults to 1)

        """
        # Normalise barcode
        barcode = normalise_barcode(barcode)
        # Store by lane
        try:
            self._seqs[lane][barcode] += incr
        except KeyError:
            try:
                self._seqs[lane][barcode] = incr
            except KeyError:
                self._seqs[lane] = { barcode: incr }
        # Store overall
        try:
            self._seqs_all[barcode] += incr
        except KeyError:
            self._seqs_all[barcode] = incr
    def barcode_lengths(self, lane=None):
        """
        Return lengths of barcode sequences

        Returns a list of the barcode sequence lengths.

        Arguments:
          lane (int): if specified then restricts the
            list to barcodes that appear in the named
            lane (default is to get lengths from all
            barcodes in all lanes)
        """
        lengths = set()
        for barcode in self.barcodes(lane=lane):
            lengths.add(len(normalise_barcode(barcode)))
        return sorted(list(lengths))