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>

source

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.

source

pub async fn with_buffer_capacity_and_detail_level( file: R, capacity: usize, detail_level: DetailLevel ) -> MzMLReaderType<R, C, D>

source

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.

source

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>

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.

source

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

source

pub fn len(&self) -> usize

Read the length of the spectrum offset index

source

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.

source

pub async fn get_spectrum_by_id( &mut self, id: &str ) -> Option<MultiLayerSpectrum<C, D>>

Retrieve a spectrum by it’s native ID

source

pub async fn get_spectrum_by_index( &mut self, index: usize ) -> Option<MultiLayerSpectrum<C, D>>

Retrieve a spectrum by it’s integer index

source

pub async fn reset(&mut self)

Return the data stream to the beginning

source

pub fn get_index(&self) -> &OffsetIndex

source

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>

source§

fn data_processings(&self) -> &Vec<DataProcessing>

The series of DataProcessing workflows applied to spectra in this data file.
source§

fn instrument_configurations(&self) -> &HashMap<u32, InstrumentConfiguration>

A mapping over different InstrumentConfiguration modes that spectra were acquired under.
source§

fn file_description(&self) -> &FileDescription

A description of the contents and the sources for this mass spectrometry data file.
source§

fn softwares(&self) -> &Vec<Software>

The series of Software applied to the data file to apply different DataProcessing methods.
source§

fn data_processings_mut(&mut self) -> &mut Vec<DataProcessing>

Mutably access the DataProcessing list for this data file
source§

fn instrument_configurations_mut( &mut self ) -> &mut HashMap<u32, InstrumentConfiguration>

Mutably access the InstrumentConfiguration mapping for this data file
source§

fn file_description_mut(&mut self) -> &mut FileDescription

Mutably access the FileDescription description of the contents and the sources for this mass spectrometry data file.
source§

fn softwares_mut(&mut self) -> &mut Vec<Software>

Mutably access the list of Software of this data file.
source§

fn run_description(&self) -> Option<&MassSpectrometryRun>

Access the MassSpectrometryRun metadata record if it is available
source§

fn run_description_mut(&mut self) -> Option<&mut MassSpectrometryRun>

Mutably access the MassSpectrometryRun metadata record if it is available
source§

fn copy_metadata_from(&mut self, source: &impl MSDataFileMetadata)

Copy the metadata from another MSDataFileMetadata implementation into this one.
source§

fn spectrum_count_hint(&self) -> Option<u64>

A hint about how many spectra are in this data file
source§

fn source_file_name(&self) -> Option<&str>

Get the name of the primary source file, if available

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>
where C: Unpin, D: Unpin,

§

impl<R, C = CentroidPeak, D = DeconvolutedPeak> !UnwindSafe for MzMLReaderType<R, C, D>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.