Struct pdbtbx::Atom

source ·
pub struct Atom { /* private fields */ }
Expand description

A struct to represent a single Atom in a protein.

Implementations§

source§

impl Atom

source

pub fn new( hetero: bool, serial_number: usize, atom_name: impl Into<String>, x: f64, y: f64, z: f64, occupancy: f64, b_factor: f64, element: impl Into<String>, charge: isize ) -> Option<Atom>

Create a new Atom. If no or an invalid element is given it tries to find the element by using the full atom name as element. If this is not valid it will use the first character of the name if it is one of “CHNOS”.

source

pub const fn hetero(&self) -> bool

Determine if this atom is an hetero atom (true), a non standard atom, or a normal atom (false).

source

pub fn set_hetero(&mut self, new_hetero: bool)

Set whether this atom is an hetero atom (true), a non standard atom, or a normal atom (false).

source

pub const fn pos(&self) -> (f64, f64, f64)

Get the position of the atom as a tuple of f64, in the following order: (x, y, z). Given in Å as defined by PDB in the orthogonal coordinate system.

source

pub fn set_pos(&mut self, new_pos: (f64, f64, f64)) -> Result<(), String>

Set the position of the atom as a tuple of f64, in the following order: (x, y, z).

Errors

It fails if one or more of the numbers is not finite (f64.is_finite()).

source

pub const fn x(&self) -> f64

Get the X position of the atom. Given in Å as defined by PDB in the orthogonal coordinate system. This number has a precision of 8.3 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_x(&mut self, new_pos: f64) -> Result<(), String>

Set the X position of the atom in Å.

Errors

It fails if new_pos is not finite (f64.is_finite()).

source

pub const fn y(&self) -> f64

Get the Y position of the atom. Given in Å as defined by PDB in the orthogonal coordinate system. This number has a precision of 8.3 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_y(&mut self, new_pos: f64) -> Result<(), String>

Set the Y position of the atom in Å.

Errors

It fails if new_pos is not finite (f64.is_finite()).

source

pub const fn z(&self) -> f64

Get the Z position of the atom. Given in Å as defined by PDB in the orthogonal coordinate system. This number has a precision of 8.3 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_z(&mut self, new_pos: f64) -> Result<(), String>

Set the Z position of the atom in Å.

Errors

It fails if new_pos is not finite (f64.is_finite()).

source

pub const fn serial_number(&self) -> usize

Get the serial number of the atom. This number, combined with the alt_loc from the Conformer of this Atom, is defined to be unique in the containing model, which is not enforced. The precision of this number is 5 digits in PDB files. If more than 99,999 atoms are present in the same model, the internal numbering will continue counting up even if the file from which the atoms were read does not. Importantly, this will not affect the saving of the file, only the internal handling of atom serial numbers.

source

pub fn set_serial_number(&mut self, new_serial_number: usize)

Set the serial number of the atom. This number, combined with the alt_loc from the Conformer, of this Atom is defined to be unique in the containing model, which is not enforced.

source

pub fn name(&self) -> &str

Get the name of the atom. The name will be trimmed (whitespace removed) and changed to ASCII uppercase.

source

pub fn set_name(&mut self, new_name: impl Into<String>) -> Result<(), String>

Set the name of the atom. The name will be trimmed (whitespace removed) and changed to ASCII uppercase as requested by PDB/PDBx standard. For PDB files the name can at most contain 4 characters, enforced when saving the file.

Errors

The name can only contain valid characters, the ASCII graphic characters (char.is_ascii_graphic() || char == ' '). If the name is invalid an error message is provided.

source

pub const fn occupancy(&self) -> f64

Get the occupancy or Q factor of the atom. This indicates the fraction of unit cells in which this atom is present, in the normal case this will be one (1) and it can range between 1 and 0 (inclusive). This number has a precision of 6.2 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_occupancy(&mut self, new_occupancy: f64) -> Result<(), String>

Set the occupancy or Q factor of the atom.

Errors

It fails if new_occupancy is not finite (f64.is_finite()) or if it is negative.

source

pub const fn b_factor(&self) -> f64

Get the B factor or temperature factor of the atom. This indicates the uncertainty in the position of the atom as seen over all unit cells in the whole crystal. A low uncertainty is modelled with a low B factor, with zero uncertainty being equal to a B factor of 0. A higher uncertainty is modelled by a high B factor. This number has a precision of 6.2 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_b_factor(&mut self, new_b_factor: f64) -> Result<(), String>

Set the B factor or temperature factor of the atom.

Errors

It fails if new_b_factor is not finite (f64.is_finite()) or if it is negative.

source

pub fn element(&self) -> Option<&Element>

Get the element of this atom. In PDB files the element can at most contain 2 characters.

source

pub fn set_element(&mut self, element: Element)

Set the element of this atom.

source

pub const fn charge(&self) -> isize

Get the charge of the atom. In PDB files the charge is one digit with a sign.

source

pub fn set_charge(&mut self, new_charge: isize)

Set the charge of this atom. In PDB files the charge is one digit with a sign.

source

pub fn pdb_charge(&self) -> String

Get the charge in the PDB format [0-9][-+]. If the charge is 0 or outside bounds (below -9 or above 9) it returns an empty string.

source

pub const fn anisotropic_temperature_factors(&self) -> Option<[[f64; 3]; 3]>

Get the anisotropic temperature factors, if available. This number has a precision of 8.3 in PDB files and 5 decimal places of precision in mmCIF files.

source

