imspy.simulation package

Subpackages

Submodules

imspy.simulation.acquisition module

class imspy.simulation.acquisition.TimsTofAcquisitionBuilder(path, reference_ds, gradient_length, rt_cycle_length, exp_name='RAW.d', verbose=False)

Bases: object

abstractmethod calculate_frame_types(*args)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

classmethod from_existing(path, reference_ds)

Create an instance from existing data without calling __init__.

Return type:

TimsTofAcquisitionBuilder

generate_frame_table(verbose=True)
Return type:

DataFrame

generate_scan_table(verbose=True)
Return type:

DataFrame

class imspy.simulation.acquisition.TimsTofAcquisitionBuilderDDA(path, reference_ds, verbose=False, gradient_length=3600, rt_cycle_length=0.109, exp_name='T001.d')

Bases: TimsTofAcquisitionBuilder, ABC

calculate_frame_types(frame_types)
class imspy.simulation.acquisition.TimsTofAcquisitionBuilderDIA(path, reference_ds, window_group_file, acquisition_name='dia', exp_name='RAW', verbose=True, precursor_every=17, gradient_length=3000, rt_cycle_length=0.1054, use_reference_ds_layout=True, round_collision_energy=True, collision_energy_decimals=1)

Bases: TimsTofAcquisitionBuilder, ABC

calculate_frame_types(verbose=True)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

static from_config(path, reference_ds, exp_name, config, verbose=True, use_reference_layout=True, round_collision_energy=True, collision_energy_decimals=1)
Return type:

TimsTofAcquisitionBuilderDIA

classmethod from_existing(path, reference_ds, use_reference_ds_layout=True, verbose=True)

Create an instance from existing data for DIA without calling __init__.

Return type:

TimsTofAcquisitionBuilderDIA

generate_frame_to_window_group_table(verbose=True)
Return type:

DataFrame

imspy.simulation.annotation module

class imspy.simulation.annotation.ContributionSource(intensity_contribution, source_type, signal_attributes=None)

Bases: RustWrapperObject

classmethod from_py_ptr(contribution_source)
Return type:

ContributionSource

get_py_ptr()
Return type:

PyContributionSource

property intensity_contribution: float
property signal_attributes: None | SignalAttributes
property source_type: SourceType
class imspy.simulation.annotation.MzSpectrumAnnotated(mz, intensity, annotations)

Bases: RustWrapperObject

property annotations: list[PeakAnnotation]
filter(mz_min=0.0, mz_max=1700.0, intensity_min=0.0, intensity_max=1000000000.0)
Return type:

MzSpectrumAnnotated

classmethod from_py_ptr(mz_spectrum_annotated)
Return type:

MzSpectrumAnnotated

get_py_ptr()
Return type:

PyMzSpectrumAnnotated

property intensity: list[float]
property mz: list[float]
class imspy.simulation.annotation.PeakAnnotation(contributions)

Bases: RustWrapperObject

property contributions: list[ContributionSource]
classmethod from_py_ptr(peak_annotation)
Return type:

PeakAnnotation

get_py_ptr()
Return type:

PyPeakAnnotation

class imspy.simulation.annotation.RustWrapperObject

Bases: ABC

abstractmethod classmethod from_py_ptr(obj)
abstractmethod get_py_ptr()
class imspy.simulation.annotation.SignalAttributes(charge_state, peptide_id, isotope_peak, description=None)

Bases: RustWrapperObject

property charge_state
property description: None | str
classmethod from_py_ptr(signal_attributes)
Return type:

SignalAttributes

get_py_ptr()
Return type:

PySignalAttributes

property isotope_peak
property peptide_id
class imspy.simulation.annotation.SourceType(source_type)

Bases: RustWrapperObject

classmethod from_py_ptr(source_type)
Return type:

SourceType

get_py_ptr()
Return type:

PySourceType

property source_type: str
class imspy.simulation.annotation.TimsFrameAnnotated(frame_id, retention_time, ms_type, tof, mz, scan, inv_mobility, intensity, annotations)

