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_: boolIf 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: booltodo 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
impl MolDynamics
Sourcepub fn from_mol2(
mol: &Mol2,
mol_specific_params: Option<ForceFieldParams>,
) -> Self
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?
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 ¶m_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, ¶m_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}Sourcepub fn from_sdf(
mol: &Sdf,
mol_specific_params: Option<ForceFieldParams>,
) -> Self
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.
Sourcepub fn from_amber_geostd(ident: &str) -> Result<Self>
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
impl Clone for MolDynamics
Source§fn clone(&self) -> MolDynamics
fn clone(&self) -> MolDynamics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MolDynamics
impl Debug for MolDynamics
Auto Trait Implementations§
impl Freeze for MolDynamics
impl RefUnwindSafe for MolDynamics
impl Send for MolDynamics
impl Sync for MolDynamics
impl Unpin for MolDynamics
impl UnsafeUnpin for MolDynamics
impl UnwindSafe for MolDynamics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.