-
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 #44 from theGreatHerrLebert/david@mixture
David@mixture
- Loading branch information
Showing
20 changed files
with
449 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import imspy_connector as pims | ||
|
||
from imspy.spectrum import IndexedMzSpectrum | ||
|
||
|
||
class FragmentDDA: | ||
def __init__(self, frame_id: int, precursor_id: int, selected_fragment: IndexedMzSpectrum): | ||
self._fragment_ptr = pims.PyTimsFragmentDDA(frame_id, precursor_id, selected_fragment.get_spec_ptr()) | ||
|
||
@classmethod | ||
def from_py_tims_fragment_dda(cls, fragment: pims.PyTimsFragmentDDA): | ||
instance = cls.__new__(cls) | ||
instance._fragment_ptr = fragment | ||
return instance | ||
|
||
@property | ||
def frame_id(self) -> int: | ||
return self._fragment_ptr.frame_id | ||
|
||
@property | ||
def precursor_id(self) -> int: | ||
return self._fragment_ptr.precursor_id | ||
|
||
@property | ||
def selected_fragment(self) -> IndexedMzSpectrum: | ||
return IndexedMzSpectrum.from_py_indexed_mz_spectrum(self._fragment_ptr.selected_fragment) | ||
|
||
def __repr__(self): | ||
return f"FragmentDDA(frame_id={self.frame_id}, precursor_id={self.precursor_id}, " \ | ||
f"selected_fragment={self.selected_fragment})" | ||
|
||
def get_fragment_ptr(self): | ||
return self._fragment_ptr | ||
|
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,44 @@ | ||
use pyo3::prelude::*; | ||
use rustdf::data::dataset::TimsDataset; | ||
use rustdf::data::handle::TimsData; | ||
|
||
use crate::py_tims_frame::{PyTimsFrame}; | ||
use crate::py_tims_slice::PyTimsSlice; | ||
|
||
#[pyclass] | ||
pub struct PyTimsDataset { | ||
inner: TimsDataset, | ||
} | ||
|
||
#[pymethods] | ||
impl PyTimsDataset { | ||
#[new] | ||
pub fn new(data_path: &str, bruker_lib_path: &str) -> Self { | ||
let dataset = TimsDataset::new(bruker_lib_path, data_path); | ||
PyTimsDataset { inner: dataset } | ||
} | ||
|
||
pub fn get_frame(&self, frame_id: u32) -> PyTimsFrame { | ||
PyTimsFrame { inner: self.inner.get_frame(frame_id) } | ||
} | ||
|
||
pub fn get_slice(&self, frame_ids: Vec<u32>) -> PyTimsSlice { | ||
PyTimsSlice { inner: self.inner.get_slice(frame_ids) } | ||
} | ||
|
||
pub fn get_aquisition_mode(&self) -> String { | ||
self.inner.get_aquisition_mode().to_string() | ||
} | ||
|
||
pub fn get_frame_count(&self) -> i32 { | ||
self.inner.get_frame_count() | ||
} | ||
|
||
pub fn get_data_path(&self) -> &str { | ||
self.inner.get_data_path() | ||
} | ||
|
||
pub fn get_bruker_lib_path(&self) -> &str { | ||
self.inner.get_bruker_lib_path() | ||
} | ||
} |
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,78 @@ | ||
use pyo3::prelude::*; | ||
|
||
use rustdf::data::dda::{PASEFDDAFragment, TimsDatasetDDA}; | ||
use rustdf::data::handle::TimsData; | ||
use crate::py_mz_spectrum::PyIndexedMzSpectrum; | ||
use crate::py_tims_frame::PyTimsFrame; | ||
use crate::py_tims_slice::PyTimsSlice; | ||
|
||
#[pyclass] | ||
pub struct PyTimsDatasetDDA { | ||
inner: TimsDatasetDDA, | ||
} | ||
|
||
#[pymethods] | ||
impl PyTimsDatasetDDA { | ||
#[new] | ||
pub fn new(data_path: &str, bruker_lib_path: &str) -> Self { | ||
let dataset = TimsDatasetDDA::new(bruker_lib_path, data_path); | ||
PyTimsDatasetDDA { inner: dataset } | ||
} | ||
pub fn get_frame(&self, frame_id: u32) -> PyTimsFrame { | ||
PyTimsFrame { inner: self.inner.get_frame(frame_id) } | ||
} | ||
|
||
pub fn get_slice(&self, frame_ids: Vec<u32>) -> PyTimsSlice { | ||
PyTimsSlice { inner: self.inner.get_slice(frame_ids) } | ||
} | ||
|
||
pub fn get_aquisition_mode(&self) -> String { | ||
self.inner.get_aquisition_mode().to_string() | ||
} | ||
|
||
pub fn get_frame_count(&self) -> i32 { | ||
self.inner.get_frame_count() | ||
} | ||
|
||
pub fn get_data_path(&self) -> &str { | ||
self.inner.get_data_path() | ||
} | ||
|
||
pub fn get_bruker_lib_path(&self) -> &str { | ||
self.inner.get_bruker_lib_path() | ||
} | ||
|
||
pub fn get_pasef_fragments(&self, num_threads: usize) -> Vec<PyTimsFragmentDDA> { | ||
let pasef_fragments = self.inner.get_pasef_fragments(num_threads); | ||
pasef_fragments.iter().map(|pasef_fragment| PyTimsFragmentDDA { inner: pasef_fragment.clone() }).collect() | ||
} | ||
} | ||
|
||
#[pyclass] | ||
pub struct PyTimsFragmentDDA { | ||
inner: PASEFDDAFragment, | ||
} | ||
|
||
#[pymethods] | ||
impl PyTimsFragmentDDA { | ||
#[new] | ||
pub fn new(frame_id: u32, precursor_id: u32, selected_fragment: &PyIndexedMzSpectrum) -> PyResult<Self> { | ||
|
||
let pasef_fragment = PASEFDDAFragment { | ||
frame_id, | ||
precursor_id, | ||
selected_fragment: selected_fragment.inner.clone(), | ||
}; | ||
|
||
Ok(PyTimsFragmentDDA { inner: pasef_fragment }) | ||
} | ||
|
||
#[getter] | ||
pub fn frame_id(&self) -> u32 { self.inner.frame_id } | ||
|
||
#[getter] | ||
pub fn precursor_id(&self) -> u32 { self.inner.precursor_id } | ||
|
||
#[getter] | ||
pub fn selected_fragment(&self) -> PyIndexedMzSpectrum { PyIndexedMzSpectrum { inner: self.inner.selected_fragment.clone() } } | ||
} |
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,43 @@ | ||
use pyo3::prelude::*; | ||
|
||
use rustdf::data::dia::TimsDatasetDIA; | ||
use rustdf::data::handle::TimsData; | ||
use crate::py_tims_frame::PyTimsFrame; | ||
use crate::py_tims_slice::PyTimsSlice; | ||
|
||
#[pyclass] | ||
pub struct PyTimsDatasetDIA { | ||
inner: TimsDatasetDIA, | ||
} | ||
|
||
#[pymethods] | ||
impl PyTimsDatasetDIA { | ||
#[new] | ||
pub fn new(data_path: &str, bruker_lib_path: &str) -> Self { | ||
let dataset = TimsDatasetDIA::new(bruker_lib_path, data_path); | ||
PyTimsDatasetDIA { inner: dataset } | ||
} | ||
pub fn get_frame(&self, frame_id: u32) -> PyTimsFrame { | ||
PyTimsFrame { inner: self.inner.get_frame(frame_id) } | ||
} | ||
|
||
pub fn get_slice(&self, frame_ids: Vec<u32>) -> PyTimsSlice { | ||
PyTimsSlice { inner: self.inner.get_slice(frame_ids) } | ||
} | ||
|
||
pub fn get_aquisition_mode(&self) -> String { | ||
self.inner.get_aquisition_mode().to_string() | ||
} | ||
|
||
pub fn get_frame_count(&self) -> i32 { | ||
self.inner.get_frame_count() | ||
} | ||
|
||
pub fn get_data_path(&self) -> &str { | ||
self.inner.get_data_path() | ||
} | ||
|
||
pub fn get_bruker_lib_path(&self) -> &str { | ||
self.inner.get_bruker_lib_path() | ||
} | ||
} |
Oops, something went wrong.