Bases: RustWrapperObject

property annotations: list[PeakAnnotation]
property charge_states_first_only: ndarray[Any, dtype[int]]
property df: DataFrame
filter(mz_min=0.0, mz_max=1700.0, inv_mobility_min=0.0, inv_mobility_max=4.0, scan_min=0, scan_max=1000, intensity_min=0.0, intensity_max=1000000000.0)
Return type:

TimsFrameAnnotated

property frame_id: int
classmethod from_py_ptr(tims_frame_annotated)
Return type:

TimsFrameAnnotated

get_py_ptr()
Return type:

PyTimsFrameAnnotated

property intensity: list[float]
property inv_mobility: list[float]
property isotope_peaks_first_only: ndarray[Any, dtype[int]]
property ms_type: int
property ms_type_numeric: int
property mz: list[float]
property peptide_ids_first_only: ndarray[Any, dtype[int]]
property retention_time: float
property scan: list[int]
property tof: list[int]

imspy.simulation.experiment module

class imspy.simulation.experiment.SyntheticExperimentDataHandle(database_path, database_name='synthetic_data.db', verbose=True)

Bases: object

append_table(table_name, table)
close()
create_table(table_name, table)
create_table_sql(sql)
get_table(table_name)
Return type:

DataFrame

list_columns(table_name)
list_tables()
class imspy.simulation.experiment.SyntheticExperimentDataHandleDIA(database_path, database_name='synthetic_data.db', verbose=True)

Bases: SyntheticExperimentDataHandle, ABC

get_frame_to_window_group()
get_window_group_settings()
class imspy.simulation.experiment.TimsTofSyntheticFrameBuilderDDA(db_path, with_annotations=False, num_threads=-1)

Bases: RustWrapperObject

build_frame(frame_id, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True)

Build a frame.

Parameters:
  • frame_id (int) – Frame ID.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

Returns:

Frame.

Return type:

TimsFrame

build_frame_annotated(frame_id, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True)

Build a frame. The frame will be annotated.

Parameters:
  • frame_id (int) – Frame ID.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

Returns:

Frame.

Return type:

TimsFrameAnnotated

build_frames(frame_ids, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True, num_threads=4)

Build frames.

Parameters:
  • frame_ids (List[int]) – Frame IDs.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

  • num_threads (int) – Number of threads.

Returns:

Frames.

Return type:

List[TimsFrame]

build_frames_annotated(frame_ids, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True, num_threads=4)

Build frames. The frames will be annotated.

Parameters:
  • frame_ids (List[int]) – Frame IDs.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

  • num_threads (int) – Number of threads.

Returns:

Frames.

Return type:

List[TimsFrameAnnotated]

classmethod from_py_ptr(py_ptr)

Create a TimsTofSyntheticFrameBuilderDDA from a PyTimsTofSyntheticsFrameBuilderDDA.

Parameters:

py_ptr (ims.PyTimsTofSyntheticsFrameBuilderDDA) – PyTimsTofSyntheticsFrameBuilderDDA.

Returns:

TimsTofSyntheticFrameBuilderDDA.

Return type:

TimsTofSyntheticFrameBuilderDDA

get_collision_energies(frame_ids, scan_ids)
Return type:

List[float]

get_collision_energy(frame_id, scan_id)
Return type:

float

get_fragment_frames()
Return type:

List[int]

get_fragment_ions_map()
get_pasef_meta()
Return type:

List[PasefMeta]

get_py_ptr()
Return type:

PyTimsTofSyntheticsFrameBuilderDDA

class imspy.simulation.experiment.TimsTofSyntheticFrameBuilderDIA(db_path, with_annotations=False, num_threads=-1)

Bases: RustWrapperObject

build_frame(frame_id, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True)

Build a frame.

Parameters:
  • frame_id (int) – Frame ID.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

Returns:

Frame.

Return type:

