Skip to content

Commit

Permalink
release 0.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
y9c committed Apr 23, 2024
1 parent 0d7bf07 commit 41a7ab8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
42 changes: 19 additions & 23 deletions cutseq/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ def pipeline_single(input1, output1, short1, untrimmed1, barcode, settings):
)

# step 9: reverse complement the read
if settings.reverse_complement and barcode.strand == "+":
logging.warn("Library is + strand, but reverse complement is enabled.")
if (settings.auto_rc and barcode.strand == "-") or settings.reverse_complement:
modifiers.append((ReverseComplementConverter(), ReverseComplementConverter()))
if settings.auto_rc:
if barcode.strand == "-":
modifiers.append(ReverseComplementConverter())
else:
logging.warn(
"Library is not (-) strand, but --auto-rc is enabled. Ignored."
)

# dry run and exit code
if settings.dry_run:
Expand Down Expand Up @@ -474,10 +477,12 @@ def pipeline_paired(
)

# step 9: reverse complement the read
if settings.reverse_complement and barcode.strand == "+":
logging.warn("Library is + strand, but reverse complement is enabled.")
if (settings.auto_rc and barcode.strand == "-") or settings.reverse_complement:
modifiers.append((ReverseComplementConverter(), ReverseComplementConverter()))
# NOTE: Do not need to rc, switch R1 and R2 since it is paired-end data
if settings.auto_rc:
if barcode.strand != "-":
logging.warn(
"Library is not (-) strand, but --auto-rc is enabled. Ignored."
)

# dry run and exit code
if settings.dry_run:
Expand Down Expand Up @@ -521,7 +526,11 @@ def pipeline_paired(
)
steps.append(
# -o ... -p ...
PairedEndSink(outfiles.open_record_writer(output1, output2))
PairedEndSink(
outfiles.open_record_writer(output1, output2)
if (settings.auto_rc and barcode.strand == "-")
else outfiles.open_record_writer(output2, output1)
)
)
pipeline = PairedEndPipeline(modifiers, steps)
stats = runner.run(pipeline, Progress(), outfiles)
Expand All @@ -542,7 +551,6 @@ def run_cutseq(args):
settings.threads = args.threads
settings.min_length = args.min_length
settings.dry_run = args.dry_run
settings.reverse_complement = args.reverse_complement
settings.auto_rc = args.auto_rc
settings.json_file = args.json_file
if len(args.input_file) == 1:
Expand Down Expand Up @@ -659,15 +667,10 @@ def main():

parser.add_argument("--trim-polyA", action="store_true", help="Trim polyA tail.")

parser.add_argument(
"--reverse-complement",
action="store_true",
help="Reverse complement the reads.",
)
parser.add_argument(
"--auto-rc",
action="store_true",
help="Reverse complete (-) strand reads only automatically.",
help="Reverse complement (-) strand automatically if the library is reverse orientation.",
)

parser.add_argument(
Expand Down Expand Up @@ -708,13 +711,6 @@ def main():
sys.exit(1)
args.adapter_scheme = args.adapter_scheme.replace(" ", "").upper()

if args.auto_rc is not None:
if args.reverse_complement:
logging.warn(
"Both --reverse-complement and --auto-rc are enabled, --reverse-complement will be ignored."
)
args.reverse_complement = False

if len(args.input_file) > 2:
logging.error("Input file can not be more than two.")
sys.exit(1)
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.23"
version = "0.0.24"
description = "Automatically cut adapter / barcode / UMI from NGS data"
authors = ["Ye Chang <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 41a7ab8

Please sign in to comment.