def _trimmed_front(self, match): """Return a trimmed read""" read = match.read self.lengths_front[match.rstop] += 1 self.errors_front[match.rstop][match.errors] += 1 # to remove a front adapter, we need to re-encode the first color following the adapter match color_after_adapter = read.sequence[match.rstop:match.rstop + 1] if not color_after_adapter: # the read is empty return read[match.rstop:] base_after_adapter = colorspace.DECODE[self.nucleotide_sequence[-1] + color_after_adapter] new_first_color = colorspace.ENCODE[read.primer + base_after_adapter] seq = new_first_color + read.sequence[(match.rstop + 1):] qual = read.qualities[match.rstop:] if read.qualities else None return ColorspaceSequence(read.name, seq, qual, read.primer)
def test_cs_5p(): read = ColorspaceSequence("name", b"0123", b"DEFG", b"T") adapter = ColorspaceAdapter(b"CG", PREFIX, 0.1) cutter = RepeatedAdapterCutter([adapter]) matches = cutter.find_match(read)
def test_invalid_primer(self): ColorspaceSequence(name="name", sequence="K0123", qualities="####")
def test_too_many_qualities_colorspace(self): ColorspaceSequence(name="name", sequence="T0123", qualities="#####")
def test_cs_5p(): read = ColorspaceSequence("name", "0123", "DEFG", "T") adapter = ColorspaceAdapter("CG", PREFIX, 0.1) cutter = AdapterCutter([adapter]) trimmed_read = cutter(read)
def test_cs_5p(): read = ColorspaceSequence("name", "0123", "DEFG", "T") adapter = ColorspaceAdapter("CG", PREFIX, 0.1) cutter = AdapterCutter([adapter]) matches = cutter.find_matches(read)