pub struct Template {
pub name: String,
/* private fields */
}Expand description
Describes the atom inventory and connectivity for a residue or ligand template.
Templates originate from the embedded parameter database and encapsulate the minimal information needed to validate coordinate files, seed missing atoms, or emit force-field compatible topologies.
Fields§
§name: StringExternal identifier such as a three-letter residue code.
Implementations§
Source§impl Template
impl Template
Sourcepub fn new<S: Into<String>>(
name: S,
atom_names: Vec<String>,
bonds: Vec<(String, String, BondOrder)>,
) -> Self
pub fn new<S: Into<String>>( name: S, atom_names: Vec<String>, bonds: Vec<(String, String, BondOrder)>, ) -> Self
Constructs a template from explicit atom and bond data.
The constructor enforces (in debug builds) that every bond references atoms present
in the provided atom_names list, preventing malformed templates from entering the
store.
§Arguments
name- Short identifier for the template (e.g., three-letter code).atom_names- Complete list of atom names belonging to the template.bonds- Connectivity tuples describing bonded atom pairs and theirBondOrder.
§Returns
A fully owned Template instance containing the supplied data.
§Panics
Panics in debug builds if any bond references an atom not listed in atom_names.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["O".into(), "H1".into(), "H2".into()];
let bonds = vec![
("O".into(), "H1".into(), BondOrder::Single),
("O".into(), "H2".into(), BondOrder::Single),
];
let template = Template::new("HOH", atoms, bonds);
assert_eq!(template.atom_count(), 3);
assert_eq!(template.bond_count(), 2);Sourcepub fn has_bond(&self, name1: &str, name2: &str) -> bool
pub fn has_bond(&self, name1: &str, name2: &str) -> bool
Reports whether the template defines a bond between the provided atom names.
Lookup is order-independent, allowing callers to check connectivity without sorting the names first.
§Arguments
name1- Name of the first atom.name2- Name of the second atom.
§Returns
true if a bond exists between the atoms, otherwise false.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["C1".into(), "C2".into()];
let bonds = vec![("C1".into(), "C2".into(), BondOrder::Single)];
let template = Template::new("ETH", atoms, bonds);
assert!(template.has_bond("C1", "C2"));
assert!(template.has_bond("C2", "C1"));
assert!(!template.has_bond("C1", "H1"));Sourcepub fn has_atom(&self, name: &str) -> bool
pub fn has_atom(&self, name: &str) -> bool
Checks whether an atom name is present in the template definition.
§Arguments
name- Atom name to search for.
§Returns
true if the atom exists in atom_names.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["N".into(), "CA".into(), "C".into()];
let template = Template::new("GLY", atoms, Vec::new());
assert!(template.has_atom("CA"));
assert!(!template.has_atom("OXT"));Sourcepub fn atom_names(&self) -> &[String]
pub fn atom_names(&self) -> &[String]
Returns the ordered slice of atom names defined for the template.
§Returns
Borrowed slice referencing the internal atom list.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["P".into(), "O5'".into()];
let template = Template::new("PO4", atoms.clone(), Vec::new());
assert_eq!(template.atom_names(), atoms.as_slice());Sourcepub fn bonds(&self) -> &[(String, String, BondOrder)]
pub fn bonds(&self) -> &[(String, String, BondOrder)]
Returns the list of bond definitions stored within the template.
§Returns
Borrowed slice of (atom_a, atom_b, BondOrder) tuples.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["C1".into(), "O1".into()];
let bonds = vec![("C1".into(), "O1".into(), BondOrder::Double)];
let template = Template::new("CO", atoms, bonds.clone());
assert_eq!(template.bonds(), bonds.as_slice());Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Sourcepub fn bond_count(&self) -> usize
pub fn bond_count(&self) -> usize
Counts bonds described by the template.
§Returns
Number of bond tuples stored in bonds.
§Examples
use bio_forge::{BondOrder, Template};
let atoms = vec!["C".into(), "O".into()];
let bonds = vec![("C".into(), "O".into(), BondOrder::Double)];
let template = Template::new("CO", atoms, bonds);
assert_eq!(template.bond_count(), 1);Trait Implementations§
impl Eq for Template
impl StructuralPartialEq for Template
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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,
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.