-
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.
Merge pull request #54 from Daniel-Ibarrola/main
Merged without further comments.
- Loading branch information
Showing
120 changed files
with
2,810 additions
and
4,823 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
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 |
---|---|---|
@@ -1,6 +1,17 @@ | ||
{ | ||
"cells": [], | ||
"cells": [ | ||
{ | ||
"cell_type": "raw", | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "" | ||
} | ||
} | ||
} | ||
], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} | ||
} |
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 |
---|---|---|
@@ -1,25 +1,22 @@ | ||
import numpy as np | ||
|
||
|
||
def complementary_atom_indices(molecular_system, atom_indices): | ||
|
||
from molsysmt.basic import get | ||
|
||
n_atoms = get(molecular_system, element='system', n_atoms=True) | ||
|
||
mask = np.ones(n_atoms,dtype=bool) | ||
mask[atom_indices]=False | ||
mask = np.ones(n_atoms, dtype=bool) | ||
mask[atom_indices] = False | ||
return list(np.where(mask)[0]) | ||
|
||
|
||
def atom_indices_to_AmberMask(molecular_system, atom_indices): | ||
|
||
from molsysmt.basic import get | ||
|
||
n_atoms = get(molecular_system, element='system', n_atoms=True) | ||
mask = np.zeros(n_atoms,dtype=int) | ||
mask[atom_indices]=1 | ||
mask = np.zeros(n_atoms, dtype=int) | ||
mask[atom_indices] = 1 | ||
return list(mask) | ||
|
||
def atom_indices_to_csv(atom_indices): | ||
|
||
return ",".join([str(ii) for ii in atom_indices]) | ||
|
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,16 @@ | ||
from molsysmt.attribute.attributes import attribute_synonyms, attributes | ||
from ..exceptions import WrongGetArgumentError | ||
|
||
|
||
def digest_argument(argument, element): | ||
""" Helper function to check keyword arguments passed to get function. | ||
""" | ||
output_argument = argument.lower() | ||
if output_argument in ['index', 'indices', 'name', 'names', 'id', 'ids', 'type', 'types', 'order']: | ||
output_argument = '_'.join([element, output_argument]) | ||
if output_argument in attribute_synonyms: | ||
output_argument = attribute_synonyms[output_argument] | ||
if output_argument in attributes: | ||
return output_argument | ||
else: | ||
raise WrongGetArgumentError(argument) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,76 +1,72 @@ | ||
import numpy as np | ||
from molsysmt import puw | ||
from ..exceptions import * | ||
from ..exceptions import IncorrectShapeError | ||
|
||
def digest_box(box): | ||
|
||
def digest_box(box): | ||
# TODO: Function doesn't do anything. | ||
return box | ||
|
||
def digest_box_lengths_value(box_lengths): | ||
|
||
output = None | ||
|
||
if type(box_lengths) is not np.ndarray: | ||
box_lengths = np.array(box_lengths) | ||
|
||
shape = box_lengths.shape | ||
|
||
if len(shape)==1: | ||
if shape[0]==3: | ||
output = np.expand_dims(box_lengths, axis=0) | ||
else: | ||
raise ValueError('box_lengths array with has not the correct shape.') | ||
elif len(shape)==2: | ||
if shape[1]==3: | ||
output = box_lengths | ||
else: | ||
raise ValueError('box_lengths array with has not the correct shape.') | ||
else: | ||
raise ValueError('box_lengths array with has not the correct shape.') | ||
|
||
return output | ||
|
||
def digest_box_lengths(box_lengths): | ||
|
||
output = None | ||
unit = puw.get_unit(box_lengths) | ||
box_lengths_value = puw.get_value(box_lengths) | ||
box_lengths_value = digest_box_lengths_value(box_lengths_value) | ||
output = box_lengths_value*unit | ||
|
||
return output | ||
def digest_box_vectors_value(box_vectors): | ||
""" Checks if box_vectors has the correct shape. | ||
def digest_box_angles_value(box_angles): | ||
The array should have shape (n, 3) where n is any integer. | ||
However, if a list, tuple is passed it will be converted | ||
to an array with the desired shape. Also, if an array of | ||
shape (3, ) is passed its dimensions will be expanded to | ||
(1, 3). If an array with rank > 2 is passed and exception | ||
is raised. | ||
output = None | ||
Parameters | ||
---------- | ||
box_vectors : np.ndarray, list or tuple | ||
A quantity with the box lengths. | ||
if type(box_angles) is not np.ndarray: | ||
box_angles = np.array(box_angles) | ||
Raises | ||
------ | ||
IncorrectShapeError | ||
If box_vectors doesn't have the correct shape. | ||
""" | ||
if not(isinstance(box_vectors, np.ndarray)): | ||
box_vectors = np.array(box_vectors) | ||
|
||
shape = box_angles.shape | ||
shape = box_vectors.shape | ||
|
||
if len(shape)==1: | ||
if shape[0]==3: | ||
output = np.expand_dims(box_angles, axis=0) | ||
if len(shape) == 1: | ||
if shape[0] == 3: | ||
box_vectors = np.expand_dims(box_vectors, axis=0) | ||
else: | ||
raise ValueError('box_angles array with has not the correct shape.') | ||
elif len(shape)==2: | ||
if shape[1]==3: | ||
output = box_angles | ||
else: | ||
raise ValueError('box_angles array with has not the correct shape.') | ||
raise IncorrectShapeError(expected_shape="(1, 3)", actual_shape=str(shape)) | ||
elif len(shape) == 2: | ||
if shape[1] != 3: | ||
raise IncorrectShapeError(expected_shape="(n, 3)", actual_shape=str(shape)) | ||
else: | ||
raise ValueError('box_angles array with has not the correct shape.') | ||
|
||
return output | ||
|
||
def digest_box_angles(box_angles): | ||
|
||
output = None | ||
unit = puw.get_unit(box_angles) | ||
box_angles_value = puw.get_value(box_angles) | ||
box_angles_value = digest_box_angles_value(box_angles_value) | ||
output = box_angles_value*unit | ||
|
||
return output | ||
|
||
raise IncorrectShapeError(expected_shape="(n, 3)", actual_shape=str(shape)) | ||
|
||
return box_vectors | ||
|
||
|
||
def digest_box_vectors(box_vectors): | ||
""" Checks if box vectors have the correct shape. Can be used | ||
to check box_lengths and box_angles. | ||
Parameters | ||
---------- | ||
box_vectors : puw.Quantity | ||
A quantity with the box vectors. | ||
Returns | ||
------- | ||
puw.Quantity | ||
The box vectors with the shape corrected. | ||
Raises | ||
------ | ||
IncorrectShapeError | ||
If box_vectors doesn't have the correct shape. | ||
""" | ||
unit = puw.get_unit(box_vectors) | ||
box_vectors = puw.get_value(box_vectors) | ||
box_vectors = digest_box_vectors_value(box_vectors) | ||
return box_vectors * unit |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from ..exceptions import * | ||
|
||
def digest_coordinates(coordinates): | ||
|
||
def digest_coordinates(coordinates): | ||
# TODO: function doesn't do anything | ||
return coordinates | ||
|
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.