Skip to main content

BondData

Struct BondData 

Source
pub struct BondData {
    pub begin: u32,
    pub end: u32,
    pub order: BondOrder,
    pub direction: BondDirection,
    pub stereo: BondStereo,
    pub stereo_atoms: [u32; 2],
    pub flags: BondFlags,
}
Expand description

单条键的可变数据。端点为分子内局部原子下标。

Fields§

§begin: u32

起点原子(局部下标)

§end: u32

终点原子(局部下标)

§order: BondOrder

键级

§direction: BondDirection

SMILES 方向键 / \

§stereo: BondStereo

双键立体。由 omgkit-io 的 stereo::perceive_bond_stereo 从 direction 感知, 与 stereo_atoms 配套。

§stereo_atoms: [u32; 2]

顺/反的参照原子:[begin 侧一个, end 侧一个]

只有 stereo 不是 BondStereo::None 时有意义,那时两个下标都合法。 无参照时是 BondData::NO_STEREO_ATOM

§为什么必须存

“顺“与“反“离开参照就没有意义 —— 一根双键两端各有两个取代基,说 “同侧“总得回答“谁和谁同侧”。

这也是它与 BondData::direction 的分工:方向是写法,依附于 某根单键,那根键被删掉信息就没了;顺反是双键自己的属性,只要 两个参照原子还在就一直成立。图编辑之后要重新写出方向键,靠的是这一对。

§flags: BondFlags

标志位

Implementations§

Source§

impl BondData

Source

pub const NO_STEREO_ATOM: u32 = u32::MAX

BondData::stereo_atoms 里表示“没有参照原子“的值。

Source

pub fn new(begin: u32, end: u32, order: BondOrder) -> Self

构造一条指定端点与键级的键。

Source

pub fn valence_contribution_to(&self, atom: u32) -> f32

本键对端点 atom价贡献

配位键的贡献是不对称的:对起点(给体)算 0,对终点(受体)算 1。 这与直觉相反,也与 BondOrder::as_double 不同 —— 后者对配位键 一律算 1。搞混会让隐式氢推断在有机金属分子上系统性出错。

atom 不是本键端点时返回 0。

Source

pub fn other_end(&self, from: u32) -> Option<u32>

给定一端,返回另一端。若 from 不是本键端点则返回 None

Trait Implementations§

Source§

impl Clone for BondData

Source§

fn clone(&self) -> BondData

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 Copy for BondData

Source§

impl Debug for BondData

Source§

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

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

impl Eq for BondData

Source§

impl PartialEq for BondData

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BondData

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> 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 = !

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.