TimsFrame

build_frame_annotated(frame_id, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True)

Build a frame. The frame will be annotated.

Parameters:
  • frame_id (int) – Frame ID.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

Returns:

Frame.

Return type:

TimsFrameAnnotated

build_frames(frame_ids, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True, num_threads=4)

Build frames.

Parameters:
  • frame_ids (List[int]) – Frame IDs.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

  • num_threads (int) – Number of threads.

Returns:

Frames.

Return type:

List[TimsFrame]

build_frames_annotated(frame_ids, fragment=True, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, mz_noise_fragment=False, fragment_noise_ppm=5.0, right_drag=True, num_threads=4)

Build frames. The frames will be annotated.

Parameters:
  • frame_ids (List[int]) – Frame IDs.

  • fragment (bool) – if true, frame will undergo synthetic fragmentation if it is a fragment frame,

  • fragmentation. (otherwise quadrupole isolation will still be applied but no)

  • mz_noise_precursor (bool) – if true, noise will be added to the precursor m/z values.

  • mz_noise_uniform (bool) – if true, noise will be added to the precursor m/z values uniformly.

  • precursor_noise_ppm (float) – PPM of the precursor noise.

  • mz_noise_fragment (bool) – if true, noise will be added to the fragment m/z values.

  • fragment_noise_ppm (float) – PPM of the fragment noise.

  • right_drag (bool) – if true, the noise will be shifted to the right.

  • num_threads (int) – Number of threads.

Returns:

Frames.

Return type:

List[TimsFrameAnnotated]

count_number_transmissions(peptide_id, charge)
Return type:

(int, int)

count_number_transmissions_parallel(peptide_ids, charges, num_threads=4)
Return type:

List[Tuple[int, int]]

classmethod from_py_ptr(py_ptr)

Create a TimsTofSyntheticFrameBuilderDIA from a PyTimsTofSyntheticsFrameBuilderDIA.

Parameters:

py_ptr (ims.PyTimsTofSyntheticsFrameBuilderDIA) – PyTimsTofSyntheticsFrameBuilderDIA.

Returns:

TimsTofSyntheticFrameBuilderDIA.

Return type:

TimsTofSyntheticFrameBuilderDIA

get_collision_energies(frame_ids, scan_ids)
Return type:

List[float]

get_collision_energy(frame_id, scan_id)
Return type:

float

get_fragment_ions_map()
get_ion_transmission_matrix(peptide_id, charge, include_precursor_frames=False)
Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

get_py_ptr()
Return type:

PyTimsTofSyntheticsFrameBuilderDIA

class imspy.simulation.experiment.TimsTofSyntheticPrecursorFrameBuilder(db_path)

Bases: RustWrapperObject

build_precursor_frame(frame_id, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, right_drag=True)
Return type:

TimsFrame

build_precursor_frame_annotated(frame_id, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, right_drag=True)
Return type:

TimsFrameAnnotated

build_precursor_frames(frame_ids, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, right_drag=True, num_threads=4)
build_precursor_frames_annotated(frame_ids, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, right_drag=True, num_threads=4)
Return type:

List[TimsFrameAnnotated]

frame_to_abundances()
classmethod from_py_ptr(py_ptr)
Return type:

TimsTofSyntheticPrecursorFrameBuilder

get_py_ptr()
Return type:

PyTimsTofSyntheticsPrecursorFrameBuilder

imspy.simulation.feature module

class imspy.simulation.feature.ChargeProfile(charges=None, rel_abundance=None, model_params=None, jsons=None)

Bases: Profile

property charges
class imspy.simulation.feature.FeatureBatch(feature_table, raw_data)

Bases: object

get_feature(mz_min, mz_max, scan_min, scan_max, rt_min, rt_max, intensity_min=20)
class imspy.simulation.feature.FeatureGenerator

Bases: ABC

abstractmethod generate_feature(mz, charge)
class imspy.simulation.feature.PrecursorFeatureGenerator

