Skip to content

Commit 74d9298

Browse files
committed
implement collision energy
1 parent 6f6dba4 commit 74d9298

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

native/ThermoNativeReader/NativeApi.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,25 @@ public static int GetScanEventActivationType(int handle, int scanNumber, int ind
12041204
try { return (int)_rawFile.GetScanEventForScanNumber(scanNumber).GetActivation(index); } catch (Exception ex) { Console.Error.WriteLine("[native-fisher-py] Exception in GetScanEventActivationType (fallback -1): " + ex.Message); return -1; }
12051205
}
12061206

1207+
1208+
1209+
[UnmanagedCallersOnly(EntryPoint = "get_scan_event_isolation_width")]
1210+
public static double GetScanEventIsolationWidth(int handle, int scanNumber, int index)
1211+
{
1212+
var _rawFile = GetFile(handle);
1213+
if (_rawFile == null) return -1;
1214+
try { return _rawFile.GetScanEventForScanNumber(scanNumber).GetIsolationWidth(index); } catch { return 0.0; }
1215+
}
1216+
1217+
[UnmanagedCallersOnly(EntryPoint = "get_scan_event_isolation_width_offset")]
1218+
public static double GetScanEventIsolationWidthOffset(int handle, int scanNumber, int index)
1219+
{
1220+
var _rawFile = GetFile(handle);
1221+
if (_rawFile == null) return -1;
1222+
try { return _rawFile.GetScanEventForScanNumber(scanNumber).GetIsolationWidthOffset(index); } catch { return 0.0; }
1223+
}
1224+
1225+
12071226
[UnmanagedCallersOnly(EntryPoint = "get_scan_event_collision_energy")]
12081227
public static double GetScanEventCollisionEnergy(int handle, int scanNumber, int index)
12091228
{

native_fisher_py/python/native_fisher_py/data/classes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,13 @@ def collision_energy_valid(self): raise NotImplementedError
12221222
@property
12231223
def first_precursor_mass(self): raise NotImplementedError
12241224
@property
1225-
def isolation_width(self): raise NotImplementedError
1225+
def isolation_width(self):
1226+
from ..native_fisher_py_backend import get_scan_event_isolation_width
1227+
return get_scan_event_isolation_width(self._handle, self._scan_number, self._index)
12261228
@property
1227-
def isolation_width_offset(self): raise NotImplementedError
1229+
def isolation_width_offset(self):
1230+
from ..native_fisher_py_backend import get_scan_event_isolation_width_offset
1231+
return get_scan_event_isolation_width_offset(self._handle, self._scan_number, self._index)
12281232
@property
12291233
def last_precursor_mass(self): raise NotImplementedError
12301234
@property

native_fisher_py/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,27 @@ fn get_scan_event_activation_type(handle: i32, scan_number: i32, index: i32) ->
11521152
}
11531153
}
11541154

1155+
1156+
#[pyfunction]
1157+
fn get_scan_event_isolation_width(handle: i32, scan_number: i32, index: i32) -> PyResult<f64> {
1158+
let lib = get_lib()?;
1159+
unsafe {
1160+
let func: Symbol<unsafe extern "C" fn(i32, i32, i32) -> f64> = lib.get(b"get_scan_event_isolation_width")
1161+
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("get function get_scan_event_isolation_width: {}", e)))?;
1162+
Ok(func(handle, scan_number, index))
1163+
}
1164+
}
1165+
1166+
#[pyfunction]
1167+
fn get_scan_event_isolation_width_offset(handle: i32, scan_number: i32, index: i32) -> PyResult<f64> {
1168+
let lib = get_lib()?;
1169+
unsafe {
1170+
let func: Symbol<unsafe extern "C" fn(i32, i32, i32) -> f64> = lib.get(b"get_scan_event_isolation_width_offset")
1171+
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("get function get_scan_event_isolation_width_offset: {}", e)))?;
1172+
Ok(func(handle, scan_number, index))
1173+
}
1174+
}
1175+
11551176
#[pyfunction]
11561177
fn get_scan_event_collision_energy(handle: i32, scan_number: i32, index: i32) -> PyResult<f64> {
11571178
let lib = get_lib()?;
@@ -1760,6 +1781,8 @@ fn native_fisher_py_backend(m: &Bound<'_, PyModule>) -> PyResult<()> {
17601781
m.add_function(wrap_pyfunction!(get_scan_event_mass_count, m)?)?;
17611782
m.add_function(wrap_pyfunction!(get_scan_event_precursor_mass, m)?)?;
17621783
m.add_function(wrap_pyfunction!(get_scan_event_activation_type, m)?)?;
1784+
m.add_function(wrap_pyfunction!(get_scan_event_isolation_width, m)?)?;
1785+
m.add_function(wrap_pyfunction!(get_scan_event_isolation_width_offset, m)?)?;
17631786
m.add_function(wrap_pyfunction!(get_scan_event_collision_energy, m)?)?;
17641787
m.add_function(wrap_pyfunction!(get_scan_stats, m)?)?;
17651788
m.add_function(wrap_pyfunction!(get_instrument_axis_label_x, m)?)?;

0 commit comments

Comments
 (0)