cutseq 0.0.6__tar.gz → 0.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cutseq
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Automatically cut adapter / barcode / UMI from NGS data
5
5
  Home-page: https://github.com/y9c/cutseq
6
6
  License: MIT
@@ -27,6 +27,7 @@ from cutadapt.modifiers import (
27
27
  PairedEndRenamer,
28
28
  QualityTrimmer,
29
29
  Renamer,
30
+ SingleEndModifier,
30
31
  SuffixRemover,
31
32
  UnconditionalCutter,
32
33
  )
@@ -55,6 +56,38 @@ def patched_problematic_method(self, *args, **kwargs):
55
56
 
56
57
  Statistics._collect_modifier = patched_problematic_method
57
58
 
59
+ ## Enhnace function for cutadapt
60
+
61
+
62
+ class IsUntrimmedAny(Predicate):
63
+ """
64
+ Select reads for which no adapter match was found
65
+ """
66
+
67
+ def __init__(self, ref_adapters):
68
+ self.ref_adapters = ref_adapters
69
+
70
+ def __repr__(self):
71
+ return "IsUntrimmedAny()"
72
+
73
+ def test(self, read, info):
74
+ # check not all adapters with ref_adapters are exist in the matches
75
+ match_adapters = [match.adapter for match in info.matches]
76
+ if any([adapter not in match_adapters for adapter in self.ref_adapters]):
77
+ return True
78
+ return False
79
+
80
+
81
+ class ReverseComplementConverter(SingleEndModifier):
82
+ def __init__(self):
83
+ self.rcd = False
84
+
85
+ def __repr__(self):
86
+ return f"UnconditionalCutter(length={self.length})"
87
+
88
+ def __call__(self, read, info):
89
+ return read.reverse_complement()
90
+
58
91
 
59
92
  __version__ = importlib.metadata.version(__package__ or __name__)
60
93
 
@@ -143,25 +176,6 @@ class CutadaptConfig:
143
176
  self.threads = 1
144
177
 
145
178
 
146
- class IsUntrimmedAny(Predicate):
147
- """
148
- Select reads for which no adapter match was found
149
- """
150
-
151
- def __init__(self, ref_adapters):
152
- self.ref_adapters = ref_adapters
153
-
154
- def __repr__(self):
155
- return "IsUntrimmedAny()"
156
-
157
- def test(self, read, info):
158
- # check not all adapters with ref_adapters are exist in the matches
159
- match_adapters = [match.adapter for match in info.matches]
160
- if any([adapter not in match_adapters for adapter in self.ref_adapters]):
161
- return True
162
- return False
163
-
164
-
165
179
  def run_steps(steps, dry_run=False):
166
180
  if dry_run:
167
181
  print(
@@ -240,6 +254,10 @@ def pipeline_single(input1, output1, short1, untrimmed1, barcode, settings):
240
254
  QualityTrimmer(cutoff_front=0, cutoff_back=settings.min_quality),
241
255
  )
242
256
 
257
+ # step 9: reverse complement the read
258
+ if settings.reverse_complement:
259
+ modifiers.append(ReverseComplementConverter())
260
+
243
261
  inpaths = InputPaths(input1)
244
262
 
245
263
  with make_runner(inpaths, cores=settings.threads) as runner:
@@ -424,6 +442,10 @@ def pipeline_paired(
424
442
  )
425
443
  )
426
444
 
445
+ # step 9: reverse complement the read
446
+ if settings.reverse_complement:
447
+ modifiers.append((ReverseComplementConverter(), ReverseComplementConverter()))
448
+
427
449
  inpaths = InputPaths(input1, input2)
428
450
 
429
451
  with make_runner(inpaths, cores=settings.threads) as runner:
@@ -481,6 +503,7 @@ def run_cutseq(args):
481
503
  settings.threads = args.threads
482
504
  settings.min_length = args.min_length
483
505
  settings.dry_run = args.dry_run
506
+ settings.reverse_complement = args.reverse_complement
484
507
  if len(args.input_file) == 1:
485
508
  pipeline_single(
486
509
  args.input_file[0],
@@ -583,6 +606,12 @@ def main():
583
606
 
584
607
  parser.add_argument("--trim-polyA", action="store_true", help="Trim polyA tail.")
585
608
 
609
+ parser.add_argument(
610
+ "--reverse-complement",
611
+ action="store_true",
612
+ help="Reverse complement the reads.",
613
+ )
614
+
586
615
  parser.add_argument(
587
616
  "-t",
588
617
  "--threads",
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cutseq"
3
- version = "0.0.6"
3
+ version = "0.0.7"
4
4
  description = "Automatically cut adapter / barcode / UMI from NGS data"
5
5
  authors = ["Ye Chang <yech1990@gmail.com>"]
6
6
  license = "MIT"
File without changes
File without changes