Bases: FeatureGenerator

generate_feature(mz, charge, pattern_generator, num_rt=64, num_im=32, distr_im=CPUDispatcher(<function gaussian>), distr_rt=CPUDispatcher(<function exp_gaussian>), rt_lower=-9, rt_upper=18, im_lower=-4, im_upper=4, intensity_amplitude=1000.0, min_intensity=5)
Return type:

TimsSlice

class imspy.simulation.feature.Profile(positions=None, rel_abundances=None, model_params=None, jsons=None)

Bases: object

property jsons
class imspy.simulation.feature.RTProfile(frames=None, rel_abundances=None, model_params=None, jsons=None)

Bases: Profile

property frames
class imspy.simulation.feature.ScanProfile(scans=None, rel_abundances=None, model_params=None, jsons=None)

Bases: Profile

property scans

imspy.simulation.handle module

class imspy.simulation.handle.TimsTofSyntheticsDataHandleRust(path)

Bases: object

get_py_ptr()
get_transmitted_ions(num_threads=-1, dda=False)

Get transmitted ions, needed to create fragment ion table for simulation. :type num_threads: int :param num_threads: Number of threads to use for the calculation. :type dda: bool :param dda: if true, the ions are sampled from a DDA experiment, otherwise from a DIA experiment.

Returns:

DataFrame with the following columns:
  • peptide_id: Peptide ID.

  • ion_id: Ion ID.

  • sequence: Peptide sequence.

  • charge: Ion charge.

  • collision_energy: Collision energy.

Return type:

pd.DataFrame

imspy.simulation.isotopes module

class imspy.simulation.isotopes.AveragineGenerator

Bases: IsotopePatternGenerator

generate_pattern(mass, charge, k=7, amp=None, resolution=3, min_intensity=5)
Return type:

Tuple[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]]

generate_spectrum(mass, charge, min_intensity=5, k=7, amp=None, resolution=3, centroided=True)
Return type:

MzSpectrum

static generate_spectrum_by_sampling(mass, charge, k=7, sigma=0.008492569002123142, ion_count=1000000, resolution=3, intensity_per_ion=1, centroided=True, min_intensity=5)
Return type:

MzSpectrum

class imspy.simulation.isotopes.IsotopePatternGenerator

Bases: ABC

abstractmethod generate_pattern(mass, charge)
Return type:

Tuple[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]]

abstractmethod generate_spectrum(mass, charge, min_intensity)
Return type:

MzSpectrum

imspy.simulation.isotopes.create_initial_feature_distribution(num_rt, num_im, rt_lower=-9, rt_upper=18, im_lower=-4, im_upper=4, distr_im=CPUDispatcher(<function gaussian>), distr_rt=CPUDispatcher(<function exp_gaussian>))
Return type:

array

imspy.simulation.isotopes.factorial(n)
imspy.simulation.isotopes.generate_isotope_pattern_rust(mass, charge, min_intensity=150, k=7, resolution=3, centroid=True)
imspy.simulation.isotopes.generate_isotope_patterns_rust(masses, charges, min_intensity=0, k=7, resolution=3, centroid=True, num_threads=4)
imspy.simulation.isotopes.get_pyopenms_weights(sequence, peak_nums, generator)
imspy.simulation.isotopes.iso(x, mass, charge, sigma, amp, K, step_size, add_detection_noise=False, mass_neutron=1.00866491595)
imspy.simulation.isotopes.lam(mass, slope=0.000594, intercept=-0.03091)
imspy.simulation.isotopes.numba_generate_pattern(lower_bound, upper_bound, mass, charge, amp, k, sigma=0.008492569002123142, resolution=3)
Return type:

Tuple[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]]

imspy.simulation.isotopes.numba_ion_sampler(mass, charge, sigma, k, ion_count, intensity_per_ion)
imspy.simulation.isotopes.simulate_precursor_spectra(sequences, charges, num_threads, peptide_ids=None)
Return type:

