ForceBalance API
1.3
Automated optimization of force fields and empirical potentials
|
Classes | |
class | ActuallyArcError |
class | Molecule |
Lee-Ping's general file format conversion class. More... | |
class | MolfileTimestep |
Wrapper for the timestep C structure used in molfile plugins. More... | |
class | RawStreamHandler |
Exactly like output.StreamHandler except it does no extra formatting before sending logging messages to the stream. More... | |
Functions | |
def | getElement (mass) |
def | elem_from_atomname (atomname) |
Given an atom name, attempt to get the element in most cases. More... | |
def | unmangle (M1, M2) |
Create a mapping that takes M1's atom indices to M2's atom indices based on position. More... | |
def | nodematch (node1, node2) |
def | isint (word) |
ONLY matches integers! If you have a decimal point? None shall pass! More... | |
def | isfloat (word) |
Matches ANY number; it can be a decimal, scientific notation, integer, or what have you. More... | |
def | CubicLattice (a) |
This function takes in three lattice lengths and three lattice angles, and tries to return a complete box specification. More... | |
def | BuildLatticeFromLengthsAngles (a, b, c, alpha, beta, gamma) |
This function takes in three lattice lengths and three lattice angles, and tries to return a complete box specification. More... | |
def | BuildLatticeFromVectors (v1, v2, v3) |
This function takes in three lattice vectors and tries to return a complete box specification. More... | |
def | TopEqual (mol1, mol2) |
For the nanoreactor project: Determine whether two Molecule objects have the same topologies. More... | |
def | MolEqual (mol1, mol2) |
Determine whether two Molecule objects have the same fragments by looking at elements and connectivity graphs. More... | |
def | format_xyz_coord (element, xyz, tinker=False) |
Print a line consisting of (element, x, y, z) in accordance with .xyz file format. More... | |
def | format_gro_coord (resid, resname, aname, seqno, xyz) |
Print a line in accordance with .gro file format, with six decimal points of precision. More... | |
def | format_xyzgen_coord (element, xyzgen) |
Print a line consisting of (element, p, q, r, s, t, ...) where (p, q, r) are arbitrary atom-wise data (this might happen, for instance, with atomic charges) More... | |
def | format_gro_box (box) |
Print a line corresponding to the box vector in accordance with .gro file format. More... | |
def | is_gro_coord (line) |
Determines whether a line contains GROMACS data or not. More... | |
def | is_charmm_coord (line) |
Determines whether a line contains CHARMM data or not. More... | |
def | is_gro_box (line) |
Determines whether a line contains a GROMACS box vector or not. More... | |
def | add_strip_to_mat (mat, strip) |
def | pvec (vec) |
def | grouper (n, iterable) |
Groups a big long iterable into groups of ten or what have you. More... | |
def | even_list (totlen, splitsize) |
Creates a list of number sequences divided as evenly as possible. More... | |
def | both (A, B, key) |
def | diff (A, B, key) |
def | either (A, B, key) |
def | EulerMatrix (T1, T2, T3) |
Constructs an Euler matrix from three Euler angles. More... | |
def | ComputeOverlap (theta, elem, xyz1, xyz2) |
Computes an 'overlap' between two molecules based on some fictitious density. More... | |
def | AlignToDensity (elem, xyz1, xyz2, binary=False) |
Computes a "overlap density" from two frames. More... | |
def | AlignToMoments (elem, xyz1, xyz2=None) |
Pre-aligns molecules to 'moment of inertia'. More... | |
def | get_rotate_translate (matrix1, matrix2) |
def | cartesian_product2 (arrays) |
Form a Cartesian product of two NumPy arrays. More... | |
def | extract_int (arr, avgthre, limthre, label="value", verbose=True) |
Get the representative integer value from an array. More... | |
def | extract_pop (M, verbose=True) |
Extract our best estimate of charge and spin-z from the comments section of a Molecule object created with Nanoreactor. More... | |
def | arc (Mol, begin=None, end=None, RMSD=True, align=True) |
Get the arc-length for a trajectory segment. More... | |
def | EqualSpacing (Mol, frames=0, dx=0, RMSD=True, align=True) |
Equalize the spacing of frames in a trajectory with linear interpolation. More... | |
def | AtomContact (xyz, pairs, box=None, displace=False) |
Compute distances between pairs of atoms. More... | |
def | form_rot (q) |
Given a quaternion p, form a rotation matrix from it. More... | |
def | axis_angle (axis, angle) |
Given a rotation axis and angle, return the corresponding 3x3 rotation matrix, which will rotate a (Nx3) array of xyz coordinates as x0_rot = np.dot(R, x0.T).T. More... | |
def | main () |
Variables | |
input = raw_input | |
dictionary | FrameVariableNames |
dictionary | AtomVariableNames |
dictionary | MetaVariableNames |
dictionary | QuantumVariableNames = {'qcrems', 'qctemplate', 'charge', 'mult', 'qcsuf', 'qm_ghost', 'qm_bondorder'} |
dictionary | AllVariableNames = QuantumVariableNames | AtomVariableNames | MetaVariableNames | FrameVariableNames |
string | package = "ForceBalance" |
logger = getLogger("MoleculeLogger") | |
handler = RawStreamHandler() | |
module_name = __name__.replace('.molecule','') | |
list | Radii |
list | Elements |
PeriodicTable | |
bool | have_dcdlib = False |
float | bohr2ang = 0.529177210 |
One bohr equals this many angstroms. More... | |
splitter = re.compile(r'(\s+|\S+)') | |
Box = namedtuple('Box',['a','b','c','alpha','beta','gamma','A','B','C','V']) | |
int | radian = 180. / np.pi |
Alive | |
def src.molecule.add_strip_to_mat | ( | mat, | |
strip | |||
) |
Definition at line 647 of file molecule.py.
def src.molecule.AlignToDensity | ( | elem, | |
xyz1, | |||
xyz2, | |||
binary = False |
|||
) |
Computes a "overlap density" from two frames.
This function can be called by AlignToMoments to get rid of inversion problems
Definition at line 753 of file molecule.py.
def src.molecule.AlignToMoments | ( | elem, | |
xyz1, | |||
xyz2 = None |
|||
) |
Pre-aligns molecules to 'moment of inertia'.
If xyz2 is passed in, it will assume that xyz1 is already aligned to the moment of inertia, and it simply does 180-degree rotations to make sure nothing is inverted.
Definition at line 765 of file molecule.py.
def src.molecule.arc | ( | Mol, | |
begin = None , |
|||
end = None , |
|||
RMSD = True , |
|||
align = True |
|||
) |
Get the arc-length for a trajectory segment.
Uses RMSD or maximum displacement of any atom in the trajectory.
Mol : Molecule Molecule object for calculating the arc length. begin : int Starting frame, defaults to first frame end : int Ending frame, defaults to final frame RMSD : bool Set to True to use frame-to-frame RMSD; otherwise use the maximum displacement of any atom
Arc : np.ndarray Arc length between frames in Angstrom, length is n_frames - 1
Definition at line 956 of file molecule.py.
def src.molecule.AtomContact | ( | xyz, | |
pairs, | |||
box = None , |
|||
displace = False |
|||
) |
Compute distances between pairs of atoms.
xyz : np.ndarray N_frames*N_atoms*3 (3D) array of atomic positions If you only have a single set of positions, pass in xyz[np.newaxis, :] pairs : list List of 2-tuples of atom indices box : np.ndarray, optional N_frames*3 (2D) array of periodic box vectors If you only have a single set of positions, pass in box[np.newaxis, :] displace : bool If True, also return N_frames*N_pairs*3 array of displacement vectors
np.ndarray N_pairs*N_frames (2D) array of minimum image convention distances np.ndarray (optional) if displace=True, N_frames*N_pairs*3 array of displacement vectors
Definition at line 1045 of file molecule.py.
def src.molecule.axis_angle | ( | axis, | |
angle | |||
) |
Given a rotation axis and angle, return the corresponding 3x3 rotation matrix, which will rotate a (Nx3) array of xyz coordinates as x0_rot = np.dot(R, x0.T).T.
axis : numpy.ndarray 1D array with 3 elements representing the rotation axis angle : float The angle of the rotation
numpy.array 3x3 rotation matrix
Definition at line 1133 of file molecule.py.
def src.molecule.both | ( | A, | |
B, | |||
key | |||
) |
Definition at line 685 of file molecule.py.
def src.molecule.BuildLatticeFromLengthsAngles | ( | a, | |
b, | |||
c, | |||
alpha, | |||
beta, | |||
gamma | |||
) |
This function takes in three lattice lengths and three lattice angles, and tries to return a complete box specification.
Definition at line 437 of file molecule.py.
def src.molecule.BuildLatticeFromVectors | ( | v1, | |
v2, | |||
v3 | |||
) |
This function takes in three lattice vectors and tries to return a complete box specification.
The hash function is something we can use to discard two things that are obviously not equal. Here we neglect the hash. Return a list of the sorted atom numbers in this graph. Return a string of atoms, which serves as a rudimentary 'fingerprint' : '99,100,103,151' . Return an array of the elements. For instance ['H' 'C' 'C' 'H']. Create an Empirical Formula Get a list of the coordinates.
Definition at line 452 of file molecule.py.
def src.molecule.cartesian_product2 | ( | arrays | ) |
Form a Cartesian product of two NumPy arrays.
Definition at line 824 of file molecule.py.
def src.molecule.ComputeOverlap | ( | theta, | |
elem, | |||
xyz1, | |||
xyz2 | |||
) |
Computes an 'overlap' between two molecules based on some fictitious density.
Good for fine-tuning alignment but gets stuck in local minima.
Definition at line 736 of file molecule.py.
def src.molecule.CubicLattice | ( | a | ) |
This function takes in three lattice lengths and three lattice angles, and tries to return a complete box specification.
Definition at line 417 of file molecule.py.
def src.molecule.diff | ( | A, | |
B, | |||
key | |||
) |
Definition at line 688 of file molecule.py.
def src.molecule.either | ( | A, | |
B, | |||
key | |||
) |
Definition at line 699 of file molecule.py.
def src.molecule.elem_from_atomname | ( | atomname | ) |
Given an atom name, attempt to get the element in most cases.
Definition at line 298 of file molecule.py.
def src.molecule.EqualSpacing | ( | Mol, | |
frames = 0 , |
|||
dx = 0 , |
|||
RMSD = True , |
|||
align = True |
|||
) |
Equalize the spacing of frames in a trajectory with linear interpolation.
This is done in a very simple way, first calculating the arc length between frames, then creating an equally spaced array, and interpolating all Cartesian coordinates along this equally spaced array.
This is intended to be used on trajectories with smooth transformations and ensures that concatenated frames containing both optimization coordinates and dynamics trajectories don't have sudden changes in their derivatives.
Mol : Molecule Molecule object for equalizing the spacing. frames : int Return a Molecule object with this number of frames. RMSD : bool Use RMSD in the arc length calculation.
Mol1 : Molecule New molecule object, either the same one (if frames > len(Mol)) or with equally spaced frames.
Definition at line 995 of file molecule.py.
def src.molecule.EulerMatrix | ( | T1, | |
T2, | |||
T3 | |||
) |
Constructs an Euler matrix from three Euler angles.
Definition at line 708 of file molecule.py.
def src.molecule.even_list | ( | totlen, | |
splitsize | |||
) |
Creates a list of number sequences divided as evenly as possible.
Definition at line 667 of file molecule.py.
def src.molecule.extract_int | ( | arr, | |
avgthre, | |||
limthre, | |||
label = "value" , |
|||
verbose = True |
|||
) |
Get the representative integer value from an array.
The integer value is the rounded mean. Perform sanity checks to ensure the array isn't overly "non-integer".
arr : numpy.ndarray NumPy array containing a series of floating point values where we'd like to extract the representative integer value. avgthre : float If the average deviates from the closest integer by more than this amount, do not pass. limthre : float If any element in this array deviates from the closest integer by more than this amount, do not pass. label : str Descriptive name of this variable, used only in printout. verbose : bool Print information in case array makes excursions larger than the threshold
int Representative integer value for the array. passed : bool Indicates whether the array mean and/or maximum deviations stayed with the thresholds.
Definition at line 860 of file molecule.py.
def src.molecule.extract_pop | ( | M, | |
verbose = True |
|||
) |
Extract our best estimate of charge and spin-z from the comments section of a Molecule object created with Nanoreactor.
Note that spin-z is 1.0 if there is one unpaired electron (not one/half) because the unit is in terms of populations.
This function is intended to work on atoms that are extracted from an ab initio MD trajectory, where the Mulliken charge and spin populations are not exactly integers. It attempts to return the closest integer but it will sometimes fail.
If the number of electrons and spin-z are inconsistent, then return -999,-999 (indicates failure).
Parameters ---------- M : Molecule Molecule object that we're getting charge and spin from, with a known comment syntax Reaction: formula CHO -> CO+H atoms ['0-2'] -> ['0-1','2'] frame 219482 charge -0.742 sz +0.000 sz^2 0.000 Returns ------- chg : int Representative integer net charge of this Molecule, or -999 if inconsistent spn : int Representative integer spin-z of this Molecule (one unpaired electron: sz=1), or -999 if inconsistent
Definition at line 906 of file molecule.py.
def src.molecule.form_rot | ( | q | ) |
Given a quaternion p, form a rotation matrix from it.
q : numpy.ndarray 1D array with 3 elements representing the rotation quaterion. Elements of quaternion are : [cos(a/2), sin(a/2)*axis[0..2]]
numpy.array 3x3 rotation matrix
Definition at line 1093 of file molecule.py.
def src.molecule.format_gro_box | ( | box | ) |
Print a line corresponding to the box vector in accordance with .gro file format.
[in] | box | Box NamedTuple |
Definition at line 598 of file molecule.py.
def src.molecule.format_gro_coord | ( | resid, | |
resname, | |||
aname, | |||
seqno, | |||
xyz | |||
) |
Print a line in accordance with .gro file format, with six decimal points of precision.
Nine decimal points of precision are necessary to get forces below 1e-3 kJ/mol/nm.
[in] | resid | The number of the residue that the atom belongs to |
[in] | resname | The name of the residue that the atom belongs to |
[in] | aname | The name of the atom |
[in] | seqno | The sequential number of the atom |
[in] | xyz | A 3-element array containing x, y, z coordinates of that atom |
Definition at line 577 of file molecule.py.
def src.molecule.format_xyz_coord | ( | element, | |
xyz, | |||
tinker = False |
|||
) |
Print a line consisting of (element, x, y, z) in accordance with .xyz file format.
[in] | element | A chemical element of a single atom |
[in] | xyz | A 3-element array containing x, y, z coordinates of that atom |
Definition at line 546 of file molecule.py.
def src.molecule.format_xyzgen_coord | ( | element, | |
xyzgen | |||
) |
Print a line consisting of (element, p, q, r, s, t, ...) where (p, q, r) are arbitrary atom-wise data (this might happen, for instance, with atomic charges)
[in] | element | A chemical element of a single atom |
[in] | xyzgen | A N-element array containing data for that atom |
Definition at line 589 of file molecule.py.
def src.molecule.get_rotate_translate | ( | matrix1, | |
matrix2 | |||
) |
Definition at line 788 of file molecule.py.
def src.molecule.getElement | ( | mass | ) |
Definition at line 293 of file molecule.py.
def src.molecule.grouper | ( | n, | |
iterable | |||
) |
Groups a big long iterable into groups of ten or what have you.
Definition at line 661 of file molecule.py.
def src.molecule.is_charmm_coord | ( | line | ) |
Determines whether a line contains CHARMM data or not.
[in] | line | The line to be tested |
Definition at line 625 of file molecule.py.
def src.molecule.is_gro_box | ( | line | ) |
Determines whether a line contains a GROMACS box vector or not.
[in] | line | The line to be tested |
Definition at line 638 of file molecule.py.
def src.molecule.is_gro_coord | ( | line | ) |
Determines whether a line contains GROMACS data or not.
[in] | line | The line to be tested |
Definition at line 610 of file molecule.py.
def src.molecule.isfloat | ( | word | ) |
Matches ANY number; it can be a decimal, scientific notation, integer, or what have you.
Definition at line 406 of file molecule.py.
def src.molecule.isint | ( | word | ) |
ONLY matches integers! If you have a decimal point? None shall pass!
Definition at line 401 of file molecule.py.
def src.molecule.main | ( | ) |
Definition at line 4663 of file molecule.py.
def src.molecule.MolEqual | ( | mol1, | |
mol2 | |||
) |
Determine whether two Molecule objects have the same fragments by looking at elements and connectivity graphs.
This is less strict than TopEqual (i.e. more often returns True).
Definition at line 534 of file molecule.py.
def src.molecule.nodematch | ( | node1, | |
node2 | |||
) |
Definition at line 395 of file molecule.py.
def src.molecule.pvec | ( | vec | ) |
Definition at line 656 of file molecule.py.
def src.molecule.TopEqual | ( | mol1, | |
mol2 | |||
) |
For the nanoreactor project: Determine whether two Molecule objects have the same topologies.
Definition at line 521 of file molecule.py.
def src.molecule.unmangle | ( | M1, | |
M2 | |||
) |
Create a mapping that takes M1's atom indices to M2's atom indices based on position.
If we start with atoms in molecule "PDB", and the new molecule "M" contains re-numbered atoms, then this code works:
M.elem = list(np.array(PDB.elem)[unmangled])
Definition at line 380 of file molecule.py.
src.molecule.Alive |
Definition at line 481 of file molecule.py.
dictionary src.molecule.AllVariableNames = QuantumVariableNames | AtomVariableNames | MetaVariableNames | FrameVariableNames |
Definition at line 180 of file molecule.py.
dictionary src.molecule.AtomVariableNames |
Definition at line 161 of file molecule.py.
float src.molecule.bohr2ang = 0.529177210 |
One bohr equals this many angstroms.
Definition at line 369 of file molecule.py.
src.molecule.Box = namedtuple('Box',['a','b','c','alpha','beta','gamma','A','B','C','V']) |
Definition at line 413 of file molecule.py.
list src.molecule.Elements |
Definition at line 240 of file molecule.py.
dictionary src.molecule.FrameVariableNames |
Definition at line 145 of file molecule.py.
src.molecule.handler = RawStreamHandler() |
Definition at line 215 of file molecule.py.
bool src.molecule.have_dcdlib = False |
Definition at line 307 of file molecule.py.
src.molecule.input = raw_input |
Definition at line 31 of file molecule.py.
src.molecule.logger = getLogger("MoleculeLogger") |
Definition at line 213 of file molecule.py.
dictionary src.molecule.MetaVariableNames |
Definition at line 175 of file molecule.py.
src.molecule.module_name = __name__.replace('.molecule','') |
Definition at line 222 of file molecule.py.
string src.molecule.package = "ForceBalance" |
Definition at line 189 of file molecule.py.
src.molecule.PeriodicTable |
Definition at line 261 of file molecule.py.
dictionary src.molecule.QuantumVariableNames = {'qcrems', 'qctemplate', 'charge', 'mult', 'qcsuf', 'qm_ghost', 'qm_bondorder'} |
Definition at line 178 of file molecule.py.
int src.molecule.radian = 180. / np.pi |
Definition at line 414 of file molecule.py.
list src.molecule.Radii |
Definition at line 225 of file molecule.py.
src.molecule.splitter = re.compile(r'(\s+|\S+)') |
Definition at line 410 of file molecule.py.