Reader for Bruker FTICR BAF files
Project description
bruker-reader
This is a simple python package for reading FTICR spectra from Bruker BAF files.
It's heavily based off of the R rtms package (https://cran.r-project.org/package=rtms),
who did the heavy lifting of reverse engineering the file format.
Usage
Usage is simple. Create a reader by pointing it to the .d directory:
>>> from bruker_reader import BAFReader
>>> rdr = BAFReader("/path/to/data/sample.d")
>>> spec = rdr.read_spectrum()
... # returns pandas DataFrame with 'mz' and 'intensity' columns
You can read partial spectra as well, which can dramatically speed up access:
>>> rdr.read_spectrum(from_mass=451.0, to_mass=509)
BAF files also store a list of the N largest peaks (where N is configurable when setting up a run). Note, this is not necessarily the same as the total peaks collected after calibrating; but it may still be useful.
>>> rdr.read_peaks()
# Returns a pandas DataFrame of `mz` and `intensity` values.
To ease the process of reading multiple Bruker .d files stored in a data dir,
the BAFCache class can be used. It creates an easy lookup for spectra files,
as well as caches the metadata for the spectrum upon first use:
>>> from bruker_reader import BAFCache
# Assuming `/path/to/data` contains `samp1.d`, `samp2.d` ...
>>> bcache = BAFCache('/path/to/data')
# Access samples by key
>>> samp1 = bcache['samp1'].read_spectrum()
# You can also access by numeric index:
>>> bcache[12]
# BAFCache has typical iterable behavior:
>>> if 'samp11' in bcache: ...
>>> for rdr in bcache: ...
# Getting directory info
>>> bcache.samples # Returns a list of sample ids
>>> bcache.files # Returns a dict of sample -> filepath
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bruker_reader-0.1.3.tar.gz.
File metadata
- Download URL: bruker_reader-0.1.3.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97cafc073e629bc7134951ffc7e684d7ef2e8a4461dd909064989962f346acf
|
|
| MD5 |
e84ff7f15b027336ba5022f10260c1ef
|
|
| BLAKE2b-256 |
c4c2d290547165d6cf9b746994f4d9ada6f72da736a76b0121c52fa21448d566
|
File details
Details for the file bruker_reader-0.1.3-py3-none-any.whl.
File metadata
- Download URL: bruker_reader-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fc26b19df84b6f2b72425758ad4b9513a4c61982fcd5d254645fba93bc1cee0
|
|
| MD5 |
740039a44b8ca74debcfbc43415e4dd9
|
|
| BLAKE2b-256 |
feb845dd1195207418567943f74e77909e5542ac4f79012c26d20a7d30d6a5e5
|