List[MzSpectrum]

imspy.simulation.isotopes.simulate_precursor_spectrum(sequence, charge, peptide_id=None)
Return type:

MzSpectrum

imspy.simulation.isotopes.weight(mass, peak_nums, normalize=True)

imspy.simulation.noise module

This module contains several noise models, such as detection noise, shot noise and baseline noise.

imspy.simulation.noise.baseline_noise()
imspy.simulation.noise.baseline_shot_noise(spectrum, window_size=50, expected_noise_peaks_per_Th=10, min_intensity=5, resolution=3)
imspy.simulation.noise.baseline_shot_noise_window(window, window_theoretical_mz_min, window_theoretical_mz_max, expected_noise_peaks=5, expected_noise_intensity=10, expected_noise_sigma=0.001, resolution=3)
Return type:

MzSpectrum

imspy.simulation.noise.detection_noise(signal, method='poisson', custom_mu_function=None, custom_sigma_function=None)
Parameters:
  • signal (Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]])

  • method (str)

  • custom_mu_function (Optional[Callable])

  • custom_sigma_function (Optional[Callable])

Return type:

Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]

imspy.simulation.noise.generate_noise_peak(pos, sigma, intensity, min_intensity=0, resolution=3)
imspy.simulation.noise.mu_function_normal_default(intensity)
Return type:

Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]

imspy.simulation.noise.mu_function_poisson_default(intensity)
Return type:

Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]

imspy.simulation.noise.sigma_function_normal_default(intensity)
Return type:

Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]

imspy.simulation.proteome module

class imspy.simulation.proteome.PeptideDigest(fasta_path, missed_cleavages=2, min_len=7, max_len=50, cleave_at='KR', restrict='P', generate_decoys=False, c_terminal=True, verbose=True, variable_mods={'M': ['[UNIMOD:35]'], '[': ['[UNIMOD:1]']}, static_mods={'C': '[UNIMOD:4]'})

Bases: object

imspy.simulation.tdf module

class imspy.simulation.tdf.TDFWriter(helper_handle, path='./', exp_name='RAW.d', offset_bytes=64, verbose=False)

Bases: object

build_frame_meta_row(intensity, frame, scan_mode, frame_start_pos, only_frame_one=False)

Build a row for the frame meta data table from a TimsFrame object. :type intensity: ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] :param intensity: NDArray :type frame: TimsFrame :param frame: TimsFrame object :type scan_mode: int :param scan_mode: int :type frame_start_pos: int :param frame_start_pos: int :type only_frame_one: bool :param only_frame_one: bool

compress_frame(frame, only_frame_one=False)

Compress a single frame using zstd. :type frame: TimsFrame :param frame: TimsFrame object :type only_frame_one: bool :param only_frame_one: bool

Returns:

intensities, compressed data

Return type:

bytes

get_frame_meta_data()
Return type:

DataFrame

inv_mobility_to_scan(frame_id, inv_mobs)

Convert inverse mobility values to scan values for a given frame using the helper handle. # CAUTION: This will use the calibration data from the reference handle.

mz_to_tof(frame_id, mzs)

Convert m/z values to TOF values for a given frame using the helper handle. # CAUTION: This will use the calibration data from the reference handle.

scan_to_inv_mobility(frame_id, scans)

Convert scan values to inverse mobility values for a given frame using the helper handle. # CAUTION: This will use the calibration data from the reference handle.

tof_to_mz(frame_id, tofs)

Convert TOF values to m/z values for a given frame using the helper handle. # CAUTION: This will use the calibration data from the reference handle.

write_calibration_info(mz_standard_deviation_ppm=0.15)
Return type:

None

write_dia_ms_ms_info(dia_ms_ms_info)
Return type:

None

write_dia_ms_ms_windows(dia_ms_ms_windows)
Return type:

None

write_frame(frame, scan_mode, only_frame_one=False)

