repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
molmod/molmod
molmod/quaternions.py
quaternion_to_rotation_matrix
def quaternion_to_rotation_matrix(quaternion): """Compute the rotation matrix representated by the quaternion""" c, x, y, z = quaternion return np.array([ [c*c + x*x - y*y - z*z, 2*x*y - 2*c*z, 2*x*z + 2*c*y ], [2*x*y + 2*c*z, c*c - x*x + y*y - z*z, 2*y*z - 2*c*x ...
python
def quaternion_to_rotation_matrix(quaternion): """Compute the rotation matrix representated by the quaternion""" c, x, y, z = quaternion return np.array([ [c*c + x*x - y*y - z*z, 2*x*y - 2*c*z, 2*x*z + 2*c*y ], [2*x*y + 2*c*z, c*c - x*x + y*y - z*z, 2*y*z - 2*c*x ...
[ "def", "quaternion_to_rotation_matrix", "(", "quaternion", ")", ":", "c", ",", "x", ",", "y", ",", "z", "=", "quaternion", "return", "np", ".", "array", "(", "[", "[", "c", "*", "c", "+", "x", "*", "x", "-", "y", "*", "y", "-", "z", "*", "z", ...
Compute the rotation matrix representated by the quaternion
[ "Compute", "the", "rotation", "matrix", "representated", "by", "the", "quaternion" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L101-L108
train
molmod/molmod
molmod/vectors.py
cosine
def cosine(a, b): """Compute the cosine between two vectors The result is clipped within the range [-1, 1] """ result = np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b) return np.clip(result, -1, 1)
python
def cosine(a, b): """Compute the cosine between two vectors The result is clipped within the range [-1, 1] """ result = np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b) return np.clip(result, -1, 1)
[ "def", "cosine", "(", "a", ",", "b", ")", ":", "result", "=", "np", ".", "dot", "(", "a", ",", "b", ")", "/", "np", ".", "linalg", ".", "norm", "(", "a", ")", "/", "np", ".", "linalg", ".", "norm", "(", "b", ")", "return", "np", ".", "cli...
Compute the cosine between two vectors The result is clipped within the range [-1, 1]
[ "Compute", "the", "cosine", "between", "two", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L37-L43
train
molmod/molmod
molmod/vectors.py
random_unit
def random_unit(size=3): """Return a random unit vector of the given dimension Optional argument: size -- the number of dimensions of the unit vector [default=3] """ while True: result = np.random.normal(0, 1, size) length = np.linalg.norm(result) if length > 1e-3:...
python
def random_unit(size=3): """Return a random unit vector of the given dimension Optional argument: size -- the number of dimensions of the unit vector [default=3] """ while True: result = np.random.normal(0, 1, size) length = np.linalg.norm(result) if length > 1e-3:...
[ "def", "random_unit", "(", "size", "=", "3", ")", ":", "while", "True", ":", "result", "=", "np", ".", "random", ".", "normal", "(", "0", ",", "1", ",", "size", ")", "length", "=", "np", ".", "linalg", ".", "norm", "(", "result", ")", "if", "le...
Return a random unit vector of the given dimension Optional argument: size -- the number of dimensions of the unit vector [default=3]
[ "Return", "a", "random", "unit", "vector", "of", "the", "given", "dimension" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L54-L64
train
molmod/molmod
molmod/vectors.py
random_orthonormal
def random_orthonormal(normal): """Return a random normalized vector orthogonal to the given vector""" u = normal_fns[np.argmin(np.fabs(normal))](normal) u /= np.linalg.norm(u) v = np.cross(normal, u) v /= np.linalg.norm(v) alpha = np.random.uniform(0.0, np.pi*2) return np.cos(alpha)*u + np....
python
def random_orthonormal(normal): """Return a random normalized vector orthogonal to the given vector""" u = normal_fns[np.argmin(np.fabs(normal))](normal) u /= np.linalg.norm(u) v = np.cross(normal, u) v /= np.linalg.norm(v) alpha = np.random.uniform(0.0, np.pi*2) return np.cos(alpha)*u + np....
[ "def", "random_orthonormal", "(", "normal", ")", ":", "u", "=", "normal_fns", "[", "np", ".", "argmin", "(", "np", ".", "fabs", "(", "normal", ")", ")", "]", "(", "normal", ")", "u", "/=", "np", ".", "linalg", ".", "norm", "(", "u", ")", "v", "...
Return a random normalized vector orthogonal to the given vector
[ "Return", "a", "random", "normalized", "vector", "orthogonal", "to", "the", "given", "vector" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L73-L80
train
molmod/molmod
molmod/vectors.py
triangle_normal
def triangle_normal(a, b, c): """Return a vector orthogonal to the given triangle Arguments: a, b, c -- three 3D numpy vectors """ normal = np.cross(a - c, b - c) norm = np.linalg.norm(normal) return normal/norm
python
def triangle_normal(a, b, c): """Return a vector orthogonal to the given triangle Arguments: a, b, c -- three 3D numpy vectors """ normal = np.cross(a - c, b - c) norm = np.linalg.norm(normal) return normal/norm
[ "def", "triangle_normal", "(", "a", ",", "b", ",", "c", ")", ":", "normal", "=", "np", ".", "cross", "(", "a", "-", "c", ",", "b", "-", "c", ")", "norm", "=", "np", ".", "linalg", ".", "norm", "(", "normal", ")", "return", "normal", "/", "nor...
Return a vector orthogonal to the given triangle Arguments: a, b, c -- three 3D numpy vectors
[ "Return", "a", "vector", "orthogonal", "to", "the", "given", "triangle" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L82-L90
train
molmod/molmod
molmod/ic.py
dot
def dot(r1, r2): """Compute the dot product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Scalar) """ if r1.size != r2.size: raise ValueError("Both arguments must have the same input size.") if r1.deriv != r2.deriv: raise ValueError("Both...
python
def dot(r1, r2): """Compute the dot product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Scalar) """ if r1.size != r2.size: raise ValueError("Both arguments must have the same input size.") if r1.deriv != r2.deriv: raise ValueError("Both...
[ "def", "dot", "(", "r1", ",", "r2", ")", ":", "if", "r1", ".", "size", "!=", "r2", ".", "size", ":", "raise", "ValueError", "(", "\"Both arguments must have the same input size.\"", ")", "if", "r1", ".", "deriv", "!=", "r2", ".", "deriv", ":", "raise", ...
Compute the dot product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Scalar)
[ "Compute", "the", "dot", "product" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L283-L295
train
molmod/molmod
molmod/ic.py
cross
def cross(r1, r2): """Compute the cross product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Vector3) """ if r1.size != r2.size: raise ValueError("Both arguments must have the same input size.") if r1.deriv != r2.deriv: raise ValueError(...
python
def cross(r1, r2): """Compute the cross product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Vector3) """ if r1.size != r2.size: raise ValueError("Both arguments must have the same input size.") if r1.deriv != r2.deriv: raise ValueError(...
[ "def", "cross", "(", "r1", ",", "r2", ")", ":", "if", "r1", ".", "size", "!=", "r2", ".", "size", ":", "raise", "ValueError", "(", "\"Both arguments must have the same input size.\"", ")", "if", "r1", ".", "deriv", "!=", "r2", ".", "deriv", ":", "raise",...
Compute the cross product Arguments: | ``r1``, ``r2`` -- two :class:`Vector3` objects (Returns a Vector3)
[ "Compute", "the", "cross", "product" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L298-L314
train
molmod/molmod
molmod/ic.py
_opbend_transform_mean
def _opbend_transform_mean(rs, fn_low, deriv=0): """Compute the mean of the 3 opbends """ v = 0.0 d = np.zeros((4,3), float) dd = np.zeros((4,3,4,3), float) #loop over the 3 cyclic permutations for p in np.array([[0,1,2], [2,0,1], [1,2,0]]): opbend = _opbend_transform([rs[p[0]], rs[p...
python
def _opbend_transform_mean(rs, fn_low, deriv=0): """Compute the mean of the 3 opbends """ v = 0.0 d = np.zeros((4,3), float) dd = np.zeros((4,3,4,3), float) #loop over the 3 cyclic permutations for p in np.array([[0,1,2], [2,0,1], [1,2,0]]): opbend = _opbend_transform([rs[p[0]], rs[p...
[ "def", "_opbend_transform_mean", "(", "rs", ",", "fn_low", ",", "deriv", "=", "0", ")", ":", "v", "=", "0.0", "d", "=", "np", ".", "zeros", "(", "(", "4", ",", "3", ")", ",", "float", ")", "dd", "=", "np", ".", "zeros", "(", "(", "4", ",", ...
Compute the mean of the 3 opbends
[ "Compute", "the", "mean", "of", "the", "3", "opbends" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L590-L636
train
molmod/molmod
molmod/ic.py
_bond_length_low
def _bond_length_low(r, deriv): """Similar to bond_length, but with a relative vector""" r = Vector3(3, deriv, r, (0, 1, 2)) d = r.norm() return d.results()
python
def _bond_length_low(r, deriv): """Similar to bond_length, but with a relative vector""" r = Vector3(3, deriv, r, (0, 1, 2)) d = r.norm() return d.results()
[ "def", "_bond_length_low", "(", "r", ",", "deriv", ")", ":", "r", "=", "Vector3", "(", "3", ",", "deriv", ",", "r", ",", "(", "0", ",", "1", ",", "2", ")", ")", "d", "=", "r", ".", "norm", "(", ")", "return", "d", ".", "results", "(", ")" ]
Similar to bond_length, but with a relative vector
[ "Similar", "to", "bond_length", "but", "with", "a", "relative", "vector" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L644-L648
train
molmod/molmod
molmod/ic.py
_bend_cos_low
def _bend_cos_low(a, b, deriv): """Similar to bend_cos, but with relative vectors""" a = Vector3(6, deriv, a, (0, 1, 2)) b = Vector3(6, deriv, b, (3, 4, 5)) a /= a.norm() b /= b.norm() return dot(a, b).results()
python
def _bend_cos_low(a, b, deriv): """Similar to bend_cos, but with relative vectors""" a = Vector3(6, deriv, a, (0, 1, 2)) b = Vector3(6, deriv, b, (3, 4, 5)) a /= a.norm() b /= b.norm() return dot(a, b).results()
[ "def", "_bend_cos_low", "(", "a", ",", "b", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "6", ",", "deriv", ",", "a", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "6", ",", "deriv", ",", "b", ",", "(", "3", ...
Similar to bend_cos, but with relative vectors
[ "Similar", "to", "bend_cos", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L651-L657
train
molmod/molmod
molmod/ic.py
_bend_angle_low
def _bend_angle_low(a, b, deriv): """Similar to bend_angle, but with relative vectors""" result = _bend_cos_low(a, b, deriv) return _cos_to_angle(result, deriv)
python
def _bend_angle_low(a, b, deriv): """Similar to bend_angle, but with relative vectors""" result = _bend_cos_low(a, b, deriv) return _cos_to_angle(result, deriv)
[ "def", "_bend_angle_low", "(", "a", ",", "b", ",", "deriv", ")", ":", "result", "=", "_bend_cos_low", "(", "a", ",", "b", ",", "deriv", ")", "return", "_cos_to_angle", "(", "result", ",", "deriv", ")" ]
Similar to bend_angle, but with relative vectors
[ "Similar", "to", "bend_angle", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L660-L663
train
molmod/molmod
molmod/ic.py
_dihed_cos_low
def _dihed_cos_low(a, b, c, deriv): """Similar to dihed_cos, but with relative vectors""" a = Vector3(9, deriv, a, (0, 1, 2)) b = Vector3(9, deriv, b, (3, 4, 5)) c = Vector3(9, deriv, c, (6, 7, 8)) b /= b.norm() tmp = b.copy() tmp *= dot(a, b) a -= tmp tmp = b.copy() tmp *= dot(c...
python
def _dihed_cos_low(a, b, c, deriv): """Similar to dihed_cos, but with relative vectors""" a = Vector3(9, deriv, a, (0, 1, 2)) b = Vector3(9, deriv, b, (3, 4, 5)) c = Vector3(9, deriv, c, (6, 7, 8)) b /= b.norm() tmp = b.copy() tmp *= dot(a, b) a -= tmp tmp = b.copy() tmp *= dot(c...
[ "def", "_dihed_cos_low", "(", "a", ",", "b", ",", "c", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "9", ",", "deriv", ",", "a", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "9", ",", "deriv", ",", "b", ",",...
Similar to dihed_cos, but with relative vectors
[ "Similar", "to", "dihed_cos", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L666-L680
train
molmod/molmod
molmod/ic.py
_dihed_angle_low
def _dihed_angle_low(av, bv, cv, deriv): """Similar to dihed_cos, but with relative vectors""" a = Vector3(9, deriv, av, (0, 1, 2)) b = Vector3(9, deriv, bv, (3, 4, 5)) c = Vector3(9, deriv, cv, (6, 7, 8)) b /= b.norm() tmp = b.copy() tmp *= dot(a, b) a -= tmp tmp = b.copy() tmp ...
python
def _dihed_angle_low(av, bv, cv, deriv): """Similar to dihed_cos, but with relative vectors""" a = Vector3(9, deriv, av, (0, 1, 2)) b = Vector3(9, deriv, bv, (3, 4, 5)) c = Vector3(9, deriv, cv, (6, 7, 8)) b /= b.norm() tmp = b.copy() tmp *= dot(a, b) a -= tmp tmp = b.copy() tmp ...
[ "def", "_dihed_angle_low", "(", "av", ",", "bv", ",", "cv", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "9", ",", "deriv", ",", "av", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "9", ",", "deriv", ",", "bv",...
Similar to dihed_cos, but with relative vectors
[ "Similar", "to", "dihed_cos", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L683-L710
train
molmod/molmod
molmod/ic.py
_opdist_low
def _opdist_low(av, bv, cv, deriv): """Similar to opdist, but with relative vectors""" a = Vector3(9, deriv, av, (0, 1, 2)) b = Vector3(9, deriv, bv, (3, 4, 5)) c = Vector3(9, deriv, cv, (6, 7, 8)) n = cross(a, b) n /= n.norm() dist = dot(c, n) return dist.results()
python
def _opdist_low(av, bv, cv, deriv): """Similar to opdist, but with relative vectors""" a = Vector3(9, deriv, av, (0, 1, 2)) b = Vector3(9, deriv, bv, (3, 4, 5)) c = Vector3(9, deriv, cv, (6, 7, 8)) n = cross(a, b) n /= n.norm() dist = dot(c, n) return dist.results()
[ "def", "_opdist_low", "(", "av", ",", "bv", ",", "cv", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "9", ",", "deriv", ",", "av", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "9", ",", "deriv", ",", "bv", ",...
Similar to opdist, but with relative vectors
[ "Similar", "to", "opdist", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L713-L721
train
molmod/molmod
molmod/ic.py
_opbend_cos_low
def _opbend_cos_low(a, b, c, deriv): """Similar to opbend_cos, but with relative vectors""" a = Vector3(9, deriv, a, (0, 1, 2)) b = Vector3(9, deriv, b, (3, 4, 5)) c = Vector3(9, deriv, c, (6, 7, 8)) n = cross(a,b) n /= n.norm() c /= c.norm() temp = dot(n,c) result = temp.copy() ...
python
def _opbend_cos_low(a, b, c, deriv): """Similar to opbend_cos, but with relative vectors""" a = Vector3(9, deriv, a, (0, 1, 2)) b = Vector3(9, deriv, b, (3, 4, 5)) c = Vector3(9, deriv, c, (6, 7, 8)) n = cross(a,b) n /= n.norm() c /= c.norm() temp = dot(n,c) result = temp.copy() ...
[ "def", "_opbend_cos_low", "(", "a", ",", "b", ",", "c", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "9", ",", "deriv", ",", "a", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "9", ",", "deriv", ",", "b", ","...
Similar to opbend_cos, but with relative vectors
[ "Similar", "to", "opbend_cos", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L724-L744
train
molmod/molmod
molmod/ic.py
_opbend_angle_low
def _opbend_angle_low(a, b, c, deriv=0): """Similar to opbend_angle, but with relative vectors""" result = _opbend_cos_low(a, b, c, deriv) sign = np.sign(np.linalg.det([a, b, c])) return _cos_to_angle(result, deriv, sign)
python
def _opbend_angle_low(a, b, c, deriv=0): """Similar to opbend_angle, but with relative vectors""" result = _opbend_cos_low(a, b, c, deriv) sign = np.sign(np.linalg.det([a, b, c])) return _cos_to_angle(result, deriv, sign)
[ "def", "_opbend_angle_low", "(", "a", ",", "b", ",", "c", ",", "deriv", "=", "0", ")", ":", "result", "=", "_opbend_cos_low", "(", "a", ",", "b", ",", "c", ",", "deriv", ")", "sign", "=", "np", ".", "sign", "(", "np", ".", "linalg", ".", "det",...
Similar to opbend_angle, but with relative vectors
[ "Similar", "to", "opbend_angle", "but", "with", "relative", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L747-L751
train
molmod/molmod
molmod/ic.py
_cos_to_angle
def _cos_to_angle(result, deriv, sign=1): """Convert a cosine and its derivatives to an angle and its derivatives""" v = np.arccos(np.clip(result[0], -1, 1)) if deriv == 0: return v*sign, if abs(result[0]) >= 1: factor1 = 0 else: factor1 = -1.0/np.sqrt(1-result[0]**2) d =...
python
def _cos_to_angle(result, deriv, sign=1): """Convert a cosine and its derivatives to an angle and its derivatives""" v = np.arccos(np.clip(result[0], -1, 1)) if deriv == 0: return v*sign, if abs(result[0]) >= 1: factor1 = 0 else: factor1 = -1.0/np.sqrt(1-result[0]**2) d =...
[ "def", "_cos_to_angle", "(", "result", ",", "deriv", ",", "sign", "=", "1", ")", ":", "v", "=", "np", ".", "arccos", "(", "np", ".", "clip", "(", "result", "[", "0", "]", ",", "-", "1", ",", "1", ")", ")", "if", "deriv", "==", "0", ":", "re...
Convert a cosine and its derivatives to an angle and its derivatives
[ "Convert", "a", "cosine", "and", "its", "derivatives", "to", "an", "angle", "and", "its", "derivatives" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L759-L775
train
molmod/molmod
molmod/ic.py
_sin_to_angle
def _sin_to_angle(result, deriv, side=1): """Convert a sine and its derivatives to an angle and its derivatives""" v = np.arcsin(np.clip(result[0], -1, 1)) sign = side if sign == -1: if v < 0: offset = -np.pi else: offset = np.pi else: offset = 0.0 ...
python
def _sin_to_angle(result, deriv, side=1): """Convert a sine and its derivatives to an angle and its derivatives""" v = np.arcsin(np.clip(result[0], -1, 1)) sign = side if sign == -1: if v < 0: offset = -np.pi else: offset = np.pi else: offset = 0.0 ...
[ "def", "_sin_to_angle", "(", "result", ",", "deriv", ",", "side", "=", "1", ")", ":", "v", "=", "np", ".", "arcsin", "(", "np", ".", "clip", "(", "result", "[", "0", "]", ",", "-", "1", ",", "1", ")", ")", "sign", "=", "side", "if", "sign", ...
Convert a sine and its derivatives to an angle and its derivatives
[ "Convert", "a", "sine", "and", "its", "derivatives", "to", "an", "angle", "and", "its", "derivatives" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L778-L802
train
molmod/molmod
molmod/ic.py
Scalar.copy
def copy(self): """Return a deep copy""" result = Scalar(self.size, self.deriv) result.v = self.v if self.deriv > 0: result.d[:] = self.d[:] if self.deriv > 1: result.dd[:] = self.dd[:] return result
python
def copy(self): """Return a deep copy""" result = Scalar(self.size, self.deriv) result.v = self.v if self.deriv > 0: result.d[:] = self.d[:] if self.deriv > 1: result.dd[:] = self.dd[:] return result
[ "def", "copy", "(", "self", ")", ":", "result", "=", "Scalar", "(", "self", ".", "size", ",", "self", ".", "deriv", ")", "result", ".", "v", "=", "self", ".", "v", "if", "self", ".", "deriv", ">", "0", ":", "result", ".", "d", "[", ":", "]", ...
Return a deep copy
[ "Return", "a", "deep", "copy" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L89-L95
train
molmod/molmod
molmod/ic.py
Scalar.results
def results(self): """Return the value and optionally derivative and second order derivative""" if self.deriv == 0: return self.v, if self.deriv == 1: return self.v, self.d if self.deriv == 2: return self.v, self.d, self.dd
python
def results(self): """Return the value and optionally derivative and second order derivative""" if self.deriv == 0: return self.v, if self.deriv == 1: return self.v, self.d if self.deriv == 2: return self.v, self.d, self.dd
[ "def", "results", "(", "self", ")", ":", "if", "self", ".", "deriv", "==", "0", ":", "return", "self", ".", "v", ",", "if", "self", ".", "deriv", "==", "1", ":", "return", "self", ".", "v", ",", "self", ".", "d", "if", "self", ".", "deriv", "...
Return the value and optionally derivative and second order derivative
[ "Return", "the", "value", "and", "optionally", "derivative", "and", "second", "order", "derivative" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L97-L104
train
molmod/molmod
molmod/ic.py
Scalar.inv
def inv(self): """In place invert""" self.v = 1/self.v tmp = self.v**2 if self.deriv > 1: self.dd[:] = tmp*(2*self.v*np.outer(self.d, self.d) - self.dd) if self.deriv > 0: self.d[:] = -tmp*self.d[:]
python
def inv(self): """In place invert""" self.v = 1/self.v tmp = self.v**2 if self.deriv > 1: self.dd[:] = tmp*(2*self.v*np.outer(self.d, self.d) - self.dd) if self.deriv > 0: self.d[:] = -tmp*self.d[:]
[ "def", "inv", "(", "self", ")", ":", "self", ".", "v", "=", "1", "/", "self", ".", "v", "tmp", "=", "self", ".", "v", "**", "2", "if", "self", ".", "deriv", ">", "1", ":", "self", ".", "dd", "[", ":", "]", "=", "tmp", "*", "(", "2", "*"...
In place invert
[ "In", "place", "invert" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L179-L186
train
molmod/molmod
molmod/ic.py
Vector3.copy
def copy(self): """Return a deep copy""" result = Vector3(self.size, self.deriv) result.x.v = self.x.v result.y.v = self.y.v result.z.v = self.z.v if self.deriv > 0: result.x.d[:] = self.x.d result.y.d[:] = self.y.d result.z.d[:] = self...
python
def copy(self): """Return a deep copy""" result = Vector3(self.size, self.deriv) result.x.v = self.x.v result.y.v = self.y.v result.z.v = self.z.v if self.deriv > 0: result.x.d[:] = self.x.d result.y.d[:] = self.y.d result.z.d[:] = self...
[ "def", "copy", "(", "self", ")", ":", "result", "=", "Vector3", "(", "self", ".", "size", ",", "self", ".", "deriv", ")", "result", ".", "x", ".", "v", "=", "self", ".", "x", ".", "v", "result", ".", "y", ".", "v", "=", "self", ".", "y", "....
Return a deep copy
[ "Return", "a", "deep", "copy" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L211-L225
train
molmod/molmod
molmod/ic.py
Vector3.norm
def norm(self): """Return a Scalar object with the norm of this vector""" result = Scalar(self.size, self.deriv) result.v = np.sqrt(self.x.v**2 + self.y.v**2 + self.z.v**2) if self.deriv > 0: result.d += self.x.v*self.x.d result.d += self.y.v*self.y.d ...
python
def norm(self): """Return a Scalar object with the norm of this vector""" result = Scalar(self.size, self.deriv) result.v = np.sqrt(self.x.v**2 + self.y.v**2 + self.z.v**2) if self.deriv > 0: result.d += self.x.v*self.x.d result.d += self.y.v*self.y.d ...
[ "def", "norm", "(", "self", ")", ":", "result", "=", "Scalar", "(", "self", ".", "size", ",", "self", ".", "deriv", ")", "result", ".", "v", "=", "np", ".", "sqrt", "(", "self", ".", "x", ".", "v", "**", "2", "+", "self", ".", "y", ".", "v"...
Return a Scalar object with the norm of this vector
[ "Return", "a", "Scalar", "object", "with", "the", "norm", "of", "this", "vector" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L251-L275
train
molmod/molmod
molmod/io/gromacs.py
GroReader._get_line
def _get_line(self): """Get a line or raise StopIteration""" line = self._f.readline() if len(line) == 0: raise StopIteration return line
python
def _get_line(self): """Get a line or raise StopIteration""" line = self._f.readline() if len(line) == 0: raise StopIteration return line
[ "def", "_get_line", "(", "self", ")", ":", "line", "=", "self", ".", "_f", ".", "readline", "(", ")", "if", "len", "(", "line", ")", "==", "0", ":", "raise", "StopIteration", "return", "line" ]
Get a line or raise StopIteration
[ "Get", "a", "line", "or", "raise", "StopIteration" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L61-L66
train
molmod/molmod
molmod/io/gromacs.py
GroReader._read_frame
def _read_frame(self): """Read one frame""" # Read the first line, ignore the title and try to get the time. The # time field is optional. line = self._get_line() pos = line.rfind("t=") if pos >= 0: time = float(line[pos+2:])*picosecond else: ...
python
def _read_frame(self): """Read one frame""" # Read the first line, ignore the title and try to get the time. The # time field is optional. line = self._get_line() pos = line.rfind("t=") if pos >= 0: time = float(line[pos+2:])*picosecond else: ...
[ "def", "_read_frame", "(", "self", ")", ":", "# Read the first line, ignore the title and try to get the time. The", "# time field is optional.", "line", "=", "self", ".", "_get_line", "(", ")", "pos", "=", "line", ".", "rfind", "(", "\"t=\"", ")", "if", "pos", ">="...
Read one frame
[ "Read", "one", "frame" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L68-L111
train
molmod/molmod
molmod/io/gromacs.py
GroReader._skip_frame
def _skip_frame(self): """Skip one frame""" self._get_line() num_atoms = int(self._get_line()) if self.num_atoms is not None and self.num_atoms != num_atoms: raise ValueError("The number of atoms must be the same over the entire file.") for i in range(num_atoms+1): ...
python
def _skip_frame(self): """Skip one frame""" self._get_line() num_atoms = int(self._get_line()) if self.num_atoms is not None and self.num_atoms != num_atoms: raise ValueError("The number of atoms must be the same over the entire file.") for i in range(num_atoms+1): ...
[ "def", "_skip_frame", "(", "self", ")", ":", "self", ".", "_get_line", "(", ")", "num_atoms", "=", "int", "(", "self", ".", "_get_line", "(", ")", ")", "if", "self", ".", "num_atoms", "is", "not", "None", "and", "self", ".", "num_atoms", "!=", "num_a...
Skip one frame
[ "Skip", "one", "frame" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L113-L120
train
molmod/molmod
molmod/examples/003_internal_coordinates/d_dft_hessian.py
setup_ics
def setup_ics(graph): """Make a list of internal coordinates based on the graph Argument: | ``graph`` -- A Graph instance. The list of internal coordinates will include all bond lengths, all bending angles, and all dihedral angles. """ ics = [] # A) Collect all bonds. ...
python
def setup_ics(graph): """Make a list of internal coordinates based on the graph Argument: | ``graph`` -- A Graph instance. The list of internal coordinates will include all bond lengths, all bending angles, and all dihedral angles. """ ics = [] # A) Collect all bonds. ...
[ "def", "setup_ics", "(", "graph", ")", ":", "ics", "=", "[", "]", "# A) Collect all bonds.", "for", "i0", ",", "i1", "in", "graph", ".", "edges", ":", "ics", ".", "append", "(", "BondLength", "(", "i0", ",", "i1", ")", ")", "# B) Collect all bends. (see ...
Make a list of internal coordinates based on the graph Argument: | ``graph`` -- A Graph instance. The list of internal coordinates will include all bond lengths, all bending angles, and all dihedral angles.
[ "Make", "a", "list", "of", "internal", "coordinates", "based", "on", "the", "graph" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L62-L92
train
molmod/molmod
molmod/examples/003_internal_coordinates/d_dft_hessian.py
compute_jacobian
def compute_jacobian(ics, coordinates): """Construct a Jacobian for the given internal and Cartesian coordinates Arguments: | ``ics`` -- A list of internal coordinate objects. | ``coordinates`` -- A numpy array with Cartesian coordinates, shape=(N,3) The ...
python
def compute_jacobian(ics, coordinates): """Construct a Jacobian for the given internal and Cartesian coordinates Arguments: | ``ics`` -- A list of internal coordinate objects. | ``coordinates`` -- A numpy array with Cartesian coordinates, shape=(N,3) The ...
[ "def", "compute_jacobian", "(", "ics", ",", "coordinates", ")", ":", "N3", "=", "coordinates", ".", "size", "jacobian", "=", "numpy", ".", "zeros", "(", "(", "N3", ",", "len", "(", "ics", ")", ")", ",", "float", ")", "for", "j", ",", "ic", "in", ...
Construct a Jacobian for the given internal and Cartesian coordinates Arguments: | ``ics`` -- A list of internal coordinate objects. | ``coordinates`` -- A numpy array with Cartesian coordinates, shape=(N,3) The return value will be a numpy array with the Jac...
[ "Construct", "a", "Jacobian", "for", "the", "given", "internal", "and", "Cartesian", "coordinates" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L95-L112
train
molmod/molmod
molmod/examples/003_internal_coordinates/d_dft_hessian.py
InternalCoordinate.fill_jacobian_column
def fill_jacobian_column(self, jaccol, coordinates): """Fill in a column of the Jacobian. Arguments: | ``jaccol`` -- The column of Jacobian to which the result must be added. | ``coordinates`` -- A numpy array with Cartesian coordinates, ...
python
def fill_jacobian_column(self, jaccol, coordinates): """Fill in a column of the Jacobian. Arguments: | ``jaccol`` -- The column of Jacobian to which the result must be added. | ``coordinates`` -- A numpy array with Cartesian coordinates, ...
[ "def", "fill_jacobian_column", "(", "self", ",", "jaccol", ",", "coordinates", ")", ":", "q", ",", "g", "=", "self", ".", "icfn", "(", "coordinates", "[", "list", "(", "self", ".", "indexes", ")", "]", ",", "1", ")", "for", "i", ",", "j", "in", "...
Fill in a column of the Jacobian. Arguments: | ``jaccol`` -- The column of Jacobian to which the result must be added. | ``coordinates`` -- A numpy array with Cartesian coordinates, shape=(N,3)
[ "Fill", "in", "a", "column", "of", "the", "Jacobian", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L32-L44
train
molmod/molmod
molmod/similarity.py
compute_similarity
def compute_similarity(a, b, margin=1.0, cutoff=10.0): """Compute the similarity between two molecules based on their descriptors Arguments: a -- the similarity measure of the first molecule b -- the similarity measure of the second molecule margin -- the sensitivity when co...
python
def compute_similarity(a, b, margin=1.0, cutoff=10.0): """Compute the similarity between two molecules based on their descriptors Arguments: a -- the similarity measure of the first molecule b -- the similarity measure of the second molecule margin -- the sensitivity when co...
[ "def", "compute_similarity", "(", "a", ",", "b", ",", "margin", "=", "1.0", ",", "cutoff", "=", "10.0", ")", ":", "return", "similarity_measure", "(", "a", ".", "table_labels", ",", "a", ".", "table_distances", ",", "b", ".", "table_labels", ",", "b", ...
Compute the similarity between two molecules based on their descriptors Arguments: a -- the similarity measure of the first molecule b -- the similarity measure of the second molecule margin -- the sensitivity when comparing distances (default = 1.0) cutoff -- don't c...
[ "Compute", "the", "similarity", "between", "two", "molecules", "based", "on", "their", "descriptors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L112-L141
train
molmod/molmod
molmod/similarity.py
SimilarityDescriptor.from_molecule
def from_molecule(cls, molecule, labels=None): """Initialize a similarity descriptor Arguments: molecule -- a Molecules object labels -- a list with integer labels used to identify atoms of the same type. When not given, the atom numbers from ...
python
def from_molecule(cls, molecule, labels=None): """Initialize a similarity descriptor Arguments: molecule -- a Molecules object labels -- a list with integer labels used to identify atoms of the same type. When not given, the atom numbers from ...
[ "def", "from_molecule", "(", "cls", ",", "molecule", ",", "labels", "=", "None", ")", ":", "if", "labels", "is", "None", ":", "labels", "=", "molecule", ".", "numbers", "return", "cls", "(", "molecule", ".", "distance_matrix", ",", "labels", ")" ]
Initialize a similarity descriptor Arguments: molecule -- a Molecules object labels -- a list with integer labels used to identify atoms of the same type. When not given, the atom numbers from the molecule are used.
[ "Initialize", "a", "similarity", "descriptor" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L71-L82
train
molmod/molmod
molmod/similarity.py
SimilarityDescriptor.from_molecular_graph
def from_molecular_graph(cls, molecular_graph, labels=None): """Initialize a similarity descriptor Arguments: molecular_graphs -- A MolecularGraphs object labels -- a list with integer labels used to identify atoms of the same type. When not giv...
python
def from_molecular_graph(cls, molecular_graph, labels=None): """Initialize a similarity descriptor Arguments: molecular_graphs -- A MolecularGraphs object labels -- a list with integer labels used to identify atoms of the same type. When not giv...
[ "def", "from_molecular_graph", "(", "cls", ",", "molecular_graph", ",", "labels", "=", "None", ")", ":", "if", "labels", "is", "None", ":", "labels", "=", "molecular_graph", ".", "numbers", ".", "astype", "(", "int", ")", "return", "cls", "(", "molecular_g...
Initialize a similarity descriptor Arguments: molecular_graphs -- A MolecularGraphs object labels -- a list with integer labels used to identify atoms of the same type. When not given, the atom numbers from the molecular graph a...
[ "Initialize", "a", "similarity", "descriptor" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L85-L96
train
molmod/molmod
molmod/similarity.py
SimilarityDescriptor.from_coordinates
def from_coordinates(cls, coordinates, labels): """Initialize a similarity descriptor Arguments: coordinates -- a Nx3 numpy array labels -- a list with integer labels used to identify atoms of the same type """ from molmod.ext im...
python
def from_coordinates(cls, coordinates, labels): """Initialize a similarity descriptor Arguments: coordinates -- a Nx3 numpy array labels -- a list with integer labels used to identify atoms of the same type """ from molmod.ext im...
[ "def", "from_coordinates", "(", "cls", ",", "coordinates", ",", "labels", ")", ":", "from", "molmod", ".", "ext", "import", "molecules_distance_matrix", "distance_matrix", "=", "molecules_distance_matrix", "(", "coordinates", ")", "return", "cls", "(", "distance_mat...
Initialize a similarity descriptor Arguments: coordinates -- a Nx3 numpy array labels -- a list with integer labels used to identify atoms of the same type
[ "Initialize", "a", "similarity", "descriptor" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L99-L109
train
molmod/molmod
molmod/io/chk.py
load_chk
def load_chk(filename): '''Load a checkpoint file Argument: | filename -- the file to load from The return value is a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean or an array of strings, integers, booleans or floats. ...
python
def load_chk(filename): '''Load a checkpoint file Argument: | filename -- the file to load from The return value is a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean or an array of strings, integers, booleans or floats. ...
[ "def", "load_chk", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "result", "=", "{", "}", "while", "True", ":", "line", "=", "f", ".", "readline", "(", ")", "if", "line", "==", "''", ":", "break", "if", "len", ...
Load a checkpoint file Argument: | filename -- the file to load from The return value is a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean or an array of strings, integers, booleans or floats. The file format is similar t...
[ "Load", "a", "checkpoint", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/chk.py#L33-L102
train
molmod/molmod
molmod/io/chk.py
dump_chk
def dump_chk(filename, data): '''Dump a checkpoint file Argument: | filename -- the file to write to | data -- a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean, an array/list of strings, integers, fl...
python
def dump_chk(filename, data): '''Dump a checkpoint file Argument: | filename -- the file to write to | data -- a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean, an array/list of strings, integers, fl...
[ "def", "dump_chk", "(", "filename", ",", "data", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "for", "key", ",", "value", "in", "sorted", "(", "data", ".", "items", "(", ")", ")", ":", "if", "not", "isinstance", "("...
Dump a checkpoint file Argument: | filename -- the file to write to | data -- a dictionary whose keys are field labels and the values can be None, string, integer, float, boolean, an array/list of strings, integers, floats or booleans. The file fo...
[ "Dump", "a", "checkpoint", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/chk.py#L105-L176
train
molmod/molmod
molmod/io/psf.py
PSFFile.clear
def clear(self): """Clear the contents of the data structure""" self.title = None self.numbers = np.zeros(0, int) self.atom_types = [] # the atom_types in the second column, used to associate ff parameters self.charges = [] # ff charges self.names = [] # a name that is un...
python
def clear(self): """Clear the contents of the data structure""" self.title = None self.numbers = np.zeros(0, int) self.atom_types = [] # the atom_types in the second column, used to associate ff parameters self.charges = [] # ff charges self.names = [] # a name that is un...
[ "def", "clear", "(", "self", ")", ":", "self", ".", "title", "=", "None", "self", ".", "numbers", "=", "np", ".", "zeros", "(", "0", ",", "int", ")", "self", ".", "atom_types", "=", "[", "]", "# the atom_types in the second column, used to associate ff param...
Clear the contents of the data structure
[ "Clear", "the", "contents", "of", "the", "data", "structure" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L69-L82
train
molmod/molmod
molmod/io/psf.py
PSFFile.read_from_file
def read_from_file(self, filename): """Load a PSF file""" self.clear() with open(filename) as f: # A) check the first line line = next(f) if not line.startswith("PSF"): raise FileFormatError("Error while reading: A PSF file must start with a li...
python
def read_from_file(self, filename): """Load a PSF file""" self.clear() with open(filename) as f: # A) check the first line line = next(f) if not line.startswith("PSF"): raise FileFormatError("Error while reading: A PSF file must start with a li...
[ "def", "read_from_file", "(", "self", ",", "filename", ")", ":", "self", ".", "clear", "(", ")", "with", "open", "(", "filename", ")", "as", "f", ":", "# A) check the first line", "line", "=", "next", "(", "f", ")", "if", "not", "line", ".", "startswit...
Load a PSF file
[ "Load", "a", "PSF", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L84-L147
train
molmod/molmod
molmod/io/psf.py
PSFFile._get_name
def _get_name(self, graph, group=None): """Convert a molecular graph into a unique name This method is not sensitive to the order of the atoms in the graph. """ if group is not None: graph = graph.get_subgraph(group, normalize=True) fingerprint = graph.fingerprin...
python
def _get_name(self, graph, group=None): """Convert a molecular graph into a unique name This method is not sensitive to the order of the atoms in the graph. """ if group is not None: graph = graph.get_subgraph(group, normalize=True) fingerprint = graph.fingerprin...
[ "def", "_get_name", "(", "self", ",", "graph", ",", "group", "=", "None", ")", ":", "if", "group", "is", "not", "None", ":", "graph", "=", "graph", ".", "get_subgraph", "(", "group", ",", "normalize", "=", "True", ")", "fingerprint", "=", "graph", "....
Convert a molecular graph into a unique name This method is not sensitive to the order of the atoms in the graph.
[ "Convert", "a", "molecular", "graph", "into", "a", "unique", "name" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L149-L162
train
molmod/molmod
molmod/io/psf.py
PSFFile.dump
def dump(self, f): """Dump the data structure to a file-like object""" # header print("PSF", file=f) print(file=f) # title print(" 1 !NTITLE", file=f) print(self.title, file=f) print(file=f) # atoms print("% 7i !NATOM" % len(self.num...
python
def dump(self, f): """Dump the data structure to a file-like object""" # header print("PSF", file=f) print(file=f) # title print(" 1 !NTITLE", file=f) print(self.title, file=f) print(file=f) # atoms print("% 7i !NATOM" % len(self.num...
[ "def", "dump", "(", "self", ",", "f", ")", ":", "# header", "print", "(", "\"PSF\"", ",", "file", "=", "f", ")", "print", "(", "file", "=", "f", ")", "# title", "print", "(", "\" 1 !NTITLE\"", ",", "file", "=", "f", ")", "print", "(", "self", ...
Dump the data structure to a file-like object
[ "Dump", "the", "data", "structure", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L169-L254
train
molmod/molmod
molmod/io/psf.py
PSFFile.add_molecule
def add_molecule(self, molecule, atom_types=None, charges=None, split=True): """Add the graph of the molecule to the data structure The molecular graph is estimated from the molecular geometry based on interatomic distances. Argument: | ``molecule`` -- a Molecule...
python
def add_molecule(self, molecule, atom_types=None, charges=None, split=True): """Add the graph of the molecule to the data structure The molecular graph is estimated from the molecular geometry based on interatomic distances. Argument: | ``molecule`` -- a Molecule...
[ "def", "add_molecule", "(", "self", ",", "molecule", ",", "atom_types", "=", "None", ",", "charges", "=", "None", ",", "split", "=", "True", ")", ":", "molecular_graph", "=", "MolecularGraph", ".", "from_geometry", "(", "molecule", ")", "self", ".", "add_m...
Add the graph of the molecule to the data structure The molecular graph is estimated from the molecular geometry based on interatomic distances. Argument: | ``molecule`` -- a Molecule instance Optional arguments: | ``atom_types`` -- a list with ...
[ "Add", "the", "graph", "of", "the", "molecule", "to", "the", "data", "structure" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L256-L272
train
molmod/molmod
molmod/io/psf.py
PSFFile.add_molecular_graph
def add_molecular_graph(self, molecular_graph, atom_types=None, charges=None, split=True, molecule=None): """Add the molecular graph to the data structure Argument: | ``molecular_graph`` -- a MolecularGraph instance Optional arguments: | ``atom_types`` -- a li...
python
def add_molecular_graph(self, molecular_graph, atom_types=None, charges=None, split=True, molecule=None): """Add the molecular graph to the data structure Argument: | ``molecular_graph`` -- a MolecularGraph instance Optional arguments: | ``atom_types`` -- a li...
[ "def", "add_molecular_graph", "(", "self", ",", "molecular_graph", ",", "atom_types", "=", "None", ",", "charges", "=", "None", ",", "split", "=", "True", ",", "molecule", "=", "None", ")", ":", "# add atom numbers and molecule indices", "new", "=", "len", "("...
Add the molecular graph to the data structure Argument: | ``molecular_graph`` -- a MolecularGraph instance Optional arguments: | ``atom_types`` -- a list with atom type strings | ``charges`` -- The net atom charges | ``split`` -- When True,...
[ "Add", "the", "molecular", "graph", "to", "the", "data", "structure" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L274-L325
train
molmod/molmod
molmod/io/psf.py
PSFFile.get_groups
def get_groups(self): """Return a list of groups of atom indexes Each atom in a group belongs to the same molecule or residue. """ groups = [] for a_index, m_index in enumerate(self.molecules): if m_index >= len(groups): groups.append([a_index]) ...
python
def get_groups(self): """Return a list of groups of atom indexes Each atom in a group belongs to the same molecule or residue. """ groups = [] for a_index, m_index in enumerate(self.molecules): if m_index >= len(groups): groups.append([a_index]) ...
[ "def", "get_groups", "(", "self", ")", ":", "groups", "=", "[", "]", "for", "a_index", ",", "m_index", "in", "enumerate", "(", "self", ".", "molecules", ")", ":", "if", "m_index", ">=", "len", "(", "groups", ")", ":", "groups", ".", "append", "(", ...
Return a list of groups of atom indexes Each atom in a group belongs to the same molecule or residue.
[ "Return", "a", "list", "of", "groups", "of", "atom", "indexes" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L398-L409
train
molmod/molmod
molmod/randomize.py
iter_halfs_bond
def iter_halfs_bond(graph): """Select a random bond (pair of atoms) that divides the molecule in two""" for atom1, atom2 in graph.edges: try: affected_atoms1, affected_atoms2 = graph.get_halfs(atom1, atom2) yield affected_atoms1, affected_atoms2, (atom1, atom2) except Gra...
python
def iter_halfs_bond(graph): """Select a random bond (pair of atoms) that divides the molecule in two""" for atom1, atom2 in graph.edges: try: affected_atoms1, affected_atoms2 = graph.get_halfs(atom1, atom2) yield affected_atoms1, affected_atoms2, (atom1, atom2) except Gra...
[ "def", "iter_halfs_bond", "(", "graph", ")", ":", "for", "atom1", ",", "atom2", "in", "graph", ".", "edges", ":", "try", ":", "affected_atoms1", ",", "affected_atoms2", "=", "graph", ".", "get_halfs", "(", "atom1", ",", "atom2", ")", "yield", "affected_ato...
Select a random bond (pair of atoms) that divides the molecule in two
[ "Select", "a", "random", "bond", "(", "pair", "of", "atoms", ")", "that", "divides", "the", "molecule", "in", "two" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L205-L213
train
molmod/molmod
molmod/randomize.py
iter_halfs_bend
def iter_halfs_bend(graph): """Select randomly two consecutive bonds that divide the molecule in two""" for atom2 in range(graph.num_vertices): neighbors = list(graph.neighbors[atom2]) for index1, atom1 in enumerate(neighbors): for atom3 in neighbors[index1+1:]: try: ...
python
def iter_halfs_bend(graph): """Select randomly two consecutive bonds that divide the molecule in two""" for atom2 in range(graph.num_vertices): neighbors = list(graph.neighbors[atom2]) for index1, atom1 in enumerate(neighbors): for atom3 in neighbors[index1+1:]: try: ...
[ "def", "iter_halfs_bend", "(", "graph", ")", ":", "for", "atom2", "in", "range", "(", "graph", ".", "num_vertices", ")", ":", "neighbors", "=", "list", "(", "graph", ".", "neighbors", "[", "atom2", "]", ")", "for", "index1", ",", "atom1", "in", "enumer...
Select randomly two consecutive bonds that divide the molecule in two
[ "Select", "randomly", "two", "consecutive", "bonds", "that", "divide", "the", "molecule", "in", "two" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L216-L234
train
molmod/molmod
molmod/randomize.py
iter_halfs_double
def iter_halfs_double(graph): """Select two random non-consecutive bonds that divide the molecule in two""" edges = graph.edges for index1, (atom_a1, atom_b1) in enumerate(edges): for atom_a2, atom_b2 in edges[:index1]: try: affected_atoms1, affected_atoms2, hinge_atoms =...
python
def iter_halfs_double(graph): """Select two random non-consecutive bonds that divide the molecule in two""" edges = graph.edges for index1, (atom_a1, atom_b1) in enumerate(edges): for atom_a2, atom_b2 in edges[:index1]: try: affected_atoms1, affected_atoms2, hinge_atoms =...
[ "def", "iter_halfs_double", "(", "graph", ")", ":", "edges", "=", "graph", ".", "edges", "for", "index1", ",", "(", "atom_a1", ",", "atom_b1", ")", "in", "enumerate", "(", "edges", ")", ":", "for", "atom_a2", ",", "atom_b2", "in", "edges", "[", ":", ...
Select two random non-consecutive bonds that divide the molecule in two
[ "Select", "two", "random", "non", "-", "consecutive", "bonds", "that", "divide", "the", "molecule", "in", "two" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L237-L246
train
molmod/molmod
molmod/randomize.py
generate_manipulations
def generate_manipulations( molecule, bond_stretch_factor=0.15, torsion_amplitude=np.pi, bending_amplitude=0.30 ): """Generate a (complete) set of manipulations The result can be used as input for the functions 'randomize_molecule' and 'single_random_manipulation' Arguments: ...
python
def generate_manipulations( molecule, bond_stretch_factor=0.15, torsion_amplitude=np.pi, bending_amplitude=0.30 ): """Generate a (complete) set of manipulations The result can be used as input for the functions 'randomize_molecule' and 'single_random_manipulation' Arguments: ...
[ "def", "generate_manipulations", "(", "molecule", ",", "bond_stretch_factor", "=", "0.15", ",", "torsion_amplitude", "=", "np", ".", "pi", ",", "bending_amplitude", "=", "0.30", ")", ":", "do_stretch", "=", "(", "bond_stretch_factor", ">", "0", ")", "do_double_s...
Generate a (complete) set of manipulations The result can be used as input for the functions 'randomize_molecule' and 'single_random_manipulation' Arguments: molecule -- a reference geometry of the molecule, with graph attribute bond_stretch_factor -- ...
[ "Generate", "a", "(", "complete", ")", "set", "of", "manipulations" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L250-L324
train
molmod/molmod
molmod/randomize.py
check_nonbond
def check_nonbond(molecule, thresholds): """Check whether all nonbonded atoms are well separated. If a nonbond atom pair is found that has an interatomic distance below the given thresholds. The thresholds dictionary has the following format: {frozenset([atom_number1, atom_number2]): distance}...
python
def check_nonbond(molecule, thresholds): """Check whether all nonbonded atoms are well separated. If a nonbond atom pair is found that has an interatomic distance below the given thresholds. The thresholds dictionary has the following format: {frozenset([atom_number1, atom_number2]): distance}...
[ "def", "check_nonbond", "(", "molecule", ",", "thresholds", ")", ":", "# check that no atoms overlap", "for", "atom1", "in", "range", "(", "molecule", ".", "graph", ".", "num_vertices", ")", ":", "for", "atom2", "in", "range", "(", "atom1", ")", ":", "if", ...
Check whether all nonbonded atoms are well separated. If a nonbond atom pair is found that has an interatomic distance below the given thresholds. The thresholds dictionary has the following format: {frozenset([atom_number1, atom_number2]): distance} When random geometries are generated fo...
[ "Check", "whether", "all", "nonbonded", "atoms", "are", "well", "separated", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L327-L350
train
molmod/molmod
molmod/randomize.py
randomize_molecule
def randomize_molecule(molecule, manipulations, nonbond_thresholds, max_tries=1000): """Return a randomized copy of the molecule. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molecul...
python
def randomize_molecule(molecule, manipulations, nonbond_thresholds, max_tries=1000): """Return a randomized copy of the molecule. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molecul...
[ "def", "randomize_molecule", "(", "molecule", ",", "manipulations", ",", "nonbond_thresholds", ",", "max_tries", "=", "1000", ")", ":", "for", "m", "in", "range", "(", "max_tries", ")", ":", "random_molecule", "=", "randomize_molecule_low", "(", "molecule", ",",...
Return a randomized copy of the molecule. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molecule is returned. The original molecule is not altered.
[ "Return", "a", "randomized", "copy", "of", "the", "molecule", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L353-L364
train
molmod/molmod
molmod/randomize.py
randomize_molecule_low
def randomize_molecule_low(molecule, manipulations): """Return a randomized copy of the molecule, without the nonbond check.""" manipulations = copy.copy(manipulations) shuffle(manipulations) coordinates = molecule.coordinates.copy() for manipulation in manipulations: manipulation.apply(coo...
python
def randomize_molecule_low(molecule, manipulations): """Return a randomized copy of the molecule, without the nonbond check.""" manipulations = copy.copy(manipulations) shuffle(manipulations) coordinates = molecule.coordinates.copy() for manipulation in manipulations: manipulation.apply(coo...
[ "def", "randomize_molecule_low", "(", "molecule", ",", "manipulations", ")", ":", "manipulations", "=", "copy", ".", "copy", "(", "manipulations", ")", "shuffle", "(", "manipulations", ")", "coordinates", "=", "molecule", ".", "coordinates", ".", "copy", "(", ...
Return a randomized copy of the molecule, without the nonbond check.
[ "Return", "a", "randomized", "copy", "of", "the", "molecule", "without", "the", "nonbond", "check", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L367-L375
train
molmod/molmod
molmod/randomize.py
single_random_manipulation
def single_random_manipulation(molecule, manipulations, nonbond_thresholds, max_tries=1000): """Apply a single random manipulation. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molec...
python
def single_random_manipulation(molecule, manipulations, nonbond_thresholds, max_tries=1000): """Apply a single random manipulation. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molec...
[ "def", "single_random_manipulation", "(", "molecule", ",", "manipulations", ",", "nonbond_thresholds", ",", "max_tries", "=", "1000", ")", ":", "for", "m", "in", "range", "(", "max_tries", ")", ":", "random_molecule", ",", "transformation", "=", "single_random_man...
Apply a single random manipulation. If no randomized molecule can be generated that survives the nonbond check after max_tries repetitions, None is returned. In case of success, the randomized molecule and the corresponding transformation is returned. The original molecule is not altered.
[ "Apply", "a", "single", "random", "manipulation", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L378-L390
train
molmod/molmod
molmod/randomize.py
single_random_manipulation_low
def single_random_manipulation_low(molecule, manipulations): """Return a randomized copy of the molecule, without the nonbond check.""" manipulation = sample(manipulations, 1)[0] coordinates = molecule.coordinates.copy() transformation = manipulation.apply(coordinates) return molecule.copy_with(coo...
python
def single_random_manipulation_low(molecule, manipulations): """Return a randomized copy of the molecule, without the nonbond check.""" manipulation = sample(manipulations, 1)[0] coordinates = molecule.coordinates.copy() transformation = manipulation.apply(coordinates) return molecule.copy_with(coo...
[ "def", "single_random_manipulation_low", "(", "molecule", ",", "manipulations", ")", ":", "manipulation", "=", "sample", "(", "manipulations", ",", "1", ")", "[", "0", "]", "coordinates", "=", "molecule", ".", "coordinates", ".", "copy", "(", ")", "transformat...
Return a randomized copy of the molecule, without the nonbond check.
[ "Return", "a", "randomized", "copy", "of", "the", "molecule", "without", "the", "nonbond", "check", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L393-L399
train
molmod/molmod
molmod/randomize.py
random_dimer
def random_dimer(molecule0, molecule1, thresholds, shoot_max): """Create a random dimer. molecule0 and molecule1 are placed in one reference frame at random relative positions. Interatomic distances are above the thresholds. Initially a dimer is created where one interatomic distance approxima...
python
def random_dimer(molecule0, molecule1, thresholds, shoot_max): """Create a random dimer. molecule0 and molecule1 are placed in one reference frame at random relative positions. Interatomic distances are above the thresholds. Initially a dimer is created where one interatomic distance approxima...
[ "def", "random_dimer", "(", "molecule0", ",", "molecule1", ",", "thresholds", ",", "shoot_max", ")", ":", "# apply a random rotation to molecule1", "center", "=", "np", ".", "zeros", "(", "3", ",", "float", ")", "angle", "=", "np", ".", "random", ".", "unifo...
Create a random dimer. molecule0 and molecule1 are placed in one reference frame at random relative positions. Interatomic distances are above the thresholds. Initially a dimer is created where one interatomic distance approximates the threshold value. Then the molecules are given an additi...
[ "Create", "a", "random", "dimer", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L402-L468
train
molmod/molmod
molmod/randomize.py
MolecularDistortion.read_from_file
def read_from_file(cls, filename): """Construct a MolecularDistortion object from a file""" with open(filename) as f: lines = list(line for line in f if line[0] != '#') r = [] t = [] for line in lines[:3]: values = list(float(word) for word in line.split()...
python
def read_from_file(cls, filename): """Construct a MolecularDistortion object from a file""" with open(filename) as f: lines = list(line for line in f if line[0] != '#') r = [] t = [] for line in lines[:3]: values = list(float(word) for word in line.split()...
[ "def", "read_from_file", "(", "cls", ",", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "lines", "=", "list", "(", "line", "for", "line", "in", "f", "if", "line", "[", "0", "]", "!=", "'#'", ")", "r", "=", "[", "]"...
Construct a MolecularDistortion object from a file
[ "Construct", "a", "MolecularDistortion", "object", "from", "a", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L60-L72
train
molmod/molmod
molmod/randomize.py
MolecularDistortion.apply
def apply(self, coordinates): """Apply this distortion to Cartesian coordinates""" for i in self.affected_atoms: coordinates[i] = self.transformation*coordinates[i]
python
def apply(self, coordinates): """Apply this distortion to Cartesian coordinates""" for i in self.affected_atoms: coordinates[i] = self.transformation*coordinates[i]
[ "def", "apply", "(", "self", ",", "coordinates", ")", ":", "for", "i", "in", "self", ".", "affected_atoms", ":", "coordinates", "[", "i", "]", "=", "self", ".", "transformation", "*", "coordinates", "[", "i", "]" ]
Apply this distortion to Cartesian coordinates
[ "Apply", "this", "distortion", "to", "Cartesian", "coordinates" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L84-L87
train
molmod/molmod
molmod/randomize.py
MolecularDistortion.write_to_file
def write_to_file(self, filename): """Write the object to a file""" r = self.transformation.r t = self.transformation.t with open(filename, "w") as f: print("# A (random) transformation of a part of a molecule:", file=f) print("# The translation vector is in atomi...
python
def write_to_file(self, filename): """Write the object to a file""" r = self.transformation.r t = self.transformation.t with open(filename, "w") as f: print("# A (random) transformation of a part of a molecule:", file=f) print("# The translation vector is in atomi...
[ "def", "write_to_file", "(", "self", ",", "filename", ")", ":", "r", "=", "self", ".", "transformation", ".", "r", "t", "=", "self", ".", "transformation", ".", "t", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "print", "(", ...
Write the object to a file
[ "Write", "the", "object", "to", "a", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L89-L101
train
molmod/molmod
molmod/randomize.py
RandomManipulation.apply
def apply(self, coordinates): """Generate, apply and return a random manipulation""" transform = self.get_transformation(coordinates) result = MolecularDistortion(self.affected_atoms, transform) result.apply(coordinates) return result
python
def apply(self, coordinates): """Generate, apply and return a random manipulation""" transform = self.get_transformation(coordinates) result = MolecularDistortion(self.affected_atoms, transform) result.apply(coordinates) return result
[ "def", "apply", "(", "self", ",", "coordinates", ")", ":", "transform", "=", "self", ".", "get_transformation", "(", "coordinates", ")", "result", "=", "MolecularDistortion", "(", "self", ".", "affected_atoms", ",", "transform", ")", "result", ".", "apply", ...
Generate, apply and return a random manipulation
[ "Generate", "apply", "and", "return", "a", "random", "manipulation" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L127-L132
train
molmod/molmod
molmod/randomize.py
RandomStretch.get_transformation
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2 = self.hinge_atoms direction = coordinates[atom1] - coordinates[atom2] direction /= np.linalg.norm(direction) direction *= np.random.uniform(-self.max_amplitude, self.max_amplitude) ...
python
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2 = self.hinge_atoms direction = coordinates[atom1] - coordinates[atom2] direction /= np.linalg.norm(direction) direction *= np.random.uniform(-self.max_amplitude, self.max_amplitude) ...
[ "def", "get_transformation", "(", "self", ",", "coordinates", ")", ":", "atom1", ",", "atom2", "=", "self", ".", "hinge_atoms", "direction", "=", "coordinates", "[", "atom1", "]", "-", "coordinates", "[", "atom2", "]", "direction", "/=", "np", ".", "linalg...
Construct a transformation object
[ "Construct", "a", "transformation", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L143-L150
train
molmod/molmod
molmod/randomize.py
RandomTorsion.get_transformation
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2 = self.hinge_atoms center = coordinates[atom1] axis = coordinates[atom1] - coordinates[atom2] axis /= np.linalg.norm(axis) angle = np.random.uniform(-self.max_amplitude, self.m...
python
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2 = self.hinge_atoms center = coordinates[atom1] axis = coordinates[atom1] - coordinates[atom2] axis /= np.linalg.norm(axis) angle = np.random.uniform(-self.max_amplitude, self.m...
[ "def", "get_transformation", "(", "self", ",", "coordinates", ")", ":", "atom1", ",", "atom2", "=", "self", ".", "hinge_atoms", "center", "=", "coordinates", "[", "atom1", "]", "axis", "=", "coordinates", "[", "atom1", "]", "-", "coordinates", "[", "atom2"...
Construct a transformation object
[ "Construct", "a", "transformation", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L157-L164
train
molmod/molmod
molmod/randomize.py
RandomBend.get_transformation
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2, atom3 = self.hinge_atoms center = coordinates[atom2] a = coordinates[atom1] - coordinates[atom2] b = coordinates[atom3] - coordinates[atom2] axis = np.cross(a, b) norm...
python
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2, atom3 = self.hinge_atoms center = coordinates[atom2] a = coordinates[atom1] - coordinates[atom2] b = coordinates[atom3] - coordinates[atom2] axis = np.cross(a, b) norm...
[ "def", "get_transformation", "(", "self", ",", "coordinates", ")", ":", "atom1", ",", "atom2", ",", "atom3", "=", "self", ".", "hinge_atoms", "center", "=", "coordinates", "[", "atom2", "]", "a", "=", "coordinates", "[", "atom1", "]", "-", "coordinates", ...
Construct a transformation object
[ "Construct", "a", "transformation", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L171-L185
train
molmod/molmod
molmod/randomize.py
RandomDoubleStretch.get_transformation
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2, atom3, atom4 = self.hinge_atoms a = coordinates[atom1] - coordinates[atom2] a /= np.linalg.norm(a) b = coordinates[atom3] - coordinates[atom4] b /= np.linalg.norm(b) d...
python
def get_transformation(self, coordinates): """Construct a transformation object""" atom1, atom2, atom3, atom4 = self.hinge_atoms a = coordinates[atom1] - coordinates[atom2] a /= np.linalg.norm(a) b = coordinates[atom3] - coordinates[atom4] b /= np.linalg.norm(b) d...
[ "def", "get_transformation", "(", "self", ",", "coordinates", ")", ":", "atom1", ",", "atom2", ",", "atom3", ",", "atom4", "=", "self", ".", "hinge_atoms", "a", "=", "coordinates", "[", "atom1", "]", "-", "coordinates", "[", "atom2", "]", "a", "/=", "n...
Construct a transformation object
[ "Construct", "a", "transformation", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L192-L202
train
molmod/molmod
molmod/binning.py
Binning.iter_surrounding
def iter_surrounding(self, center_key): """Iterate over all bins surrounding the given bin""" for shift in self.neighbor_indexes: key = tuple(np.add(center_key, shift).astype(int)) if self.integer_cell is not None: key = self.wrap_key(key) bin = self._...
python
def iter_surrounding(self, center_key): """Iterate over all bins surrounding the given bin""" for shift in self.neighbor_indexes: key = tuple(np.add(center_key, shift).astype(int)) if self.integer_cell is not None: key = self.wrap_key(key) bin = self._...
[ "def", "iter_surrounding", "(", "self", ",", "center_key", ")", ":", "for", "shift", "in", "self", ".", "neighbor_indexes", ":", "key", "=", "tuple", "(", "np", ".", "add", "(", "center_key", ",", "shift", ")", ".", "astype", "(", "int", ")", ")", "i...
Iterate over all bins surrounding the given bin
[ "Iterate", "over", "all", "bins", "surrounding", "the", "given", "bin" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L94-L102
train
molmod/molmod
molmod/binning.py
Binning.wrap_key
def wrap_key(self, key): """Translate the key into the central cell This method is only applicable in case of a periodic system. """ return tuple(np.round( self.integer_cell.shortest_vector(key) ).astype(int))
python
def wrap_key(self, key): """Translate the key into the central cell This method is only applicable in case of a periodic system. """ return tuple(np.round( self.integer_cell.shortest_vector(key) ).astype(int))
[ "def", "wrap_key", "(", "self", ",", "key", ")", ":", "return", "tuple", "(", "np", ".", "round", "(", "self", ".", "integer_cell", ".", "shortest_vector", "(", "key", ")", ")", ".", "astype", "(", "int", ")", ")" ]
Translate the key into the central cell This method is only applicable in case of a periodic system.
[ "Translate", "the", "key", "into", "the", "central", "cell" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L104-L111
train
molmod/molmod
molmod/binning.py
PairSearchBase._setup_grid
def _setup_grid(self, cutoff, unit_cell, grid): """Choose a proper grid for the binning process""" if grid is None: # automatically choose a decent grid if unit_cell is None: grid = cutoff/2.9 else: # The following would be faster, but ...
python
def _setup_grid(self, cutoff, unit_cell, grid): """Choose a proper grid for the binning process""" if grid is None: # automatically choose a decent grid if unit_cell is None: grid = cutoff/2.9 else: # The following would be faster, but ...
[ "def", "_setup_grid", "(", "self", ",", "cutoff", ",", "unit_cell", ",", "grid", ")", ":", "if", "grid", "is", "None", ":", "# automatically choose a decent grid", "if", "unit_cell", "is", "None", ":", "grid", "=", "cutoff", "/", "2.9", "else", ":", "# The...
Choose a proper grid for the binning process
[ "Choose", "a", "proper", "grid", "for", "the", "binning", "process" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L116-L152
train
molmod/molmod
molmod/units.py
parse_unit
def parse_unit(expression): """Evaluate a python expression string containing constants Argument: | ``expression`` -- A string containing a numerical expressions including unit conversions. In addition to the variables in this module, also the following ...
python
def parse_unit(expression): """Evaluate a python expression string containing constants Argument: | ``expression`` -- A string containing a numerical expressions including unit conversions. In addition to the variables in this module, also the following ...
[ "def", "parse_unit", "(", "expression", ")", ":", "try", ":", "g", "=", "globals", "(", ")", "g", ".", "update", "(", "shorthands", ")", "return", "float", "(", "eval", "(", "str", "(", "expression", ")", ",", "g", ")", ")", "except", ":", "raise",...
Evaluate a python expression string containing constants Argument: | ``expression`` -- A string containing a numerical expressions including unit conversions. In addition to the variables in this module, also the following shorthands are supported:
[ "Evaluate", "a", "python", "expression", "string", "containing", "constants" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/units.py#L66-L82
train
thavel/synolopy
synolopy/cgi.py
PathElement.parents
def parents(self): """ Returns an simple FIFO queue with the ancestors and itself. """ q = self.__parent__.parents() q.put(self) return q
python
def parents(self): """ Returns an simple FIFO queue with the ancestors and itself. """ q = self.__parent__.parents() q.put(self) return q
[ "def", "parents", "(", "self", ")", ":", "q", "=", "self", ".", "__parent__", ".", "parents", "(", ")", "q", ".", "put", "(", "self", ")", "return", "q" ]
Returns an simple FIFO queue with the ancestors and itself.
[ "Returns", "an", "simple", "FIFO", "queue", "with", "the", "ancestors", "and", "itself", "." ]
fdb23cdde693b13a59af9873f03b2afab35cb50e
https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L56-L62
train
thavel/synolopy
synolopy/cgi.py
PathElement.url
def url(self): """ Returns the whole URL from the base to this node. """ path = None nodes = self.parents() while not nodes.empty(): path = urljoin(path, nodes.get().path()) return path
python
def url(self): """ Returns the whole URL from the base to this node. """ path = None nodes = self.parents() while not nodes.empty(): path = urljoin(path, nodes.get().path()) return path
[ "def", "url", "(", "self", ")", ":", "path", "=", "None", "nodes", "=", "self", ".", "parents", "(", ")", "while", "not", "nodes", ".", "empty", "(", ")", ":", "path", "=", "urljoin", "(", "path", ",", "nodes", ".", "get", "(", ")", ".", "path"...
Returns the whole URL from the base to this node.
[ "Returns", "the", "whole", "URL", "from", "the", "base", "to", "this", "node", "." ]
fdb23cdde693b13a59af9873f03b2afab35cb50e
https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L70-L78
train
thavel/synolopy
synolopy/cgi.py
PathElement.auth_required
def auth_required(self): """ If any ancestor required an authentication, this node needs it too. """ if self._auth: return self._auth, self return self.__parent__.auth_required()
python
def auth_required(self): """ If any ancestor required an authentication, this node needs it too. """ if self._auth: return self._auth, self return self.__parent__.auth_required()
[ "def", "auth_required", "(", "self", ")", ":", "if", "self", ".", "_auth", ":", "return", "self", ".", "_auth", ",", "self", "return", "self", ".", "__parent__", ".", "auth_required", "(", ")" ]
If any ancestor required an authentication, this node needs it too.
[ "If", "any", "ancestor", "required", "an", "authentication", "this", "node", "needs", "it", "too", "." ]
fdb23cdde693b13a59af9873f03b2afab35cb50e
https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L80-L86
train
molmod/molmod
molmod/molecules.py
Molecule._check_graph
def _check_graph(self, graph): """the atomic numbers must match""" if graph.num_vertices != self.size: raise TypeError("The number of vertices in the graph does not " "match the length of the atomic numbers array.") # In practice these are typically the same arrays us...
python
def _check_graph(self, graph): """the atomic numbers must match""" if graph.num_vertices != self.size: raise TypeError("The number of vertices in the graph does not " "match the length of the atomic numbers array.") # In practice these are typically the same arrays us...
[ "def", "_check_graph", "(", "self", ",", "graph", ")", ":", "if", "graph", ".", "num_vertices", "!=", "self", ".", "size", ":", "raise", "TypeError", "(", "\"The number of vertices in the graph does not \"", "\"match the length of the atomic numbers array.\"", ")", "# I...
the atomic numbers must match
[ "the", "atomic", "numbers", "must", "match" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L64-L73
train
molmod/molmod
molmod/molecules.py
Molecule.from_file
def from_file(cls, filename): """Construct a molecule object read from the given file. The file format is inferred from the extensions. Currently supported formats are: ``*.cml``, ``*.fchk``, ``*.pdb``, ``*.sdf``, ``*.xyz`` If a file contains more than one molecule, only the f...
python
def from_file(cls, filename): """Construct a molecule object read from the given file. The file format is inferred from the extensions. Currently supported formats are: ``*.cml``, ``*.fchk``, ``*.pdb``, ``*.sdf``, ``*.xyz`` If a file contains more than one molecule, only the f...
[ "def", "from_file", "(", "cls", ",", "filename", ")", ":", "# TODO: many different API's to load files. brrr...", "if", "filename", ".", "endswith", "(", "\".cml\"", ")", ":", "from", "molmod", ".", "io", "import", "load_cml", "return", "load_cml", "(", "filename"...
Construct a molecule object read from the given file. The file format is inferred from the extensions. Currently supported formats are: ``*.cml``, ``*.fchk``, ``*.pdb``, ``*.sdf``, ``*.xyz`` If a file contains more than one molecule, only the first one is read. ...
[ "Construct", "a", "molecule", "object", "read", "from", "the", "given", "file", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L121-L157
train
molmod/molmod
molmod/molecules.py
Molecule.com
def com(self): """the center of mass of the molecule""" return (self.coordinates*self.masses.reshape((-1,1))).sum(axis=0)/self.mass
python
def com(self): """the center of mass of the molecule""" return (self.coordinates*self.masses.reshape((-1,1))).sum(axis=0)/self.mass
[ "def", "com", "(", "self", ")", ":", "return", "(", "self", ".", "coordinates", "*", "self", ".", "masses", ".", "reshape", "(", "(", "-", "1", ",", "1", ")", ")", ")", ".", "sum", "(", "axis", "=", "0", ")", "/", "self", ".", "mass" ]
the center of mass of the molecule
[ "the", "center", "of", "mass", "of", "the", "molecule" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L174-L176
train
molmod/molmod
molmod/molecules.py
Molecule.inertia_tensor
def inertia_tensor(self): """the intertia tensor of the molecule""" result = np.zeros((3,3), float) for i in range(self.size): r = self.coordinates[i] - self.com # the diagonal term result.ravel()[::4] += self.masses[i]*(r**2).sum() # the outer pro...
python
def inertia_tensor(self): """the intertia tensor of the molecule""" result = np.zeros((3,3), float) for i in range(self.size): r = self.coordinates[i] - self.com # the diagonal term result.ravel()[::4] += self.masses[i]*(r**2).sum() # the outer pro...
[ "def", "inertia_tensor", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "3", ",", "3", ")", ",", "float", ")", "for", "i", "in", "range", "(", "self", ".", "size", ")", ":", "r", "=", "self", ".", "coordinates", "[", "i", ...
the intertia tensor of the molecule
[ "the", "intertia", "tensor", "of", "the", "molecule" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L179-L188
train
molmod/molmod
molmod/molecules.py
Molecule.chemical_formula
def chemical_formula(self): """the chemical formula of the molecule""" counts = {} for number in self.numbers: counts[number] = counts.get(number, 0)+1 items = [] for number, count in sorted(counts.items(), reverse=True): if count == 1: ite...
python
def chemical_formula(self): """the chemical formula of the molecule""" counts = {} for number in self.numbers: counts[number] = counts.get(number, 0)+1 items = [] for number, count in sorted(counts.items(), reverse=True): if count == 1: ite...
[ "def", "chemical_formula", "(", "self", ")", ":", "counts", "=", "{", "}", "for", "number", "in", "self", ".", "numbers", ":", "counts", "[", "number", "]", "=", "counts", ".", "get", "(", "number", ",", "0", ")", "+", "1", "items", "=", "[", "]"...
the chemical formula of the molecule
[ "the", "chemical", "formula", "of", "the", "molecule" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L191-L202
train
molmod/molmod
molmod/molecules.py
Molecule.set_default_masses
def set_default_masses(self): """Set self.masses based on self.numbers and periodic table.""" self.masses = np.array([periodic[n].mass for n in self.numbers])
python
def set_default_masses(self): """Set self.masses based on self.numbers and periodic table.""" self.masses = np.array([periodic[n].mass for n in self.numbers])
[ "def", "set_default_masses", "(", "self", ")", ":", "self", ".", "masses", "=", "np", ".", "array", "(", "[", "periodic", "[", "n", "]", ".", "mass", "for", "n", "in", "self", ".", "numbers", "]", ")" ]
Set self.masses based on self.numbers and periodic table.
[ "Set", "self", ".", "masses", "based", "on", "self", ".", "numbers", "and", "periodic", "table", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L204-L206
train
molmod/molmod
molmod/molecules.py
Molecule.set_default_symbols
def set_default_symbols(self): """Set self.symbols based on self.numbers and the periodic table.""" self.symbols = tuple(periodic[n].symbol for n in self.numbers)
python
def set_default_symbols(self): """Set self.symbols based on self.numbers and the periodic table.""" self.symbols = tuple(periodic[n].symbol for n in self.numbers)
[ "def", "set_default_symbols", "(", "self", ")", ":", "self", ".", "symbols", "=", "tuple", "(", "periodic", "[", "n", "]", ".", "symbol", "for", "n", "in", "self", ".", "numbers", ")" ]
Set self.symbols based on self.numbers and the periodic table.
[ "Set", "self", ".", "symbols", "based", "on", "self", ".", "numbers", "and", "the", "periodic", "table", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L222-L224
train
molmod/molmod
molmod/molecules.py
Molecule.write_to_file
def write_to_file(self, filename): """Write the molecular geometry to a file. The file format is inferred from the extensions. Currently supported formats are: ``*.xyz``, ``*.cml`` Argument: | ``filename`` -- a filename """ # TODO: give all file f...
python
def write_to_file(self, filename): """Write the molecular geometry to a file. The file format is inferred from the extensions. Currently supported formats are: ``*.xyz``, ``*.cml`` Argument: | ``filename`` -- a filename """ # TODO: give all file f...
[ "def", "write_to_file", "(", "self", ",", "filename", ")", ":", "# TODO: give all file format writers the same API", "if", "filename", ".", "endswith", "(", "'.cml'", ")", ":", "from", "molmod", ".", "io", "import", "dump_cml", "dump_cml", "(", "filename", ",", ...
Write the molecular geometry to a file. The file format is inferred from the extensions. Currently supported formats are: ``*.xyz``, ``*.cml`` Argument: | ``filename`` -- a filename
[ "Write", "the", "molecular", "geometry", "to", "a", "file", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L226-L252
train
molmod/molmod
molmod/molecules.py
Molecule.rmsd
def rmsd(self, other): """Compute the RMSD between two molecules. Arguments: | ``other`` -- Another molecule with the same atom numbers Return values: | ``transformation`` -- the transformation that brings 'self' into overlap ...
python
def rmsd(self, other): """Compute the RMSD between two molecules. Arguments: | ``other`` -- Another molecule with the same atom numbers Return values: | ``transformation`` -- the transformation that brings 'self' into overlap ...
[ "def", "rmsd", "(", "self", ",", "other", ")", ":", "if", "self", ".", "numbers", ".", "shape", "!=", "other", ".", "numbers", ".", "shape", "or", "(", "self", ".", "numbers", "!=", "other", ".", "numbers", ")", ".", "all", "(", ")", ":", "raise"...
Compute the RMSD between two molecules. Arguments: | ``other`` -- Another molecule with the same atom numbers Return values: | ``transformation`` -- the transformation that brings 'self' into overlap with 'other' | ``other...
[ "Compute", "the", "RMSD", "between", "two", "molecules", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L254-L276
train
molmod/molmod
molmod/molecules.py
Molecule.compute_rotsym
def compute_rotsym(self, threshold=1e-3*angstrom): """Compute the rotational symmetry number. Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is considered to transform the ...
python
def compute_rotsym(self, threshold=1e-3*angstrom): """Compute the rotational symmetry number. Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is considered to transform the ...
[ "def", "compute_rotsym", "(", "self", ",", "threshold", "=", "1e-3", "*", "angstrom", ")", ":", "# Generate a graph with a more permissive threshold for bond lengths:", "# (is convenient in case of transition state geometries)", "graph", "=", "MolecularGraph", ".", "from_geometry...
Compute the rotational symmetry number. Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is considered to transform the molecule onto itself.
[ "Compute", "the", "rotational", "symmetry", "number", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L278-L292
train
molmod/molmod
molmod/io/atrj.py
SectionFile._get_current_label
def _get_current_label(self): """Get the label from the last line read""" if len(self._last) == 0: raise StopIteration return self._last[:self._last.find(":")]
python
def _get_current_label(self): """Get the label from the last line read""" if len(self._last) == 0: raise StopIteration return self._last[:self._last.find(":")]
[ "def", "_get_current_label", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_last", ")", "==", "0", ":", "raise", "StopIteration", "return", "self", ".", "_last", "[", ":", "self", ".", "_last", ".", "find", "(", "\":\"", ")", "]" ]
Get the label from the last line read
[ "Get", "the", "label", "from", "the", "last", "line", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L45-L49
train
molmod/molmod
molmod/io/atrj.py
SectionFile._skip_section
def _skip_section(self): """Skip a section""" self._last = self._f.readline() while len(self._last) > 0 and len(self._last[0].strip()) == 0: self._last = self._f.readline()
python
def _skip_section(self): """Skip a section""" self._last = self._f.readline() while len(self._last) > 0 and len(self._last[0].strip()) == 0: self._last = self._f.readline()
[ "def", "_skip_section", "(", "self", ")", ":", "self", ".", "_last", "=", "self", ".", "_f", ".", "readline", "(", ")", "while", "len", "(", "self", ".", "_last", ")", ">", "0", "and", "len", "(", "self", ".", "_last", "[", "0", "]", ".", "stri...
Skip a section
[ "Skip", "a", "section" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L51-L55
train
molmod/molmod
molmod/io/atrj.py
SectionFile._read_section
def _read_section(self): """Read and return an entire section""" lines = [self._last[self._last.find(":")+1:]] self._last = self._f.readline() while len(self._last) > 0 and len(self._last[0].strip()) == 0: lines.append(self._last) self._last = self._f.readline() ...
python
def _read_section(self): """Read and return an entire section""" lines = [self._last[self._last.find(":")+1:]] self._last = self._f.readline() while len(self._last) > 0 and len(self._last[0].strip()) == 0: lines.append(self._last) self._last = self._f.readline() ...
[ "def", "_read_section", "(", "self", ")", ":", "lines", "=", "[", "self", ".", "_last", "[", "self", ".", "_last", ".", "find", "(", "\":\"", ")", "+", "1", ":", "]", "]", "self", ".", "_last", "=", "self", ".", "_f", ".", "readline", "(", ")",...
Read and return an entire section
[ "Read", "and", "return", "an", "entire", "section" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L57-L64
train
molmod/molmod
molmod/io/atrj.py
SectionFile.get_next
def get_next(self, label): """Get the next section with the given label""" while self._get_current_label() != label: self._skip_section() return self._read_section()
python
def get_next(self, label): """Get the next section with the given label""" while self._get_current_label() != label: self._skip_section() return self._read_section()
[ "def", "get_next", "(", "self", ",", "label", ")", ":", "while", "self", ".", "_get_current_label", "(", ")", "!=", "label", ":", "self", ".", "_skip_section", "(", ")", "return", "self", ".", "_read_section", "(", ")" ]
Get the next section with the given label
[ "Get", "the", "next", "section", "with", "the", "given", "label" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L66-L70
train
molmod/molmod
molmod/io/atrj.py
ATRJReader._read_frame
def _read_frame(self): """Read a single frame from the trajectory""" self._secfile.get_next("Frame Number") frame = ATRJFrame() # Read the time and energy energy_lines = self._secfile.get_next("Time/Energy") energy_words = energy_lines[0].split() frame.time = floa...
python
def _read_frame(self): """Read a single frame from the trajectory""" self._secfile.get_next("Frame Number") frame = ATRJFrame() # Read the time and energy energy_lines = self._secfile.get_next("Time/Energy") energy_words = energy_lines[0].split() frame.time = floa...
[ "def", "_read_frame", "(", "self", ")", ":", "self", ".", "_secfile", ".", "get_next", "(", "\"Frame Number\"", ")", "frame", "=", "ATRJFrame", "(", ")", "# Read the time and energy", "energy_lines", "=", "self", ".", "_secfile", ".", "get_next", "(", "\"Time/...
Read a single frame from the trajectory
[ "Read", "a", "single", "frame", "from", "the", "trajectory" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L107-L127
train
molmod/molmod
molmod/io/cube.py
get_cube_points
def get_cube_points(origin, axes, nrep): '''Generate the Cartesian coordinates of the points in a cube file *Arguemnts:* origin The cartesian coordinate for the origin of the grid. axes The 3 by 3 array with the grid spacings as rows. nrep The numb...
python
def get_cube_points(origin, axes, nrep): '''Generate the Cartesian coordinates of the points in a cube file *Arguemnts:* origin The cartesian coordinate for the origin of the grid. axes The 3 by 3 array with the grid spacings as rows. nrep The numb...
[ "def", "get_cube_points", "(", "origin", ",", "axes", ",", "nrep", ")", ":", "points", "=", "np", ".", "zeros", "(", "(", "nrep", "[", "0", "]", ",", "nrep", "[", "1", "]", ",", "nrep", "[", "2", "]", ",", "3", ")", ",", "float", ")", "points...
Generate the Cartesian coordinates of the points in a cube file *Arguemnts:* origin The cartesian coordinate for the origin of the grid. axes The 3 by 3 array with the grid spacings as rows. nrep The number of grid points along each axis.
[ "Generate", "the", "Cartesian", "coordinates", "of", "the", "points", "in", "a", "cube", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cube.py#L37-L56
train
molmod/molmod
molmod/io/cube.py
Cube.from_file
def from_file(cls, filename): '''Create a cube object by loading data from a file. *Arguemnts:* filename The file to load. It must contain the header with the description of the grid and the molecule. ''' with open(filename) as f: ...
python
def from_file(cls, filename): '''Create a cube object by loading data from a file. *Arguemnts:* filename The file to load. It must contain the header with the description of the grid and the molecule. ''' with open(filename) as f: ...
[ "def", "from_file", "(", "cls", ",", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "molecule", ",", "origin", ",", "axes", ",", "nrep", ",", "subtitle", ",", "nuclear_charges", "=", "read_cube_header", "(", "f", ")", "data...
Create a cube object by loading data from a file. *Arguemnts:* filename The file to load. It must contain the header with the description of the grid and the molecule.
[ "Create", "a", "cube", "object", "by", "loading", "data", "from", "a", "file", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cube.py#L167-L190
train
molmod/molmod
molmod/io/cube.py
Cube.write_to_file
def write_to_file(self, fn): '''Write the cube to a file in the Gaussian cube format.''' with open(fn, 'w') as f: f.write(' {}\n'.format(self.molecule.title)) f.write(' {}\n'.format(self.subtitle)) def write_grid_line(n, v): f.write('%5i % 11.6f % 11....
python
def write_to_file(self, fn): '''Write the cube to a file in the Gaussian cube format.''' with open(fn, 'w') as f: f.write(' {}\n'.format(self.molecule.title)) f.write(' {}\n'.format(self.subtitle)) def write_grid_line(n, v): f.write('%5i % 11.6f % 11....
[ "def", "write_to_file", "(", "self", ",", "fn", ")", ":", "with", "open", "(", "fn", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "' {}\\n'", ".", "format", "(", "self", ".", "molecule", ".", "title", ")", ")", "f", ".", "write", "(...
Write the cube to a file in the Gaussian cube format.
[ "Write", "the", "cube", "to", "a", "file", "in", "the", "Gaussian", "cube", "format", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cube.py#L226-L258
train
molmod/molmod
molmod/io/cube.py
Cube.copy
def copy(self, newdata=None): '''Return a copy of the cube with optionally new data.''' if newdata is None: newdata = self.data.copy() return self.__class__( self.molecule, self.origin.copy(), self.axes.copy(), self.nrep.copy(), newdata, self.subtitle, self.nu...
python
def copy(self, newdata=None): '''Return a copy of the cube with optionally new data.''' if newdata is None: newdata = self.data.copy() return self.__class__( self.molecule, self.origin.copy(), self.axes.copy(), self.nrep.copy(), newdata, self.subtitle, self.nu...
[ "def", "copy", "(", "self", ",", "newdata", "=", "None", ")", ":", "if", "newdata", "is", "None", ":", "newdata", "=", "self", ".", "data", ".", "copy", "(", ")", "return", "self", ".", "__class__", "(", "self", ".", "molecule", ",", "self", ".", ...
Return a copy of the cube with optionally new data.
[ "Return", "a", "copy", "of", "the", "cube", "with", "optionally", "new", "data", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cube.py#L260-L267
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection._consistent
def _consistent(self): """Checks the constency between self.__index and self.__order""" if len(self.__order) != sum(len(values) for values in self.__index.values()): return False import copy tmp = copy.copy(self.__order) for key, values in self.__index.items(): ...
python
def _consistent(self): """Checks the constency between self.__index and self.__order""" if len(self.__order) != sum(len(values) for values in self.__index.values()): return False import copy tmp = copy.copy(self.__order) for key, values in self.__index.items(): ...
[ "def", "_consistent", "(", "self", ")", ":", "if", "len", "(", "self", ".", "__order", ")", "!=", "sum", "(", "len", "(", "values", ")", "for", "values", "in", "self", ".", "__index", ".", "values", "(", ")", ")", ":", "return", "False", "import", ...
Checks the constency between self.__index and self.__order
[ "Checks", "the", "constency", "between", "self", ".", "__index", "and", "self", ".", "__order" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L63-L80
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.append
def append(self, child): """Add a child section or keyword""" if not (isinstance(child, CP2KSection) or isinstance(child, CP2KKeyword)): raise TypeError("The child must be a CP2KSection or a CP2KKeyword, got: %s." % child) l = self.__index.setdefault(child.name, []) l.append(...
python
def append(self, child): """Add a child section or keyword""" if not (isinstance(child, CP2KSection) or isinstance(child, CP2KKeyword)): raise TypeError("The child must be a CP2KSection or a CP2KKeyword, got: %s." % child) l = self.__index.setdefault(child.name, []) l.append(...
[ "def", "append", "(", "self", ",", "child", ")", ":", "if", "not", "(", "isinstance", "(", "child", ",", "CP2KSection", ")", "or", "isinstance", "(", "child", ",", "CP2KKeyword", ")", ")", ":", "raise", "TypeError", "(", "\"The child must be a CP2KSection or...
Add a child section or keyword
[ "Add", "a", "child", "section", "or", "keyword" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L177-L183
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.dump_children
def dump_children(self, f, indent=''): """Dump the children of the current section to a file-like object""" for child in self.__order: child.dump(f, indent+' ')
python
def dump_children(self, f, indent=''): """Dump the children of the current section to a file-like object""" for child in self.__order: child.dump(f, indent+' ')
[ "def", "dump_children", "(", "self", ",", "f", ",", "indent", "=", "''", ")", ":", "for", "child", "in", "self", ".", "__order", ":", "child", ".", "dump", "(", "f", ",", "indent", "+", "' '", ")" ]
Dump the children of the current section to a file-like object
[ "Dump", "the", "children", "of", "the", "current", "section", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L193-L196
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.dump
def dump(self, f, indent=''): """Dump this section and its children to a file-like object""" print(("%s&%s %s" % (indent, self.__name, self.section_parameters)).rstrip(), file=f) self.dump_children(f, indent) print("%s&END %s" % (indent, self.__name), file=f)
python
def dump(self, f, indent=''): """Dump this section and its children to a file-like object""" print(("%s&%s %s" % (indent, self.__name, self.section_parameters)).rstrip(), file=f) self.dump_children(f, indent) print("%s&END %s" % (indent, self.__name), file=f)
[ "def", "dump", "(", "self", ",", "f", ",", "indent", "=", "''", ")", ":", "print", "(", "(", "\"%s&%s %s\"", "%", "(", "indent", ",", "self", ".", "__name", ",", "self", ".", "section_parameters", ")", ")", ".", "rstrip", "(", ")", ",", "file", "...
Dump this section and its children to a file-like object
[ "Dump", "this", "section", "and", "its", "children", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L198-L202
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.readline
def readline(self, f): """A helper method that only reads uncommented lines""" while True: line = f.readline() if len(line) == 0: raise EOFError line = line[:line.find('#')] line = line.strip() if len(line) > 0: ...
python
def readline(self, f): """A helper method that only reads uncommented lines""" while True: line = f.readline() if len(line) == 0: raise EOFError line = line[:line.find('#')] line = line.strip() if len(line) > 0: ...
[ "def", "readline", "(", "self", ",", "f", ")", ":", "while", "True", ":", "line", "=", "f", ".", "readline", "(", ")", "if", "len", "(", "line", ")", "==", "0", ":", "raise", "EOFError", "line", "=", "line", "[", ":", "line", ".", "find", "(", ...
A helper method that only reads uncommented lines
[ "A", "helper", "method", "that", "only", "reads", "uncommented", "lines" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L204-L213
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.load_children
def load_children(self, f): """Load the children of this section from a file-like object""" while True: line = self.readline(f) if line[0] == '&': if line[1:].startswith("END"): check_name = line[4:].strip().upper() if check...
python
def load_children(self, f): """Load the children of this section from a file-like object""" while True: line = self.readline(f) if line[0] == '&': if line[1:].startswith("END"): check_name = line[4:].strip().upper() if check...
[ "def", "load_children", "(", "self", ",", "f", ")", ":", "while", "True", ":", "line", "=", "self", ".", "readline", "(", "f", ")", "if", "line", "[", "0", "]", "==", "'&'", ":", "if", "line", "[", "1", ":", "]", ".", "startswith", "(", "\"END\...
Load the children of this section from a file-like object
[ "Load", "the", "children", "of", "this", "section", "from", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L215-L232
train
molmod/molmod
molmod/io/cp2k.py
CP2KSection.load
def load(self, f, line=None): """Load this section from a file-like object""" if line is None: # in case the file contains only a fragment of an input file, # this is useful. line = f.readlin() words = line[1:].split() self.__name = words[0].upper() ...
python
def load(self, f, line=None): """Load this section from a file-like object""" if line is None: # in case the file contains only a fragment of an input file, # this is useful. line = f.readlin() words = line[1:].split() self.__name = words[0].upper() ...
[ "def", "load", "(", "self", ",", "f", ",", "line", "=", "None", ")", ":", "if", "line", "is", "None", ":", "# in case the file contains only a fragment of an input file,", "# this is useful.", "line", "=", "f", ".", "readlin", "(", ")", "words", "=", "line", ...
Load this section from a file-like object
[ "Load", "this", "section", "from", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L235-L247
train
molmod/molmod
molmod/io/cp2k.py
CP2KKeyword.dump
def dump(self, f, indent=''): """Dump this keyword to a file-like object""" if self.__unit is None: print(("%s%s %s" % (indent, self.__name, self.__value)).rstrip(), file=f) else: print(("%s%s [%s] %s" % (indent, self.__name, self.__unit, self.__value)).rstrip(), file=f)
python
def dump(self, f, indent=''): """Dump this keyword to a file-like object""" if self.__unit is None: print(("%s%s %s" % (indent, self.__name, self.__value)).rstrip(), file=f) else: print(("%s%s [%s] %s" % (indent, self.__name, self.__unit, self.__value)).rstrip(), file=f)
[ "def", "dump", "(", "self", ",", "f", ",", "indent", "=", "''", ")", ":", "if", "self", ".", "__unit", "is", "None", ":", "print", "(", "(", "\"%s%s %s\"", "%", "(", "indent", ",", "self", ".", "__name", ",", "self", ".", "__value", ")", ")", "...
Dump this keyword to a file-like object
[ "Dump", "this", "keyword", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L273-L278
train
molmod/molmod
molmod/io/cp2k.py
CP2KKeyword.load
def load(self, line): """Load this keyword from a file-like object""" words = line.split() try: float(words[0]) self.__name = "" self.__value = " ".join(words) except ValueError: self.__name = words[0].upper() if len(words) > 2 ...
python
def load(self, line): """Load this keyword from a file-like object""" words = line.split() try: float(words[0]) self.__name = "" self.__value = " ".join(words) except ValueError: self.__name = words[0].upper() if len(words) > 2 ...
[ "def", "load", "(", "self", ",", "line", ")", ":", "words", "=", "line", ".", "split", "(", ")", "try", ":", "float", "(", "words", "[", "0", "]", ")", "self", ".", "__name", "=", "\"\"", "self", ".", "__value", "=", "\" \"", ".", "join", "(", ...
Load this keyword from a file-like object
[ "Load", "this", "keyword", "from", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L280-L293
train
molmod/molmod
molmod/io/cp2k.py
CP2KKeyword.set_value
def set_value(self, value): """Set the value associated with the keyword""" if not isinstance(value, str): raise TypeError("A value must be a string, got %s." % value) self.__value = value
python
def set_value(self, value): """Set the value associated with the keyword""" if not isinstance(value, str): raise TypeError("A value must be a string, got %s." % value) self.__value = value
[ "def", "set_value", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "raise", "TypeError", "(", "\"A value must be a string, got %s.\"", "%", "value", ")", "self", ".", "__value", "=", "value" ]
Set the value associated with the keyword
[ "Set", "the", "value", "associated", "with", "the", "keyword" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L296-L300
train
molmod/molmod
molmod/io/cp2k.py
CP2KInputFile.read_from_file
def read_from_file(filename): """ Arguments: | ``filename`` -- the filename of the input file Use as follows:: >>> if = CP2KInputFile.read_from_file("somefile.inp") >>> for section in if: ... print section.name """ ...
python
def read_from_file(filename): """ Arguments: | ``filename`` -- the filename of the input file Use as follows:: >>> if = CP2KInputFile.read_from_file("somefile.inp") >>> for section in if: ... print section.name """ ...
[ "def", "read_from_file", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "result", "=", "CP2KInputFile", "(", ")", "try", ":", "while", "True", ":", "result", ".", "load_children", "(", "f", ")", "except", "EOFError", "...
Arguments: | ``filename`` -- the filename of the input file Use as follows:: >>> if = CP2KInputFile.read_from_file("somefile.inp") >>> for section in if: ... print section.name
[ "Arguments", ":", "|", "filename", "--", "the", "filename", "of", "the", "input", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cp2k.py#L323-L341
train
molmod/molmod
molmod/io/cpmd.py
CPMDTrajectoryReader._read_frame
def _read_frame(self): """Read and return the next time frame""" pos = np.zeros((self.num_atoms, 3), float) vel = np.zeros((self.num_atoms, 3), float) for i in range(self.num_atoms): line = next(self._f) words = line.split() pos[i, 0] = float(words[1])...
python
def _read_frame(self): """Read and return the next time frame""" pos = np.zeros((self.num_atoms, 3), float) vel = np.zeros((self.num_atoms, 3), float) for i in range(self.num_atoms): line = next(self._f) words = line.split() pos[i, 0] = float(words[1])...
[ "def", "_read_frame", "(", "self", ")", ":", "pos", "=", "np", ".", "zeros", "(", "(", "self", ".", "num_atoms", ",", "3", ")", ",", "float", ")", "vel", "=", "np", ".", "zeros", "(", "(", "self", ".", "num_atoms", ",", "3", ")", ",", "float", ...
Read and return the next time frame
[ "Read", "and", "return", "the", "next", "time", "frame" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cpmd.py#L64-L77
train
molmod/molmod
molmod/transformations.py
check_matrix
def check_matrix(m): """Check the sanity of the given 4x4 transformation matrix""" if m.shape != (4, 4): raise ValueError("The argument must be a 4x4 array.") if max(abs(m[3, 0:3])) > eps: raise ValueError("The given matrix does not have correct translational part") if abs(m[3, 3] - 1.0)...
python
def check_matrix(m): """Check the sanity of the given 4x4 transformation matrix""" if m.shape != (4, 4): raise ValueError("The argument must be a 4x4 array.") if max(abs(m[3, 0:3])) > eps: raise ValueError("The given matrix does not have correct translational part") if abs(m[3, 3] - 1.0)...
[ "def", "check_matrix", "(", "m", ")", ":", "if", "m", ".", "shape", "!=", "(", "4", ",", "4", ")", ":", "raise", "ValueError", "(", "\"The argument must be a 4x4 array.\"", ")", "if", "max", "(", "abs", "(", "m", "[", "3", ",", "0", ":", "3", "]", ...
Check the sanity of the given 4x4 transformation matrix
[ "Check", "the", "sanity", "of", "the", "given", "4x4", "transformation", "matrix" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/transformations.py#L48-L55
train
molmod/molmod
molmod/transformations.py
superpose
def superpose(ras, rbs, weights=None): """Compute the transformation that minimizes the RMSD between the points ras and rbs Arguments: | ``ras`` -- a ``np.array`` with 3D coordinates of geometry A, shape=(N,3) | ``rbs`` -- a ``np.array`` with 3D coordinates of geom...
python
def superpose(ras, rbs, weights=None): """Compute the transformation that minimizes the RMSD between the points ras and rbs Arguments: | ``ras`` -- a ``np.array`` with 3D coordinates of geometry A, shape=(N,3) | ``rbs`` -- a ``np.array`` with 3D coordinates of geom...
[ "def", "superpose", "(", "ras", ",", "rbs", ",", "weights", "=", "None", ")", ":", "if", "weights", "is", "None", ":", "ma", "=", "ras", ".", "mean", "(", "axis", "=", "0", ")", "mb", "=", "rbs", ".", "mean", "(", "axis", "=", "0", ")", "else...
Compute the transformation that minimizes the RMSD between the points ras and rbs Arguments: | ``ras`` -- a ``np.array`` with 3D coordinates of geometry A, shape=(N,3) | ``rbs`` -- a ``np.array`` with 3D coordinates of geometry B, shape=(N,3) ...
[ "Compute", "the", "transformation", "that", "minimizes", "the", "RMSD", "between", "the", "points", "ras", "and", "rbs" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/transformations.py#L434-L477
train