Skip to main content

This program calculates the high-resolution filter score while doing GC/MS annotation.

Project description

pyMSHRF - HRF Calculator for GC/MS annotation

Theoritical Background

High-resolution filtering (HRF) approach is both feasible and highly specific toward correct identifications, which bridges the gap between unit resolution GC/MS spectra and accurate mass data dubious. (ref)

The isotope pattern calculator module is based on pyISOPACh package. (ref)

Installation

pyMSHRF requires Python 3+ and is unfortunately not compatible with Python 2. If you are still using Python 2, a clever workaround is to install Python 3 and use that instead.

The easiest way of installing pyMSHRF is using pip:

pip install pyMSHRF

Usage

Usage of HRF calculation function

import pyMSHRF
import numpy as np

formula = 'C5H7N3O2'
peaks_query = np.array([[191.09071, 14670.0], [124.05742, 3543.0], [141.09334, 6191.0]], dtype = np.float32)

# Add TMS-derived group if desired
formula_derived = pyMSHRF.derivatization(formula, num_tms=1, num_meox=0)

# Calculate HRF score
HRF_score = pyMSHRF.HRF(formula, peaks_query, delta_da = 0.02)
print(f"HRF score is {HRF_score}.")

Calculate the reverse high-resolution filtering (RHRF) score need reference spectrum:

peaks_reference = np.array([[82, 6.99], [141, 999.0], [124, 562.49]], dtype = np.float32)

# Calculate RHRF score
RHRF_score = pyMSHRF.RHRF(formula, peaks_query, peaks_reference, delta_da = 0.02)
print(f"RHRF score is {RHRF_score}.")

Useful functions

Reading Spectra from a File

For ease of use, a function named read_one_spectrum is provided in the pyMSHRF package, allowing you to easily read spectra from a file.(ref) Here is an example of how you can use it:

import pyMSHRF

# Load all spectra from file into python
spectra_list = list(pyMSHRF.read_one_spectrum('path/to/spectrum/file'))

# Get spectrum peak list
for spectrum in spectra_list:
    query_spec = spectrum['peaks']

This function returns a dictionary, where each key-value pair corresponds to a specific metadata of the spectrum.

Currently, the read_one_spectrum function supports the following file formats: .mgf, .msp, .mzML, and .lbm2.

Reference

  1. N. W. Kwiecien et al., High-Resolution Filtering for Improved Small Molecule Identification via GC/MS. Analytical Chemistry 87, 8328-8335 (2015).

  2. https://github.com/AberystwythSystemsBiology/pyISOPACh

  3. https://github.com/YuanyueLi/MSEntropy

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

pyMSHRF-0.3.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

pyMSHRF-0.3.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file pyMSHRF-0.3.0.tar.gz.

File metadata

  • Download URL: pyMSHRF-0.3.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.17

File hashes

Hashes for pyMSHRF-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f1bfdee5616b9870ff5f0c1734e5dcb8221c43ed635054696ad2b90d6c79e63a
MD5 c7cfea1ff9350381b629f90966f52351
BLAKE2b-256 44e1dcb6074dd474bb228364a0e78e82a4e88bbb90e3545f91695344ae5854c1

See more details on using hashes here.

File details

Details for the file pyMSHRF-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pyMSHRF-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.17

File hashes

Hashes for pyMSHRF-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46b0b8d9b5a64b53991b0a137cf74bb3447e9c81202b4d530e0ce2f89888635f
MD5 6628b0c8b85938cda0dc1bb3f67ac74f
BLAKE2b-256 60997d7fbea10392d8d078f639f310140dae6d19f2905a972f10855fa674ab61

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