Skip to content

Commit

Permalink
Merge pull request #122 from theGreatHerrLebert/david@simulation
Browse files Browse the repository at this point in the history
David@simulation
  • Loading branch information
theGreatHerrLebert committed Feb 22, 2024
2 parents 82e714d + 4a90afb commit 2572d0d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
46 changes: 45 additions & 1 deletion imspy/imspy/simulation/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import math
import importlib.resources as resources

from imspy.chemistry.mass import AMINO_ACID_MASSES, MASS_WATER, calculate_mz, MODIFICATIONS_MZ
from imspy.chemistry.mass import AMINO_ACID_MASSES, MASS_WATER, calculate_mz

import imspy_connector as ims

Expand Down Expand Up @@ -37,6 +37,50 @@ def flatten_prosit_array(array):
return array_return


def sequences_to_all_ions(
sequences: List[str],
charges: List[int],
intensities_flat: List[List[float]],
normalized: bool = True,
half_charge_one: bool = True,
num_threads: int = 4) -> List[str]:
"""
Simulate ion intensities for a list of peptide sequences, charges, and collision energies.
Args:
sequences: List of peptide sequences
charges: List of peptide charges
intensities_flat: List of intensities
normalized: Whether to normalize the intensities
half_charge_one: Whether to divide the intensity by 2 if the charge is 1
num_threads: Number of threads to use for the calculation
Returns:
NDArray: Array of ion intensities
"""
return ims.sequence_to_all_ions_par(sequences, charges, intensities_flat, normalized, half_charge_one, num_threads)


def sequence_to_all_ions(
sequence: str,
charge: int,
intensities_flat: List[float],
normalized: bool = True,
half_charge_one: bool = True) -> List[str]:
"""
Simulate ion intensities for a peptide sequence, charge, and collision energy.
Args:
sequence: Peptide sequence
charge: Peptide charge
intensities_flat: List of intensities
normalized: Whether to normalize the intensities
half_charge_one: Whether to divide the intensity by 2 if the charge is 1
Returns:
NDArray: Array of ion intensities
"""
return ims.sequence_to_all_ions_ims(sequence, charge, intensities_flat, normalized, half_charge_one)


def get_acquisition_builder_resource_path(acquisition_mode: str = 'dia') -> Traversable:
""" Get the path to a pretrained model
Expand Down
4 changes: 2 additions & 2 deletions imspy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "imspy"
version = "0.2.15"
version = "0.2.16"
description = ""
authors = ["theGreatHerrLebert <[email protected]>"]
readme = "README.md"
Expand All @@ -19,7 +19,7 @@ pyopenms = ">=2.6.0"
sagepy = ">=0.2.6"
sagepy-connector = ">=0.2.6"

imspy-connector = ">=0.2.15"
imspy-connector = ">=0.2.16"

scipy = ">=1.7.1"
tqdm = ">=4.66"
Expand Down
2 changes: 1 addition & 1 deletion imspy_connector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "imspy-connector"
version = "0.2.15"
version = "0.2.16"
edition = "2021"

[lib]
Expand Down

0 comments on commit 2572d0d

Please sign in to comment.