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>
impl<D: Read + Seek> SpectrumAccess<D>
Sourcepub fn new(data_location: Arc<Mutex<D>>, spectrum: Arc<Spectrum>) -> Self
pub fn new(data_location: Arc<Mutex<D>>, spectrum: Arc<Spectrum>) -> Self
Creates a new SpectrumAccess from the specified data_location and Spectrum
Sourcepub fn mz_array(&self) -> Option<&DataAccess<D>>
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}Sourcepub fn intensity_array(&self) -> Option<&DataAccess<D>>
pub fn intensity_array(&self) -> Option<&DataAccess<D>>
Returns the DataAccess for the intensity array
Sourcepub fn representation(&self) -> Option<Representation>
pub fn representation(&self) -> Option<Representation>
Returns the spectral representation (centroid, profile) of this spectrum
Sourcepub fn coordinate(&self) -> Option<Coordinate>
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> 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
Mutably borrows from an owned value. Read more