Skip to content

Commit

Permalink
added missing member
Browse files Browse the repository at this point in the history
  • Loading branch information
theGreatHerrLebert committed Nov 10, 2023
1 parent 74e5b92 commit 69be452
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 8 additions & 3 deletions imspy/imspy/dda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@


class FragmentDDA:
def __init__(self, precursor_id, selected_fragment: IndexedMzSpectrum):
self._fragment_ptr = pims.PyTimsFragmentDDA(precursor_id, selected_fragment.get_spec_ptr())
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
Expand All @@ -25,7 +29,8 @@ def selected_fragment(self) -> IndexedMzSpectrum:
return IndexedMzSpectrum.from_py_indexed_mz_spectrum(self._fragment_ptr.selected_fragment)

def __repr__(self):
return f"FragmentDDA({self.precursor_id}, {self.selected_fragment})"
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
Expand Down
6 changes: 5 additions & 1 deletion imspy_connector/src/py_dda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ pub struct PyTimsFragmentDDA {
#[pymethods]
impl PyTimsFragmentDDA {
#[new]
pub fn new(precursor_id: u32, selected_fragment: &PyIndexedMzSpectrum) -> PyResult<Self> {
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 }

Expand Down
2 changes: 2 additions & 0 deletions rustdf/src/data/dda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::data::meta::{DDAPrecursorMeta, PasefMsMsMeta, read_dda_precursor_meta

#[derive(Clone)]
pub struct PASEFDDAFragment {
pub frame_id: u32,
pub precursor_id: u32,
pub selected_fragment: IndexedMzSpectrum,
}
Expand Down Expand Up @@ -58,6 +59,7 @@ impl TimsDatasetDDA {
);

PASEFDDAFragment {
frame_id: pasef_info.frame_id as u32,
precursor_id: pasef_info.precursor_id as u32,
// flatten the spectrum
selected_fragment: filtered_frame.to_indexed_mz_spectrum(),
Expand Down

0 comments on commit 69be452

Please sign in to comment.