-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
359 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from ...exceptions import ArgumentError | ||
from ...variables import is_all | ||
import numpy as np | ||
|
||
def digest_bond_indices(bond_indices, caller=None): | ||
""" Checks if bond_indices has the expected type and value. | ||
Parameters | ||
---------- | ||
indices : str or int or list or tuple or range. | ||
The indices | ||
caller: str, optional | ||
Name of the function or method that is being digested. | ||
For debugging purposes. | ||
Returns | ||
------- | ||
str or ndarray or None | ||
Either None, 'all' or an numpy array of integers with the indices. | ||
Raises | ||
------- | ||
ArgumentError | ||
If the given indices are not of the correct type. | ||
""" | ||
|
||
if bond_indices is None: | ||
return None | ||
elif is_all(bond_indices): | ||
return 'all' | ||
elif isinstance(bond_indices, (int, np.int64, np.int32)): | ||
return np.array([bond_indices], dtype='int64') | ||
elif isinstance(bond_indices, (np.ndarray, list, tuple, range)): | ||
if all(isinstance(ii, (int, np.int64, np.int32)) for ii in bond_indices): | ||
return np.array(bond_indices, dtype='int64') | ||
else: | ||
return [digest_bond_indices(ii) for ii in bond_indices] | ||
|
||
raise ArgumentError('bond_indices', caller=caller, message=None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from molsysmt._private.exceptions import NotImplementedMethodError | ||
from molsysmt._private.digestion import digest | ||
from molsysmt._private.variables import is_all | ||
|
||
@digest() | ||
def remove_bonds(molecular_system, bond_indices='all', in_place=True, skip_digestion=False): | ||
|
||
from molsysmt.basic import where_is_attribute | ||
from molsysmt.form import _dict_modules | ||
|
||
if in_place: | ||
|
||
item, form = where_is_attribute(molecular_system, 'bond_index', check_if_None=False, | ||
skip_digestion=True) | ||
|
||
add_bonds_function = getattr(_dict_modules[form], f'remove_bonds') | ||
add_bonds_function(item, bond_indices, skip_digestion=True) | ||
|
||
else: | ||
|
||
raise NotImplementedMethodError | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from molsysmt._private.exceptions import NotImplementedMethodError | ||
from molsysmt._private.digestion import digest | ||
from molsysmt._private.variables import is_all | ||
|
||
@digest(form='molsysmt.MolSys') | ||
def remove_bonds(item, bond_indices='all', skip_digestion=False): | ||
|
||
return item.topology.remove_bonds(bond_indices=bond_indices, skip_digestion=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from molsysmt._private.exceptions import NotImplementedMethodError | ||
from molsysmt._private.digestion import digest | ||
from molsysmt import pyunitwizard as puw | ||
import numpy as np | ||
|
||
@digest(form='molsysmt.Topology') | ||
def add_bonds(item, bonded_atom_pairs, skip_digestion=False): | ||
|
||
item.add_bonds(bonded_atom_pairs, skip_digestion=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from molsysmt._private.exceptions import NotImplementedMethodError | ||
from molsysmt._private.digestion import digest | ||
from molsysmt._private.variables import is_all | ||
|
||
@digest(form='molsysmt.Topology') | ||
def remove_bonds(item, bond_indices='all', skip_digestion=False): | ||
|
||
return item.remove_bonds(bond_indices=bond_indices, skip_digestion=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.