Skip to main content

Reads a few common file formats for processed mass spectra and generates consistent objects from them.

Project description

linting: pylint

This is a small library intended to read different types of mass spectrometry files, store them as (somewhat) standardized objects, and run some exploratory checks on the spectra as a whole. The focus is on open, text-based file formats for already-processed spectra. Functionality has been added for reading MSP, JCAMP-DX, and MassBank EU-styled files.

I wrote this because of a project that grabbed collections of mass spectra from a variety of sources. A number of these sources had inconsistencies within their libraries -- sometimes due to fields that don't appear in all spectra, sometimes becuase the field does always appear but it has some sort of null value in the field, and so on. Some exploration of the data was usually necessary, and much of it was repetetive. This library was written to streamline some of that work for anyone else in the same position.

NumPy is the only dependency for this library.

Feedback on other real-world edge cases is welcome.

Usage

Install from PyPI:

pip install ms-file-reader

To import the individual readers:

from ms_file_reader.jcamp import JCAMPFileReader
from ms_file_reader.massbank import MassBankFileReader
from ms_file_reader.msp import MSPFileReader

The individual readers -- mostly the ones for JCAMP-DX and MSP -- come with options for trying to deal with any non-standardness of files; see the docstrings for argument details. Processing is done by a process_file() method associated with each class. The method acts on text objects instead of file handles or paths, so the content of a file has to be read in first.

A basic example:

from ms_file_reader.msp import MSPFileReader
with open("test.msp", "r", encoding="utf-8") as f:
    file_text = f.read()

reader = MSPFileReader(keep_empty_fields=False, max_intensity=100)
spectrum_library = reader.process_file(file_text)

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

ms_file_reader-0.1.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

ms_file_reader-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ms_file_reader-0.1.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ms_file_reader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 80f1219f7af955795a5e8bc5d8f77c335bbb8baf155a8c90500e94f78e5f14d5
MD5 af8873899c5824640f0f676041ea0ffa
BLAKE2b-256 34fc88f1da30d5e513c78220c8174ff5305019e53d5d330309c5ee5dbe740ff7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ms_file_reader-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ms_file_reader-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f78f5ad45d27e7a0c77821e053800f93ec764fce25a43a0e328f5e0c58699021
MD5 6f6dd9a3fc079acb0f41e79eba6ca8b2
BLAKE2b-256 74055b9ff6c495bdb163aa30a8a5e6f29179d48ba9bdb28fb2d2d4e227d9493d

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