Write a single frame to the binary file. :type frame: TimsFrame :param frame: TimsFrame object :type scan_mode: int :param scan_mode: int :type only_frame_one: bool :param only_frame_one: bool

Return type:

None

write_frame_meta_data()
Return type:

None

write_pasef_frame_ms_ms_info()
Return type:

None

write_pasef_meta_table(pasef_meta_table)
Return type:

None

write_precursor_table(precursor_table)
Return type:

None

write_prm_frame_ms_ms_info()
Return type:

None

imspy.simulation.utility module

imspy.simulation.utility.accumulated_intensity_cdf_numba(sample_start, sample_end, mean, std_dev)

Calculate the accumulated intensity between two points using the custom CDF.

imspy.simulation.utility.add_uniform_noise(rt_abu, noise_level=1.0)
imspy.simulation.utility.calculate_b_y_fragment_mz(sequence, modifications, is_y=False, charge=1)

Calculate the m/z value of a b or y fragment. :type sequence: str :param sequence: the peptide sequence :type modifications: ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] :param modifications: potential modifications :type is_y: bool :param is_y: is the fragment a y ion :type charge: int :param charge: the charge state of the peptide precursor

Return type:

float

Returns:

m/z value of the fragment

imspy.simulation.utility.calculate_b_y_ion_series_ims(sequence, modifications, charge=1)

Calculate the b and y ion series for a given peptide sequence. :type sequence: str :param sequence: the peptide sequence :type modifications: ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]] :param modifications: potential modifications :type charge: int :param charge: the charge state of the peptide precursor

Return type:

Tuple[List, List]

Returns:

b ion series, y ion series

imspy.simulation.utility.calculate_bounds_numba(mean, std, z_score)

Calculate the bounds of a normal distribution for a given z-score.

Parameters:
  • mean (float) – Mean of the normal distribution

  • std (float) – Standard deviation of the normal distribution

  • z_score (float) – Z-score of the normal distribution

Returns:

Lower bound of the normal distribution

Return type:

float

imspy.simulation.utility.calculate_mobility_spacing(mobility_min, mobility_max, num_scans)

Calculate the amount of mobility that will be occupied by a single scan

Parameters:
  • mobility_min (float) – Minimum mobility value

  • mobility_max (float) – Maximum mobility value

  • num_scans (int) – Number of scans that will be taken during the acquisition

Returns:

Mobility spacing

Return type:

float

imspy.simulation.utility.calculate_number_frames(gradient_length, rt_cycle_length)

Calculate the number of frames that will be taken during the acquisition

Parameters:
  • gradient_length (float) – Length of the gradient in seconds

  • rt_cycle_length (float) – Length of the RT cycle in seconds

Returns:

Number of frames that will be taken during the acquisition

Return type:

int

imspy.simulation.utility.custom_cdf(x, mean, std_dev)

Custom implementation of the CDF for a normal distribution.

imspy.simulation.utility.flat_intensity_to_sparse(intensity_flat, num_elements=174)
imspy.simulation.utility.flatten_prosit_array(array)
imspy.simulation.utility.generate_events(n, mean, min_val, max_val, mixture_contribution=1.0)
imspy.simulation.utility.get_acquisition_builder_resource_path(acquisition_mode='dia')

Get the path to a pretrained model

Parameters:

acquisition_mode (str) – The name of the model to load

Return type:

Traversable

Returns:

The path to the pretrained model

imspy.simulation.utility.get_compressible_data(tofs, scans, intensities, num_scans)
imspy.simulation.utility.get_dilution_factors(path=None)
Return type:

Dict[str, float]

imspy.simulation.utility.get_fasta_file_paths(fasta_path)

Check if the provided fasta path is a folder or file, if its a folder, check if it exists and return all fasta :type fasta_path: :param fasta_path: Path to the fasta file or folder containing fasta files

Return type:

Dict[str, str]

Returns:

List of fasta file paths

imspy.simulation.utility.get_ms_ms_window_layout_resource_path(acquisition_mode)

Get the path to a pretrained model

