Python package to perform compound identification in mass spectrometry via spectral library matching.
Project description
PyCompound is a Python-based tool for spectral library matching designed to identify chemical compounds from mass spectrometry data. It is available in three formats: a Python package, a command-line interface (CLI), and a graphical user interface (GUI) built with Python/Shiny. PyCompound provides a flexible and extensible framework for spectral library matching and introduces several key features. These include entropy-based similarity measures such as Shannon, Tsallis, and the Rényi entropy similarity measure introduced here for the first time, as well as conventional similarity metrics, including cosine and binary similarity measures. PyCompound supports customizable preprocessing workflows that allow users to explicitly control the order of spectral preprocessing steps. In addition, PyCompound includes transformation parameter optimization using grid search and metaheuristic algorithms, and it supports the construction of user-defined mixture or composite similarity measures by combining two or more similarity metrics. PyCompound supports both high-resolution mass spectrometry (HRMS) data (e.g., LC-MS/MS) and nominal-resolution mass spectrometry (NRMS) data (e.g., GC-MS). For the full documentation, including toy examples, see the GitHub repository (https://github.com/hdlugas/pycompound).
Installation
PyCompound requires the Python dependencies Matplotlib, NumPy, Pandas, SciPy, Pyteomics, and netCDF4. Specifically, PyCompound was validated with python=3.12.4, matplotlib=3.8.4, numpy=1.26.4, pandas=2.2.2, scipy=1.13.1, pyteomics=4.7.2, netCDF4=1.6.5, lxml=5.1.0, joblib=1.5.2, and shiny=1.4.0, although it may work with other versions of these tools. A user may consider creating a conda environment (see https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html for guidance on getting started with conda if you are unfamiliar). For a system with conda installed, one can create the environment pycompound_env, activate it, and install the necessary dependencies with:
1. Prerequisites by Operating System
Before installing, ensure your system is prepared for the specific requirements of your operating system.
Windows Users (Setup & Dependencies)
Windows users should use the Anaconda PowerShell Prompt to ensure all paths are configured correctly.
- Initial Setup: If you do not have a Python manager, download and install Miniconda https://docs.anaconda.com/miniconda/.
- Open the Prompt: Click Start, search for "Anaconda PowerShell Prompt", and open it.
- Install Core Tools: Run the following to install the required data libraries and Git:
conda install -c conda-forge netcdf4 lxml git -y
Linux Users
To ensure Git is available within your environment, run:
conda install -c conda-forge git -y
Note: If you are on an older system and see a C++ Compiler does not support -std=c++17 error, run this command instead:
conda install -c conda-forge gxx_linux-64 gcc_linux-64 git -y
2. Environment Setup & Cloning the Repository
To run the provided examples or the Shiny app, you must clone the repository to access the sample data and visual assets.
# 1. Clone the repository
git clone https://github.com/hdlugas/pycompound.git
cd pycompound
# 2. Create and activate the environment
conda create -n pycompound_env -y python=3.12
conda activate pycompound_env
3 Install PyCompound
Option A: Install from PyPI (Stable)
pip install pycompound
Note: To install a specific version, for example, you can install version 0.1.15 by: pip install pycompound==0.1.15
Option B: Install from GitHub (Development)
pip install git+https://github.com/hdlugas/pycompound.git
4 Running PyCompound
Run the Toy Examples
With the repository cloned and the environment active, you can now run the Python package examples. Navigate to the Toy Examples section below and copy the code into a Python script or interpreter. Since you are in the pycompound root directory, the paths to tests/data/ will work automatically.
Launch the Shiny App
The Shiny app requires the www/ folder to display correctly. Since you have cloned the repository, you can launch it immediately:
shiny run --launch-browser app.py
Note: If the browser does not open automatically, navigate to the address shown in your terminal (usually http://127.0.0.1:8000).
Publicly available web version: https://connect.posit.cloud/fy7392
Toy examples of the Python package and CLI versions are available Toy Examples on the GitHub repository.
Toy examples and video tutorials for the PyCompound Shiny application are available on YouTube (https://www.youtube.com/@PyCompound).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycompound-0.1.15.tar.gz.
File metadata
- Download URL: pycompound-0.1.15.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5902743155873d449cce540bcf28681fd31ad2c230d7f1def5af8633bbb6a734
|
|
| MD5 |
c6c01cd5a4fbbb4e271bbbbc160778cf
|
|
| BLAKE2b-256 |
3af19c6b8989e1c872cdfbd94aacfe4142b78cfb7e15ad3782d0df8d0ca5cdfb
|
File details
Details for the file pycompound-0.1.15-py3-none-any.whl.
File metadata
- Download URL: pycompound-0.1.15-py3-none-any.whl
- Upload date:
- Size: 34.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81aa8887403cbfd9226ea5f688d68bc3328e32638ee3eddd457421861b25a4ff
|
|
| MD5 |
be119e22b0689ac586b8eaf5bc129d73
|
|
| BLAKE2b-256 |
d73e7bdf9a5aecbdcf9c5889a23a86b62ff8f6ddabb8243123c2bd6724a32b84
|