buttle 0.3.0__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.
buttle-0.3.0/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2026 David Vance
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
buttle-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,268 @@
1
+ Metadata-Version: 2.4
2
+ Name: buttle
3
+ Version: 0.3.0
4
+ Requires-Dist: pillow>=12.3.0
5
+ License-File: LICENSE
6
+ Summary: Command-line utilities for DNA and protein sequence analysis. At your service.
7
+ License-Expression: BSD-3-Clause
8
+ Requires-Python: >=3.15
9
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
10
+ Project-URL: Homepage, https://github.com/DJV512/Buttle
11
+ Project-URL: Issues, https://github.com/DJV512/Buttle/issues
12
+ Project-URL: Repository, https://github.com/DJV512/Buttle
13
+
14
+ ![Logo](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/buttle_logo_with_tag.png)
15
+ Buttle was developed as a lightweight collection of bioinformatics utilities for common sequence-analysis tasks, with an emphasis on convenient command-line use. It provides tools for working with DNA and protein sequences, including sequence manipulation, peptide properties, motif searching, pairwise alignment, and multiple sequence alignment.
16
+
17
+ Buttle is currently under active development.
18
+
19
+ ## Features
20
+
21
+ ### General sequence tools
22
+
23
+ - Search for sequences and report their positions
24
+ - Calculate sequence length
25
+ - Calculate pairwise percent identity for sequences in a FASTA file
26
+
27
+ ### DNA sequences
28
+
29
+ - Transcribe DNA to RNA
30
+ - Translate DNA in three reading frames
31
+ - Generate reverse complements
32
+ - Calculate GC content
33
+ - Pairwise DNA sequence alignment
34
+
35
+ ### Protein sequence tools
36
+ - Calculate protein net charge
37
+ - Calculate molecular weight
38
+ - Calculate extinction coefficient
39
+ - Identify and highlight potential N-linked glycosylation sites
40
+ - Compare two sequences and look for conserved motifs of varying lengths
41
+ - Pairwise sequence alignment from two raw sequence arguments
42
+ - Rust backend by default, with a Python backend available
43
+ - Multiple sequence alignment (MSA) from FASTA files or FASTA-formatted strings
44
+ - Rust backend by default, with a Python backend available
45
+
46
+
47
+ ### Rendering
48
+ - Display alignments in the terminal (when no `--save` argument provided)
49
+ - Generate publication-quality PNG and TIFF alignment images
50
+ - Save Pairwise DNA and protein alignments
51
+ - Save multiple protein sequence alignments
52
+ - Alignment row length can be tuned with `--wrap`
53
+ - Argument `--real-ruler` displays residue number based on the first sequence, skipping gaps
54
+ - Argument `--diff` displays alignment differences relative to a reference sequence
55
+ - MSA optionally adds a consensus sequence with `--consensus`
56
+
57
+
58
+ ## Installation/Requirements
59
+
60
+ Buttle is distributed through PyPI and requires Python 3.15 or newer. Prebuilt wheels include both the Python modules and the compiled Rust extension, so Rust and Cargo are not required when installing a compatible wheel.
61
+
62
+
63
+ ### Command-line installation
64
+
65
+ Install Buttle as a standalone command-line tool using uv:
66
+
67
+ ```bash
68
+ uv tool install buttle
69
+ ```
70
+
71
+ Alternatively, install it with pip:
72
+
73
+ ```bash
74
+ pip install buttle
75
+ ```
76
+
77
+ Once installed, run:
78
+
79
+ ```bash
80
+ buttle --help
81
+ ```
82
+
83
+ ### Using Buttle in Python
84
+
85
+
86
+ To add Buttle to an existing Python project:
87
+
88
+ ```bash
89
+ uv add buttle
90
+ ```
91
+
92
+ Or install it into your active Python environment:
93
+
94
+ ```bash
95
+ pip install buttle
96
+ ```
97
+
98
+ Buttle's Python modules can then be imported and used directly.
99
+ ```python
100
+ from buttle import sequences
101
+
102
+ # Use functions from the sequences module
103
+ ```
104
+
105
+ ### Building from source
106
+
107
+ Prebuilt wheels include the compiled Rust extension, so Rust and Cargo are not required for normal installation on supported platforms.
108
+ To build Buttle from source, you'll need Python 3.15+, Rust/Cargo, and a compatible build environment. The Rust toolchain (the Rust compiler and Cargo build system) can be installed from https://rustup.rs.
109
+
110
+ To verify that Rust is installed, run
111
+
112
+ ```bash
113
+ rustc --version
114
+ cargo --version
115
+ ```
116
+
117
+ Rust is only required during installation to compile the extension; it is not required to run Buttle afterward.
118
+
119
+
120
+ ### Using uv to install buttle from source
121
+
122
+ Installing uv:
123
+
124
+ The following instructions use uv to install Buttle from source. Other Python build tools may also be used.
125
+ If you don't already have uv installed, follow the official installation instructions at
126
+
127
+ https://docs.astral.sh/uv/getting-started/installation/
128
+
129
+ On macOS and Linux, you can install it with:
130
+
131
+ ```bash
132
+ curl -LsSf https://astral.sh/uv/install.sh | sh
133
+ ```
134
+
135
+ Verify the installation:
136
+
137
+ ```bash
138
+ uv --version
139
+ ```
140
+
141
+ Install Python 3.15:
142
+
143
+ ```bash
144
+ uv python install 3.15
145
+ ```
146
+
147
+ Clone the repository:
148
+ ```bash
149
+ git clone https://github.com/DJV512/buttle/
150
+ cd buttle
151
+ ```
152
+
153
+ Finally, install Buttle using uv:
154
+
155
+ ```bash
156
+ uv tool install --python 3.15 .
157
+ ```
158
+
159
+ After installation:
160
+ ```bash
161
+ buttle -h
162
+ ```
163
+
164
+ ## Usage
165
+
166
+ Buttle provides a command-line interface:
167
+ ```bash
168
+ buttle <command> [options]
169
+ ```
170
+
171
+ For a list of available commands:
172
+ ```bash
173
+ buttle -h
174
+ ```
175
+
176
+ For help with an individual command:
177
+ ```bash
178
+ buttle msa -h
179
+ ```
180
+
181
+ ## Development
182
+
183
+ ### Rebuilding the Rust extension
184
+
185
+ After modifying Rust source code, rebuild and reinstall Buttle
186
+ from the repository root:
187
+
188
+ uv tool install --reinstall -e .
189
+
190
+ This recompiles the Rust extension and updates the globally
191
+ installed `buttle` command.
192
+
193
+ ## Examples
194
+
195
+ #### Translate DNA in all three forward reading frames.
196
+
197
+ ```console
198
+ $ buttle translate acttactggtcgtagtca
199
+ Frame 1: TYWS*S
200
+ Frame 2: LTGRS
201
+ Frame 3: LLVVV
202
+ ```
203
+
204
+ #### GC Content
205
+
206
+ ```console
207
+ $ buttle gc atgacggtagctagtagctacgtatcattcatctatccgcgcgtagtagtacgt
208
+ Total bases: 54
209
+ A: 13
210
+ C: 12
211
+ G: 13
212
+ T: 16
213
+ AT Content: 53.70
214
+ GC Content: 46.30
215
+ ```
216
+
217
+ #### Display protein charge, molecular weight, and extinction coefficient together with props, or calculate each individually.
218
+ ```console
219
+ $ buttle props adlsykfehyaskgascwedasdkflsdad
220
+ Charge = -4
221
+ Molecular Weight = 3357.6
222
+ Extinction Coefficient = 8370
223
+ ```
224
+
225
+ #### Pairwise Alignment of DNA or Protein
226
+ ```console
227
+ $ buttle dna_align atctcatgcgtcgtacgtacgt tgcatgcgtacgtagtcgatgtc
228
+ ```
229
+ ![Pairwise DNA Alignment](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/dna_pairwise_align.png)
230
+
231
+ #### Multiple Protein Sequence Alignment
232
+ Buttle implements a custom progressive multiple protein sequence alignment algorithm using an average-linkage guide tree, BLOSUM62-based scoring, and tunable affine gap open and extension penalties. Optional "X" residues can be used as alignment anchors. Computationally intensive operations are accelerated using a Rust extension.
233
+
234
+
235
+ ```console
236
+ $ buttle msa docs/examples/synthetic_example_proteins.fasta --save docs/images/synthetic_alignment.png --diff --wrap 100
237
+ ```
238
+ ![Multiple Protein Sequence Alignment](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/synthetic_alignment.png)
239
+
240
+ Conservative substitutions are shown in purple, non-conservative substitutions in red, and gaps as black dashes. When `--diff` is enabled, identities to the reference sequence are shown as dots.
241
+
242
+ The sequences used in this example are available in
243
+ [synthetic_example_proteins.fasta](docs/examples/synthetic_example_proteins.fasta).
244
+
245
+ #### Rust vs Python
246
+ The computationally intensive sequence alignment algorithms in Buttle were originally implemented in Python and subsequently ported to Rust to improve performance.
247
+ The Rust implementations are used by default, but the original Python implementations remain available for comparison, testing, and experimentation.
248
+ When Buttle is installed, you can select the Python implementation for supported alignment commands using:
249
+
250
+ ```console
251
+ buttle msa sequences.fasta --backend python
252
+ ```
253
+
254
+ Omitting `--backend` uses the Rust implementation.
255
+
256
+ **Installation note:** Buttle includes a compiled Rust extension, even when using the Python alignment backend. Python-only installation is not currently supported.
257
+
258
+ ## Development status
259
+
260
+ Buttle is currently in development. Interfaces and command-line options may change before version 1.0. Known limitations include:
261
+
262
+ - Multiple sequence alignment currently supports proteins only.
263
+ - DNA alignment image output currently limited to PNG, and does not support some arguments.
264
+ - Guide tree visualization is still experimental.
265
+
266
+ ## License
267
+
268
+ Buttle is licensed under the BSD 3-Clause License.
buttle-0.3.0/README.md ADDED
@@ -0,0 +1,255 @@
1
+ ![Logo](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/buttle_logo_with_tag.png)
2
+ Buttle was developed as a lightweight collection of bioinformatics utilities for common sequence-analysis tasks, with an emphasis on convenient command-line use. It provides tools for working with DNA and protein sequences, including sequence manipulation, peptide properties, motif searching, pairwise alignment, and multiple sequence alignment.
3
+
4
+ Buttle is currently under active development.
5
+
6
+ ## Features
7
+
8
+ ### General sequence tools
9
+
10
+ - Search for sequences and report their positions
11
+ - Calculate sequence length
12
+ - Calculate pairwise percent identity for sequences in a FASTA file
13
+
14
+ ### DNA sequences
15
+
16
+ - Transcribe DNA to RNA
17
+ - Translate DNA in three reading frames
18
+ - Generate reverse complements
19
+ - Calculate GC content
20
+ - Pairwise DNA sequence alignment
21
+
22
+ ### Protein sequence tools
23
+ - Calculate protein net charge
24
+ - Calculate molecular weight
25
+ - Calculate extinction coefficient
26
+ - Identify and highlight potential N-linked glycosylation sites
27
+ - Compare two sequences and look for conserved motifs of varying lengths
28
+ - Pairwise sequence alignment from two raw sequence arguments
29
+ - Rust backend by default, with a Python backend available
30
+ - Multiple sequence alignment (MSA) from FASTA files or FASTA-formatted strings
31
+ - Rust backend by default, with a Python backend available
32
+
33
+
34
+ ### Rendering
35
+ - Display alignments in the terminal (when no `--save` argument provided)
36
+ - Generate publication-quality PNG and TIFF alignment images
37
+ - Save Pairwise DNA and protein alignments
38
+ - Save multiple protein sequence alignments
39
+ - Alignment row length can be tuned with `--wrap`
40
+ - Argument `--real-ruler` displays residue number based on the first sequence, skipping gaps
41
+ - Argument `--diff` displays alignment differences relative to a reference sequence
42
+ - MSA optionally adds a consensus sequence with `--consensus`
43
+
44
+
45
+ ## Installation/Requirements
46
+
47
+ Buttle is distributed through PyPI and requires Python 3.15 or newer. Prebuilt wheels include both the Python modules and the compiled Rust extension, so Rust and Cargo are not required when installing a compatible wheel.
48
+
49
+
50
+ ### Command-line installation
51
+
52
+ Install Buttle as a standalone command-line tool using uv:
53
+
54
+ ```bash
55
+ uv tool install buttle
56
+ ```
57
+
58
+ Alternatively, install it with pip:
59
+
60
+ ```bash
61
+ pip install buttle
62
+ ```
63
+
64
+ Once installed, run:
65
+
66
+ ```bash
67
+ buttle --help
68
+ ```
69
+
70
+ ### Using Buttle in Python
71
+
72
+
73
+ To add Buttle to an existing Python project:
74
+
75
+ ```bash
76
+ uv add buttle
77
+ ```
78
+
79
+ Or install it into your active Python environment:
80
+
81
+ ```bash
82
+ pip install buttle
83
+ ```
84
+
85
+ Buttle's Python modules can then be imported and used directly.
86
+ ```python
87
+ from buttle import sequences
88
+
89
+ # Use functions from the sequences module
90
+ ```
91
+
92
+ ### Building from source
93
+
94
+ Prebuilt wheels include the compiled Rust extension, so Rust and Cargo are not required for normal installation on supported platforms.
95
+ To build Buttle from source, you'll need Python 3.15+, Rust/Cargo, and a compatible build environment. The Rust toolchain (the Rust compiler and Cargo build system) can be installed from https://rustup.rs.
96
+
97
+ To verify that Rust is installed, run
98
+
99
+ ```bash
100
+ rustc --version
101
+ cargo --version
102
+ ```
103
+
104
+ Rust is only required during installation to compile the extension; it is not required to run Buttle afterward.
105
+
106
+
107
+ ### Using uv to install buttle from source
108
+
109
+ Installing uv:
110
+
111
+ The following instructions use uv to install Buttle from source. Other Python build tools may also be used.
112
+ If you don't already have uv installed, follow the official installation instructions at
113
+
114
+ https://docs.astral.sh/uv/getting-started/installation/
115
+
116
+ On macOS and Linux, you can install it with:
117
+
118
+ ```bash
119
+ curl -LsSf https://astral.sh/uv/install.sh | sh
120
+ ```
121
+
122
+ Verify the installation:
123
+
124
+ ```bash
125
+ uv --version
126
+ ```
127
+
128
+ Install Python 3.15:
129
+
130
+ ```bash
131
+ uv python install 3.15
132
+ ```
133
+
134
+ Clone the repository:
135
+ ```bash
136
+ git clone https://github.com/DJV512/buttle/
137
+ cd buttle
138
+ ```
139
+
140
+ Finally, install Buttle using uv:
141
+
142
+ ```bash
143
+ uv tool install --python 3.15 .
144
+ ```
145
+
146
+ After installation:
147
+ ```bash
148
+ buttle -h
149
+ ```
150
+
151
+ ## Usage
152
+
153
+ Buttle provides a command-line interface:
154
+ ```bash
155
+ buttle <command> [options]
156
+ ```
157
+
158
+ For a list of available commands:
159
+ ```bash
160
+ buttle -h
161
+ ```
162
+
163
+ For help with an individual command:
164
+ ```bash
165
+ buttle msa -h
166
+ ```
167
+
168
+ ## Development
169
+
170
+ ### Rebuilding the Rust extension
171
+
172
+ After modifying Rust source code, rebuild and reinstall Buttle
173
+ from the repository root:
174
+
175
+ uv tool install --reinstall -e .
176
+
177
+ This recompiles the Rust extension and updates the globally
178
+ installed `buttle` command.
179
+
180
+ ## Examples
181
+
182
+ #### Translate DNA in all three forward reading frames.
183
+
184
+ ```console
185
+ $ buttle translate acttactggtcgtagtca
186
+ Frame 1: TYWS*S
187
+ Frame 2: LTGRS
188
+ Frame 3: LLVVV
189
+ ```
190
+
191
+ #### GC Content
192
+
193
+ ```console
194
+ $ buttle gc atgacggtagctagtagctacgtatcattcatctatccgcgcgtagtagtacgt
195
+ Total bases: 54
196
+ A: 13
197
+ C: 12
198
+ G: 13
199
+ T: 16
200
+ AT Content: 53.70
201
+ GC Content: 46.30
202
+ ```
203
+
204
+ #### Display protein charge, molecular weight, and extinction coefficient together with props, or calculate each individually.
205
+ ```console
206
+ $ buttle props adlsykfehyaskgascwedasdkflsdad
207
+ Charge = -4
208
+ Molecular Weight = 3357.6
209
+ Extinction Coefficient = 8370
210
+ ```
211
+
212
+ #### Pairwise Alignment of DNA or Protein
213
+ ```console
214
+ $ buttle dna_align atctcatgcgtcgtacgtacgt tgcatgcgtacgtagtcgatgtc
215
+ ```
216
+ ![Pairwise DNA Alignment](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/dna_pairwise_align.png)
217
+
218
+ #### Multiple Protein Sequence Alignment
219
+ Buttle implements a custom progressive multiple protein sequence alignment algorithm using an average-linkage guide tree, BLOSUM62-based scoring, and tunable affine gap open and extension penalties. Optional "X" residues can be used as alignment anchors. Computationally intensive operations are accelerated using a Rust extension.
220
+
221
+
222
+ ```console
223
+ $ buttle msa docs/examples/synthetic_example_proteins.fasta --save docs/images/synthetic_alignment.png --diff --wrap 100
224
+ ```
225
+ ![Multiple Protein Sequence Alignment](https://raw.githubusercontent.com/DJV512/Buttle/v0.3.0/docs/images/synthetic_alignment.png)
226
+
227
+ Conservative substitutions are shown in purple, non-conservative substitutions in red, and gaps as black dashes. When `--diff` is enabled, identities to the reference sequence are shown as dots.
228
+
229
+ The sequences used in this example are available in
230
+ [synthetic_example_proteins.fasta](docs/examples/synthetic_example_proteins.fasta).
231
+
232
+ #### Rust vs Python
233
+ The computationally intensive sequence alignment algorithms in Buttle were originally implemented in Python and subsequently ported to Rust to improve performance.
234
+ The Rust implementations are used by default, but the original Python implementations remain available for comparison, testing, and experimentation.
235
+ When Buttle is installed, you can select the Python implementation for supported alignment commands using:
236
+
237
+ ```console
238
+ buttle msa sequences.fasta --backend python
239
+ ```
240
+
241
+ Omitting `--backend` uses the Rust implementation.
242
+
243
+ **Installation note:** Buttle includes a compiled Rust extension, even when using the Python alignment backend. Python-only installation is not currently supported.
244
+
245
+ ## Development status
246
+
247
+ Buttle is currently in development. Interfaces and command-line options may change before version 1.0. Known limitations include:
248
+
249
+ - Multiple sequence alignment currently supports proteins only.
250
+ - DNA alignment image output currently limited to PNG, and does not support some arguments.
251
+ - Guide tree visualization is still experimental.
252
+
253
+ ## License
254
+
255
+ Buttle is licensed under the BSD 3-Clause License.
@@ -0,0 +1,46 @@
1
+ [project]
2
+ name = "buttle"
3
+ version = "0.3.0"
4
+ description = "Command-line utilities for DNA and protein sequence analysis. At your service."
5
+ readme = "README.md"
6
+ license = "BSD-3-Clause"
7
+ requires-python = ">=3.15"
8
+ dependencies = [
9
+ "pillow>=12.3.0",
10
+ ]
11
+
12
+ [project.scripts]
13
+ buttle = "buttle.cli:main"
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "hypothesis>=6.168.0",
18
+ "maturin>=1.15.0",
19
+ "pytest>=9.1.1",
20
+ "pytest-cov>=7.1.0",
21
+ "pytest-randomly>=5.0.0",
22
+ ]
23
+
24
+ [build-system]
25
+ requires = ["maturin>=1.9,<2"]
26
+ build-backend = "maturin"
27
+
28
+ [tool.maturin]
29
+ manifest-path = "rust/Cargo.toml"
30
+ features = ["python"]
31
+ python-source = "src"
32
+ module-name = "buttle.buttle_rust"
33
+
34
+ [tool.pytest.ini_options]
35
+ addopts = [
36
+ "--cov=buttle",
37
+ "--cov-branch",
38
+ "--cov-report=term-missing",
39
+ "--cov-report=html",
40
+ "-vv",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/DJV512/Buttle"
45
+ Repository = "https://github.com/DJV512/Buttle"
46
+ Issues = "https://github.com/DJV512/Buttle/issues"