rust-sasa-python 0.2.1__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.
@@ -138,7 +138,7 @@ jobs:
138
138
  name: Release
139
139
  runs-on: ubuntu-latest
140
140
  needs: [linux, windows, macos, sdist, test]
141
- if: github.ref_name != 'radical'
141
+ if: startsWith(github.ref, 'refs/tags/v')
142
142
  steps:
143
143
  - uses: actions/download-artifact@v4
144
144
  - name: Publish to PyPI
@@ -659,8 +659,9 @@ dependencies = [
659
659
 
660
660
  [[package]]
661
661
  name = "rust-sasa-python"
662
- version = "0.2.1"
662
+ version = "0.2.2"
663
663
  dependencies = [
664
+ "nalgebra",
664
665
  "pdbtbx",
665
666
  "pyo3",
666
667
  "rust-sasa",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rust-sasa-python"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  edition = "2024"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -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.1
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
@@ -132,3 +132,20 @@ def calculate_chain_sasa(pdb_path: str) -> List[Chain]:
132
132
  List[Chain]: List of chain-level SASA results
133
133
 
134
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::{AtomLevel, ChainLevel, ProteinLevel, ResidueLevel};
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
  }
@@ -84,7 +84,7 @@ wheels = [
84
84
 
85
85
  [[package]]
86
86
  name = "rust-sasa-python"
87
- version = "0.2.0"
87
+ version = "0.2.1"
88
88
  source = { editable = "." }
89
89
 
90
90
  [package.optional-dependencies]