pub struct Atom { /* private fields */ }
Expand description
A struct to represent a single Atom in a protein.
Implementations§
source§impl Atom
impl Atom
sourcepub 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>
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”.
sourcepub const fn hetero(&self) -> bool
pub const fn hetero(&self) -> bool
Determine if this atom is an hetero atom (true
), a non standard atom, or a normal atom (false
).
sourcepub fn set_hetero(&mut self, new_hetero: bool)
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
).
sourcepub const fn pos(&self) -> (f64, f64, f64)
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.
sourcepub fn set_pos(&mut self, new_pos: (f64, f64, f64)) -> Result<(), String>
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()
).
sourcepub const fn x(&self) -> f64
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.
sourcepub const fn y(&self) -> f64
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.
sourcepub const fn z(&self) -> f64
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.
sourcepub const fn serial_number(&self) -> usize
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.
sourcepub fn set_serial_number(&mut self, new_serial_number: usize)
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.
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the name of the atom. The name will be trimmed (whitespace removed) and changed to ASCII uppercase.
sourcepub fn set_name(&mut self, new_name: impl Into<String>) -> Result<(), String>
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.
sourcepub const fn occupancy(&self) -> f64
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.
sourcepub fn set_occupancy(&mut self, new_occupancy: f64) -> Result<(), String>
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.
sourcepub const fn b_factor(&self) -> f64
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.
sourcepub fn set_b_factor(&mut self, new_b_factor: f64) -> Result<(), String>
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.
sourcepub fn element(&self) -> Option<&Element>
pub fn element(&self) -> Option<&Element>
Get the element of this atom. In PDB files the element can at most contain 2 characters.
sourcepub fn set_element(&mut self, element: Element)
pub fn set_element(&mut self, element: Element)
Set the element of this atom.
sourcepub const fn charge(&self) -> isize
pub const fn charge(&self) -> isize
Get the charge of the atom. In PDB files the charge is one digit with a sign.
sourcepub fn set_charge(&mut self, new_charge: isize)
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.
sourcepub fn pdb_charge(&self) -> String
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.
sourcepub const fn anisotropic_temperature_factors(&self) -> Option<[[f64; 3]; 3]>
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.
sourcepub fn set_anisotropic_temperature_factors(&mut self, factors: [[f64; 3]; 3])
pub fn set_anisotropic_temperature_factors(&mut self, factors: [[f64; 3]; 3])
Set the anisotropic temperature factors.
sourcepub fn is_backbone(&self) -> bool
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
.
sourcepub fn apply_transformation(&mut self, transformation: &TransformationMatrix)
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.
sourcepub fn corresponds(&self, other: &Atom) -> bool
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.
sourcepub fn distance(&self, other: &Atom) -> f64
pub fn distance(&self, other: &Atom) -> f64
Gives the distance between the centers of two atoms in Aͦ.
sourcepub fn distance_wrapping(&self, other: &Atom, cell: &UnitCell) -> f64
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.
sourcepub fn angle(&self, atom2: &Atom, atom3: &Atom) -> f64
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]
sourcepub fn dihedral(&self, atom2: &Atom, atom3: &Atom, atom4: &Atom) -> f64
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].
sourcepub fn overlaps(&self, other: &Atom) -> Option<bool>
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.
sourcepub fn overlaps_wrapping(&self, other: &Atom, cell: &UnitCell) -> Option<bool>
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.
sourcepub fn overlaps_bound(&self, other: &Atom) -> Option<bool>
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.
sourcepub fn overlaps_bound_wrapping(
&self,
other: &Atom,
cell: &UnitCell
) -> Option<bool>
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<'de> Deserialize<'de> for Atom
impl<'de> Deserialize<'de> for Atom
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Extend<Atom> for Conformer
impl Extend<Atom> for Conformer
source§fn extend<T: IntoIterator<Item = Atom>>(&mut self, iter: T)
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)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Ord for Atom
impl Ord for Atom
source§impl PartialEq<Atom> for Atom
impl PartialEq<Atom> for Atom
source§impl PartialOrd<Atom> for Atom
impl PartialOrd<Atom> for Atom
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PointDistance for &Atom
impl PointDistance for &Atom
source§fn distance_2(&self, other: &(f64, f64, f64)) -> f64
fn distance_2(&self, other: &(f64, f64, f64)) -> f64
source§fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
true
if a point is contained within this object. Read moresource§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>
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>
None
if the distance
is larger than a given maximum value. Read moresource§impl RTreeObject for &Atom
impl RTreeObject for &Atom
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> 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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.