pyprobound.cooperativity.Spacing
- class Spacing(mode_key_a, mode_key_b, score_same=True, score_reverse=True, score_mode='both', max_overlap=None, max_spacing=None, normalize=False, ignore_pad=False, name='')
Bases:
SpecExperiment-independent dimer cooperativity modeling.
\(\omega_{a:b}(x^a, x^b)\) represents a scaling factor to the outer sum of sliding windows of the two binding modes in the dimer. Its experiment- independent formulation consists of a scaling for each relative offset between any pair of sliding windows, such that \(\omega_{a:b}(x^a_m, x^b_n) = \omega_{a:b}(x^a_{m+i}, x^b_{n+i}) \forall i\).
- log_spacing
The flattened representation of \(\omega_{a:b}(x^a, x^b)\).
- Type:
Tensor
- __init__(mode_key_a, mode_key_b, score_same=True, score_reverse=True, score_mode='both', max_overlap=None, max_spacing=None, normalize=False, ignore_pad=False, name='')
Initializes the experiment-independent dimer cooperativity.
- Parameters:
mode_key_a (
Iterable[LayerSpec]) – The specification of the first binding mode contributing to the dimer.mode_key_b (
Iterable[LayerSpec]) – The specification of the second binding mode contributing to the dimer.score_same (
bool) – Whether to score when both modes on the same strand.score_reverse (
bool) – Whether to score when modes are on opposite strands.score_mode (
Literal['both','positive','negative']) – Whether to score positive offsets (mode_b to the right of mode_a), negative offsets (mode_a to the right), or both.max_overlap (
int|None) – The maximum number of bases shared by two windows.max_spacing (
int|None) – The maximum number of bases apart two windows can be.normalize (
bool) – Whether to mean-center log_spacing over all windows.ignore_pad (
bool) – Whether to ignore padding layers in calculating sizes.name (
str) – A string used to describe the cooperativity.
Methods
check_length_consistency()Checks that input lengths of Binding components are consistent.
Iterator of child components.
forward()Define the computation performed at every call.
freeze()Turns off gradient calculation for all parameters.
get_log_spacing(n_windows_a, n_windows_b)Adjusts log_spacing for windows, max_spacing, and max_overlap.
get_log_spacing_matrix(n_windows_a, n_windows_b)The diagonal-constant cooperativity \(\omega_{a:b}(x^a, x^b)\).
max_embedding_size()The maximum number of bytes needed to encode a sequence.
optim_procedure([ancestry, current_order])The sequential optimization procedure for all Binding components.
reload(checkpoint)Loads the model from a checkpoint file.
reload_from_state_dict(state_dict)Loads the model from a state dict.
save(checkpoint[, flank_lengths])Saves the model to a file with "state_dict" and "metadata" fields.
unfreeze([parameter])Turns on gradient calculation for the specified parameter.
update_binding_optim(binding_optim)Updates a BindingOptim with the specification's optimization steps.
Attributes
The number of sliding windows modeled by log_spacing.
The number of output channels of the component modes.
alias of
Literal['all', 'spacing']Non-Inherited Members
- unfreezable
alias of
Literal[‘all’, ‘spacing’]
- property n_strands: Literal[1, 2]
The number of output channels of the component modes.
- property max_num_windows: int
The number of sliding windows modeled by log_spacing.
- unfreeze(parameter='all')
Turns on gradient calculation for the specified parameter.
- Parameters:
parameter (unfreezable) – Parameter to be unfrozen, defaults to all parameters.
- Return type:
None
- update_binding_optim(binding_optim)
Updates a BindingOptim with the specification’s optimization steps.
- Parameters:
binding_optim (
BindingOptim) – The parent BindingOptim to be updated.- Return type:
- Returns:
The updated BindingOptim.
- get_log_spacing(n_windows_a, n_windows_b)
Adjusts log_spacing for windows, max_spacing, and max_overlap.
- Parameters:
n_windows_a (
int) – The number of windows in the first binding mode.n_windows_b (
int) – The number of windows in the second binding mode.strand_b – The strand index of the second binding mode
- Return type:
Tensor- Returns:
A tensor with the flattened representation of the cooperativity of each pair of windows \((x^a_m, x^b_n)\), of shape \((\text{n_strands}_a,\text{n_strands}_b, \text{out_length}_a+\text{out_length}_b-1)\).
- get_log_spacing_matrix(n_windows_a, n_windows_b)
The diagonal-constant cooperativity \(\omega_{a:b}(x^a, x^b)\).
- Parameters:
n_windows_a (
int) – The number of windows in the first binding mode.n_windows_b (
int) – The number of windows in the second binding mode.
- Return type:
Tensor- Returns:
A diagonal-constant tensor with the cooperativity of each pair of windows \((x^a_m, x^b_n)\) of shape \((\text{n_strands}_a,\text{n_strands}_b, \text{out_length}_a,\text{out_length}_b)\).)`