-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from theGreatHerrLebert/david@mixture
David@mixture
- Loading branch information
Showing
16 changed files
with
424 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "imspy" | ||
version = "0.2.2" | ||
version = "0.2.5" | ||
description = "" | ||
authors = ["theGreatHerrLebert <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -11,7 +11,7 @@ pandas = ">=2.1" | |
numpy = ">=1.21" | ||
tensorflow = ">=2.14" | ||
tensorflow-probability = ">=0.22.1" | ||
imspy-connector = ">=0.2.0" | ||
imspy-connector = ">=0.2.5" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use pyo3::prelude::*; | ||
use mscore::{ TimsDDAPrecursor }; | ||
|
||
#[pyclass] | ||
#[derive(Clone)] | ||
pub struct PyTimsDDAPrecursor { | ||
pub inner: TimsDDAPrecursor, | ||
} | ||
|
||
#[pymethods] | ||
impl PyTimsDDAPrecursor { | ||
#[new] | ||
pub fn new( | ||
_py: Python, | ||
id: u32, | ||
parent_id: u32, | ||
scan_num: u32, | ||
mz_average: f32, | ||
mz_most_intense: f32, | ||
intensity: f32, | ||
mz_mono_isotopic: Option<f32>, | ||
charge: Option<u32>, | ||
) -> PyResult<Self> { | ||
let tims_dda_precursor = TimsDDAPrecursor { | ||
id, | ||
parent_id, | ||
scan_num, | ||
mz_average, | ||
mz_most_intense, | ||
intensity, | ||
mz_mono_isotopic, | ||
charge, | ||
}; | ||
|
||
Ok(PyTimsDDAPrecursor { inner: tims_dda_precursor }) | ||
} | ||
|
||
#[getter] | ||
pub fn id(&self) -> u32 { self.inner.id } | ||
|
||
#[getter] | ||
pub fn parent_id(&self) -> u32 { self.inner.parent_id } | ||
|
||
#[getter] | ||
pub fn scan_num(&self) -> u32 { self.inner.scan_num } | ||
|
||
#[getter] | ||
pub fn mz_average(&self) -> f32 { self.inner.mz_average } | ||
|
||
#[getter] | ||
pub fn mz_most_intense(&self) -> f32 { self.inner.mz_most_intense } | ||
|
||
#[getter] | ||
pub fn intensity(&self) -> f32 { self.inner.intensity } | ||
|
||
#[getter] | ||
pub fn mz_mono_isotopic(&self) -> Option<f32> { self.inner.mz_mono_isotopic } | ||
|
||
#[getter] | ||
pub fn charge(&self) -> Option<u32> { self.inner.charge } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/// convert 1 over reduced ion mobility (1/k0) to CCS | ||
/// | ||
/// Arguments: | ||
/// | ||
/// * `one_over_k0` - 1 over reduced ion mobility (1/k0) | ||
/// * `charge` - charge state of the ion | ||
/// * `mz` - mass-over-charge of the ion | ||
/// * `mass_gas` - mass of drift gas (N2) | ||
/// * `temp` - temperature of the drift gas in C° | ||
/// * `t_diff` - factor to translate from C° to K | ||
/// | ||
/// Returns: | ||
/// | ||
/// * `ccs` - collision cross-section | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use mscore::one_over_reduced_mobility_to_ccs; | ||
/// | ||
/// let ccs = one_over_reduced_mobility_to_ccs(0.5, 1000.0, 2, 28.013, 31.85, 273.15); | ||
/// assert_eq!(ccs, 806.5918693771381); | ||
/// ``` | ||
pub fn one_over_reduced_mobility_to_ccs( | ||
one_over_k0: f64, | ||
mz: f64, | ||
charge: u32, | ||
mass_gas: f64, | ||
temp: f64, | ||
t_diff: f64, | ||
) -> f64 { | ||
let summary_constant = 18509.8632163405; | ||
let reduced_mass = (mz * charge as f64 * mass_gas) / (mz * charge as f64 + mass_gas); | ||
summary_constant * charge as f64 / (reduced_mass * (temp + t_diff)).sqrt() / one_over_k0 | ||
} | ||
|
||
|
||
/// convert CCS to 1 over reduced ion mobility (1/k0) | ||
/// | ||
/// Arguments: | ||
/// | ||
/// * `ccs` - collision cross-section | ||
/// * `charge` - charge state of the ion | ||
/// * `mz` - mass-over-charge of the ion | ||
/// * `mass_gas` - mass of drift gas (N2) | ||
/// * `temp` - temperature of the drift gas in C° | ||
/// * `t_diff` - factor to translate from C° to K | ||
/// | ||
/// Returns: | ||
/// | ||
/// * `one_over_k0` - 1 over reduced ion mobility (1/k0) | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use mscore::ccs_to_reduced_mobility; | ||
/// | ||
/// let k0 = ccs_to_reduced_mobility(806.5918693771381, 1000.0, 2, 28.013, 31.85, 273.15); | ||
/// assert_eq!(1.0 / k0, 0.5); | ||
/// ``` | ||
pub fn ccs_to_reduced_mobility( | ||
ccs: f64, | ||
mz: f64, | ||
charge: u32, | ||
mass_gas: f64, | ||
temp: f64, | ||
t_diff: f64, | ||
) -> f64 { | ||
let summary_constant = 18509.8632163405; | ||
let reduced_mass = (mz * charge as f64 * mass_gas) / (mz * charge as f64 + mass_gas); | ||
((reduced_mass * (temp + t_diff)).sqrt() * ccs) / (summary_constant * charge as f64) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#[derive(Clone)] | ||
pub struct TimsDDAPrecursor { | ||
pub id: u32, | ||
pub parent_id: u32, | ||
pub scan_num: u32, | ||
pub mz_average: f32, | ||
pub mz_most_intense: f32, | ||
pub intensity: f32, | ||
pub mz_mono_isotopic: Option<f32>, | ||
pub charge: Option<u32>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.