pub fn set_anisotropic_temperature_factors(&mut self, factors: [[f64; 3]; 3])

Set the anisotropic temperature factors.

source

pub fn is_backbone(&self) -> bool

Determine whether this atom is likely to be a part of the backbone of a protein. This is based on this Atom only, for a more precise definition use hierarchy::ContainsAtomConformer::is_backbone.

source

pub fn apply_transformation(&mut self, transformation: &TransformationMatrix)

Apply a transformation using a given TransformationMatrix to the position of this atom, the new position is immediately set.

source

pub fn corresponds(&self, other: &Atom) -> bool

See if the other Atom corresponds with this Atom. This means that the Atoms are equal except for the position, occupancy, and b_factor. Used to validate that multiple models contain the same atoms, but with different positional data.

source

pub fn distance(&self, other: &Atom) -> f64

Gives the distance between the centers of two atoms in Aͦ.

source

pub fn distance_wrapping(&self, other: &Atom, cell: &UnitCell) -> f64

Gives the distance between the centers of two atoms in Aͦ, wrapping around the unit cell if needed. This will give the shortest distance between the two atoms or any of their copies given a crystal of the size of the given unit cell stretching out to all sides.

source

pub fn angle(&self, atom2: &Atom, atom3: &Atom) -> f64

Gives the angle between the centers of three atoms in degrees. The angle is calculated as the angle between the two lines that include atoms [1, 2] and [2, 3]

source

pub fn dihedral(&self, atom2: &Atom, atom3: &Atom, atom4: &Atom) -> f64

Gives the dihedral between the centers of four atoms in degrees. The angle is calculated as the angle between the two planes spanned by atoms [1, 2, 3] and [2, 3, 4].

source

pub fn overlaps(&self, other: &Atom) -> Option<bool>

Checks if this Atom overlaps with the given atom. It overlaps if the distance between the atoms is less then the sum of the radius from this atom and the other atom. The used radius is AtomicRadius.unbound.

Note: the atomic radius used is the unbound radius, this is in most cases bigger than the bound radius and as such can result in false positives.

It fails if for any one of the two atoms the element or unbound radius is not known.

source

pub fn overlaps_wrapping(&self, other: &Atom, cell: &UnitCell) -> Option<bool>

Checks if this Atom overlaps with the given atom. It overlaps if the distance between the atoms is less then the sum of the radius from this atom and the other atom. The used radius is AtomicRadius.unbound. Wrapping around the unit cell if needed. Meaning it will give the shortest distance between the two atoms or any of their copies given a crystal of the size of the given unit cell stretching out to all sides.

Note: the atomic radius used is the unbound radius, this is in most cases bigger than the bound radius and as such can result in false positives.

It fails if for any one of the two atoms the element or unbound radius is not known.

source

pub fn overlaps_bound(&self, other: &Atom) -> Option<bool>

Checks if this Atom overlaps with the given atom. It overlaps if the distance between the atoms is less then the sum of the radius from this atom and the other atom. The used radius is AtomicRadius.covalent_single.

Note: the atomic radius used in the bound radius to a single atom, this is similar to the bound radius for double or triple bonds but could result in incorrect results.

It fails if for any one of the two atoms the element is not known.

source

pub fn overlaps_bound_wrapping( &self, other: &Atom, cell: &UnitCell ) -> Option<bool>

Checks if this Atom overlaps with the given atom. It overlaps if the distance between the atoms is less then the sum of the radius from this atom and the other atom. The used radius is AtomicRadius.covalent_single. Wrapping around the unit cell if needed. Meaning it will give the shortest distance between the two atoms or any of their copies given a crystal of the size of the given unit cell stretching out to all sides.

Note: the atomic radius used is the bound radius to a single atom, this is similar to the bound radius for double or triple bonds but could result in incorrect results.

It fails if for any one of the two atoms the element is not known.

Trait Implementations§

source§

impl Clone for Atom

source§

fn clone(&self) -> Self

The clone implementation needs to use the constructor to guarantee the uniqueness of the counter

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Atom

source§

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

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

impl<'de> Deserialize<'de> for Atom

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Atom

source§

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

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

impl Extend<Atom> for Conformer

source§

fn extend<T: IntoIterator<Item = Atom>>(&mut self, iter: T)

Extend the Atoms on this Conformer by the given iterator over Atoms.

source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Ord for Atom

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Atom> for Atom

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Atom> for Atom

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PointDistance for &Atom

source§

fn distance_2(&self, other: &(f64, f64, f64)) -> f64

Returns the squared euclidean distance between an object to a point.
source§

fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool

Returns true if a point is contained within this object. Read more
source§

fn distance_2_if_less_or_equal( &self, point: &<Self::Envelope as Envelope>::Point, max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar ) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>

Returns the squared distance to this object, or None if the distance is larger than a given maximum value. Read more
source§

impl RTreeObject for &Atom

§

type Envelope = AABB<(f64, f64, f64)>

The object’s envelope type. Usually, AABB will be the right choice. This type also defines the object’s dimensionality.
source§

fn envelope(&self) -> Self::Envelope

Returns the object’s envelope. Read more
source§

impl Serialize for Atom

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Atom

As there are a lot of checks to make sure only ‘normal’ f64 values are used Atom satisfies the properties needed for Eq while having f64 values.

Auto Trait Implementations§

§

impl RefUnwindSafe for Atom

§

impl Send for Atom

§

impl Sync for Atom

§

impl Unpin for Atom

§

impl UnwindSafe for Atom

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,