Return type:

Traversable

Returns:

The path to the pretrained model

imspy.simulation.utility.get_native_dataset_path(ds_name='NATIVE.d')

Get the path to a pretrained model

Parameters:

ds_name (str) – The name of the dataset to load

Return type:

str

Returns:

The path to the pretrained model

imspy.simulation.utility.get_peak_cnts(total_scans, scans)
imspy.simulation.utility.get_realdata(peak_cnts, interleaved)
imspy.simulation.utility.get_realdata_loop(peak_cnts, interleaved, back_data, real_data)
imspy.simulation.utility.get_z_score_for_percentile(target_score=0.95)
imspy.simulation.utility.irt_to_rts_numba(irt, new_min=0, new_max=120)

Scale an array of values from the original range (min_val, max_val) to a new range (new_min, new_max).

Parameters:
  • irt (NDArray) – Array of values to be scaled.

  • new_min (float) – Minimum value of the new range.

  • new_max (float) – Maximum value of the new range.

Returns:

Array of scaled values.

Return type:

NDArray

imspy.simulation.utility.iter_frame_batches(raw_data_handle, frame_builder, batch_size=256, level='precursor')

Iterates over frame batches and yields the frames as pandas dataframes. :type raw_data_handle: :param raw_data_handle: :type frame_builder: :param frame_builder: :type batch_size: int :param batch_size: :type level: :param level:

Returns:

imspy.simulation.utility.json_string_to_python_list(json_string)
imspy.simulation.utility.modify_tofs(tofs, scans)
imspy.simulation.utility.np_zip(xx, yy)
imspy.simulation.utility.python_list_to_json_string(lst, as_float=True, num_decimals=4)
Return type:

str

imspy.simulation.utility.read_acquisition_config(acquisition_name='dia')
Return type:

Dict[str, Any]

imspy.simulation.utility.sequence_to_all_ions(sequence, charge, intensities_flat, normalized=True, half_charge_one=True)

Simulate ion intensities for a peptide sequence, charge, and collision energy. :type sequence: str :param sequence: Peptide sequence :type charge: int :param charge: Peptide charge :type intensities_flat: List[float] :param intensities_flat: List of intensities :type normalized: bool :param normalized: Whether to normalize the intensities :type half_charge_one: bool :param half_charge_one: Whether to divide the intensity by 2 if the charge is 1

Returns:

Array of ion intensities

Return type:

NDArray

imspy.simulation.utility.sequence_to_numpy(sequence, max_length=30)

translate a peptide sequence given as python string into a numpy array of characters with a fixed length :type sequence: str :param sequence: the peptide sequence :type max_length: int :param max_length: the maximum length a sequence can have

Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

Returns:

numpy array of characters

imspy.simulation.utility.sequences_to_all_ions(sequences, charges, intensities_flat, normalized=True, half_charge_one=True, num_threads=4)

Simulate ion intensities for a list of peptide sequences, charges, and collision energies. :type sequences: List[str] :param sequences: List of peptide sequences :type charges: List[int] :param charges: List of peptide charges :type intensities_flat: List[List[float]] :param intensities_flat: List of intensities :type normalized: bool :param normalized: Whether to normalize the intensities :type half_charge_one: bool :param half_charge_one: Whether to divide the intensity by 2 if the charge is 1 :type num_threads: int :param num_threads: Number of threads to use for the calculation

Returns:

Array of ion intensities

Return type:

NDArray

imspy.simulation.utility.set_percentage_to_zero(row, percentage)

Sets a given percentage of the non-zero elements of a numpy vector to zero, where the probability of being set to 0 is inversely proportional to the element’s value relative to other values in the vector.

Parameters:
  • row (np.ndarray) – Input vector of arbitrary length

  • percentage (float) – Percentage of non-zero elements to set to zero (between 0 and 1)

Returns:

Modified vector with the specified percentage of non-zero elements set to zero

Return type:

np.ndarray

Module contents