luna.interaction.calc module¶
- class InteractionCalculator(inter_config={'boundary_cutoff': 6.2, 'max_an_ey_ang_ortho_multipolar_inter': 110, 'max_an_ey_ang_para_multipolar_inter': 25, 'max_cc_dist_amide_pi_inter': 4.5, 'max_cc_dist_pi_pi_inter': 6, 'max_da_dist_hb_inter': 3.9, 'max_da_dist_whb_inter': 4, 'max_dc_dist_whb_inter': 4.5, 'max_dihed_ang_amide_pi_inter': 30, 'max_dihed_ang_slope_pi_pi_inter': 60, 'max_disp_ang_ion_multipole_inter': 40, 'max_disp_ang_multipolar_inter': 40, 'max_disp_ang_offset_pi_pi_inter': 60, 'max_disp_ang_pi_pi_inter': 30, 'max_disp_ang_whb_inter': 40, 'max_disp_ang_xbond_inter': 60, 'max_disp_ang_ybond_inter': 60, 'max_dist_attract_inter': 6, 'max_dist_cation_pi_inter': 6, 'max_dist_hydrop_inter': 4.5, 'max_dist_proximal': 6, 'max_dist_repuls_inter': 6, 'max_ha_dist_hb_inter': 2.8, 'max_ha_dist_whb_inter': 3, 'max_hc_dist_whb_inter': 3.5, 'max_id_dist_ion_multipole_inter': 4.5, 'max_ne_dist_multipolar_inter': 4, 'max_ney_ang_multipolar_inter': 110, 'max_xa_dist_xbond_inter': 4, 'max_xc_dist_xbond_inter': 4.5, 'max_ya_dist_ybond_inter': 4, 'max_yc_dist_ybond_inter': 4.5, 'min_an_ey_ang_antipara_multipolar_inter': 155, 'min_an_ey_ang_ortho_multipolar_inter': 70, 'min_bond_separation': 3, 'min_bond_separation_for_clash': 4, 'min_cxa_ang_xbond_inter': 120, 'min_dar_ang_hb_inter': 90, 'min_dar_ang_whb_inter': 90, 'min_dha_ang_hb_inter': 90, 'min_dha_ang_whb_inter': 110, 'min_dhc_ang_whb_inter': 120, 'min_dihed_ang_slope_pi_pi_inter': 30, 'min_disp_ang_offset_pi_pi_inter': 30, 'min_dist_proximal': 2, 'min_har_ang_hb_inter': 90, 'min_har_ang_whb_inter': 90, 'min_idy_ang_ion_multipole_inter': 60, 'min_inter_atom_in_surf': 1, 'min_ney_ang_multipolar_inter': 70, 'min_rya_ang_ybond_inter': 120, 'min_surf_size': 1, 'min_xar_ang_xbond_inter': 80, 'min_yan_ang_ybond_inter': 80, 'vdw_clash_tolerance': 0.6, 'vdw_tolerance': 0.1}, inter_filter=None, inter_funcs=None, add_non_cov=True, add_cov=True, add_proximal=False, add_atom_atom=True, add_dependent_inter=False, add_h2o_pairs_with_no_target=False, strict_donor_rules=True, strict_weak_donor_rules=True, lazy_comps_list=['HOH', 'DOD', 'WAT', 'H2O', 'OH2'])[source]¶
Bases:
object
Calculate interactions.
Note
This class provides default LUNA methods to calculate interactions. However, one can provide their own methods without modifying this class. In the Examples section, we will show how to define custom functions.
Note
In case you want to disable specific parameters (e.g., angles) used during the calculation of interactions, you do not need to define a custom function for it. You could just delete the parameter from the configuration and LUNA will automatically recognize that a given parameter is not necessary anymore.
Check Examples 3 to see how to do it and how to implement this automatic behavior on your custom functions.
- Parameters
inter_config (
InteractionConfig
) – AnInteractionConfig
object with all parameters and cutoffs necessary to compute interactions defined ininter_funcs
. If not provided, the default LUNA configuration will be used instead (DefaultInteractionConfig
).inter_filter (
InteractionFilter
, optional) – AnInteractionFilter
object to filter out interactions on-the-fly. The default value is None, which implies no interaction will be filtered out.inter_funcs (dict of {tuple : iterable of callable}) – A dict to define custom functions to calculate interactions, where keys are tuples of feature names (e.g.
("Hydrophobic", "Hydrophobic")
) and values are lists of references to custom functions (see Examples for more details). If not provided, the default LUNA methods will be used instead.add_non_cov (bool) – If True (the default), compute non-covalent interactions. If you are providing custom functions to compute non-covalent interactions and want to make them controllable by this flag, make sure to verify the state of
add_non_cov
at the beginning of the function and return an empty list in case it is False.add_cov (bool) – If True (the default), compute covalent interactions. If you are providing custom functions to compute covalent interactions and want to make them controllable by this flag, make sure to verify the state of
add_cov
at the beginning of the function and return an empty list in case it is False.add_proximal (bool) – If True, compute proximal interactions, which are only distance-based contacts between atoms or atom groups that, therefore, only imply proximity. The default value is False. If you are providing custom functions to compute proximal interactions and want to make them controllable by this flag, make sure to verify the state of
add_proximal
at the beginning of the function and return an empty list in case it is False.add_atom_atom (bool) – If True (the default), compute atom-atom interactions, which, as the name suggests, are interactions that only involve atoms no matter their features. If you are providing custom functions to compute atom-atom interactions and want to make them controllable by this flag, make sure to verify the state of
add_atom_atom
at the beginning of the function and return an empty list in case it is False.Note
In LUNA, we consider the following interactions as atom-atom: Van der Waals, Van der Waals clash, and Atom overlap. We opted to separate Van der Waals from other non-covalent interactions because LUNA may generate an unnecessary number of additional interactions that are usually already represented by other non-covalent interactions as weak hydrogen bonds, hydrophobic, or dipole-dipole interactions. Thus, to give users a fine-grain control over which interactions to calculate, we provided this additional flag to turn off the calculation of Van der Waals interactions.
add_dependent_inter (bool) – If True, compute interactions that depend on other interactions. Currently, only water-bridged hydrogen bonds and salt bridges have a dependency on other interactions. The first, depends on two or more hydrogen bonds, while the second depends on an ionic and a hydrogen bond. The default value is False, which implies no dependent interaction will be computed.
add_h2o_pairs_with_no_target (bool) – If True, keep interactions of water with atoms and atom groups that do not belong to the target of LUNA’s analysis, which are chains or molecules defined as an
Entry
instance. For example, if the target is a ligand andadd_h2o_pairs_with_no_target
is False, then water-water and water-residue hydrogen bonds will be removed because the ligand is not participating in the interactions. The default value is False.strict_donor_rules (bool) – If True (the default), hydrogen bonds will only be considered for donor atoms with explicit hydrogens bound to them. In that case, angles and distances will be evaluated. However, if the molecule containing the donor atom is in
lazy_comps_list
, then angles and hydrogens will be ignored and LUNA will proceed with the determination of hydrogen bonds based only on donor-acceptor distances. Another exception occurs for solvent molecules in which the donor atom is only bound to hydrogens atoms (e.g., water, ammonia, and hydrogen sulfide). In that case, hydrogens can be positioned in many different ways by Open Babel, which may cause LUNA to detect different hydrogen bonds at each run. So, to circumvent this problem, by default, LUNA always ignores the explicit hydrogen position for donor atoms that only contain hydrogens bound to it.strict_weak_donor_rules (bool) – If True (the default), weak hydrogen bonds will only be considered for donor atoms with explicit hydrogens bound to them. In that case, angles and distances will be evaluated. The same exceptions described for
strict_donor_rules
apply here.lazy_comps_list (iterable) – A sequence of molecule names to ignore explicit hydrogen position during the calculation of hydrogen bonds and weak hydrogen bonds. The default list is [‘HOH’, ‘DOD’, ‘WAT’, ‘H2O’, ‘OH2’], which only contains water molecule names, including variations used by different programs.
Examples
Example 1) How to define custom interactions:
In this example, we will define a custom function to calculate hydrogen bonds.
First, let’s start importing the classes and the function we will use.
>>> from luna.interaction.type import InteractionType >>> from luna.interaction.calc import InteractionCalculator >>> from luna.util.math import euclidean_distance
Now, we define the custom function, which simply calculates hydrogen bonds based on donor-acceptor distances. If it is less than 3.5, then a new
InteractionType
object is created with type Hydrogen bond.def custom_hbond_function(self, params): if not self.add_non_cov: return [] group1, group2, feat1, feat2 = params interactions = [] cc_dist = euclidean_distance(group1.centroid, group2.centroid) if cc_dist <= 3.5: params = {"dist_hbond_inter": cc_dist} inter = InteractionType(group1, group2, "Hydrogen bond", params=params) interactions.append(inter) return interactions
Note
Observe that the function checks if
add_non_cov
has been turned off and if so returns an empty list. That’s a recommended strategy because it allows one to turn off all non-covalent interactions with a single flag.Also, observe that
InteractionCalculator
always expects functions to return a list at the end. That means multiple interactions may be detected for a single pair ofAtomGroup
objects. For example, a donor atom containing 2 hydrogens could, in theory, form two different hydrogen bonds with an acceptor atom.Now, we have two options to set the custom function to an
InteractionCalculator
object:Define a new dict with the custom functions:
>>> custom_funcs = {("Donor", "Acceptor"): [custom_hbond_function]} >>> ic = InteractionCalculator(inter_funcs=custom_funcs)
Overwrite the default dict in InteractionCalculator:
>>> ic = InteractionCalculator() >>> ic.funcs[("Donor", "Acceptor")] = [custom_hbond_function]
Example 2) How to modify parameters to calculate interactions:
If you just want to modify specific values from the default configuration, you can create a new
DefaultInteractionConfig
, alter parameters, and pass it toInteractionCalculator
.>>> from luna.interaction.calc import InteractionCalculator >>> from luna.interaction.config import DefaultInteractionConfig >>> custom_config = DefaultInteractionConfig() >>> custom_config.config["min_dha_ang_hb_inter"] = 120 >>> ic = InteractionCalculator(inter_config=custom_config)
Alternatively, you can initiate a new
InteractionCalculator
without providing anInteractionConfig
object, which will causeInteractionCalculator
to initiate the default configuration. Then, you can modify it directly as we did before.>>> from luna.interaction.calc import InteractionCalculator >>> ic = InteractionCalculator() >>> print(ic.inter_config["min_dha_ang_hb_inter"]) 90 >>> ic.inter_config["min_dha_ang_hb_inter"] = 120 >>> print(ic.inter_config["min_dha_ang_hb_inter"]) 120
Finally, if you want to define a custom configuration that will be used in your custom functions, you first need to define the parameters as a dict and then initiate a new
InteractionConfig
. See below:>>> from luna.interaction.config import InteractionConfig >>> config = {"param1": 2.5, "param2": 90} >>> custom_config = InteractionConfig(config) >>> ic = InteractionCalculator(inter_config=custom_config) >>> print(ic.inter_config["param1"]) 2.5 >>> print(ic.inter_config["param2"]) 90
Example 3) How to disable specific parameters and how to enable automatic recognition of disabled parameters in custom functions:
To automatically disable, for instance, verification of angles during the calculation of interactions using LUNA’s default functions, we just need to remove the parameters related to angles from
inter_config
. Let’s see an example where we disable angles from hydrogen bonds:>>> ic = InteractionCalculator() >>> del ic.inter_config["min_dha_ang_hb_inter"] >>> del ic.inter_config["min_har_ang_hb_inter"] >>> del ic.inter_config["min_dar_ang_hb_inter"]
This simple behavior is possible thanks to the function
is_within_boundary
, which always returns True if the parameter does not exist ininter_config
. Thus, you can take advantage of this system when implementing custom functions so others will also have the possibility to turn off specific parameters without modifying the code directly. Let’s see that in practice.First, let’s start importing the classes and the function we will use.
>>> from luna.interaction.config import InteractionConfig >>> from luna.interaction.type import InteractionType >>> from luna.interaction.calc import InteractionCalculator >>> from luna.util.math import euclidean_distance >>> from operator import le
Now, we define a custom function that calculates hydrogen bonds based on donor-acceptor distances only. Observe at line #9 that instead of checking the cutoff directly, we call
is_within_boundary
with the value, parameter, and a comparison function (le
: less than or equal), which will make it possible to modify or even disable the parameter automatically.1def custom_hbond_function(self, params): 2 if not self.add_non_cov: 3 return [] 4 5 group1, group2, feat1, feat2 = params 6 interactions = [] 7 8 cc_dist = euclidean_distance(group1.centroid, group2.centroid) 9 if self.is_within_boundary(cc_dist, "max_hb_dist", le): 10 params = {"dist_hbond_inter": cc_dist} 11 inter = InteractionType(group1, group2, "Hydrogen bond", params=params) 12 interactions.append(inter) 13 return interactions
Finally, we are ready to provide the function and custom parameters to
InteractionCalculator
.>>> custom_config = InteractionConfig({"max_hb_dist": 3}) >>> custom_funcs = {("Donor", "Acceptor"): [custom_hbond_function]} >>> ic = InteractionCalculator(inter_funcs=custom_funcs, inter_config=custom_config)
By doing so, we can now alter the new parameter or turn it off.
>>> ic.inter_config["max_hb_dist"] = 3.5 >>> del ic.inter_config["max_hb_dist"]
- static calc_amide_pi(self, params)[source]¶
Default method to calculate amide-pi stackings.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_atom_atom(self, params)[source]¶
Default method to calculate atom-atom interactions, which include covalent bonds, Van der Waals, Van der Waals clash, and atom overlap.
Note that covalent bonds are controlled by the flag
add_cov
, while the other three interactions are controlled by the flagadd_atom_atom
.Note
We opted to separate Van der Waals from other non-covalent interactions because LUNA may generate an unnecessary number of additional interactions that are usually already represented by other non-covalent interactions as weak hydrogen bonds, hydrophobic, or dipole-dipole interactions. Thus, to give users a fine-grain control over which interactions to calculate, we provided this additional flag to turn off the calculation of Van der Waals interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_cation_pi(self, params)[source]¶
Default method to calculate cation-pi interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_chalc_bond(self, params)[source]¶
Default method to calculate chalcogen bonds.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_chalc_bond_pi(self, params)[source]¶
Default method to calculate chalcogen bonds between chalcogens and aromatic rings.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_hbond(self, params)[source]¶
Default method to calculate hydrogen bonds.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_hbond_pi(self, params)[source]¶
Default method to calculate hydrogen bonds between (weak) donors and aromatic rings.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_hydrop(self, params)[source]¶
Default method to calculate hydrophobic interactons.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- calc_interactions(trgt_atm_grps, nb_atm_grps=None)[source]¶
Calculate interactions established by atoms and atoms groups in
trgt_atm_grps
using methods available infuncs
.The functions in
funcs
are chosen based on the features of each atom or atom group. For example, consider that a pair ofAtomGroup
objects have both the features ‘Hydrophobic’. Then,calc_interactions
will call any interaction function defined for the tuple("Hydrophobic", "Hydrophobic")
infuncs
. Consider now a pair ofAtomGroup
objects whose features are ‘Donor’ and ‘Hydrophobic’. Once again,calc_interactions
will evaluate if there is any function defined for the tuple("Donor", "Hydrophobic")
(the order does not matter). If there is none, nothing is done and the pair is skipped.- Parameters
trgt_atm_grps (iterable of
AtomGroup
) – Compute interactions involving theseAtomGroup
objects.nb_atm_grps (iterable of
AtomGroup
) – If defined, only compute interactions betweenAtomGroup
objects fromtrgt_atm_grps
withAtomGroup
objects fromnb_atm_grps
. If not provided, setnb_atm_grps
to be the same astrgt_atm_grps
, which implies that interactions will be calculated using only pairs ofAtomGroup
objects fromtrgt_atm_grps
.
- static calc_ion_multipole(self, params)[source]¶
Default method to calculate favorable and unfavorable ion-dipole interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_ionic(self, params)[source]¶
Default method to calculate attractive ionic interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_multipolar(self, params)[source]¶
Default method to calculate favorable and unfavorable dipole-dipole interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_pi_pi(self, params)[source]¶
Default method to calculate aromatic stackings.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_proximal(self, params)[source]¶
Default method to calculate proximal interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_repulsive(self, params)[source]¶
Default method to calculate repulsive ionic interactions.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_weak_hbond(self, params)[source]¶
Default method to calculate weak hydrogen bonds.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_xbond(self, params)[source]¶
Default method to calculate halogen bonds.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- static calc_xbond_pi(self, params)[source]¶
Default method to calculate halogen bonds between halogens and aromatic rings.
- Parameters
params (tuple of (
AtomGroup
,AtomGroup
,ChemicalFeature
,ChemicalFeature
)) – The tuple follows the order (\(A\), \(B\), \(A_f\), \(B_f\)), where \(A\) and \(B\) are twoAtomGroup
objects, and \(A_f\) and \(B_f\) are their features (ChemicalFeature
objects), respectively.- Return type
- find_dependent_interactions(interactions)[source]¶
Compute interactions that depend on other interactions. Currently, only water-bridged hydrogen bonds and salt bridges have a dependency on other interactions. The first, depends on two or more hydrogen bonds, while the second depends on an ionic and a hydrogen bond. The default value is False, which implies no dependent interaction will be computed.
- Parameters
interactions (
InteractionType
) – Use these interactions to compute dependent interactions.
- get_functions(feat1, feat2)[source]¶
Get the functions to calculate interactions for the given features.
- Parameters
feat1, feat2 (
ChemicalFeature
)- Return type
iterable of callable
- is_feature_pair_valid(feat1, feat2)[source]¶
Check if the provided pair of features is valid or not.
It will be valid if the pair exists in
funcs
, i.e., there is one or more functions to calculate interactions defined for that given pair of features.It also return False if non-covalent interactions is turned off (
add_non_cov = False
) and at least one of the features is not Atom. This is useful to save processing time as it skips pairs that have functions to calculate non-covalent interactions right away.- Parameters
feat1, feat2 (
ChemicalFeature
)- Return type
- is_within_boundary(value, key, func)[source]¶
Check if a value is within the boundary defined for a given parameter.
Note
It will always return True if the parameter does not exist in
inter_config
.- Parameters
value (any) – The value to be evaluated.
key – A parameter defined in
inter_config
.func (callable) – The function that evaluates if
value
is within the boundaries defined for the parameterkey
.Usually, the comparison functions (e.g., lt, le, ge, gt) available in the Python module
operator
are enough for number comparisons. If you need custom comparison functions, just provide them here.
- Return type
- remove_h2o_pairs_with_no_target(interactions)[source]¶
Remove interactions of water with atoms and atom groups that do not belong to the target of LUNA’s analysis, which are chains or molecules defined as an
Entry
instance.- Parameters
interactions (
InteractionType
)
- remove_inconsistencies(interactions)[source]¶
Remove conflicts between interactions in
interactions
.Note
By default, LUNA defines conflicts as any unfavorable dipole interaction involving an atom establishing a hydrogen bond. Due to the strength of a hydrogen bond, atoms may approximate more to each other, which sometimes may cause unfavorable interactions involving dipoles to be detected. To avoid such conflicts, LUNA removes the unfavorable interactions.
Also, it may occur that unfavorable dipole interactions are detected for amide-aromatic stackings, in which the aromatic ring contains heteroatoms. To avoid such conflicts, LUNA also removes those unfavorable interactions.
- Parameters
interactions (
InteractionType
)
- set_functions_to_pair(pair, funcs)[source]¶
Set functions to calculate interaction for the given pair of features.
- Parameters
pair (tuple of (
ChemicalFeature
,ChemicalFeature
))funcs (iterable of callable)
- class InteractionsManager(interactions=None, entry=None)[source]¶
Bases:
object
Store and manage
InteractionType
objects.- Parameters
interactions (iterable of
InteractionType
, optional) – An initial sequence ofInteractionType
objects.entry (
Entry
, optional) – The chain or compound used as reference to calculate interactions.
- add_interactions(interactions)[source]¶
Add one or more
InteractionType
objects tointeractions
.
- count_interations(must_have_target=False)[source]¶
Count the number of each type of interaction in
interactions
.- Parameters
must_have_target (bool) – If True, count only interactions involving the target ligand. The default value is False, which implies all interactions will be considered.
- Return type
- filter_by_types(types)[source]¶
Filter
InteractionType
objects by their types.- Parameters
types (iterable of str) – A sequence of interaction types.
- Yields
- filter_out_by_binding_mode(binding_modes_filter)[source]¶
Filter out interactions based on binding modes.
Note: this method modifies
interactions
.- Parameters
binding_modes_filter (
BindingModeFilter
) – ABindingModeFilter
object that defines binding mode conditions to decide which interactions are valid.- Returns
The interactions that were filtered out.
- Return type
set of
InteractionType
- get_all_atm_grps()[source]¶
Get all atom groups establishing interactions.
- Return type
set of
AtomGroup
- property interactions¶
The list of interactions. Additional interactions should be added using the method
add_interactions()
.- Type
list of
InteractionType
, read-only
- static load(input_file)[source]¶
Load the pickled representation of an
InteractionsManager
object saved at the fileinput_file
.- Returns
The reconstituted
InteractionsManager
object.- Return type
- Raises
PKLNotReadError – If the file could not be loaded.
- remove_interactions(interactions)[source]¶
Remove one or more
InteractionType
objects frominteractions
.Any recursive references to the removed objects will also be cleared.
- save(output_file, compressed=True)[source]¶
Write the pickled representation of the
InteractionsManager
object to the fileoutput_file
.- Parameters
output_file (str) – The output file.
compressed (bool, optional) – If True (the default), compress the pickled representation as a gzip file (.gz).
- Raises
FileNotCreated – If the file could not be created.
- to_csv(output_file)[source]¶
Write interactions to a comma-separated values (csv) file.
- Parameters
output_file (str) – The output CSV file.
- to_json(output_file=None, indent=None)[source]¶
Write interactions to a_initial_shell_data JSON file.
- Parameters
output_file (str) – The output JSON file.
indent (int or str, optional) – Indent level for pretty-printed JSON files. An indent level of 0, negative, or ‘’ only insert newlines. Positive integers indent that many spaces per level. If a string is provided (e.g., ‘\t’), it will be used to indent each level. The default value is None, which selects the most compact representation.