Template

Struct Template 

Source
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: String

External identifier such as a three-letter residue code.

Implementations§

Source§

impl Template

Source

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 their BondOrder.
§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);
Source

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"));
Source

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"));
Source

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());
Source

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());
Source

pub fn atom_count(&self) -> usize

Counts atoms described by the template.

§Returns

Number of atom entries in atom_names.

§Examples
use bio_forge::{BondOrder, Template};

let template = Template::new("ION", vec!["K".into()], Vec::new());
assert_eq!(template.atom_count(), 1);
Source

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§

Source§

impl Clone for Template

Source§

fn clone(&self) -> Template

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Template

Source§

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

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

impl Display for Template

Source§

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

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

impl PartialEq for Template

Source§

fn eq(&self, other: &Template) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Template

Source§

impl StructuralPartialEq for Template

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,