cifmi 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.
Files changed (40) hide show
  1. cifmi-0.1.0/.gitignore +19 -0
  2. cifmi-0.1.0/CHANGELOG.md +5 -0
  3. cifmi-0.1.0/Cargo.lock +160 -0
  4. cifmi-0.1.0/Cargo.toml +37 -0
  5. cifmi-0.1.0/LICENSE +21 -0
  6. cifmi-0.1.0/PKG-INFO +72 -0
  7. cifmi-0.1.0/README.md +54 -0
  8. cifmi-0.1.0/THIRD_PARTY_NOTICES.md +27 -0
  9. cifmi-0.1.0/docs/design.md +322 -0
  10. cifmi-0.1.0/pyproject.toml +38 -0
  11. cifmi-0.1.0/python/cifmi/__init__.py +48 -0
  12. cifmi-0.1.0/src/crystallographic.rs +1507 -0
  13. cifmi-0.1.0/src/document.rs +313 -0
  14. cifmi-0.1.0/src/element.rs +129 -0
  15. cifmi-0.1.0/src/error.rs +28 -0
  16. cifmi-0.1.0/src/lattice.rs +188 -0
  17. cifmi-0.1.0/src/lexer.rs +555 -0
  18. cifmi-0.1.0/src/lib.rs +81 -0
  19. cifmi-0.1.0/src/options.rs +42 -0
  20. cifmi-0.1.0/src/python.rs +256 -0
  21. cifmi-0.1.0/src/sites.rs +183 -0
  22. cifmi-0.1.0/src/spacegroups.rs +5815 -0
  23. cifmi-0.1.0/src/structure.rs +205 -0
  24. cifmi-0.1.0/src/symmetry.rs +790 -0
  25. cifmi-0.1.0/src/symop.rs +165 -0
  26. cifmi-0.1.0/tests/README.md +28 -0
  27. cifmi-0.1.0/tests/check_python_package.py +119 -0
  28. cifmi-0.1.0/tests/check_release_version.py +102 -0
  29. cifmi-0.1.0/tests/data/cif/cod__1000126.cif +99 -0
  30. cifmi-0.1.0/tests/data/cif/cod__1010642.cif +74 -0
  31. cifmi-0.1.0/tests/data/cif/cod__1100217.cif +154 -0
  32. cifmi-0.1.0/tests/data/cif/cod__2003493.cif +70 -0
  33. cifmi-0.1.0/tests/data/cif/cod__2100690.cif +546 -0
  34. cifmi-0.1.0/tests/data/cif/cod__4001733.cif +78 -0
  35. cifmi-0.1.0/tests/data/cif/cod__5910103.cif +60 -0
  36. cifmi-0.1.0/tests/data/cif/cod__7046814.cif +435 -0
  37. cifmi-0.1.0/tests/data/cif/cod__9005920.cif +83 -0
  38. cifmi-0.1.0/tests/reading.rs +682 -0
  39. cifmi-0.1.0/tests/release_version_cases.py +103 -0
  40. cifmi-0.1.0/tests/test_python.py +96 -0
