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.1.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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bruker_reader-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bb887e81d28ac26e6e7bd5575e5dd263b710aa9bffdd7c1f6442b28d0a7398da
MD5 b5da78f7dac1a4be36c8c4429f473ffb
BLAKE2b-256 ea5141745d4a0e9a49f86e2348182422f4e5831c9a9f197659d2d773a6354ed3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bruker_reader-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 501ca9362721c84367ec2cb67c7bb62ca1a600fc1bb1f29eb37400fc76f314c5
MD5 b148818afd9f942bd7c8e7af9e3fe5f1
BLAKE2b-256 390caa8ffcd83bfef3cec50604be4d163b22c4d015f3844f5aa1e9a15af912ec

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