Skip to main content

MolDynamics

Struct MolDynamics 

Source
pub struct MolDynamics {
    pub ff_mol_type: FfMolType,
    pub atoms: Vec<AtomGeneric>,
    pub atom_posits: Option<Vec<Vec3>>,
    pub atom_init_velocities: Option<Vec<Vec3>>,
    pub bonds: Vec<BondGeneric>,
    pub adjacency_list: Option<Vec<Vec<usize>>>,
    pub static_: bool,
    pub mol_specific_params: Option<ForceFieldParams>,
    pub bonded_only: bool,
}
Expand description

Packages information required to perform dynamics on a Molecule. This is used to initialize the simulation with atoms and related; one or more of these is passed at init.

Fields§

§ff_mol_type: FfMolType§atoms: Vec<AtomGeneric>

These must hold force field type and partial charge.

§atom_posits: Option<Vec<Vec3>>

Separate from atoms; this may be more convenient than mutating the atoms as they may move! If None, we use the positions stored in the atoms.

§atom_init_velocities: Option<Vec<Vec3>>

This may have uses if “shooting” a molecule into a docking position?

§bonds: Vec<BondGeneric>

Not required if static.

§adjacency_list: Option<Vec<Vec<usize>>>

A fast lookup for finding atoms, by index, covalently bonded to each atom. If None, will be generated automatically from atoms and bonds. Use this if you wish to cache.

§static_: bool

If true, the atoms in the molecule don’t move, but exert LJ and Coulomb forces on other atoms in the system.

§mol_specific_params: Option<ForceFieldParams>

If present, any values here override molecule-type general parameters.

§bonded_only: bool

todo experimentin If true, this atom exerts and experiences non-bonded forces only. This may be useful for protein atoms that aren’t near a docking site.

Implementations§

Source§

impl MolDynamics

Source

pub fn from_mol2( mol: &Mol2, mol_specific_params: Option<ForceFieldParams>, ) -> Self

Load a molecule from a Mol2 file. Includes optional molecule-specific pararmeters. To work directly, this assumes that forcefield names, and partial charge are present in the Mol2 struct for all atoms.

You may wish to modify the atom_posits field after to position this relative to other molecules.

Examples found in repository?
examples/minimal.rs (line 29)
11fn main() {
12    let dev = ComputationDevice::Cpu;
13    let param_set = FfParamSet::new_amber().unwrap();
14
15    let mut protein = MmCif::load(Path::new("1c8k.cif")).unwrap();
16    let mol = Mol2::load(Path::new("CPB.mol2")).unwrap();
17
18    // Add Hydrogens, force field type, and partial charge to atoms in the protein; these usually aren't
19    // included from RSCB PDB. You can also call `populate_hydrogens_dihedrals()`, and
20    // `populate_peptide_ff_and_q() separately. Add bonds.
21    let (_bonds, _dihedrals) = prepare_peptide_mmcif(
22        &mut protein,
23        &param_set.peptide_ff_q_map.as_ref().unwrap(),
24        7.0,
25    )
26    .unwrap();
27
28    let mols = vec![
29        MolDynamics::from_mol2(&mol, None),
30        MolDynamics {
31            ff_mol_type: FfMolType::Peptide,
32            atoms: protein.atoms.clone(),
33            static_: true,
34            ..Default::default()
35        },
36    ];
37
38    let (mut md, _) = MdState::new(&dev, &MdConfig::default(), &mols, &param_set).unwrap();
39
40    let n_steps = 100;
41    let dt = 0.002; // picoseconds.
42
43    for _ in 0..n_steps {
44        md.step(&dev, dt, None);
45    }
46
47    let snap = &md.snapshots[md.snapshots.len() - 1]; // A/R.
48    let energy = snap.energy_data.as_ref().unwrap();
49    println!(
50        "KE: {}, PE: {}, Atom posits:",
51        energy.energy_kinetic, energy.energy_potential
52    );
53    for posit in &snap.atom_posits {
54        println!("Posit: {posit}");
55        // Also keeps track of velocities, and solvent molecule positions/velocity
56    }
57
58    // Do something with snapshot data, like displaying atom positions in your UI.
59    // You can save to DCD file, and adjust the ratio they're saved at using the `MdConfig.snapshot_setup`
60    // field: See the example below.
61    for _snap in &md.snapshots {}
62}
Source

pub fn from_sdf( mol: &Sdf, mol_specific_params: Option<ForceFieldParams>, ) -> Self

Load a molecule from a SDF file. Includes optional molecule-specific pararmeters. To work directly, this assumes that forcefield names, and partial charge are present in the Mol2 struct for all atoms. Note that these are not present in SDF files that come from most online databases.

You may wish to modify the atom_posits field after to position this relative to other molecules.

Source

pub fn from_amber_geostd(ident: &str) -> Result<Self>

Load an Amber Geostd molecule from an online database, from its unique identifier. This includes molecule-specific parameters.

You may wish to modify the atom_posits field after to position this relative to other molecules.

Trait Implementations§

Source§

impl Clone for MolDynamics

Source§

fn clone(&self) -> MolDynamics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MolDynamics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MolDynamics

This is mainly for overriding, while specifying atoms, bonds, posits, and mol type explicitly.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V