rust-sasa-python 0.2.0__tar.gz → 0.2.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.
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/.github/workflows/CI.yml +1 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/Cargo.lock +2 -1
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/Cargo.toml +3 -2
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/DOCS.md +35 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/PKG-INFO +1 -1
- rust_sasa_python-0.2.2/rust-sasa-python.pyi +151 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/src/lib.rs +27 -1
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/uv.lock +1 -1
- rust_sasa_python-0.2.0/test.py +0 -6
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/.gitignore +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/LICENSE.md +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/README.md +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/example.cif +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/pyproject.toml +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/pytest.ini +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/tests/__init__.py +0 -0
- {rust_sasa_python-0.2.0 → rust_sasa_python-0.2.2}/tests/test_sasa.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rust-sasa-python"
|
|
3
|
-
version = "0.2.
|
|
4
|
-
edition = "
|
|
3
|
+
version = "0.2.2"
|
|
4
|
+
edition = "2024"
|
|
5
5
|
|
|
6
6
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
7
|
[lib]
|
|
@@ -12,3 +12,4 @@ crate-type = ["cdylib"]
|
|
|
12
12
|
pdbtbx = "0.12.0"
|
|
13
13
|
pyo3 = "0.25.1"
|
|
14
14
|
rust-sasa = "0.3.2"
|
|
15
|
+
nalgebra = "0.33.2"
|
|
@@ -84,6 +84,41 @@ atom_results = sasa.calculate_atom_sasa("protein.pdb")
|
|
|
84
84
|
chain_results = sasa.calculate_chain_sasa("protein.pdb")
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
### Low-level Functions
|
|
88
|
+
|
|
89
|
+
For advanced use cases where you need to calculate SASA for custom atom sets:
|
|
90
|
+
|
|
91
|
+
**`calculate_sasa_internal(atoms_in: list[tuple[tuple[float, float, float], float, int]], probe_radius: float, n_points: int) -> list[float]`**
|
|
92
|
+
|
|
93
|
+
Calculate SASA for a set of atoms directly without PDB file parsing.
|
|
94
|
+
|
|
95
|
+
**Parameters:**
|
|
96
|
+
- `atoms_in`: List of tuples, each containing:
|
|
97
|
+
- Atom coordinates as `(x, y, z)` tuple of floats
|
|
98
|
+
- Atom radius as float
|
|
99
|
+
- Atom index as int
|
|
100
|
+
- `probe_radius`: Probe sphere radius in Ångströms
|
|
101
|
+
- `n_points`: Number of points for surface sampling
|
|
102
|
+
|
|
103
|
+
**Returns:**
|
|
104
|
+
- List of SASA values (floats) corresponding to each input atom
|
|
105
|
+
|
|
106
|
+
**Example:**
|
|
107
|
+
```python
|
|
108
|
+
import rust_sasa_python as sasa
|
|
109
|
+
|
|
110
|
+
# Define atoms: [(coordinates, radius, index), ...]
|
|
111
|
+
atoms = [
|
|
112
|
+
((0.0, 0.0, 0.0), 1.7, 0), # Carbon atom
|
|
113
|
+
((2.0, 0.0, 0.0), 1.2, 1), # Hydrogen atom
|
|
114
|
+
((0.0, 2.0, 0.0), 1.55, 2), # Nitrogen atom
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
# Calculate SASA
|
|
118
|
+
sasa_values = sasa.calculate_sasa_internal(atoms, probe_radius=1.4, n_points=100)
|
|
119
|
+
print(f"SASA values: {sasa_values}")
|
|
120
|
+
```
|
|
121
|
+
|
|
87
122
|
## Usage Examples
|
|
88
123
|
|
|
89
124
|
### Basic Usage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rust-sasa-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""Type stubs for rust_sasa_python module."""
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
class Protein:
|
|
6
|
+
"""Protein-level SASA results."""
|
|
7
|
+
|
|
8
|
+
total: float
|
|
9
|
+
polar: float
|
|
10
|
+
non_polar: float
|
|
11
|
+
|
|
12
|
+
class Residue:
|
|
13
|
+
"""Residue-level SASA results."""
|
|
14
|
+
|
|
15
|
+
chain_id: str
|
|
16
|
+
residue_name: str
|
|
17
|
+
residue_number: int
|
|
18
|
+
sasa: float
|
|
19
|
+
|
|
20
|
+
class Chain:
|
|
21
|
+
"""Chain-level SASA results."""
|
|
22
|
+
|
|
23
|
+
chain_id: str
|
|
24
|
+
sasa: float
|
|
25
|
+
|
|
26
|
+
class SASACalculator:
|
|
27
|
+
"""SASA calculator with configurable parameters."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, pdb_path: str) -> None:
|
|
30
|
+
"""Initialize SASA calculator with PDB file path.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
pdb_path: Path to PDB or mmCIF file
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def with_probe_radius(self, radius: float) -> SASACalculator:
|
|
38
|
+
"""Set the probe radius for SASA calculation.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
radius: Probe sphere radius in Ångströms (default: 1.4)
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Self for method chaining
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def with_n_points(self, points: int) -> SASACalculator:
|
|
49
|
+
"""Set the number of points for surface sampling.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
points: Number of sampling points (default: 100)
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
Self for method chaining
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def calculate_protein(self) -> Protein:
|
|
60
|
+
"""Calculate SASA at the protein level.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Protein: Object containing total, polar, and non-polar SASA values
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def calculate_chain(self) -> List[Chain]:
|
|
68
|
+
"""Calculate SASA at the chain level.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List[Chain]: List of chain-level SASA results
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def calculate_residue(self) -> List[Residue]:
|
|
76
|
+
"""Calculate SASA at the residue level.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
List[Residue]: List of residue-level SASA results
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
def calculate_atom(self) -> List[float]:
|
|
84
|
+
"""Calculate SASA at the atom level.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
List[float]: List of atom-level SASA values
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
# Convenience functions
|
|
92
|
+
def calculate_protein_sasa(pdb_path: str) -> Protein:
|
|
93
|
+
"""Calculate protein-level SASA for a PDB file.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
pdb_path: Path to PDB or mmCIF file
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Protein: Object containing total, polar, and non-polar SASA values
|
|
100
|
+
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
def calculate_residue_sasa(pdb_path: str) -> List[Residue]:
|
|
104
|
+
"""Calculate residue-level SASA for a PDB file.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
pdb_path: Path to PDB or mmCIF file
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
List[Residue]: List of residue-level SASA results
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
def calculate_atom_sasa(pdb_path: str) -> List[float]:
|
|
115
|
+
"""Calculate atom-level SASA for a PDB file.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
pdb_path: Path to PDB or mmCIF file
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
List[float]: List of atom-level SASA values
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
def calculate_chain_sasa(pdb_path: str) -> List[Chain]:
|
|
126
|
+
"""Calculate chain-level SASA for a PDB file.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
pdb_path: Path to PDB or mmCIF file
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
List[Chain]: List of chain-level SASA results
|
|
133
|
+
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
def calculate_sasa_internal(
|
|
137
|
+
atoms_in: list[tuple[tuple[float, float, float], float, int]],
|
|
138
|
+
probe_radius: float,
|
|
139
|
+
n_points: int,
|
|
140
|
+
) -> list[float]:
|
|
141
|
+
"""Calculate SASA for a set of atoms.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
atoms_in: List of atom coordinates, radii, and indices
|
|
145
|
+
probe_radius: Probe radius
|
|
146
|
+
n_points: Number of points on the sphere
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
List[float]: List of SASA values
|
|
150
|
+
|
|
151
|
+
"""
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
use nalgebra::Point3;
|
|
1
2
|
use pdbtbx;
|
|
2
3
|
use pyo3::exceptions::PyRuntimeError;
|
|
3
4
|
use pyo3::prelude::*;
|
|
4
5
|
use rust_sasa::options::SASAOptions;
|
|
5
|
-
use rust_sasa::{
|
|
6
|
+
use rust_sasa::{Atom, calculate_sasa_internal as calculate_sasa_internal_internal};
|
|
7
|
+
use rust_sasa::{AtomLevel, ChainLevel, ProteinLevel, ResidueLevel}; // As in long long
|
|
6
8
|
|
|
7
9
|
#[pyclass]
|
|
8
10
|
#[derive(Clone)]
|
|
@@ -291,6 +293,29 @@ pub fn calculate_chain_sasa(pdb_path: String) -> PyResult<Vec<Chain>> {
|
|
|
291
293
|
SASACalculator::new(pdb_path).calculate_chain()
|
|
292
294
|
}
|
|
293
295
|
|
|
296
|
+
#[pyfunction]
|
|
297
|
+
pub fn calculate_sasa_internal(
|
|
298
|
+
atoms_in: Vec<((f32, f32, f32), f32, usize)>,
|
|
299
|
+
probe_radius: f32,
|
|
300
|
+
n_points: usize,
|
|
301
|
+
) -> PyResult<Vec<f32>> {
|
|
302
|
+
let atoms: Vec<Atom> = atoms_in
|
|
303
|
+
.into_iter()
|
|
304
|
+
.map(|(pos, radius, index)| Atom {
|
|
305
|
+
position: Point3::new(pos.0, pos.1, pos.2),
|
|
306
|
+
id: index,
|
|
307
|
+
parent_id: None,
|
|
308
|
+
radius,
|
|
309
|
+
})
|
|
310
|
+
.collect();
|
|
311
|
+
Ok(calculate_sasa_internal_internal(
|
|
312
|
+
atoms.as_slice(),
|
|
313
|
+
probe_radius,
|
|
314
|
+
n_points,
|
|
315
|
+
true,
|
|
316
|
+
))
|
|
317
|
+
}
|
|
318
|
+
|
|
294
319
|
#[pymodule]
|
|
295
320
|
fn rust_sasa_python(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
296
321
|
m.add_class::<SASACalculator>()?;
|
|
@@ -303,6 +328,7 @@ fn rust_sasa_python(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
303
328
|
m.add_function(wrap_pyfunction!(calculate_residue_sasa, m)?)?;
|
|
304
329
|
m.add_function(wrap_pyfunction!(calculate_atom_sasa, m)?)?;
|
|
305
330
|
m.add_function(wrap_pyfunction!(calculate_chain_sasa, m)?)?;
|
|
331
|
+
m.add_function(wrap_pyfunction!(calculate_sasa_internal, m)?)?;
|
|
306
332
|
|
|
307
333
|
Ok(())
|
|
308
334
|
}
|
rust_sasa_python-0.2.0/test.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|