tsalign 2.1.0__tar.gz → 2.1.2__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.
Files changed (103) hide show
  1. {tsalign-2.1.0 → tsalign-2.1.2}/Cargo.lock +8 -8
  2. tsalign-2.1.2/PKG-INFO +144 -0
  3. {tsalign-2.1.0/python_bindings → tsalign-2.1.2}/README.md +1 -1
  4. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/Cargo.toml +1 -1
  5. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/Cargo.toml +3 -3
  6. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/Cargo.toml +2 -2
  7. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/inner.rs +12 -8
  8. {tsalign-2.1.0 → tsalign-2.1.2}/pyproject.toml +1 -0
  9. {tsalign-2.1.0 → tsalign-2.1.2}/python_bindings/Cargo.toml +3 -3
  10. tsalign-2.1.2/python_bindings/README.md +134 -0
  11. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/Cargo.toml +2 -2
  12. tsalign-2.1.0/PKG-INFO +0 -7
  13. {tsalign-2.1.0 → tsalign-2.1.2}/Cargo.toml +0 -0
  14. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/clippy.toml +0 -0
  15. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/closed_lists.rs +0 -0
  16. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/comparator.rs +0 -0
  17. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/cost.rs +0 -0
  18. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/lib.rs +0 -0
  19. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/open_lists/linear_heap.rs +0 -0
  20. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/open_lists.rs +0 -0
  21. {tsalign-2.1.0 → tsalign-2.1.2}/generic_a_star/src/reset.rs +0 -0
  22. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_geometry.rs +0 -0
  23. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result/a_star_sequences.rs +0 -0
  24. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result/alignment/iter.rs +0 -0
  25. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result/alignment/stream.rs +0 -0
  26. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result/alignment/template_switch_specifics.rs +0 -0
  27. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result/alignment.rs +0 -0
  28. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/alignment_result.rs +0 -0
  29. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs +0 -0
  30. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/gap_affine_edit_distance.rs +0 -0
  31. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/alignment_type/equal_cost_range.rs +0 -0
  32. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/alignment_type.rs +0 -0
  33. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/context.rs +0 -0
  34. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/display.rs +0 -0
  35. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/identifier.rs +0 -0
  36. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/lower_bounds/template_switch.rs +0 -0
  37. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/lower_bounds/template_switch_alignment.rs +0 -0
  38. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/lower_bounds.rs +0 -0
  39. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/chaining.rs +0 -0
  40. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/descendant.rs +0 -0
  41. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/node_ord.rs +0 -0
  42. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/primary_match.rs +0 -0
  43. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/primary_range.rs +0 -0
  44. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/secondary_deletion.rs +0 -0
  45. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/shortcut.rs +0 -0
  46. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/template_switch_count.rs +0 -0
  47. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/template_switch_min_length.rs +0 -0
  48. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/template_switch_total_length.rs +0 -0
  49. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance/strategies.rs +0 -0
  50. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/template_switch_distance.rs +0 -0
  51. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner/tests.rs +0 -0
  52. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/a_star_aligner.rs +0 -0
  53. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/alignment_configuration.rs +0 -0
  54. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/alignment_matrix/index/iterators.rs +0 -0
  55. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/alignment_matrix/index.rs +0 -0
  56. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/alignment_matrix.rs +0 -0
  57. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/config/io.rs +0 -0
  58. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/config.rs +0 -0
  59. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs/cost_function/io.rs +0 -0
  60. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs/cost_function.rs +0 -0
  61. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs/gap_affine/io/tests.rs +0 -0
  62. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs/gap_affine/io.rs +0 -0
  63. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs/gap_affine.rs +0 -0
  64. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/costs.rs +0 -0
  65. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/error.rs +0 -0
  66. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/io.rs +0 -0
  67. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/lib.rs +0 -0
  68. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsalign/src/tests.rs +0 -0
  69. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/error.rs +0 -0
  70. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/lib.rs +0 -0
  71. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/plain_text/alignment_stream.rs +0 -0
  72. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/plain_text/mutlipair_alignment_renderer/tests.rs +0 -0
  73. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/plain_text/mutlipair_alignment_renderer.rs +0 -0
  74. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/plain_text/parse_template_switches.rs +0 -0
  75. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/plain_text.rs +0 -0
  76. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/arrows.rs +0 -0
  77. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/font/sans_serif_mono.rs +0 -0
  78. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/font/typewriter.rs +0 -0
  79. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/font.rs +0 -0
  80. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/indexed_str.rs +0 -0
  81. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/labelled_sequence.rs +0 -0
  82. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg/numbers.rs +0 -0
  83. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/svg.rs +0 -0
  84. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/character.rs +0 -0
  85. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/complement.rs +0 -0
  86. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/index_types.rs +0 -0
  87. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/row.rs +0 -0
  88. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/source.rs +0 -0
  89. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement/template_switch.rs +0 -0
  90. {tsalign-2.1.0 → tsalign-2.1.2}/lib_tsshow/src/ts_arrangement.rs +0 -0
  91. {tsalign-2.1.0 → tsalign-2.1.2}/python/tsalign/__init__.py +0 -0
  92. {tsalign-2.1.0 → tsalign-2.1.2}/python/tsalign/_types.py +0 -0
  93. {tsalign-2.1.0 → tsalign-2.1.2}/python/tsalign/py.typed +0 -0
  94. {tsalign-2.1.0 → tsalign-2.1.2}/python_bindings/.gitignore +0 -0
  95. {tsalign-2.1.0 → tsalign-2.1.2}/python_bindings/BUILD.md +0 -0
  96. {tsalign-2.1.0 → tsalign-2.1.2}/python_bindings/src/lib.rs +0 -0
  97. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/chain/context.rs +0 -0
  98. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/chain/display.rs +0 -0
  99. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/chain/node/display.rs +0 -0
  100. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/chain/node.rs +0 -0
  101. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/chain.rs +0 -0
  102. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/lib.rs +0 -0
  103. {tsalign-2.1.0 → tsalign-2.1.2}/seed_chain/src/seed.rs +0 -0
