ferritin_core/bonds.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
/// Bond
///
/// Struct for creating Bonds of type [BondOrder]
///
#[derive(Debug, PartialEq)]
pub struct Bond {
atom1: i32,
atom2: i32,
order: BondOrder,
// id
// stereo
// unique_id
// has_setting
}
impl Bond {
pub fn new(atom1: i32, atom2: i32, order: BondOrder) -> Self {
Bond {
atom1,
atom2,
order,
}
}
pub fn get_atom_indices(&self) -> (i32, i32) {
(self.atom1, self.atom2)
}
}
#[repr(u8)]
#[derive(Debug, PartialEq)]
/// BondOrder:
///
/// Enum for defining Bond orders.
/// **Note: subject to change.**
/// Needs more research on which convention to follow.
/// - [biotite](https://www.biotite-python.org/latest/apidoc/biotite.structure.BondType.html#biotite.structure.BondType)
/// - see also [cdk](http://cdk.github.io/cdk/latest/docs/api/org/openscience/cdk/Bond.html)
pub enum BondOrder {
/// Used if the actual type is unknown
Unset,
/// Single bond
Single,
/// Double bond
Double,
/// Triple bond
Triple,
/// A quadruple bond
Quadruple,
}
impl BondOrder {
pub fn match_bond(bond_int: i32) -> BondOrder {
match bond_int {
0 => BondOrder::Unset,
1 => BondOrder::Single,
2 => BondOrder::Double,
3 => BondOrder::Triple,
4 | 5 | 6 => BondOrder::Quadruple,
_ => {
panic!("Bond Order not found: {}", bond_int);
}
}
}
}