imspy.simulation package¶
Subpackages¶
- imspy.simulation.timsim package
- Subpackages
- imspy.simulation.timsim.jobs package
- Submodules
- imspy.simulation.timsim.jobs.add_noise_from_real_data module
- imspy.simulation.timsim.jobs.assemble_frames module
- imspy.simulation.timsim.jobs.build_acquisition module
- imspy.simulation.timsim.jobs.digest_fasta module
- imspy.simulation.timsim.jobs.simulate_charge_states module
- imspy.simulation.timsim.jobs.simulate_fragment_intensities module
- imspy.simulation.timsim.jobs.simulate_frame_distributions module
- imspy.simulation.timsim.jobs.simulate_frame_distributions_emg module
- imspy.simulation.timsim.jobs.simulate_ion_mobilities module
- imspy.simulation.timsim.jobs.simulate_occurrences module
- imspy.simulation.timsim.jobs.simulate_precursor_spectra module
- imspy.simulation.timsim.jobs.simulate_retention_time module
- imspy.simulation.timsim.jobs.simulate_scan_distributions module
- imspy.simulation.timsim.jobs.utility module
- Module contents
- imspy.simulation.timsim.jobs package
- Submodules
- imspy.simulation.timsim.simulator module
- Module contents
- Subpackages
Submodules¶
imspy.simulation.acquisition module¶
- class imspy.simulation.acquisition.TimsTofAcquisitionBuilder(path, reference_ds, gradient_length, rt_cycle_length, exp_name='RAW.d')¶
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:
- 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=True, precursor_every=7, gradient_length=7200, rt_cycle_length=0.109, exp_name='RAW.d')¶
Bases:
TimsTofAcquisitionBuilder
,ABC
- calculate_frame_types(table, precursor_every=7, verbose=True)¶
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]
- 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:
- 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:
- 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:
- 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:
- classmethod from_py_ptr(mz_spectrum_annotated)¶
- Return type:
- 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:
- 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:
- 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:
- 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:
- property frame_id: int¶
- classmethod from_py_ptr(tims_frame_annotated)¶
- Return type:
- 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.TimsTofSyntheticFrameBuilderDIA(db_path, with_annotations=False, num_threads=4)¶
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:
- 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:
- 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:
- get_collision_energies(frame_ids, scan_ids)¶
- Return type:
List
[float
]
- get_collision_energy(frame_id, scan_id)¶
- Return type:
float
- 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:
- build_precursor_frame_annotated(frame_id, mz_noise_precursor=False, mz_noise_uniform=False, precursor_noise_ppm=5.0, right_drag=True)¶
- Return type:
- 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
]
- classmethod from_py_ptr(py_ptr)¶
- Return type:
- get_py_ptr()¶
- Return type:
PyTimsTofSyntheticsPrecursorFrameBuilder
imspy.simulation.feature module¶
imspy.simulation.handle module¶
imspy.simulation.isotopes module¶
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:
- 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)¶
Bases:
object
- build_frame_meta_row(frame, scan_mode, frame_start_pos, only_frame_one=False)¶
Build a row for the frame meta data table from a TimsFrame object. :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:
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_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
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_frames_numba(rt_value, times_array, std_rt, z_score)¶
Get the frames that will be acquired for a given retention time value. :type rt_value: :param rt_value: Retention time value :type rt_value: float :type times_array: :param times_array: Array of retention times :type times_array: NDArray :type std_rt: :param std_rt: Standard deviation of the retention time :type std_rt: float :type z_score: :param z_score: Z-score of the normal distribution :type z_score: float
- Returns:
Array of frame indices
- Return type:
NDArray
- 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_scans_numba(im_value, ims_array, scans_array, std_im, z_score)¶
Get the scans that will be acquired for a given ion mobility value.
- 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.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