Skip to main content

example workflow example workflow

ExclusionMS Package

This Python package provides a way to manage and query exclusion intervals. It uses a 1-dimensional IntervalTree to efficiently store exclusion intervals based on their neutral mass and perform various operations on them.

Installation

To use this library, simply download or clone the repository and import the necessary classes and functions in your Python project.

Repo:

git clone https://github.com/pgarrett-scripps/ExclusionMs.git
cd ExclusionMs
pip install .

or

Pypi:

pip install exclusionms

Usage

Import classes and functions

from exclusion_list.components import ExclusionInterval, ExclusionPoint
from exclusion_list.mass_interval_tree import MassIntervalTree

Create an exclusion interval

ex_interval = ExclusionInterval(
    interval_id="ID1",
    charge=2,
    min_mass=100.0,
    max_mass=200.0,
    min_rt=10.0,
    max_rt=20.0,
    min_ook0=None,
    max_ook0=None,
    min_intensity=None,
    max_intensity=None,
)

Create a mass interval tree and add exclusion intervals

tree = MassIntervalTree()
tree.add(ex_interval)

Query intervals by ID, mass interval, or a specific data point

# Query by ID
result = tree.query_by_id("ID1")

# Query by interval
query_interval = ExclusionInterval(
    interval_id=None,
    charge=None,
    min_mass=50.0,
    max_mass=250.0,
    min_rt=None,
    max_rt=None,
    min_ook0=None,
    max_ook0=None,
    min_intensity=None,
    max_intensity=None,
)
result = tree.query_by_interval(query_interval)

# Query by point
point = ExclusionPoint(charge=2, mass=120.0, rt=15.0, ook0=None, intensity=None)
result = tree.query_by_point(point)

Check if a data point is excluded by any of the intervals in the tree

is_excluded = tree.is_excluded(point)

Remove exclusion intervals

removed_intervals = tree.remove(ex_interval)

Save and load interval trees

tree.save("interval_tree.pickle")
tree.load("interval_tree.pickle")

Clear all data in the interval tree

tree.clear()

Handling None Values in Exclusion Intervals

When defining exclusion intervals, you may want to leave certain attributes unspecified by setting them to None. This can be useful when you want to represent a range that is unbounded or applicable to all values of that attribute. Here's how the library handles None values for various attributes:

  • interval_id: If the interval ID is set to None, the exclusion interval cannot be added to the interval tree. An exception will be raised if you attempt to do so.

  • charge: If the charge is set to None, the interval represents all charge states. It will match any charge value when checking if a data point is excluded or when querying intervals.

  • min_bounds and max_bounds: For attributes such as mass, retention time (rt), ook0, and intensity, you can set the lower (min_bounds) or upper (max_bounds) bounds to None. In such cases, the library will use the following values as default bounds:

    • Lower bound (min_bounds): -sys.float_info.max
    • Upper bound (max_bounds): sys.float_info.max
    • (This means that if you set the lower bound to None, it will be treated as the minimum representable float value. Similarly, if you set the upper bound to None, it will be treated as the maximum representable float value. This effectively makes the range unbounded for the respective attribute.)

By using None values in exclusion intervals, you can create more flexible and versatile exclusion rules that can match a broader range of data points.

Stress Tester

stress_test.py is designed to stress test the ExclusionMS server by generating a large number of random points and intervals, and then querying the server to check for exclusions. The script also plots the query processing time, along with additional information such as the running average and interval addition events. The plot can be updated in real-time or saved as a PNG file.

Metadata

Release files for exclusionms 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exclusionms 0.4.1
File Size Uploaded Provenance Actions
exclusionms-0.4.1.tar.gz 23.1 kB Without provenance Details for exclusionms-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exclusionms 0.4.1
File Interpreter ABI Platform Actions
exclusionms-0.4.1-py3-none-any.whl Python 3 none any Details for exclusionms-0.4.1-py3-none-any.whl

Total release size: 43.8 kB

Release files / exclusionms-0.4.1.tar.gz

Download URL exclusionms-0.4.1.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b32be654bdd4a5a6391a7e88241a53b746aa6e6b0c0d60096c61f8f728845407
BLAKE2b-256 checksum
How to use checksums
41e6706f50f2c0195fbf98bf1e556485cd2b32ef5757c29abb1851d0322b7bc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / exclusionms-0.4.1-py3-none-any.whl

Download URL exclusionms-0.4.1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09cfcc7e65bc46edd0bc167c842f8e3bb405d26048a73ba203ef53ea764af46c
BLAKE2b-256 checksum
How to use checksums
b0661c35789fd8ca87fac269655a366237743bc75076dfdc84fc219207833a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for exclusionms 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page