@@ -417,7 +417,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
417
417
 
418
418
  [[package]]
419
419
  name = "generic_a_star"
420
- version = "2.1.0"
420
+ version = "2.1.2"
421
421
  dependencies = [
422
422
  "binary-heap-plus",
423
423
  "compare",
@@ -548,7 +548,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
548
548
 
549
549
  [[package]]
550
550
  name = "lib_ts_chainalign"
551
- version = "2.1.0"
551
+ version = "2.1.2"
552
552
  dependencies = [
553
553
  "binary-heap-plus",
554
554
  "bincode",
@@ -568,7 +568,7 @@ dependencies = [
568
568
 
569
569
  [[package]]
570
570
  name = "lib_tsalign"
571
- version = "2.1.0"
571
+ version = "2.1.2"
572
572
  dependencies = [
573
573
  "binary-heap-plus",
574
574
  "compact-genome",
@@ -589,7 +589,7 @@ dependencies = [
589
589
 
590
590
  [[package]]
591
591
  name = "lib_tsshow"
592
- version = "2.1.0"
592
+ version = "2.1.2"
593
593
  dependencies = [
594
594
  "ena",
595
595
  "itertools",
@@ -804,7 +804,7 @@ dependencies = [
804
804
 
805
805
  [[package]]
806
806
  name = "py_lib_tsalign"
807
- version = "2.1.0"
807
+ version = "2.1.2"
808
808
  dependencies = [
809
809
  "compact-genome",
810
810
  "lib_tsalign",
@@ -1008,7 +1008,7 @@ dependencies = [
1008
1008
 
1009
1009
  [[package]]
1010
1010
  name = "seed_chain"
1011
- version = "2.1.0"
1011
+ version = "2.1.2"
1012
1012
  dependencies = [
1013
1013
  "compact-genome",
1014
1014
  "generic_a_star",
@@ -1360,7 +1360,7 @@ checksum = "2b939c825d0c4295ac520f7b479927c1e5b458c9107a9d6f5ba65bc867bb93a5"
1360
1360
 
1361
1361
  [[package]]
1362
1362
  name = "tsalign"
1363
- version = "2.1.0"
1363
+ version = "2.1.2"
1364
1364
  dependencies = [
1365
1365
  "anyhow",
1366
1366
  "bincode",
@@ -1381,7 +1381,7 @@ dependencies = [
1381
1381
 
1382
1382
  [[package]]
1383
1383
  name = "tsalign-tests"
1384
- version = "2.1.0"
1384
+ version = "2.1.2"
1385
1385
  dependencies = [
1386
1386
  "anyhow",
1387
1387
  "clap",
tsalign-2.1.2/PKG-INFO ADDED
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: tsalign
3
+ Version: 2.1.2
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
9
+
10
+ # Python Bindings for [`lib_tsalign`](https://crates.io/crates/lib_tsalign)
11
+
12
+ [![PyPI](https://img.shields.io/pypi/v/tsalign)](https://pypi.org/project/tsalign/)
13
+
14
+ Python bindings for the template switch aligner. Aligns two DNA sequences
15
+ while detecting template switches — short-range translocations where a query
16
+ region is copied from (or aligns to) a different location, possibly on the
17
+ reverse complement strand.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install tsalign
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ ```python
28
+ import tsalign
29
+
30
+ result = tsalign.align("ACGTACGT", "ACGACGT")
31
+ print(result.cigar()) # compact alignment string
32
+ print(result.stats()) # cost, duration, node counts, …
33
+ ```
34
+
35
+ ## Aligner options
36
+
37
+ Create an `Aligner` once and reuse it for many sequences:
38
+
39
+ ```python
40
+ aligner = tsalign.Aligner(
41
+ min_length_strategy="preprocess_lookahead", # default: "lookahead"
42
+ chaining_strategy="lower_bound", # default: "none"
43
+ total_length_strategy="maximise", # default: "maximise"
44
+ no_ts=False, # set True for plain gap-affine
45
+ )
46
+
47
+ result = aligner.align("ACGTACGT", "ACGACGT")
48
+ ```
49
+
50
+ ## Custom cost configuration
51
+
52
+ Costs are specified in `.tsa` format. Use `sample_tsa_config/config.tsa`
53
+ as a starting point and consult the [main repository README](../README.md#modifying-the-cost-function) for a description
54
+ of each parameter.
55
+
56
+ ```python
57
+ aligner = tsalign.Aligner(costs_file="sample_tsa_config/config.tsa")
58
+ result = aligner.align("ACGTACGT", "ACGACGT")
59
+ ```
60
+
61
+ You can also pass the cost string directly:
62
+
63
+ ```python
64
+ with open("my_costs.tsa") as f:
65
+ cost_str = f.read()
66
+ aligner = tsalign.Aligner(costs=cost_str)
67
+ ```
68
+
69
+ ## Restricting the alignment range
70
+
71
+ Use `AlignmentRange` to align only a window of the input sequences:
72
+
73
+ ```python
74
+ from tsalign import Aligner, AlignmentRange
75
+
76
+ aligner = Aligner()
77
+ result = aligner.align(
78
+ "NNNACGTACGTNNN",
79
+ "ACGACGT",
80
+ range=AlignmentRange(reference_start=3, reference_end=11),
81
+ )
82
+ print(result.cigar())
83
+ ```
84
+
85
+ Individual start/limit keyword arguments are also accepted when `range` is
86
+ not provided:
87
+
88
+ ```python
89
+ result = aligner.align(
90
+ "NNNACGTACGTNNN",
91
+ "ACGACGT",
92
+ reference_start=3,
93
+ reference_limit=11,
94
+ )
95
+ ```
96
+
97
+ ## Working with alignment operations
98
+
99
+ `alignment.alignments()` returns a typed list of `(count, op)` pairs:
100
+
101
+ ```python
102
+ from tsalign import align, TemplateSwitchEntranceOp, TemplateSwitchExitOp
103
+
104
+ result = align(reference, query)
105
+ for count, op in result.alignments():
106
+ if isinstance(op, TemplateSwitchEntranceOp):
107
+ print(f"Template switch: {op.direction}, primary={op.primary}, offset={op.first_offset}")
108
+ elif isinstance(op, TemplateSwitchExitOp):
109
+ print(f"Exit, anti-primary gap: {op.anti_primary_gap}")
110
+ else:
111
+ # SimpleAlignmentOp — a basic edit in the primary or secondary track
112
+ print(f"{count}x {op.kind}")
113
+ ```
114
+
115
+ ## Visualisation
116
+
117
+ ```python
118
+ result = tsalign.align(reference, query)
119
+ result.viz_template_switches() # prints ASCII art to stdout
120
+ ```
121
+
122
+ ## Limiting search resources
123
+
124
+ ```python
125
+ result = aligner.align(
126
+ reference,
127
+ query,
128
+ cost_limit=100, # return None if cost would exceed this
129
+ memory_limit=500_000, # return None if memory exceeds this number of bytes
130
+ )
131
+ if result is None:
132
+ print("No alignment found within limits")
133
+ ```
134
+
135
+ ## Accepted sequence types
136
+
137
+ Any object whose `str()` representation is a valid DNA string (ACGTN) is
138
+ accepted — including `Bio.Seq`:
139
+
140
+ ```python
141
+ from Bio.Seq import Seq
142
+ result = tsalign.align(Seq("ACGTACGT"), Seq("ACGACGT"))
143
+ ```
144
+
@@ -41,7 +41,7 @@ result = aligner.align("ACGTACGT", "ACGACGT")
41
41
  ## Custom cost configuration
42
42
 
43
43
  Costs are specified in `.tsa` format. Use `sample_tsa_config/config.tsa`
44
- as a starting point and consult the main repository README for a description
44
+ as a starting point and consult the [main repository README](../README.md#modifying-the-cost-function) for a description
45
45
  of each parameter.
46
46
 
47
47
  ```python
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "generic_a_star"
3
3
  description = "A generic implementation of the A* algorithm"
4
- version = "2.1.0"
4
+ version = "2.1.2"
5
5
  edition.workspace = true
6
6
  rust-version.workspace = true
7
7
  license.workspace = true
@@ -2,7 +2,7 @@
2
2
  name = "lib_tsalign"
3
3
  description = "A sequence-to-sequence aligner that accounts for template switches"
4
4
  authors = ["Sebastian Schmidt <sebastian.schmidt@helsinki.fi>"]
5
- version = "2.1.0"
5
+ version = "2.1.2"
6
6
  license.workspace = true
7
7
  edition.workspace = true
8
8
  rust-version.workspace = true
@@ -26,9 +26,9 @@ thiserror = "2.0.3"
26
26
  num-traits.workspace = true
27
27
  serde = { workspace = true, features = ["derive"], optional = true }
28
28
  noisy_float = { version = "0.2.0" }
29
- generic_a_star = { version = "2.1.0", path = "../generic_a_star" }
29
+ generic_a_star = { version = "2.1.2", path = "../generic_a_star" }
30
30
  log.workspace = true
31
31
  rustc-hash = "2.1.1"
32
- seed_chain = { version = "2.1.0", path = "../seed_chain" }
32
+ seed_chain = { version = "2.1.2", path = "../seed_chain" }
33
33
  extend_map = "0.14.3"
34
34
  template-switch-error-free-inners = "0.1.1"
@@ -3,13 +3,13 @@ name = "lib_tsshow"
3
3
  description = "A visualiser for template-switch alignments"
4
4
  license.workspace = true
5
5
  authors = ["Sebastian Schmidt <sebastian.schmidt@helsinki.fi>"]
6
- version = "2.1.0"
6
+ version = "2.1.2"
7
7
  edition.workspace = true
8
8
  rust-version.workspace = true
9
9
  repository.workspace = true
10
10
 
11
11
  [dependencies]
12
- lib_tsalign = { version = "2.1.0", path = "../lib_tsalign" }
12
+ lib_tsalign = { version = "2.1.2", path = "../lib_tsalign" }
13
13
  log.workspace = true
14
14
  svg = "0.18.0"
15
15
  resvg = "0.45.0"
@@ -330,15 +330,19 @@ impl TsInnerArrangement {
330
330
  .iter()
331
331
  .take_while(|(_, c)| c.is_blank())
332
332
  .last()
333
- .unwrap()
334
- .0;
333
+ .map(|(i, _)| i);
335
334
  let first_final_blank = inner
336
335
  .iter()
337
336
  .rev()
338
337
  .take_while(|(_, c)| c.is_blank())
339
338
  .last()
340
- .unwrap()
341
- .0;
339
+ .map(|(i, _)| i)
340
+ .unwrap_or(inner.len().into());
341
+ let first_non_blank = inner
342
+ .iter()
343
+ .find(|(_, c)| !c.is_blank())
344
+ .map(|(i, _)| i)
345
+ .unwrap();
342
346
  let first_source_column = inner
343
347
  .iter_values()
344
348
  .filter(|c| c.is_source_char())
@@ -355,7 +359,8 @@ impl TsInnerArrangement {
355
359
  assert!(first_source_column >= last_source_column);
356
360
 
357
361
  // Add prefix to extend to max_end.
358
- let mut arrangement_column = last_initial_blank + 1usize;
362
+ let mut arrangement_column =
363
+ last_initial_blank.map(|i| i + 1usize).unwrap_or(0.into());
359
364
  let mut source_column = first_source_column;
360
365
  #[allow(clippy::explicit_counter_loop)]
361
366
  for _ in 0..ts.equal_cost_range.max_end {
@@ -384,15 +389,14 @@ impl TsInnerArrangement {
384
389
  }
385
390
 
386
391
  // Convert prefix to extend to min_end.
387
- let mut arrangement_column = last_initial_blank;
392
+ let mut arrangement_column = first_non_blank;
388
393
  for _ in 0..-ts.equal_cost_range.min_end {
389
- arrangement_column += 1;
390
-
391
394
  while !inner[arrangement_column].is_source_char() {
392
395
  arrangement_column += 1;
393
396
  }
394
397
 
395
398
  inner[arrangement_column].to_optional();
399
+ arrangement_column += 1;
396
400
  }
397
401
 
398
402
  // Convert suffix to extend to max_start.
@@ -10,6 +10,7 @@ classifiers = [
10
10
  "Programming Language :: Python :: Implementation :: CPython",
11
11
  "Programming Language :: Python :: Implementation :: PyPy",
12
12
  ]
13
+ readme = "README.md"
13
14
  dynamic = ["version"]
14
15
  [tool.maturin]
15
16
  features = ["pyo3/extension-module"]
@@ -6,7 +6,7 @@ authors = [
6
6
  "Sebastian Schmidt <sebastian.schmidt@helsinki.fi>",
7
7
  "Jasper Krauter <jasper.krauter@helsinki.fi>",
8
8
  ]
9
- version = "2.1.0"
9
+ version = "2.1.2"
10
10
  edition.workspace = true
11
11
  rust-version.workspace = true
12
12
  repository.workspace = true
@@ -19,10 +19,10 @@ crate-type = ["cdylib"]
19
19
 
20
20
  [dependencies]
21
21
  pyo3 = "0.26"
22
- lib_tsalign = { version = "2.1.0", path = "../lib_tsalign", features = [
22
+ lib_tsalign = { version = "2.1.2", path = "../lib_tsalign", features = [
23
23
  "serde",
24
24
  ] }
25
- lib_tsshow = { version = "2.1.0", path = "../lib_tsshow" }
25
+ lib_tsshow = { version = "2.1.2", path = "../lib_tsshow" }
26
26
  serde.workspace = true
27
27
  pythonize = "0.26"
28
28
  pyo3-log = "0.13"
@@ -0,0 +1,134 @@
1
+ # Python Bindings for [`lib_tsalign`](https://crates.io/crates/lib_tsalign)
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/tsalign)](https://pypi.org/project/tsalign/)
4
+
5
+ Python bindings for the template switch aligner. Aligns two DNA sequences
6
+ while detecting template switches — short-range translocations where a query
7
+ region is copied from (or aligns to) a different location, possibly on the
8
+ reverse complement strand.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pip install tsalign
14
+ ```
15
+
16
+ ## Quick start
17
+
18
+ ```python
19
+ import tsalign
20
+
21
+ result = tsalign.align("ACGTACGT", "ACGACGT")
22
+ print(result.cigar()) # compact alignment string
23
+ print(result.stats()) # cost, duration, node counts, …
24
+ ```
25
+
26
+ ## Aligner options
27
+
28
+ Create an `Aligner` once and reuse it for many sequences:
29
+
30
+ ```python
31
+ aligner = tsalign.Aligner(
32
+ min_length_strategy="preprocess_lookahead", # default: "lookahead"
33
+ chaining_strategy="lower_bound", # default: "none"
34
+ total_length_strategy="maximise", # default: "maximise"
35
+ no_ts=False, # set True for plain gap-affine
36
+ )
37
+
38
+ result = aligner.align("ACGTACGT", "ACGACGT")
39
+ ```
40
+
41
+ ## Custom cost configuration
42
+
43
+ Costs are specified in `.tsa` format. Use `sample_tsa_config/config.tsa`
44
+ as a starting point and consult the [main repository README](../README.md#modifying-the-cost-function) for a description
45
+ of each parameter.
46
+
47
+ ```python
48
+ aligner = tsalign.Aligner(costs_file="sample_tsa_config/config.tsa")
49
+ result = aligner.align("ACGTACGT", "ACGACGT")
50
+ ```
51
+
52
+ You can also pass the cost string directly:
53
+
54
+ ```python
55
+ with open("my_costs.tsa") as f:
56
+ cost_str = f.read()
57
+ aligner = tsalign.Aligner(costs=cost_str)
58
+ ```
59
+
60
+ ## Restricting the alignment range
61
+
62
+ Use `AlignmentRange` to align only a window of the input sequences:
63
+
64
+ ```python
65
+ from tsalign import Aligner, AlignmentRange
66
+
67
+ aligner = Aligner()
68
+ result = aligner.align(
69
+ "NNNACGTACGTNNN",
70
+ "ACGACGT",
71
+ range=AlignmentRange(reference_start=3, reference_end=11),
72
+ )
73
+ print(result.cigar())
74
+ ```
75
+
76
+ Individual start/limit keyword arguments are also accepted when `range` is
77
+ not provided:
78
+
79
+ ```python
80
+ result = aligner.align(
81
+ "NNNACGTACGTNNN",
82
+ "ACGACGT",
83
+ reference_start=3,
84
+ reference_limit=11,
85
+ )
86
+ ```
87
+
88
+ ## Working with alignment operations
89
+
90
+ `alignment.alignments()` returns a typed list of `(count, op)` pairs:
91
+
92
+ ```python
93
+ from tsalign import align, TemplateSwitchEntranceOp, TemplateSwitchExitOp
94
+
95
+ result = align(reference, query)
96
+ for count, op in result.alignments():
97
+ if isinstance(op, TemplateSwitchEntranceOp):
98
+ print(f"Template switch: {op.direction}, primary={op.primary}, offset={op.first_offset}")
99
+ elif isinstance(op, TemplateSwitchExitOp):
100
+ print(f"Exit, anti-primary gap: {op.anti_primary_gap}")
101
+ else:
102
+ # SimpleAlignmentOp — a basic edit in the primary or secondary track
103
+ print(f"{count}x {op.kind}")
104
+ ```
105
+
106
+ ## Visualisation
107
+
108
+ ```python
109
+ result = tsalign.align(reference, query)
110
+ result.viz_template_switches() # prints ASCII art to stdout
111
+ ```
112
+
113
+ ## Limiting search resources
114
+
115
+ ```python
116
+ result = aligner.align(
117
+ reference,
118
+ query,
119
+ cost_limit=100, # return None if cost would exceed this
120
+ memory_limit=500_000, # return None if memory exceeds this number of bytes
121
+ )
122
+ if result is None:
123
+ print("No alignment found within limits")
124
+ ```
125
+
126
+ ## Accepted sequence types
127
+
128
+ Any object whose `str()` representation is a valid DNA string (ACGTN) is
129
+ accepted — including `Bio.Seq`:
130
+
131
+ ```python
132
+ from Bio.Seq import Seq
133
+ result = tsalign.align(Seq("ACGTACGT"), Seq("ACGACGT"))
134
+ ```
@@ -3,7 +3,7 @@ name = "seed_chain"
3
3
  description = "A seeding and generic chaining mechanism for sequence-to-sequence alignment"
4
4
  license.workspace = true
5
5
  authors = ["Sebastian Schmidt <sebastian.schmidt@helsinki.fi>"]
6
- version = "2.1.0"
6
+ version = "2.1.2"
7
7
  edition.workspace = true
8
8
  rust-version.workspace = true
9
9
  repository.workspace = true
@@ -12,5 +12,5 @@ repository.workspace = true
12
12
  [dependencies]
13
13
  compact-genome.workspace = true
14
14
  log.workspace = true
15
- generic_a_star = { version = "2.1.0", path = "../generic_a_star" }
15
+ generic_a_star = { version = "2.1.2", path = "../generic_a_star" }
16
16
  num-traits.workspace = true
tsalign-2.1.0/PKG-INFO DELETED
@@ -1,7 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: tsalign
3
- Version: 2.1.0
4
- Classifier: Programming Language :: Rust
5
- Classifier: Programming Language :: Python :: Implementation :: CPython
6
- Classifier: Programming Language :: Python :: Implementation :: PyPy
7
- Requires-Python: >=3.8
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes