Skip to content

Commit

Permalink
release 0.0.49
Browse files Browse the repository at this point in the history
  • Loading branch information
y9c committed Jul 2, 2024
1 parent dc7ee14 commit aa5c9ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions cutseq/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
SuffixAdapter,
)
from cutadapt.files import InputPaths, OutputFiles
from cutadapt.info import ModificationInfo
from cutadapt.modifiers import (
AdapterCutter,
PairedEndRenamer,
Expand Down Expand Up @@ -79,6 +80,24 @@ def test(self, read, info):
return False


class ConditionalCutter(SingleEndModifier):
def __init__(self, length: int):
self.length = length

def __repr__(self):
return f"ConditionalCutter(length={self.length})"

def __call__(self, read, info: ModificationInfo):
if not info.matches:
return read
if self.length > 0:
info.cut_prefix = read.sequence[: self.length]
return read[self.length :]
elif self.length < 0:
info.cut_suffix = read.sequence[self.length :]
return read[: self.length]


class ReverseComplementConverter(SingleEndModifier):
def __init__(self):
self.rcd = False
Expand Down Expand Up @@ -548,15 +567,15 @@ def pipeline_paired(
UnconditionalCutter(barcode.umi5.len),
UnconditionalCutter(-barcode.umi5.len)
if settings.read_through
else None,
else ConditionalCutter(-barcode.umi5.len),
),
)
if barcode.umi3.len > 0:
modifiers.append(
(
UnconditionalCutter(-barcode.umi3.len)
if settings.read_through
else None,
else ConditionalCutter(-barcode.umi3.len),
UnconditionalCutter(barcode.umi3.len),
)
)
Expand All @@ -572,15 +591,15 @@ def pipeline_paired(
UnconditionalCutter(barcode.mask5.len),
UnconditionalCutter(-barcode.mask5.len)
if settings.read_through
else None,
else ConditionalCutter(-barcode.mask5.len),
)
)
if barcode.mask3.len > 0:
modifiers.append(
(
UnconditionalCutter(-barcode.mask3.len)
if settings.read_through
else None,
else ConditionalCutter(-barcode.mask3.len),
UnconditionalCutter(barcode.mask3.len),
)
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cutseq"
version = "0.0.48"
version = "0.0.49"
description = "Automatically cut adapter / barcode / UMI from NGS data"
authors = ["Ye Chang <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit aa5c9ba

Please sign in to comment.