Struct mzdata::io::mzml::AsyncMzMLReaderType
source · pub struct AsyncMzMLReaderType<R: AsyncReadType + Unpin, C: CentroidPeakAdapting + Send + Sync = CentroidPeak, D: DeconvolutedPeakAdapting + Send + Sync = DeconvolutedPeak> {
pub state: MzMLParserState,
pub index: OffsetIndex,
pub reference_param_groups: HashMap<String, Vec<Param>>,
pub detail_level: DetailLevel,
pub run: MassSpectrometryRun,
/* private fields */
}
Expand description
An asynchronous version of MzMLReaderType
that
works with the tokio
runtime.
Fields§
§state: MzMLParserState
The state the parser was in last.
index: OffsetIndex
A spectrum ID to byte offset for fast random access
reference_param_groups: HashMap<String, Vec<Param>>
A cache of repeated paramters
detail_level: DetailLevel
§run: MassSpectrometryRun
Implementations§
source§impl<'a, R: AsyncReadType + Unpin + Sync, C: CentroidPeakAdapting + Send + Sync + BuildFromArrayMap, D: DeconvolutedPeakAdapting + Send + Sync + BuildFromArrayMap> MzMLReaderType<R, C, D>
impl<'a, R: AsyncReadType + Unpin + Sync, C: CentroidPeakAdapting + Send + Sync + BuildFromArrayMap, D: DeconvolutedPeakAdapting + Send + Sync + BuildFromArrayMap> MzMLReaderType<R, C, D>
sourcepub async fn new(file: R) -> MzMLReaderType<R, C, D>
pub async fn new(file: R) -> MzMLReaderType<R, C, D>
Create a new MzMLReaderType
instance, wrapping the tokio::io::AsyncRead
handle
provided with an [io::BufReader
] and parses the metadata section of the file.
pub async fn with_buffer_capacity_and_detail_level( file: R, capacity: usize, detail_level: DetailLevel ) -> MzMLReaderType<R, C, D>
sourcepub async fn read_into(
&mut self,
spectrum: &mut MultiLayerSpectrum<C, D>
) -> Result<usize, MzMLParserError>
pub async fn read_into( &mut self, spectrum: &mut MultiLayerSpectrum<C, D> ) -> Result<usize, MzMLParserError>
Populate a new Spectrum
in-place on the next available spectrum data.
This allocates memory to build the spectrum’s attributes but then moves it
into spectrum
rather than copying it.
sourcepub async fn read_next(&mut self) -> Option<MultiLayerSpectrum<C, D>>
pub async fn read_next(&mut self) -> Option<MultiLayerSpectrum<C, D>>
Read the next spectrum directly. Used to implement iteration.
source§impl<R: AsyncReadType + AsyncSeek + AsyncSeekExt + Unpin + Sync, C: CentroidPeakAdapting + Send + Sync + BuildFromArrayMap, D: DeconvolutedPeakAdapting + Send + Sync + BuildFromArrayMap> MzMLReaderType<R, C, D>
impl<R: AsyncReadType + AsyncSeek + AsyncSeekExt + Unpin + Sync, C: CentroidPeakAdapting + Send + Sync + BuildFromArrayMap, D: DeconvolutedPeakAdapting + Send + Sync + BuildFromArrayMap> MzMLReaderType<R, C, D>
When the underlying stream supports random access, this type can read the index at the end of
an indexedmzML
document and use the offset map to jump to immediately jump to a specific spectrum.
Note: Because async traits are not yet stable, and this is currently the only asynchronous reader
in the library, this also re-creates the SpectrumSource
API with
asynchronous execution.
sourcepub async fn read_index_from_end(&mut self) -> Result<u64, MzMLIndexingError>
pub async fn read_index_from_end(&mut self) -> Result<u64, MzMLIndexingError>
Jump to the end of the document and read the offset indices, if they are available
sourcepub async fn get_spectrum_by_time(
&mut self,
time: f64
) -> Option<MultiLayerSpectrum<C, D>>
pub async fn get_spectrum_by_time( &mut self, time: f64 ) -> Option<MultiLayerSpectrum<C, D>>
Retrieve a spectrum by its scan start time Considerably more complex than seeking by ID or index, this involves a binary search over the spectrum index and assumes that spectra are stored in chronological order.
sourcepub async fn get_spectrum_by_id(
&mut self,
id: &str
) -> Option<MultiLayerSpectrum<C, D>>
pub async fn get_spectrum_by_id( &mut self, id: &str ) -> Option<MultiLayerSpectrum<C, D>>
Retrieve a spectrum by it’s native ID
sourcepub async fn get_spectrum_by_index(
&mut self,
index: usize
) -> Option<MultiLayerSpectrum<C, D>>
pub async fn get_spectrum_by_index( &mut self, index: usize ) -> Option<MultiLayerSpectrum<C, D>>
Retrieve a spectrum by it’s integer index
pub fn get_index(&self) -> &OffsetIndex
pub fn set_index(&mut self, index: OffsetIndex)
Trait Implementations§
source§impl<R: AsyncReadType + Unpin, C: CentroidPeakAdapting + Send + Sync, D: DeconvolutedPeakAdapting + Send + Sync> MSDataFileMetadata for MzMLReaderType<R, C, D>
impl<R: AsyncReadType + Unpin, C: CentroidPeakAdapting + Send + Sync, D: DeconvolutedPeakAdapting + Send + Sync> MSDataFileMetadata for MzMLReaderType<R, C, D>
source§fn data_processings(&self) -> &Vec<DataProcessing>
fn data_processings(&self) -> &Vec<DataProcessing>
DataProcessing
workflows applied to spectra in
this data file.source§fn instrument_configurations(&self) -> &HashMap<u32, InstrumentConfiguration>
fn instrument_configurations(&self) -> &HashMap<u32, InstrumentConfiguration>
InstrumentConfiguration
modes that spectra
were acquired under.source§fn file_description(&self) -> &FileDescription
fn file_description(&self) -> &FileDescription
source§fn softwares(&self) -> &Vec<Software>
fn softwares(&self) -> &Vec<Software>
Software
applied to the data file to apply different
DataProcessing
methods.source§fn data_processings_mut(&mut self) -> &mut Vec<DataProcessing>
fn data_processings_mut(&mut self) -> &mut Vec<DataProcessing>
DataProcessing
list for this data filesource§fn instrument_configurations_mut(
&mut self
) -> &mut HashMap<u32, InstrumentConfiguration>
fn instrument_configurations_mut( &mut self ) -> &mut HashMap<u32, InstrumentConfiguration>
InstrumentConfiguration
mapping for this data filesource§fn file_description_mut(&mut self) -> &mut FileDescription
fn file_description_mut(&mut self) -> &mut FileDescription
FileDescription
description of the contents and the
sources for this mass spectrometry data file.source§fn softwares_mut(&mut self) -> &mut Vec<Software>
fn softwares_mut(&mut self) -> &mut Vec<Software>
Software
of this data file.source§fn run_description(&self) -> Option<&MassSpectrometryRun>
fn run_description(&self) -> Option<&MassSpectrometryRun>
MassSpectrometryRun
metadata record if it is availablesource§fn run_description_mut(&mut self) -> Option<&mut MassSpectrometryRun>
fn run_description_mut(&mut self) -> Option<&mut MassSpectrometryRun>
MassSpectrometryRun
metadata record if it is availablesource§fn copy_metadata_from(&mut self, source: &impl MSDataFileMetadata)
fn copy_metadata_from(&mut self, source: &impl MSDataFileMetadata)
MSDataFileMetadata
implementation into
this one.source§fn spectrum_count_hint(&self) -> Option<u64>
fn spectrum_count_hint(&self) -> Option<u64>
source§fn source_file_name(&self) -> Option<&str>
fn source_file_name(&self) -> Option<&str>
Auto Trait Implementations§
impl<R, C, D> Freeze for MzMLReaderType<R, C, D>where
R: Freeze,
impl<R, C = CentroidPeak, D = DeconvolutedPeak> !RefUnwindSafe for MzMLReaderType<R, C, D>
impl<R, C, D> Send for MzMLReaderType<R, C, D>where
R: Send,
impl<R, C, D> Sync for MzMLReaderType<R, C, D>where
R: Sync,
impl<R, C, D> Unpin for MzMLReaderType<R, C, D>
impl<R, C = CentroidPeak, D = DeconvolutedPeak> !UnwindSafe for MzMLReaderType<R, C, D>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.