starfile-rs 0.1.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.
- starfile_rs-0.1.0/.gitattributes +1 -0
- starfile_rs-0.1.0/.github/workflows/CI.yml +181 -0
- starfile_rs-0.1.0/.github/workflows/test.yml +56 -0
- starfile_rs-0.1.0/.gitignore +73 -0
- starfile_rs-0.1.0/.pre-commit-config.yaml +18 -0
- starfile_rs-0.1.0/Cargo.lock +172 -0
- starfile_rs-0.1.0/Cargo.toml +13 -0
- starfile_rs-0.1.0/LICENSE +29 -0
- starfile_rs-0.1.0/PKG-INFO +21 -0
- starfile_rs-0.1.0/README.md +96 -0
- starfile_rs-0.1.0/images/time-large-block.png +0 -0
- starfile_rs-0.1.0/images/time-random-access.png +0 -0
- starfile_rs-0.1.0/pyproject.toml +36 -0
- starfile_rs-0.1.0/python/starfile_rs/__init__.py +21 -0
- starfile_rs-0.1.0/python/starfile_rs/_starfile_rs_rust.pyi +40 -0
- starfile_rs-0.1.0/python/starfile_rs/compat.py +37 -0
- starfile_rs-0.1.0/python/starfile_rs/components.py +476 -0
- starfile_rs-0.1.0/python/starfile_rs/core.py +318 -0
- starfile_rs-0.1.0/python/starfile_rs/io.py +33 -0
- starfile_rs-0.1.0/python/tests/__init__.py +2 -0
- starfile_rs-0.1.0/python/tests/constants.py +33 -0
- starfile_rs-0.1.0/python/tests/data/basic_block.star +131 -0
- starfile_rs-0.1.0/python/tests/data/basic_double_quote.star +7 -0
- starfile_rs-0.1.0/python/tests/data/basic_single_quote.star +7 -0
- starfile_rs-0.1.0/python/tests/data/default_pipeline.star +270 -0
- starfile_rs-0.1.0/python/tests/data/empty_loop.star +6 -0
- starfile_rs-0.1.0/python/tests/data/from_df.star +14 -0
- starfile_rs-0.1.0/python/tests/data/from_list.star +25 -0
- starfile_rs-0.1.0/python/tests/data/loop_block.star +36 -0
- starfile_rs-0.1.0/python/tests/data/loop_double_quote.star +13 -0
- starfile_rs-0.1.0/python/tests/data/loop_single_quote.star +13 -0
- starfile_rs-0.1.0/python/tests/data/multiblock.star +131 -0
- starfile_rs-0.1.0/python/tests/data/one_loop.star +32 -0
- starfile_rs-0.1.0/python/tests/data/postprocess.star +130 -0
- starfile_rs-0.1.0/python/tests/data/relion_tutorial/run_it025_optimiser_2D.star +92 -0
- starfile_rs-0.1.0/python/tests/data/relion_tutorial/run_it025_optimiser_3D.star +92 -0
- starfile_rs-0.1.0/python/tests/data/relion_tutorial/run_it025_sampling_2D.star +18 -0
- starfile_rs-0.1.0/python/tests/data/relion_tutorial/run_it025_sampling_3D.star +222 -0
- starfile_rs-0.1.0/python/tests/data/rln3.1_data_style.star +39 -0
- starfile_rs-0.1.0/python/tests/data/single_line_end_of_multiblock.star +24 -0
- starfile_rs-0.1.0/python/tests/data/single_line_middle_of_multiblock.star +23 -0
- starfile_rs-0.1.0/python/tests/data/test_write.star +14 -0
- starfile_rs-0.1.0/python/tests/data/two_basic_blocks.star +14 -0
- starfile_rs-0.1.0/python/tests/data/two_single_line_loop_blocks.star +16 -0
- starfile_rs-0.1.0/python/tests/test_parsing.py +301 -0
- starfile_rs-0.1.0/python/tests/test_stardict.py +311 -0
- starfile_rs-0.1.0/python/tests/test_writing.py +134 -0
- starfile_rs-0.1.0/python/tests/utils.py +15 -0
- starfile_rs-0.1.0/src/blocks.rs +288 -0
- starfile_rs-0.1.0/src/lib.rs +13 -0
- starfile_rs-0.1.0/src/reader.rs +277 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.star linguist-vendored
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# This file is autogenerated by maturin v1.10.2
|
|
2
|
+
# To update, run
|
|
3
|
+
#
|
|
4
|
+
# maturin generate-ci github
|
|
5
|
+
#
|
|
6
|
+
name: CI
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- master
|
|
13
|
+
tags:
|
|
14
|
+
- '*'
|
|
15
|
+
pull_request:
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
linux:
|
|
23
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
platform:
|
|
27
|
+
- runner: ubuntu-22.04
|
|
28
|
+
target: x86_64
|
|
29
|
+
- runner: ubuntu-22.04
|
|
30
|
+
target: x86
|
|
31
|
+
- runner: ubuntu-22.04
|
|
32
|
+
target: aarch64
|
|
33
|
+
- runner: ubuntu-22.04
|
|
34
|
+
target: armv7
|
|
35
|
+
- runner: ubuntu-22.04
|
|
36
|
+
target: s390x
|
|
37
|
+
- runner: ubuntu-22.04
|
|
38
|
+
target: ppc64le
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
- uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: 3.x
|
|
44
|
+
- name: Build wheels
|
|
45
|
+
uses: PyO3/maturin-action@v1
|
|
46
|
+
with:
|
|
47
|
+
target: ${{ matrix.platform.target }}
|
|
48
|
+
args: --release --out dist --find-interpreter
|
|
49
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
50
|
+
manylinux: auto
|
|
51
|
+
- name: Upload wheels
|
|
52
|
+
uses: actions/upload-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: wheels-linux-${{ matrix.platform.target }}
|
|
55
|
+
path: dist
|
|
56
|
+
|
|
57
|
+
musllinux:
|
|
58
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
59
|
+
strategy:
|
|
60
|
+
matrix:
|
|
61
|
+
platform:
|
|
62
|
+
- runner: ubuntu-22.04
|
|
63
|
+
target: x86_64
|
|
64
|
+
- runner: ubuntu-22.04
|
|
65
|
+
target: x86
|
|
66
|
+
- runner: ubuntu-22.04
|
|
67
|
+
target: aarch64
|
|
68
|
+
- runner: ubuntu-22.04
|
|
69
|
+
target: armv7
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- uses: actions/setup-python@v5
|
|
73
|
+
with:
|
|
74
|
+
python-version: 3.x
|
|
75
|
+
- name: Build wheels
|
|
76
|
+
uses: PyO3/maturin-action@v1
|
|
77
|
+
with:
|
|
78
|
+
target: ${{ matrix.platform.target }}
|
|
79
|
+
args: --release --out dist --find-interpreter
|
|
80
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
81
|
+
manylinux: musllinux_1_2
|
|
82
|
+
- name: Upload wheels
|
|
83
|
+
uses: actions/upload-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
86
|
+
path: dist
|
|
87
|
+
|
|
88
|
+
windows:
|
|
89
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
90
|
+
strategy:
|
|
91
|
+
matrix:
|
|
92
|
+
platform:
|
|
93
|
+
- runner: windows-latest
|
|
94
|
+
target: x64
|
|
95
|
+
- runner: windows-latest
|
|
96
|
+
target: x86
|
|
97
|
+
steps:
|
|
98
|
+
- uses: actions/checkout@v4
|
|
99
|
+
- uses: actions/setup-python@v5
|
|
100
|
+
with:
|
|
101
|
+
python-version: 3.x
|
|
102
|
+
architecture: ${{ matrix.platform.target }}
|
|
103
|
+
- name: Build wheels
|
|
104
|
+
uses: PyO3/maturin-action@v1
|
|
105
|
+
with:
|
|
106
|
+
target: ${{ matrix.platform.target }}
|
|
107
|
+
args: --release --out dist --find-interpreter
|
|
108
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
109
|
+
- name: Upload wheels
|
|
110
|
+
uses: actions/upload-artifact@v4
|
|
111
|
+
with:
|
|
112
|
+
name: wheels-windows-${{ matrix.platform.target }}
|
|
113
|
+
path: dist
|
|
114
|
+
|
|
115
|
+
macos:
|
|
116
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
117
|
+
strategy:
|
|
118
|
+
matrix:
|
|
119
|
+
platform:
|
|
120
|
+
- runner: macos-latest
|
|
121
|
+
target: x86_64
|
|
122
|
+
- runner: macos-14
|
|
123
|
+
target: aarch64
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: 3.x
|
|
129
|
+
- name: Build wheels
|
|
130
|
+
uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
target: ${{ matrix.platform.target }}
|
|
133
|
+
args: --release --out dist --find-interpreter
|
|
134
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
135
|
+
- name: Upload wheels
|
|
136
|
+
uses: actions/upload-artifact@v4
|
|
137
|
+
with:
|
|
138
|
+
name: wheels-macos-${{ matrix.platform.target }}
|
|
139
|
+
path: dist
|
|
140
|
+
|
|
141
|
+
sdist:
|
|
142
|
+
runs-on: ubuntu-latest
|
|
143
|
+
steps:
|
|
144
|
+
- uses: actions/checkout@v4
|
|
145
|
+
- name: Build sdist
|
|
146
|
+
uses: PyO3/maturin-action@v1
|
|
147
|
+
with:
|
|
148
|
+
command: sdist
|
|
149
|
+
args: --out dist
|
|
150
|
+
- name: Upload sdist
|
|
151
|
+
uses: actions/upload-artifact@v4
|
|
152
|
+
with:
|
|
153
|
+
name: wheels-sdist
|
|
154
|
+
path: dist
|
|
155
|
+
|
|
156
|
+
release:
|
|
157
|
+
name: Release
|
|
158
|
+
runs-on: ubuntu-latest
|
|
159
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
160
|
+
needs: [linux, musllinux, windows, macos, sdist]
|
|
161
|
+
permissions:
|
|
162
|
+
# Use to sign the release artifacts
|
|
163
|
+
id-token: write
|
|
164
|
+
# Used to upload release artifacts
|
|
165
|
+
contents: write
|
|
166
|
+
# Used to generate artifact attestation
|
|
167
|
+
attestations: write
|
|
168
|
+
steps:
|
|
169
|
+
- uses: actions/download-artifact@v4
|
|
170
|
+
- name: Generate artifact attestation
|
|
171
|
+
uses: actions/attest-build-provenance@v2
|
|
172
|
+
with:
|
|
173
|
+
subject-path: 'wheels-*/*'
|
|
174
|
+
- name: Publish to PyPI
|
|
175
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
176
|
+
uses: PyO3/maturin-action@v1
|
|
177
|
+
env:
|
|
178
|
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
179
|
+
with:
|
|
180
|
+
command: upload
|
|
181
|
+
args: --non-interactive --skip-existing wheels-*/*
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
name: ${{ matrix.platform }} (${{ matrix.python-version }})
|
|
17
|
+
runs-on: ${{ matrix.platform }}
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
22
|
+
platform: [ubuntu-latest, macos-latest, windows-latest]
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: Cancel Previous Runs
|
|
26
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
27
|
+
with:
|
|
28
|
+
access_token: ${{ github.token }}
|
|
29
|
+
|
|
30
|
+
- uses: actions/checkout@v3
|
|
31
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
32
|
+
uses: actions/setup-python@v4
|
|
33
|
+
with:
|
|
34
|
+
python-version: ${{ matrix.python-version }}
|
|
35
|
+
|
|
36
|
+
- name: Create virtual environment
|
|
37
|
+
env:
|
|
38
|
+
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
|
|
39
|
+
run: |
|
|
40
|
+
python -m venv .venv
|
|
41
|
+
echo "$GITHUB_WORKSPACE/.venv/$BIN" >> $GITHUB_PATH
|
|
42
|
+
|
|
43
|
+
- name: Install dependencies
|
|
44
|
+
run: python -m pip install .[testing]
|
|
45
|
+
|
|
46
|
+
- name: Build Rust extension
|
|
47
|
+
run: maturin develop --release
|
|
48
|
+
|
|
49
|
+
- name: Test with pytest
|
|
50
|
+
run: |
|
|
51
|
+
python -m pytest --cov=starfile_rs --cov-report=xml
|
|
52
|
+
|
|
53
|
+
- name: Upload coverage reports to Codecov
|
|
54
|
+
uses: codecov/codecov-action@v5
|
|
55
|
+
with:
|
|
56
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/target
|
|
2
|
+
benchmarks/
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
|
|
9
|
+
# C extensions
|
|
10
|
+
*.so
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
.venv/
|
|
15
|
+
env/
|
|
16
|
+
bin/
|
|
17
|
+
build/
|
|
18
|
+
develop-eggs/
|
|
19
|
+
dist/
|
|
20
|
+
eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
include/
|
|
27
|
+
man/
|
|
28
|
+
venv/
|
|
29
|
+
*.egg-info/
|
|
30
|
+
.installed.cfg
|
|
31
|
+
*.egg
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
pip-selfcheck.json
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.cache
|
|
43
|
+
nosetests.xml
|
|
44
|
+
coverage.xml
|
|
45
|
+
|
|
46
|
+
# Translations
|
|
47
|
+
*.mo
|
|
48
|
+
|
|
49
|
+
# Mr Developer
|
|
50
|
+
.mr.developer.cfg
|
|
51
|
+
.project
|
|
52
|
+
.pydevproject
|
|
53
|
+
|
|
54
|
+
# Rope
|
|
55
|
+
.ropeproject
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
*.pot
|
|
60
|
+
|
|
61
|
+
.DS_Store
|
|
62
|
+
|
|
63
|
+
# Sphinx documentation
|
|
64
|
+
docs/_build/
|
|
65
|
+
|
|
66
|
+
# PyCharm
|
|
67
|
+
.idea/
|
|
68
|
+
|
|
69
|
+
# VSCode
|
|
70
|
+
.vscode/
|
|
71
|
+
|
|
72
|
+
# Pyenv
|
|
73
|
+
.python-version
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: end-of-file-fixer
|
|
6
|
+
- id: trailing-whitespace
|
|
7
|
+
- repo: https://github.com/asottile/pyupgrade
|
|
8
|
+
rev: v3.21.2
|
|
9
|
+
hooks:
|
|
10
|
+
- id: pyupgrade
|
|
11
|
+
args: ["--py37-plus", "--keep-runtime-typing"]
|
|
12
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
13
|
+
rev: v0.14.8
|
|
14
|
+
hooks:
|
|
15
|
+
- id: ruff
|
|
16
|
+
args: ["--fix"]
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
exclude: (examples|docs|tests)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "heck"
|
|
13
|
+
version = "0.5.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "indoc"
|
|
19
|
+
version = "2.0.7"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
|
22
|
+
dependencies = [
|
|
23
|
+
"rustversion",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "libc"
|
|
28
|
+
version = "0.2.178"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "memoffset"
|
|
34
|
+
version = "0.9.1"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
37
|
+
dependencies = [
|
|
38
|
+
"autocfg",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "once_cell"
|
|
43
|
+
version = "1.21.3"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "portable-atomic"
|
|
49
|
+
version = "1.11.1"
|
|
50
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
51
|
+
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
|
52
|
+
|
|
53
|
+
[[package]]
|
|
54
|
+
name = "proc-macro2"
|
|
55
|
+
version = "1.0.103"
|
|
56
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
+
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
|
58
|
+
dependencies = [
|
|
59
|
+
"unicode-ident",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[[package]]
|
|
63
|
+
name = "pyo3"
|
|
64
|
+
version = "0.27.2"
|
|
65
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
66
|
+
checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d"
|
|
67
|
+
dependencies = [
|
|
68
|
+
"indoc",
|
|
69
|
+
"libc",
|
|
70
|
+
"memoffset",
|
|
71
|
+
"once_cell",
|
|
72
|
+
"portable-atomic",
|
|
73
|
+
"pyo3-build-config",
|
|
74
|
+
"pyo3-ffi",
|
|
75
|
+
"pyo3-macros",
|
|
76
|
+
"unindent",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[[package]]
|
|
80
|
+
name = "pyo3-build-config"
|
|
81
|
+
version = "0.27.2"
|
|
82
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
83
|
+
checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
|
|
84
|
+
dependencies = [
|
|
85
|
+
"target-lexicon",
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
[[package]]
|
|
89
|
+
name = "pyo3-ffi"
|
|
90
|
+
version = "0.27.2"
|
|
91
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
92
|
+
checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089"
|
|
93
|
+
dependencies = [
|
|
94
|
+
"libc",
|
|
95
|
+
"pyo3-build-config",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "pyo3-macros"
|
|
100
|
+
version = "0.27.2"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02"
|
|
103
|
+
dependencies = [
|
|
104
|
+
"proc-macro2",
|
|
105
|
+
"pyo3-macros-backend",
|
|
106
|
+
"quote",
|
|
107
|
+
"syn",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
[[package]]
|
|
111
|
+
name = "pyo3-macros-backend"
|
|
112
|
+
version = "0.27.2"
|
|
113
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
+
checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9"
|
|
115
|
+
dependencies = [
|
|
116
|
+
"heck",
|
|
117
|
+
"proc-macro2",
|
|
118
|
+
"pyo3-build-config",
|
|
119
|
+
"quote",
|
|
120
|
+
"syn",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[[package]]
|
|
124
|
+
name = "quote"
|
|
125
|
+
version = "1.0.42"
|
|
126
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
127
|
+
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
|
128
|
+
dependencies = [
|
|
129
|
+
"proc-macro2",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "rustversion"
|
|
134
|
+
version = "1.0.22"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "starfile_rs_rust"
|
|
140
|
+
version = "0.1.0"
|
|
141
|
+
dependencies = [
|
|
142
|
+
"pyo3",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
[[package]]
|
|
146
|
+
name = "syn"
|
|
147
|
+
version = "2.0.111"
|
|
148
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
+
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
|
150
|
+
dependencies = [
|
|
151
|
+
"proc-macro2",
|
|
152
|
+
"quote",
|
|
153
|
+
"unicode-ident",
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
[[package]]
|
|
157
|
+
name = "target-lexicon"
|
|
158
|
+
version = "0.13.4"
|
|
159
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
160
|
+
checksum = "b1dd07eb858a2067e2f3c7155d54e929265c264e6f37efe3ee7a8d1b5a1dd0ba"
|
|
161
|
+
|
|
162
|
+
[[package]]
|
|
163
|
+
name = "unicode-ident"
|
|
164
|
+
version = "1.0.22"
|
|
165
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
+
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
|
167
|
+
|
|
168
|
+
[[package]]
|
|
169
|
+
name = "unindent"
|
|
170
|
+
version = "0.2.4"
|
|
171
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
172
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "starfile_rs_rust"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
|
|
7
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
8
|
+
[lib]
|
|
9
|
+
name = "_starfile_rs_rust"
|
|
10
|
+
crate-type = ["cdylib"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
pyo3 = "0.27.0"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Alister Burt
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: starfile-rs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Requires-Dist: pytest ; extra == 'testing'
|
|
8
|
+
Requires-Dist: pytest-cov ; extra == 'testing'
|
|
9
|
+
Requires-Dist: starfile-rs[pandas] ; extra == 'testing'
|
|
10
|
+
Requires-Dist: starfile-rs[polars] ; extra == 'testing'
|
|
11
|
+
Requires-Dist: starfile-rs[numpy] ; extra == 'testing'
|
|
12
|
+
Requires-Dist: maturin>=1.10,<2.0 ; extra == 'testing'
|
|
13
|
+
Requires-Dist: pandas>=2.0.0 ; extra == 'pandas'
|
|
14
|
+
Requires-Dist: polars>=1.35.2 ; extra == 'polars'
|
|
15
|
+
Requires-Dist: numpy>=1.24.0 ; extra == 'numpy'
|
|
16
|
+
Provides-Extra: testing
|
|
17
|
+
Provides-Extra: pandas
|
|
18
|
+
Provides-Extra: polars
|
|
19
|
+
Provides-Extra: numpy
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Python: >=3.10
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# :star: starfile-rs :crab:
|
|
2
|
+
|
|
3
|
+
[](https://github.com/hanjinliu/starfile-rs/blob/main/LICENSE)
|
|
4
|
+
[](https://pypistats.org/packages/starfile-rs)
|
|
5
|
+
[](https://badge.fury.io/py/starfile-rs)
|
|
6
|
+
[](https://pypi.org/project/starfile-rs)
|
|
7
|
+
[](https://codecov.io/gh/hanjinliu/starfile-rs)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
A blazing-fast and type-safe STAR file reader and writer powered by Rust (as a successor of [`starfile`](https://github.com/teamtomo/starfile)). This package implements interface with [`pandas`](https://github.com/pandas-dev/pandas), [`polars`](https://github.com/pola-rs/polars) and [`numpy`](https://github.com/numpy/numpy) for modern data manipulation.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install starfile-rs[pandas] # for pandas support
|
|
16
|
+
pip install starfile-rs[polars] # for polars support
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or clone this repository and install locally (requires Rust):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/hanjinliu/starfile-rs.git
|
|
23
|
+
cd starfile-rs
|
|
24
|
+
pip install -e .[pandas] # for pandas support
|
|
25
|
+
pip install -e .[polars] # for polars support
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Highlights
|
|
29
|
+
|
|
30
|
+
### Easy to Use
|
|
31
|
+
|
|
32
|
+
`StarDict` provides a dict-like interface and each data block can be converted to/from popular data structures.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from starfile_rs import read_star
|
|
36
|
+
|
|
37
|
+
# read as a dict-like object of data blocks
|
|
38
|
+
star = read_star("path/to/file.star")
|
|
39
|
+
|
|
40
|
+
# convert the first data block to pandas.DataFrame
|
|
41
|
+
star.nth(0).to_pandas()
|
|
42
|
+
|
|
43
|
+
# convert the "particles" data block to polars.DataFrame
|
|
44
|
+
star["particles"].to_polars()
|
|
45
|
+
|
|
46
|
+
# trust the "general" data block is a single data block and convert to dict
|
|
47
|
+
star["general"].trust_single().to_dict()
|
|
48
|
+
|
|
49
|
+
# update or add a new loop data block
|
|
50
|
+
import pandas as pd
|
|
51
|
+
|
|
52
|
+
star.with_loop_block(
|
|
53
|
+
name="new_loop_data",
|
|
54
|
+
data=pd.DataFrame({"col1": [1, 2, 3], "col2": ["a", "b", "c"]}),
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Performance
|
|
59
|
+
|
|
60
|
+
All the data are from [Burt et al.](https://zenodo.org/records/11068319)
|
|
61
|
+
|
|
62
|
+
- **Example 1**: Random access to a data block located at an unknown position in a 15 MB STAR file (`Polish/job050/motion.star`)
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
`starfile-rs` does not parse string to `pandas.DataFrame` until you call `.to_pandas()`, so it is extremely fast for random access in a large STAR file compared to [`starfile`](https://github.com/teamtomo/starfile).
|
|
67
|
+
|
|
68
|
+
- **Example 2**: Parsing a 12 MB data block (The "particles" block from `"Refine3D/bin6/run_it000_data.star"`).
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
Reading lines and whitespace trimming are performed in Rust. This speeds up the parsing significantly even though the table parsing is similarly done by `pandas`. If you use `polars`, the performance gain is more significant.
|
|
73
|
+
|
|
74
|
+
### Type Safety
|
|
75
|
+
|
|
76
|
+
One cannot determine the structure of a STAR file until actually parsing it.`starfile-rs` splits the safe (`try_*`) and unsafe (`trust_*`) methods to avoid extensive isinstance checks.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from starfile_rs import read_star
|
|
80
|
+
|
|
81
|
+
path = "path/to/file.star"
|
|
82
|
+
|
|
83
|
+
star = read_star(path) # Safe, unless the file is broken
|
|
84
|
+
star["general"] # Unsafe, if the block does not exist
|
|
85
|
+
|
|
86
|
+
if block := star.get("general"): # Safe
|
|
87
|
+
block.to_pandas()
|
|
88
|
+
block.to_polars()
|
|
89
|
+
|
|
90
|
+
if block := star.get("general"):
|
|
91
|
+
block.trust_single() # Unsafe, if the block is not a single data block
|
|
92
|
+
|
|
93
|
+
if block := star.get("general"):
|
|
94
|
+
if single := block.try_single(): # Safe
|
|
95
|
+
single.to_dict()
|
|
96
|
+
```
|
|
Binary file
|
|
Binary file
|