imspy.algorithm.ionization package¶
Submodules¶
imspy.algorithm.ionization.predictors module¶
- class imspy.algorithm.ionization.predictors.BinomialChargeStateDistributionModel(charged_probability=0.5, max_charge=4)¶
Bases:
PeptideChargeStateDistribution
,ABC
- simulate_charge_state_distribution_pandas(data, min_charge_contrib=0.005)¶
- Return type:
DataFrame
- simulate_ionizations(sequences)¶
- Return type:
array
- class imspy.algorithm.ionization.predictors.DeepChargeStateDistribution(model, tokenizer, allowed_charges=array([1, 2, 3, 4]), name='gru_predictor', verbose=True)¶
Bases:
PeptideChargeStateDistribution
,ABC
- simulate_charge_state_distribution_pandas(data, charge_state_one_probability=0.1, batch_size=1024, min_charge_contrib=0.005)¶
Simulate charge state distribution for a pandas DataFrame containing peptide sequences
- Parameters:
data (
DataFrame
) – pandas DataFrame containing peptide sequencescharge_state_one_probability (
float
) – probability of charge state 1batch_size (
int
) – batch size for predictionmin_charge_contrib (
float
) – minimum relative abundance of a charge state to be included in the output
- Return type:
DataFrame
- Returns:
pandas DataFrame containing simulated charge state distributions
- simulate_ionizations(sequences, batch_size=1024)¶
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]
- class imspy.algorithm.ionization.predictors.GRUChargeStatePredictor(*args, **kwargs)¶
Bases:
Model
- build(input_shape)¶
Builds the model based on input shapes received.
This is to be used for subclassed models, which do not know at instantiation time what their inputs look like.
This method only exists for users who want to call model.build() in a standalone way (as a substitute for calling the model on real data to build it). It will never be called by the framework (and thus it will never throw unexpected errors in an unrelated workflow).
- Parameters:
input_shape – Single tuple, TensorShape instance, or list/dict of shapes, where shapes are tuples, integers, or TensorShape instances.
- Raises:
ValueError –
In case of invalid user-provided data (not of type tuple, list, TensorShape, or dict). 2. If the model requires call arguments that are agnostic to the input shapes (positional or keyword arg in call signature). 3. If not all layers were properly built. 4. If float type inputs are not supported within the layers.
In each of these cases, the user should build their model by calling –
it on real tensor data. –
- call(inputs, training=False)¶
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- classmethod from_config(config)¶
Creates a layer from its config.
This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).
- Parameters:
config – A Python dictionary, typically the output of get_config.
- Returns:
A layer instance.
- get_config()¶
Returns the config of the Model.
Config is a Python dictionary (serializable) containing the configuration of an object, which in this case is a Model. This allows the Model to be be reinstantiated later (without its trained weights) from this configuration.
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
Developers of subclassed Model are advised to override this method, and continue to update the dict from super(MyModel, self).get_config() to provide the proper configuration of this Model. The default config will return config dict for init parameters if they are basic types. Raises NotImplementedError when in cases where a custom get_config() implementation is required for the subclassed model.
- Returns:
Python dictionary containing the configuration of this Model.
- class imspy.algorithm.ionization.predictors.PeptideChargeStateDistribution¶
Bases:
ABC
ABSTRACT INTERFACE for ionization simulation of peptides
- abstractmethod simulate_charge_state_distribution_pandas(data)¶
- Return type:
DataFrame
- abstractmethod simulate_ionizations(sequences)¶
- Return type:
array
- imspy.algorithm.ionization.predictors.charge_state_distribution_from_sequence_rust(sequence, max_charge=None, charge_probability=None)¶
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]
- imspy.algorithm.ionization.predictors.charge_state_distributions_from_sequences_rust(sequences, n_threads=4, max_charge=None, charge_probability=None)¶
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]
- imspy.algorithm.ionization.predictors.load_deep_charge_state_predictor()¶
Get a pretrained deep predictor model
- Return type:
Model
- Returns:
The pretrained deep predictor model