SpectrumAccess

Struct SpectrumAccess 

Source
pub struct SpectrumAccess<D: Read + Seek> { /* private fields */ }
Expand description

Provide ability to access a spectrum (contains DataAccess for both m/z and intensity arrays)

Implementations§

Source§

impl<D: Read + Seek> SpectrumAccess<D>

Source

pub fn new(data_location: Arc<Mutex<D>>, spectrum: Arc<Spectrum>) -> Self

Creates a new SpectrumAccess from the specified data_location and Spectrum

Source

pub fn mz_array(&self) -> Option<&DataAccess<D>>

Returns the DataAccess for the m/z array

Examples found in repository?
examples/rewrite.rs (line 31)
11fn main() {
12    let filename = "test/only_ms2_mzml.mzML";
13
14    let start = Instant::now();
15    let file = File::open(filename).unwrap();
16    let header_reader = BufReader::new(file);
17
18    let data_file = File::open(filename).unwrap();
19    let data_reader = BufReader::new(data_file);
20
21    let parser = ImzMLReader::new(header_reader, data_reader).unwrap();
22
23    let duration = start.elapsed();
24
25    for error in parser.errors() {
26        println!("{:?}", error);
27    }
28    println!("Time elapsed when parsing is: {:?}", duration);
29
30    let spectrum = parser.spectrum(0).unwrap();
31    let mzs = spectrum.mz_array().unwrap();
32    println!("Data: {:?}", mzs.as_f64());
33
34    let start = Instant::now();
35
36    let mut writer = ImzMLWriter::from_parser(&parser);
37
38    writer
39        .write(
40            "test/only_ms2_mzml.imzML",
41            ImzMLWritableSpectrumIterator::new(&parser),
42            RectangleImage::new(10, 10),
43        )
44        .unwrap();
45
46    // let file = File::create("test/only_ms2_mzml.imzML").unwrap();
47    // let mut writer = Writer::new_with_indent(BufWriter::new(file), b' ', 2);
48    // let decl_elem = quick_xml::events::BytesDecl::new(
49    //     "1.1".as_ref(),
50    //     Some("UTF-8".as_ref()),
51    //     Some("yes".as_ref()),
52    // );
53    // writer
54    //     .write_event(quick_xml::events::Event::Decl(decl_elem))
55    //     .unwrap();
56
57    // parser.mzml().unwrap().write_xml(&mut writer).unwrap();
58    let duration = start.elapsed();
59    println!("Time elapsed when writing is: {:?}", duration);
60}
Source

pub fn intensity_array(&self) -> Option<&DataAccess<D>>

Returns the DataAccess for the intensity array

Source

pub fn spectrum(&self) -> &Spectrum

Returns the spectrum metadata

Source

pub fn representation(&self) -> Option<Representation>

Returns the spectral representation (centroid, profile) of this spectrum

Source

pub fn polarity(&self) -> Option<Polarity>

Returns the polarity of this spectrum

Source

pub fn coordinate(&self) -> Option<Coordinate>

Returns the pixel coordinate of the spectrum

Auto Trait Implementations§

§

impl<D> Freeze for SpectrumAccess<D>

§

impl<D> RefUnwindSafe for SpectrumAccess<D>

§

impl<D> Send for SpectrumAccess<D>
where D: Send,

§

impl<D> Sync for SpectrumAccess<D>
where D: Send,

§

impl<D> Unpin for SpectrumAccess<D>

§

impl<D> UnwindSafe for SpectrumAccess<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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,