コード例 #1
0
import numpy as np

try:
    from mdtraj import trajectory
except ImportError:
    print "Download and install the mdtraj package from"
    print "https://github.com/rmcgibbo/mdtraj"
    raise

try:
    from nebterpolator.mpiutils import mpi_root
    from nebterpolator.io import XYZFile
    from nebterpolator.path_operations import smooth_internal, smooth_cartesian
except ImportError:
    print "Download and install the nebterpolator package from"
    print "https://github.com/rmcgibbo/nebterpolator"
    raise


traj = trajectory.load_dcd("pulling.dcd", "input.pdb")
atom_names = [a.element.symbol for a in traj.topology.atoms()]

traj.xyz = smooth_cartesian(traj.xyz, strength=150)
for i in range(traj.n_frames):
    traj._xyz[i] -= np.mean(traj._xyz[i], axis=0)

traj.xyz = traj.xyz[::10]
print "Saving to disk"
traj.save_dcd("smoothed.dcd", force_overwrite=True)
コード例 #2
0
ファイル: Nebterpolate.py プロジェクト: leeping/nanoreactor
                  smoothing_width)
        else:
            smoothed = smoothed_[::-1]
            print("\x1b[92mFinished (reverse)\x1b[0m")
            break
    else:
        print("\x1b[92mFinished (forward)\x1b[0m")
        break

print('Saving output to', output_filename)

#-----
# The cartesian smoothing step optionally runs after the internal coordinates
# smoother. The point of this is ONLY to correct for "jitters" in the
# xyz coordinates that are introduced by imperfections in the
# redundant internal coordinate -> xyz coordinate step
#-----
jitter_free = smooth_cartesian(smoothed,
                               strength=xyz_smoothing_strength,
                               weights=1.0 / errors)

# Equalize distances between frames (distance metric is max displacement.)
Equalize = True
if Equalize:
    equalized_v = equal_velocity(jitter_free)
    with XYZFile(output_filename, 'w') as f:
        f.write_trajectory(equalized_v / nm_in_angstrom, atom_names)
else:
    with XYZFile(output_filename, 'w') as f:
        f.write_trajectory(jitter_free / nm_in_angstrom, atom_names)
コード例 #3
0
ファイル: Nebterpolate.py プロジェクト: nelsont/nebterpolator
# transform into redundant internal coordinates, apply a fourier based
# smoothing, and then transform back to cartesian.
# the internal -> cartesian bit is the hard step, since there's no
# guarentee that a set of cartesian coordinates even exist that satisfy
# the redundant internal coordinates, after smoothing.

# we're using a levenberg-marquardt optimizer to find the "most consistent"
# cartesian coordinates

# currently, the choice of what internal coordinates to use is buried
# a little in the code, in the function path_operations.union_connectivity
# basically, we're using ALL pairwise distances, all of the angles between
# sets of three atoms, a-b-c, that actually get "bonded" during the
# trajectory, and all of the dihedral angles between sets of 4 atoms,
# a-b-c-d, that actually get "bonded" during the trajectory.
smoothed, errors = smooth_internal(xyzlist, atom_names, width=smoothing_width, bond_width=smoothing_width, angle_width = smoothing_width, dihedral_width = smoothing_width, w_morse = args.morse)


print 'Saving output to', output_filename
# apply a bit of spline smoothing in cartesian coordinates to
# correct for jitters
jitter_free = smooth_cartesian(smoothed,
                               strength=xyz_smoothing_strength,
                               weights=1.0/errors)
with XYZFile(output_filename, 'w') as f:
    f.write_trajectory(jitter_free / nm_in_angstrom, atom_names)
# else:
#     with XYZFile(output_filename, 'w') as f:
#         f.write_trajectory(smoothed / nm_in_angstrom, atom_names)