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.0.tar.gz (7.8 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.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bruker_reader-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 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.0.tar.gz
Algorithm Hash digest
SHA256 354d7b2eb63af43828a3ea96f4475c42729dc3eb9957d87f146defa5ad5de717
MD5 3320c3c18414e40cba749964fb4cab7f
BLAKE2b-256 1094e393d49a968ceb132b0bd4bd64199822565a4fca374cec9da2f95ae0b2fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bruker_reader-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa25c244d0bc9df6ee794a8bc14baaff04112fd6e2a45f504099cbc3fb4ec33a
MD5 fbde5cfa6d14fd07d696383279ba50d0
BLAKE2b-256 ce0c5868c444e649f8db394e80dd5e8d913e995a079aa40e402b5a3e09324f3a

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