cifmi-0.1.0/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ # Rust build artifacts
2
+ /target
3
+ node/target/
4
+
5
+ # Python environments, caches and the built extension
6
+ .venv/
7
+ __pycache__/
8
+ .pytest_cache/
9
+ /dist/
10
+ *.so
11
+
12
+ # Node.js dependencies and build outputs
13
+ node/node_modules/
14
+ node/npm/
15
+ node/artifacts/
16
+ node/packages/
17
+ node/*.node
18
+
19
+ .claude/
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - First release: a reader of CIF 1.1 and 2.0 files into crystal structures, for Rust, Python and Node.js.
cifmi-0.1.0/Cargo.lock ADDED
@@ -0,0 +1,160 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "cifmi"
7
+ version = "0.1.0"
8
+ dependencies = [
9
+ "pyo3",
10
+ "rustc-hash",
11
+ "thiserror",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "heck"
16
+ version = "0.5.0"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
19
+
20
+ [[package]]
21
+ name = "libc"
22
+ version = "0.2.191"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
25
+
26
+ [[package]]
27
+ name = "once_cell"
28
+ version = "1.21.4"
29
+ source = "registry+https://github.com/rust-lang/crates.io-index"
30
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
31
+
32
+ [[package]]
33
+ name = "portable-atomic"
34
+ version = "1.15.0"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
37
+
38
+ [[package]]
39
+ name = "proc-macro2"
40
+ version = "1.0.107"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
43
+ dependencies = [
44
+ "unicode-ident",
45
+ ]
46
+
47
+ [[package]]
48
+ name = "pyo3"
49
+ version = "0.30.1"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
52
+ dependencies = [
53
+ "libc",
54
+ "once_cell",
55
+ "portable-atomic",
56
+ "pyo3-build-config",
57
+ "pyo3-ffi",
58
+ "pyo3-macros",
59
+ ]
60
+
61
+ [[package]]
62
+ name = "pyo3-build-config"
63
+ version = "0.30.1"
64
+ source = "registry+https://github.com/rust-lang/crates.io-index"
65
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
66
+ dependencies = [
67
+ "target-lexicon",
68
+ ]
69
+
70
+ [[package]]
71
+ name = "pyo3-ffi"
72
+ version = "0.30.1"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
75
+ dependencies = [
76
+ "libc",
77
+ "pyo3-build-config",
78
+ ]
79
+
80
+ [[package]]
81
+ name = "pyo3-macros"
82
+ version = "0.30.1"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
85
+ dependencies = [
86
+ "proc-macro2",
87
+ "pyo3-macros-backend",
88
+ "quote",
89
+ "syn",
90
+ ]
91
+
92
+ [[package]]
93
+ name = "pyo3-macros-backend"
94
+ version = "0.30.1"
95
+ source = "registry+https://github.com/rust-lang/crates.io-index"
96
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
97
+ dependencies = [
98
+ "heck",
99
+ "proc-macro2",
100
+ "quote",
101
+ "syn",
102
+ ]
103
+
104
+ [[package]]
105
+ name = "quote"
106
+ version = "1.0.47"
107
+ source = "registry+https://github.com/rust-lang/crates.io-index"
108
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
109
+ dependencies = [
110
+ "proc-macro2",
111
+ ]
112
+
113
+ [[package]]
114
+ name = "rustc-hash"
115
+ version = "2.1.3"
116
+ source = "registry+https://github.com/rust-lang/crates.io-index"
117
+ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
118
+
119
+ [[package]]
120
+ name = "syn"
121
+ version = "3.0.9"
122
+ source = "registry+https://github.com/rust-lang/crates.io-index"
123
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
124
+ dependencies = [
125
+ "proc-macro2",
126
+ "quote",
127
+ "unicode-ident",
128
+ ]
129
+
130
+ [[package]]
131
+ name = "target-lexicon"
132
+ version = "0.13.5"
133
+ source = "registry+https://github.com/rust-lang/crates.io-index"
134
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
135
+
136
+ [[package]]
137
+ name = "thiserror"
138
+ version = "2.0.21"
139
+ source = "registry+https://github.com/rust-lang/crates.io-index"
140
+ checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
141
+ dependencies = [
142
+ "thiserror-impl",
143
+ ]
144
+
145
+ [[package]]
146
+ name = "thiserror-impl"
147
+ version = "2.0.21"
148
+ source = "registry+https://github.com/rust-lang/crates.io-index"
149
+ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
150
+ dependencies = [
151
+ "proc-macro2",
152
+ "quote",
153
+ "syn",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "unicode-ident"
158
+ version = "1.0.27"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
cifmi-0.1.0/Cargo.toml ADDED
@@ -0,0 +1,37 @@
1
+ [package]
2
+ name = "cifmi"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ rust-version = "1.88"
6
+ description = "Reads CIF 1.1 and 2.0 files into crystal structures"
7
+ license = "MIT"
8
+ repository = "https://github.com/jcwang587/cifmi"
9
+ readme = "README.md"
10
+ keywords = ["cif", "crystallography", "crystal", "structure", "parser"]
11
+ categories = ["science", "parser-implementations"]
12
+ # The crate carries the Rust sources, the tests and their fixtures. The Node
13
+ # package, the development tooling and the macOS linker wrapper stay in the
14
+ # repository: a crate built from a registry has no tools/ directory for the
15
+ # wrapper that .cargo/config.toml names.
16
+ exclude = ["/.cargo", "/.github", "/.pre-commit-config.yaml", "/CONTRIBUTING.md", "/node", "/tools"]
17
+
18
+ [lib]
19
+ crate-type = ["rlib", "cdylib"]
20
+
21
+ [dependencies]
22
+ pyo3 = { version = "0.30", optional = true, features = ["extension-module", "abi3-py310"] }
23
+ rustc-hash = "2.1"
24
+ thiserror = "2.0.18"
25
+
26
+ [features]
27
+ default = []
28
+ python = ["dep:pyo3"]
29
+
30
+ # Nothing is stripped, not even the debug information Cargo strips from
31
+ # release builds by default: stripping runs after the linker and can misalign
32
+ # a macOS library again after tools/macos-link has aligned it (see
33
+ # .cargo/config.toml).
34
+ [profile.release]
35
+ lto = true
36
+ codegen-units = 1
37
+ strip = "none"
cifmi-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jiacheng Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cifmi-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: cifmi
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Operating System :: OS Independent
7
+ Requires-Dist: pytest>=8 ; extra == 'test'
8
+ Provides-Extra: test
9
+ License-File: LICENSE
10
+ License-File: THIRD_PARTY_NOTICES.md
11
+ Summary: Reads CIF 1.1 and 2.0 files into crystal structures
12
+ Keywords: cif,crystallography,crystal structure,parser,rust
13
+ License-Expression: MIT
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
16
+ Project-URL: Repository, https://github.com/jcwang587/cifmi
17
+
18
+ # cifmi
19
+
20
+ [![Crates.io](https://img.shields.io/crates/v/cifmi?logo=rust&color=264323)](https://crates.io/crates/cifmi)
21
+ [![PyPI](https://img.shields.io/pypi/v/cifmi?logo=pypi&logoColor=white&color=3775A9)](https://pypi.org/project/cifmi/)
22
+ [![npm](https://img.shields.io/npm/v/cifmi?logo=npm&color=CB3837)](https://www.npmjs.com/package/cifmi)
23
+
24
+ cifmi reads CIF 1.1 and 2.0 files into crystal structures: the cell, the
25
+ space group, the sites, the symmetry operations and every atom of the unit
26
+ cell. It is written in Rust, with Python and Node.js bindings.
27
+
28
+ ## Quick start
29
+
30
+ ### Python
31
+
32
+ ```python
33
+ import cifmi
34
+
35
+ structure = cifmi.read_cif("sample.cif")
36
+ for atom in structure.atoms:
37
+ print(structure.sites[atom.site].label, atom.fractional)
38
+ ```
39
+
40
+ ### Rust
41
+
42
+ ```rust
43
+ use cifmi::{read_cif, CifOptions};
44
+
45
+ fn main() -> Result<(), cifmi::Error> {
46
+ let structure = read_cif("sample.cif", &CifOptions::default())?;
47
+ for atom in &structure.atoms {
48
+ println!("{} {:?}", structure.sites[atom.site].label, atom.position);
49
+ }
50
+ Ok(())
51
+ }
52
+ ```
53
+
54
+ ### Node.js
55
+
56
+ ```javascript
57
+ const cifmi = require('cifmi')
58
+
59
+ cifmi.readCifFile('sample.cif').then((structure) => {
60
+ for (const atom of structure.atoms) {
61
+ console.log(structure.sites[atom.site].label, atom.fractional)
62
+ }
63
+ })
64
+ ```
65
+
66
+ Every file is read one way, by crystallographic rules, and a file cifmi
67
+ cannot read is an error with the reason. See the
68
+ [design](https://github.com/jcwang587/cifmi/blob/main/docs/design.md) for
69
+ the rules and the evidence behind them, and
70
+ [CONTRIBUTING.md](https://github.com/jcwang587/cifmi/blob/main/CONTRIBUTING.md)
71
+ for development and releases.
72
+
cifmi-0.1.0/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # cifmi
2
+
3
+ [![Crates.io](https://img.shields.io/crates/v/cifmi?logo=rust&color=264323)](https://crates.io/crates/cifmi)
4
+ [![PyPI](https://img.shields.io/pypi/v/cifmi?logo=pypi&logoColor=white&color=3775A9)](https://pypi.org/project/cifmi/)
5
+ [![npm](https://img.shields.io/npm/v/cifmi?logo=npm&color=CB3837)](https://www.npmjs.com/package/cifmi)
6
+
7
+ cifmi reads CIF 1.1 and 2.0 files into crystal structures: the cell, the
8
+ space group, the sites, the symmetry operations and every atom of the unit
9
+ cell. It is written in Rust, with Python and Node.js bindings.
10
+
11
+ ## Quick start
12
+
13
+ ### Python
14
+
15
+ ```python
16
+ import cifmi
17
+
18
+ structure = cifmi.read_cif("sample.cif")
19
+ for atom in structure.atoms:
20
+ print(structure.sites[atom.site].label, atom.fractional)
21
+ ```
22
+
23
+ ### Rust
24
+
25
+ ```rust
26
+ use cifmi::{read_cif, CifOptions};
27
+
28
+ fn main() -> Result<(), cifmi::Error> {
29
+ let structure = read_cif("sample.cif", &CifOptions::default())?;
30
+ for atom in &structure.atoms {
31
+ println!("{} {:?}", structure.sites[atom.site].label, atom.position);
32
+ }
33
+ Ok(())
34
+ }
35
+ ```
36
+
37
+ ### Node.js
38
+
39
+ ```javascript
40
+ const cifmi = require('cifmi')
41
+
42
+ cifmi.readCifFile('sample.cif').then((structure) => {
43
+ for (const atom of structure.atoms) {
44
+ console.log(structure.sites[atom.site].label, atom.fractional)
45
+ }
46
+ })
47
+ ```
48
+
49
+ Every file is read one way, by crystallographic rules, and a file cifmi
50
+ cannot read is an error with the reason. See the
51
+ [design](https://github.com/jcwang587/cifmi/blob/main/docs/design.md) for
52
+ the rules and the evidence behind them, and
53
+ [CONTRIBUTING.md](https://github.com/jcwang587/cifmi/blob/main/CONTRIBUTING.md)
54
+ for development and releases.
@@ -0,0 +1,27 @@
1
+ # Third-party notices
2
+
3
+ cifmi is licensed under the MIT License (see [LICENSE](LICENSE)). It has no
4
+ runtime dependencies beyond the Rust crates its `Cargo.toml` lists. Two parts
5
+ of the repository come from elsewhere.
6
+
7
+ ## gemmi
8
+
9
+ `src/spacegroups.rs` is generated by `tools/generate_spacegroups.py` from
10
+ gemmi's table of space-group settings: the number, Hermann-Mauguin symbol,
11
+ Hall symbol and symmetry operations of each of its 564 settings. gemmi
12
+ (<https://github.com/project-gemmi/gemmi>) is licensed under the Mozilla
13
+ Public License 2.0 (<https://www.mozilla.org/MPL/2.0/>). The generator runs
14
+ against an installed gemmi and is not part of the published packages.
15
+
16
+ The generated table and its generator are available in the
17
+ [cifmi release tags](https://github.com/jcwang587/cifmi/tags). Select the tag
18
+ `v<package version>` and see `src/spacegroups.rs` and
19
+ `tools/generate_spacegroups.py` for the source corresponding to a release.
20
+
21
+ ## Crystallography Open Database
22
+
23
+ The CIF files under `tests/data/cif/` are entries of the Crystallography Open
24
+ Database (<https://www.crystallography.net/cod/>), which places its data in
25
+ the public domain. Each file keeps its COD number in its name and its
26
+ bibliographic reference in its header; [tests/README.md](tests/README.md)
27
+ says what each one tests.