Skip to content

Commit

Permalink
In process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Apr 22, 2024
1 parent ca9ace5 commit 23d1046
Show file tree
Hide file tree
Showing 7 changed files with 1,097 additions and 136 deletions.
13 changes: 13 additions & 0 deletions molsysmt/_private/digestion/argument/output_indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ...exceptions import ArgumentError
from ...variables import is_all

def digest_output_indices(output_indices, caller=None):

if caller=='molsysmt.structure.get_contacts.get_contacts':

if isinstance(output_indices, str):
if output_indices.lower() in ['selection', 'atom', 'group']:
return output_indices.lower()

raise ArgumentError('output_indices', value=output_indices, caller=caller, message=None)

2 changes: 1 addition & 1 deletion molsysmt/_private/digestion/argument/output_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def digest_output_type(output_type, caller=None):
elif caller=='molsysmt.structure.get_contacts.get_contacts':

if isinstance(output_type, str):
if output_type.lower() in ['numpy.ndarray', 'dictionary']:
if output_type.lower() in ['pairs', 'sorted pairs', 'matrix']:
return output_type.lower()

elif caller=='molsysmt.topology.get_covalent_blocks.get_covalent_blocks':
Expand Down
29 changes: 21 additions & 8 deletions molsysmt/basic/selector/molsysmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,33 @@ def select_standard(item, selection):
from molsysmt.basic import convert, get_form
from molsysmt.config import selection_shortcuts


tmp_selection = selection

shortcuts = selection_shortcuts['MolSysMT']

for key in shortcuts:
if key in selection:
tmp_selection = tmp_selection.replace(key, shortcuts[key])



form_in = get_form(item)

if form_in == 'molsysmt.Topology':
tmp_item = item
else:
tmp_item = convert(item, to_form='molsysmt.Topology', skip_digestion=True)

tmp_selection = selection
from molsysmt.attribute.bonds_are_required_to_get_attribute import bond_dependent_attributes

bonds_required_by_selection = False
for attribute in bond_dependent_attributes:
if attribute in tmp_selection:
bonds_required_by_selection = True
break

tmp_item = convert(item, to_form='molsysmt.Topology', get_missing_bonds=bonds_required_by_selection,
skip_digestion=True)


if '@' in selection:
Expand Down Expand Up @@ -100,12 +119,6 @@ def select_standard(item, selection):
var_value = list(var_value)
locals()['auxiliar_variable_'+var_name]=var_value

shortcuts = selection_shortcuts['MolSysMT']

for key in shortcuts:
if key in selection:
tmp_selection = tmp_selection.replace(key, shortcuts[key])

if is_all(tmp_selection):

output = np.array(np.arange(tmp_item.atoms.shape[0]))
Expand Down
5 changes: 3 additions & 2 deletions molsysmt/build/get_missing_bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ def get_missing_bonds(molecular_system, threshold='2 angstroms', selection='all'
bonds_templates = []
bonds_distances = []

print('llega_0')
n_atoms = get(molecular_system, n_atoms=True)
atoms_water = select(molecular_system, selection='group_type=="water"')
atoms_not_water = complementary_atom_indices(molecular_system, atoms_water)
heavy_atoms_not_water = select(molecular_system, selection='atom_type!="H"', mask=atoms_not_water)
h_atoms_no_water = [ii for ii in atoms_not_water if ii not in heavy_atoms_not_water]

if with_distances:

print('llega_1')
contacts_heavy_atoms = get_contacts(molecular_system, selection=heavy_atoms_not_water,
threshold=threshold, output_type='pairs',
output_indices='atom_index', pbc=True)
output_indices='atom', pbc=True, skip_digestion=False)

return contacts_heavy_atoms

Expand Down
4 changes: 2 additions & 2 deletions molsysmt/form/nglview_NGLWidget/get_structural_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def get_coordinates_from_atom(item, indices='all', structure_indices='all', skip

coordinates = []
for ii in structure_indices:
if is_all(atom_indices):
if is_all(indices):
coordinates.append(item[0].get_coordinates(ii))
else:
coordinates.append(item[0].get_coordinates(ii)[atom_indices,:])
coordinates.append(item[0].get_coordinates(ii)[indices,:])
coordinates = np.array(coordinates)
coordinates = puw.quantity(coordinates, unit='angstroms')
coordinates = puw.standardize(coordinates)
Expand Down
6 changes: 3 additions & 3 deletions molsysmt/structure/get_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@digest()
def get_contacts(molecular_system, selection=None, center_of_atoms=False, weights=None, structure_indices="all",
selection_2=None, center_of_atoms_2=False, weights_2=None, structure_indices_2=None,
threshold='12 angstroms', pbc=True, syntax='MolSysMT', output_type='map', output_indices=None,
threshold='12 angstroms', pbc=True, syntax='MolSysMT', output_type='matrix', output_indices='selection',
skip_digestion=False):

"""
Expand Down Expand Up @@ -48,7 +48,7 @@ def get_contacts(molecular_system, selection=None, center_of_atoms=False, weight

output = None

if output_type=='map':
if output_type=='matrix':

output = contact_map

Expand All @@ -62,7 +62,7 @@ def get_contacts(molecular_system, selection=None, center_of_atoms=False, weight
aux_pairs = np.column_stack(aux_pairs).tolist()
pairs.append(aux_pairs)

if output_indices=='atom_index':
if output_indices=='atom':

atom_indices = np.array(atom_indices)

Expand Down
Loading

0 comments on commit 23d1046

Please sign in to comment.