repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
molmod/molmod | molmod/io/cml.py | CMLMoleculeLoader._get_extra | def _get_extra(self, attrs, exclude):
"""Read the extra properties, taking into account an exclude list"""
result = {}
for key in attrs.getNames():
if key not in exclude:
result[str(key)] = str(attrs[key])
return result | python | def _get_extra(self, attrs, exclude):
"""Read the extra properties, taking into account an exclude list"""
result = {}
for key in attrs.getNames():
if key not in exclude:
result[str(key)] = str(attrs[key])
return result | [
"def",
"_get_extra",
"(",
"self",
",",
"attrs",
",",
"exclude",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"attrs",
".",
"getNames",
"(",
")",
":",
"if",
"key",
"not",
"in",
"exclude",
":",
"result",
"[",
"str",
"(",
"key",
")",
"]",
... | Read the extra properties, taking into account an exclude list | [
"Read",
"the",
"extra",
"properties",
"taking",
"into",
"account",
"an",
"exclude",
"list"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L62-L68 |
molmod/molmod | molmod/io/fchk.py | FCHKFile._read | def _read(self, filename, field_labels=None):
"""Read all the requested fields
Arguments:
| ``filename`` -- the filename of the FCHK file
| ``field_labels`` -- when given, only these fields are read
"""
# if fields is None, all fields are read
def ... | python | def _read(self, filename, field_labels=None):
"""Read all the requested fields
Arguments:
| ``filename`` -- the filename of the FCHK file
| ``field_labels`` -- when given, only these fields are read
"""
# if fields is None, all fields are read
def ... | [
"def",
"_read",
"(",
"self",
",",
"filename",
",",
"field_labels",
"=",
"None",
")",
":",
"# if fields is None, all fields are read",
"def",
"read_field",
"(",
"f",
")",
":",
"\"\"\"Read a single field\"\"\"",
"datatype",
"=",
"None",
"while",
"datatype",
"is",
"N... | Read all the requested fields
Arguments:
| ``filename`` -- the filename of the FCHK file
| ``field_labels`` -- when given, only these fields are read | [
"Read",
"all",
"the",
"requested",
"fields"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L73-L156 |
molmod/molmod | molmod/io/fchk.py | FCHKFile._analyze | def _analyze(self):
"""Convert a few elementary fields into a molecule object"""
if ("Atomic numbers" in self.fields) and ("Current cartesian coordinates" in self.fields):
self.molecule = Molecule(
self.fields["Atomic numbers"],
np.reshape(self.fields["Current... | python | def _analyze(self):
"""Convert a few elementary fields into a molecule object"""
if ("Atomic numbers" in self.fields) and ("Current cartesian coordinates" in self.fields):
self.molecule = Molecule(
self.fields["Atomic numbers"],
np.reshape(self.fields["Current... | [
"def",
"_analyze",
"(",
"self",
")",
":",
"if",
"(",
"\"Atomic numbers\"",
"in",
"self",
".",
"fields",
")",
"and",
"(",
"\"Current cartesian coordinates\"",
"in",
"self",
".",
"fields",
")",
":",
"self",
".",
"molecule",
"=",
"Molecule",
"(",
"self",
".",... | Convert a few elementary fields into a molecule object | [
"Convert",
"a",
"few",
"elementary",
"fields",
"into",
"a",
"molecule",
"object"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L158-L165 |
molmod/molmod | molmod/io/fchk.py | FCHKFile.get_optimization_coordinates | def get_optimization_coordinates(self):
"""Return the coordinates of the geometries at each point in the optimization"""
coor_array = self.fields.get("Opt point 1 Geometries")
if coor_array is None:
return []
else:
return np.reshape(coor_array, (-1, len(self... | python | def get_optimization_coordinates(self):
"""Return the coordinates of the geometries at each point in the optimization"""
coor_array = self.fields.get("Opt point 1 Geometries")
if coor_array is None:
return []
else:
return np.reshape(coor_array, (-1, len(self... | [
"def",
"get_optimization_coordinates",
"(",
"self",
")",
":",
"coor_array",
"=",
"self",
".",
"fields",
".",
"get",
"(",
"\"Opt point 1 Geometries\"",
")",
"if",
"coor_array",
"is",
"None",
":",
"return",
"[",
"]",
"else",
":",
"return",
"np",
".",
"re... | Return the coordinates of the geometries at each point in the optimization | [
"Return",
"the",
"coordinates",
"of",
"the",
"geometries",
"at",
"each",
"point",
"in",
"the",
"optimization"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L179-L185 |
molmod/molmod | molmod/io/fchk.py | FCHKFile.get_optimized_molecule | def get_optimized_molecule(self):
"""Return a molecule object of the optimal geometry"""
opt_coor = self.get_optimization_coordinates()
if len(opt_coor) == 0:
return None
else:
return Molecule(
self.molecule.numbers,
opt_coor[-1],
... | python | def get_optimized_molecule(self):
"""Return a molecule object of the optimal geometry"""
opt_coor = self.get_optimization_coordinates()
if len(opt_coor) == 0:
return None
else:
return Molecule(
self.molecule.numbers,
opt_coor[-1],
... | [
"def",
"get_optimized_molecule",
"(",
"self",
")",
":",
"opt_coor",
"=",
"self",
".",
"get_optimization_coordinates",
"(",
")",
"if",
"len",
"(",
"opt_coor",
")",
"==",
"0",
":",
"return",
"None",
"else",
":",
"return",
"Molecule",
"(",
"self",
".",
"molec... | Return a molecule object of the optimal geometry | [
"Return",
"a",
"molecule",
"object",
"of",
"the",
"optimal",
"geometry"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L187-L196 |
molmod/molmod | molmod/io/fchk.py | FCHKFile.get_optimization_gradients | def get_optimization_gradients(self):
"""Return the energy gradients of all geometries during an optimization"""
grad_array = self.fields.get("Opt point 1 Gradient at each geome")
if grad_array is None:
return []
else:
return np.reshape(grad_array, (-1, len(... | python | def get_optimization_gradients(self):
"""Return the energy gradients of all geometries during an optimization"""
grad_array = self.fields.get("Opt point 1 Gradient at each geome")
if grad_array is None:
return []
else:
return np.reshape(grad_array, (-1, len(... | [
"def",
"get_optimization_gradients",
"(",
"self",
")",
":",
"grad_array",
"=",
"self",
".",
"fields",
".",
"get",
"(",
"\"Opt point 1 Gradient at each geome\"",
")",
"if",
"grad_array",
"is",
"None",
":",
"return",
"[",
"]",
"else",
":",
"return",
"np",
... | Return the energy gradients of all geometries during an optimization | [
"Return",
"the",
"energy",
"gradients",
"of",
"all",
"geometries",
"during",
"an",
"optimization"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L198-L204 |
molmod/molmod | molmod/io/fchk.py | FCHKFile.get_hessian | def get_hessian(self):
"""Return the hessian"""
force_const = self.fields.get("Cartesian Force Constants")
if force_const is None:
return None
N = len(self.molecule.numbers)
result = np.zeros((3*N, 3*N), float)
counter = 0
for row in range(3*N):
... | python | def get_hessian(self):
"""Return the hessian"""
force_const = self.fields.get("Cartesian Force Constants")
if force_const is None:
return None
N = len(self.molecule.numbers)
result = np.zeros((3*N, 3*N), float)
counter = 0
for row in range(3*N):
... | [
"def",
"get_hessian",
"(",
"self",
")",
":",
"force_const",
"=",
"self",
".",
"fields",
".",
"get",
"(",
"\"Cartesian Force Constants\"",
")",
"if",
"force_const",
"is",
"None",
":",
"return",
"None",
"N",
"=",
"len",
"(",
"self",
".",
"molecule",
".",
"... | Return the hessian | [
"Return",
"the",
"hessian"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L214-L226 |
molmod/molmod | molmod/utils.py | ReadOnly.copy_with | def copy_with(self, **kwargs):
"""Return a copy with (a few) changed attributes
The keyword arguments are the attributes to be replaced by new
values. All other attributes are copied (or referenced) from the
original object. This only works if the constructor takes all
... | python | def copy_with(self, **kwargs):
"""Return a copy with (a few) changed attributes
The keyword arguments are the attributes to be replaced by new
values. All other attributes are copied (or referenced) from the
original object. This only works if the constructor takes all
... | [
"def",
"copy_with",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"attrs",
"=",
"{",
"}",
"for",
"key",
",",
"descriptor",
"in",
"self",
".",
"__class__",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"descriptor",
",",
"... | Return a copy with (a few) changed attributes
The keyword arguments are the attributes to be replaced by new
values. All other attributes are copied (or referenced) from the
original object. This only works if the constructor takes all
(read-only) attributes as arguments. | [
"Return",
"a",
"copy",
"with",
"(",
"a",
"few",
")",
"changed",
"attributes"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/utils.py#L290-L306 |
molmod/molmod | molmod/io/gamess.py | PunchFile._read | def _read(self, filename):
"""Internal routine that reads all data from the punch file."""
data = {}
parsers = [
FirstDataParser(), CoordinateParser(), EnergyGradParser(),
SkipApproxHessian(), HessianParser(), MassParser(),
]
with open(filename) as f:
... | python | def _read(self, filename):
"""Internal routine that reads all data from the punch file."""
data = {}
parsers = [
FirstDataParser(), CoordinateParser(), EnergyGradParser(),
SkipApproxHessian(), HessianParser(), MassParser(),
]
with open(filename) as f:
... | [
"def",
"_read",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"{",
"}",
"parsers",
"=",
"[",
"FirstDataParser",
"(",
")",
",",
"CoordinateParser",
"(",
")",
",",
"EnergyGradParser",
"(",
")",
",",
"SkipApproxHessian",
"(",
")",
",",
"HessianParser... | Internal routine that reads all data from the punch file. | [
"Internal",
"routine",
"that",
"reads",
"all",
"data",
"from",
"the",
"punch",
"file",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L55-L75 |
molmod/molmod | molmod/io/gamess.py | FirstDataParser.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
self.used = True
data["title"] = f.readline().strip()
data["symmetry"] = f.readline().split()[0]
if data["symmetry"] != "C1":
raise NotImplementedError("Only C1 symmetry is supported.")
symbols ... | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
self.used = True
data["title"] = f.readline().strip()
data["symmetry"] = f.readline().split()[0]
if data["symmetry"] != "C1":
raise NotImplementedError("Only C1 symmetry is supported.")
symbols ... | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"self",
".",
"used",
"=",
"True",
"data",
"[",
"\"title\"",
"]",
"=",
"f",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"data",
"[",
"\"symmetry\"",
"]",
"=",
"f",
... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L117-L129 |
molmod/molmod | molmod/io/gamess.py | CoordinateParser.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
f.readline()
f.readline()
N = len(data["symbols"])
# if the data are already read before, just overwrite them
numbers = data.get("numbers")
if numbers is None:
numbers = np.zeros(N, int)... | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
f.readline()
f.readline()
N = len(data["symbols"])
# if the data are already read before, just overwrite them
numbers = data.get("numbers")
if numbers is None:
numbers = np.zeros(N, int)... | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"f",
".",
"readline",
"(",
")",
"f",
".",
"readline",
"(",
")",
"N",
"=",
"len",
"(",
"data",
"[",
"\"symbols\"",
"]",
")",
"# if the data are already read before, just overwrite t... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L140-L159 |
molmod/molmod | molmod/io/gamess.py | EnergyGradParser.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
data["energy"] = float(f.readline().split()[1])
N = len(data["symbols"])
# if the data are already read before, just overwrite them
gradient = data.get("gradient")
if gradient is None:
gradient ... | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
data["energy"] = float(f.readline().split()[1])
N = len(data["symbols"])
# if the data are already read before, just overwrite them
gradient = data.get("gradient")
if gradient is None:
gradient ... | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"data",
"[",
"\"energy\"",
"]",
"=",
"float",
"(",
"f",
".",
"readline",
"(",
")",
".",
"split",
"(",
")",
"[",
"1",
"]",
")",
"N",
"=",
"len",
"(",
"data",
"[",
"\"s... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L169-L182 |
molmod/molmod | molmod/io/gamess.py | SkipApproxHessian.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
line = f.readline()
assert(line == " $HESS\n")
while line != " $END\n":
line = f.readline() | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
line = f.readline()
assert(line == " $HESS\n")
while line != " $END\n":
line = f.readline() | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
"assert",
"(",
"line",
"==",
"\" $HESS\\n\"",
")",
"while",
"line",
"!=",
"\" $END\\n\"",
":",
"line",
"=",
"f",
".",
"readline",... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L192-L197 |
molmod/molmod | molmod/io/gamess.py | HessianParser.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
assert("hessian" not in data)
f.readline()
N = len(data["symbols"])
hessian = np.zeros((3*N, 3*N), float)
tmp = hessian.ravel()
counter = 0
while True:
line = f.readline()
... | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
assert("hessian" not in data)
f.readline()
N = len(data["symbols"])
hessian = np.zeros((3*N, 3*N), float)
tmp = hessian.ravel()
counter = 0
while True:
line = f.readline()
... | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"assert",
"(",
"\"hessian\"",
"not",
"in",
"data",
")",
"f",
".",
"readline",
"(",
")",
"N",
"=",
"len",
"(",
"data",
"[",
"\"symbols\"",
"]",
")",
"hessian",
"=",
"np",
... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L207-L223 |
molmod/molmod | molmod/io/gamess.py | MassParser.read | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
N = len(data["symbols"])
masses = np.zeros(N, float)
counter = 0
while counter < N:
words = f.readline().split()
for word in words:
masses[counter] = float(word)*amu
... | python | def read(self, line, f, data):
"""See :meth:`PunchParser.read`"""
N = len(data["symbols"])
masses = np.zeros(N, float)
counter = 0
while counter < N:
words = f.readline().split()
for word in words:
masses[counter] = float(word)*amu
... | [
"def",
"read",
"(",
"self",
",",
"line",
",",
"f",
",",
"data",
")",
":",
"N",
"=",
"len",
"(",
"data",
"[",
"\"symbols\"",
"]",
")",
"masses",
"=",
"np",
".",
"zeros",
"(",
"N",
",",
"float",
")",
"counter",
"=",
"0",
"while",
"counter",
"<",
... | See :meth:`PunchParser.read` | [
"See",
":",
"meth",
":",
"PunchParser",
".",
"read"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L233-L243 |
molmod/molmod | molmod/examples/003_internal_coordinates/c_ff_hessian.py | setup_hydrocarbon_ff | def setup_hydrocarbon_ff(graph):
"""Create a simple ForceField object for hydrocarbons based on the graph."""
# A) Define parameters.
# the bond parameters:
bond_params = {
(6, 1): 310*kcalmol/angstrom**2,
(6, 6): 220*kcalmol/angstrom**2,
}
# for every (a, b), also add (b, a)
... | python | def setup_hydrocarbon_ff(graph):
"""Create a simple ForceField object for hydrocarbons based on the graph."""
# A) Define parameters.
# the bond parameters:
bond_params = {
(6, 1): 310*kcalmol/angstrom**2,
(6, 6): 220*kcalmol/angstrom**2,
}
# for every (a, b), also add (b, a)
... | [
"def",
"setup_hydrocarbon_ff",
"(",
"graph",
")",
":",
"# A) Define parameters.",
"# the bond parameters:",
"bond_params",
"=",
"{",
"(",
"6",
",",
"1",
")",
":",
"310",
"*",
"kcalmol",
"/",
"angstrom",
"**",
"2",
",",
"(",
"6",
",",
"6",
")",
":",
"220"... | Create a simple ForceField object for hydrocarbons based on the graph. | [
"Create",
"a",
"simple",
"ForceField",
"object",
"for",
"hydrocarbons",
"based",
"on",
"the",
"graph",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L106-L144 |
molmod/molmod | molmod/examples/003_internal_coordinates/c_ff_hessian.py | HarmonicEnergyTerm.add_to_hessian | def add_to_hessian(self, coordinates, hessian):
"""Add the contributions of this energy term to the Hessian
Arguments:
| ``coordinates`` -- A numpy array with 3N Cartesian coordinates.
| ``hessian`` -- A matrix for the full Hessian to which this energy
... | python | def add_to_hessian(self, coordinates, hessian):
"""Add the contributions of this energy term to the Hessian
Arguments:
| ``coordinates`` -- A numpy array with 3N Cartesian coordinates.
| ``hessian`` -- A matrix for the full Hessian to which this energy
... | [
"def",
"add_to_hessian",
"(",
"self",
",",
"coordinates",
",",
"hessian",
")",
":",
"# Compute the derivatives of the bond stretch towards the two cartesian",
"# coordinates. The bond length is computed too, but not used.",
"q",
",",
"g",
"=",
"self",
".",
"icfn",
"(",
"coord... | Add the contributions of this energy term to the Hessian
Arguments:
| ``coordinates`` -- A numpy array with 3N Cartesian coordinates.
| ``hessian`` -- A matrix for the full Hessian to which this energy
term has to add its contribution. | [
"Add",
"the",
"contributions",
"of",
"this",
"energy",
"term",
"to",
"the",
"Hessian"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L26-L43 |
molmod/molmod | molmod/examples/003_internal_coordinates/c_ff_hessian.py | ForceField.hessian | def hessian(self, coordinates):
"""Compute the force-field Hessian for the given coordinates.
Argument:
| ``coordinates`` -- A numpy array with the Cartesian atom
coordinates, with shape (N,3).
Returns:
| ``hessian`` -- A numpy arr... | python | def hessian(self, coordinates):
"""Compute the force-field Hessian for the given coordinates.
Argument:
| ``coordinates`` -- A numpy array with the Cartesian atom
coordinates, with shape (N,3).
Returns:
| ``hessian`` -- A numpy arr... | [
"def",
"hessian",
"(",
"self",
",",
"coordinates",
")",
":",
"# N3 is 3 times the number of atoms.",
"N3",
"=",
"coordinates",
".",
"size",
"# Start with a zero hessian.",
"hessian",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"N3",
",",
"N3",
")",
",",
"float",
")"... | Compute the force-field Hessian for the given coordinates.
Argument:
| ``coordinates`` -- A numpy array with the Cartesian atom
coordinates, with shape (N,3).
Returns:
| ``hessian`` -- A numpy array with the Hessian, with shape (3*N,
... | [
"Compute",
"the",
"force",
"-",
"field",
"Hessian",
"for",
"the",
"given",
"coordinates",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L85-L103 |
molmod/molmod | molmod/symmetry.py | compute_rotsym | def compute_rotsym(molecule, graph, threshold=1e-3*angstrom):
"""Compute the rotational symmetry number
Arguments:
| ``molecule`` -- The molecule
| ``graph`` -- The corresponding bond graph
Optional argument:
| ``threshold`` -- only when a rotation results in an rmsd be... | python | def compute_rotsym(molecule, graph, threshold=1e-3*angstrom):
"""Compute the rotational symmetry number
Arguments:
| ``molecule`` -- The molecule
| ``graph`` -- The corresponding bond graph
Optional argument:
| ``threshold`` -- only when a rotation results in an rmsd be... | [
"def",
"compute_rotsym",
"(",
"molecule",
",",
"graph",
",",
"threshold",
"=",
"1e-3",
"*",
"angstrom",
")",
":",
"result",
"=",
"0",
"for",
"match",
"in",
"graph",
".",
"symmetries",
":",
"permutation",
"=",
"list",
"(",
"j",
"for",
"i",
",",
"j",
"... | Compute the rotational symmetry number
Arguments:
| ``molecule`` -- The molecule
| ``graph`` -- The corresponding bond graph
Optional argument:
| ``threshold`` -- only when a rotation results in an rmsd below the
given threshold, the rotation is... | [
"Compute",
"the",
"rotational",
"symmetry",
"number"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/symmetry.py#L33-L52 |
molmod/molmod | molmod/quaternions.py | quaternion_product | def quaternion_product(quat1, quat2):
"""Return the quaternion product of the two arguments"""
return np.array([
quat1[0]*quat2[0] - np.dot(quat1[1:], quat2[1:]),
quat1[0]*quat2[1] + quat2[0]*quat1[1] + quat1[2]*quat2[3] - quat1[3]*quat2[2],
quat1[0]*quat2[2] + quat2[0]*quat1[2] + quat1[... | python | def quaternion_product(quat1, quat2):
"""Return the quaternion product of the two arguments"""
return np.array([
quat1[0]*quat2[0] - np.dot(quat1[1:], quat2[1:]),
quat1[0]*quat2[1] + quat2[0]*quat1[1] + quat1[2]*quat2[3] - quat1[3]*quat2[2],
quat1[0]*quat2[2] + quat2[0]*quat1[2] + quat1[... | [
"def",
"quaternion_product",
"(",
"quat1",
",",
"quat2",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"quat1",
"[",
"0",
"]",
"*",
"quat2",
"[",
"0",
"]",
"-",
"np",
".",
"dot",
"(",
"quat1",
"[",
"1",
":",
"]",
",",
"quat2",
"[",
"1",
"... | Return the quaternion product of the two arguments | [
"Return",
"the",
"quaternion",
"product",
"of",
"the",
"two",
"arguments"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L40-L47 |
molmod/molmod | molmod/quaternions.py | quaternion_rotation | def quaternion_rotation(quat, vector):
"""Apply the rotation represented by the quaternion to the vector
Warning: This only works correctly for normalized quaternions.
"""
dp = np.dot(quat[1:], vector)
cos = (2*quat[0]*quat[0] - 1)
return np.array([
2 * (quat[0] * (quat[2] * vector[2... | python | def quaternion_rotation(quat, vector):
"""Apply the rotation represented by the quaternion to the vector
Warning: This only works correctly for normalized quaternions.
"""
dp = np.dot(quat[1:], vector)
cos = (2*quat[0]*quat[0] - 1)
return np.array([
2 * (quat[0] * (quat[2] * vector[2... | [
"def",
"quaternion_rotation",
"(",
"quat",
",",
"vector",
")",
":",
"dp",
"=",
"np",
".",
"dot",
"(",
"quat",
"[",
"1",
":",
"]",
",",
"vector",
")",
"cos",
"=",
"(",
"2",
"*",
"quat",
"[",
"0",
"]",
"*",
"quat",
"[",
"0",
"]",
"-",
"1",
")... | Apply the rotation represented by the quaternion to the vector
Warning: This only works correctly for normalized quaternions. | [
"Apply",
"the",
"rotation",
"represented",
"by",
"the",
"quaternion",
"to",
"the",
"vector"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L58-L69 |
molmod/molmod | molmod/quaternions.py | rotation_matrix_to_quaternion | def rotation_matrix_to_quaternion(rotation_matrix):
"""Compute the quaternion representing the rotation given by the matrix"""
invert = (np.linalg.det(rotation_matrix) < 0)
if invert:
factor = -1
else:
factor = 1
c2 = 0.25*(factor*np.trace(rotation_matrix) + 1)
if c2 < 0:
... | python | def rotation_matrix_to_quaternion(rotation_matrix):
"""Compute the quaternion representing the rotation given by the matrix"""
invert = (np.linalg.det(rotation_matrix) < 0)
if invert:
factor = -1
else:
factor = 1
c2 = 0.25*(factor*np.trace(rotation_matrix) + 1)
if c2 < 0:
... | [
"def",
"rotation_matrix_to_quaternion",
"(",
"rotation_matrix",
")",
":",
"invert",
"=",
"(",
"np",
".",
"linalg",
".",
"det",
"(",
"rotation_matrix",
")",
"<",
"0",
")",
"if",
"invert",
":",
"factor",
"=",
"-",
"1",
"else",
":",
"factor",
"=",
"1",
"c... | Compute the quaternion representing the rotation given by the matrix | [
"Compute",
"the",
"quaternion",
"representing",
"the",
"rotation",
"given",
"by",
"the",
"matrix"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L74-L98 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L101-L108 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L37-L43 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L54-L64 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L73-L80 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/vectors.py#L82-L90 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L283-L295 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L298-L314 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L590-L636 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L644-L648 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L651-L657 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L660-L663 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L666-L680 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L683-L710 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L713-L721 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L724-L744 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L747-L751 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L759-L775 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L778-L802 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L89-L95 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L97-L104 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L179-L186 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L211-L225 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L251-L275 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L61-L66 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L68-L111 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gromacs.py#L113-L120 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L62-L92 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L95-L112 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/d_dft_hessian.py#L32-L44 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L112-L141 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L71-L82 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L85-L96 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/similarity.py#L99-L109 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/chk.py#L33-L102 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/chk.py#L105-L176 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L69-L82 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L84-L147 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L149-L162 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L169-L254 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L256-L272 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L274-L325 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/psf.py#L398-L409 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L205-L213 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L216-L234 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L237-L246 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L250-L324 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L327-L350 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L353-L364 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L367-L375 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L378-L390 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L393-L399 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L402-L468 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L60-L72 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L84-L87 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L89-L101 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L127-L132 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L143-L150 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L157-L164 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L171-L185 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/randomize.py#L192-L202 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L94-L102 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L104-L111 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/binning.py#L116-L152 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/units.py#L66-L82 |
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",
"."
] | train | https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L56-L62 |
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",
"."
] | train | https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L70-L78 |
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",
"."
] | train | https://github.com/thavel/synolopy/blob/fdb23cdde693b13a59af9873f03b2afab35cb50e/synolopy/cgi.py#L80-L86 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L64-L73 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L121-L157 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L174-L176 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L179-L188 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L191-L202 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L204-L206 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L222-L224 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L226-L252 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L254-L276 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L278-L292 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/atrj.py#L45-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.