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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ms_file_reader-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 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.0.tar.gz
Algorithm Hash digest
SHA256 304398d421bc87db58968c649406bfccdae1a49477ab7764d4dd7950172a2989
MD5 544bc983646eba933fb6348010c5b027
BLAKE2b-256 81fef43120318da51f07df078d5220175085304ac98515a6977ca18634114056

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ms_file_reader-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1ac82b0448a472931076b5255e57e3425ee83c4749e0e90ca0403e7fb3ecb23
MD5 2d321f9110300b129667092a97e530b9
BLAKE2b-256 33242187261cd38cf2e42ec012a7b853bbf06558915a4b83892987a47dd9e8fb

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