Skip to main content

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

bruker_reader-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bruker_reader-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file bruker_reader-0.1.2.tar.gz.

File metadata

  • Download URL: bruker_reader-0.1.2.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

Hashes for bruker_reader-0.1.2.tar.gz
Algorithm Hash digest
SHA256 14f23109351fd95187c0c0588a094fdfcd22fb5f5ad9141cacd046cb21daec84
MD5 a6d8b6d7f86ced7713a663c5bae8d7f5
BLAKE2b-256 74993e5e32b18ea44afbac036908423b8ee4d0122d46d67766e2285260d1a4ac

See more details on using hashes here.

File details

Details for the file bruker_reader-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bruker_reader-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for bruker_reader-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fcb00e878f0656dfb52ee31bc5a1a1615f3a803c31f08cc1aea430c5841115a5
MD5 106dbf625c60949254a12702623be0ab
BLAKE2b-256 d89e0e8a9d373dba4721b40a05c0d6a3b3b59c8c90e0408edb6853384b3d63e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page