Releases: Ladme/groan_rs
Releases · Ladme/groan_rs
v0.9.0
Version 0.9.0
Atom Index
- Introduced a new
Atom
fieldindex
, which corresponds to the index of the atom in the system (starting from 0). This field can be accessed usingAtom::get_index
and is only valid if the atom is part of a system. - Several functions have been reworked to improve efficiency by utilizing the new
index
field. - Breaking change: The keyword
atomid
in the Groan Selection Language has been removed to avoid confusion with the newindex
field. Useatomnum
instead. PositionError
andMassError
now report the atom index instead of the atom number.
Reworked Trajectory Writing
- Breaking changes:
- Trajectory writing has been completely reworked.
- Trajectory writers are now attached to
System
structures, making them memory safe. - A trajectory writer can be initialized and attached to a
System
usingSystem::traj_writer_init
(orSystem::traj_group_writer_init
to write information about a specific group). - Multiple trajectory writers can be attached to a single
System
. - The system state can be written into all open output trajectory files using
System::traj_write_frame
or to a specific file usingSystem::traj_write_frame_to_file
.
RMSD Calculation
- Introduced
System::calc_rmsd
to calculate RMSD between the current and a reference structure. - RMSD-fitting of a structure to a reference structure can be performed using
System::calc_rmsd_and_fit
. - Calculating RMSD and RMSD-fitting for trajectories is more efficient with
RMSDTrajRead::calc_rmsd
andRMSDTrajRead::calc_rmsd_and_fit
, implemented for all trajectory readers.
Reading GRO Trajectories
- Trajectories in 'gro' format can now be read using
System::gro_iter
. - The
with_step
method can be used with the 'gro' iterator, but thewith_range
method is unavailable since 'gro' trajectories do not guarantee simulation time information. - A
System
can now be constructed by callingSystem::from_file
on a trajectory in 'gro' format. Only the first frame is read, and the system is constructed based on the atoms in this frame.
Getters and Setters
- Breaking changes:
- Many 'setter' and 'getter' methods have been renamed:
get_atoms_as_ref
->get_atoms
get_atoms_as_mut
->get_atoms_mut
get_groups_as_ref
->get_groups
get_box_as_ref
->get_box
get_box_as_mut
->get_box_mut
get_atom_as_ref
->get_atom
get_atom_as_mut
->get_atom_mut
get_atom_unchecked_as_ref
->get_atom_unchecked
get_atom_unchecked_as_mut
->get_atom_unchecked_mut
get_labeled_atom_as_ref
->get_labeled_atom
get_labeled_atom_as_mut
->get_labeled_atom_mut
get_atoms_mut
now returns a mutable slice&mut [Atom]
instead of a mutable vector&mut Vec<Atom>
, preventing users from adding or removing atoms.- Signatures of several 'getter' methods originally returning
&str
orOption<&str>
have been changed to return&String
orOption<&String>
, which may cause minor compatibility issues, for instance when comparing strings.
- Many 'setter' and 'getter' methods have been renamed:
Changes to System::traj_iter_map_reduce
- Breaking change:
System::traj_iter_map_reduce
now requires the user to provide the initialData
structure. TheData
structure no longer needs to implementDefault
but must implementClone
. System::traj_iter_map_reduce
now properly propagates errors and failures from individual threads to the master thread'sProgressPrinter
.
Changes to Atom Iterators
- Breaking change: Renamed
MasterAtomIterator
andMasterMutAtomIterator
toAtomIterable
. - Introduced new traits:
AtomIteratorWithBox
andMutAtomIteratorWithBox
implemented by all (im)mutable atom iterators containing information about the simulation box. - Added a new trait
OrderedAtomIterator
, implemented by all immutable and mutable iterators yielding atoms in the order they appear in the molecular system. - Iterator unions and intersections can be constructed for iterators implementing
OrderedAtomIterator
usingOrderedAtomIterator::union
andOrderedAtomIterator::intersection
. - Added
AtomPairIterator
andMutAtomPairIterator
for iterating over pairs of atoms. These iterators currently support iterating over molecule bonds and can be created usingSystem::molecule_bonds_iter
andSystem::molecule_bonds_iter_mut
for immutable and mutable access, respectively. - Note: The design of these iterators and the structure of atom pairs are subject to future refinement and potential expansion.
Bug Fixes and Other Changes
- Introduced
System::make_group_whole
to make a group "whole" in the system (similar toSystem::make_molecules_whole
). - Breaking change:
System::group_all_distances
now returns ndarray'sArray2
instead of a vector of vectors. FileType
is now part of the prelude.- Properly implemented
Deref
andDerefMut
forVector3D
, simplifying access to methods fromnalgebra::Vector3
. - Improved the performance of
AtomContainer::isin
(and consequentlySystem::group_isin
). Vector3D
now implements theDisplay
trait.- Introduced
Vector3D::average
for calculating the average 3D vector from a collection of vectors. - Introduced
System::groups_member
to return a vector of all group names an atom with a specified index is a member of. - Values in
GridMap
can now be cleared usingGridMap::clear
. - Reworked the loading of
GridMaps
from files, ensuring invalid coordinates cannot be loaded. - Introduced
System::guess_elements_unknown
to assign elements only to atoms without an assigned element. ProgressPrinter
now uses a mutex only if theparallel
feature is enabled.- Introduced
Vector3D::rotate
,Atom::rotate
, andAtom::rotate_nopbc
for performing rotations using rotation matrices. - Added trajectory converters and analyzers, which are trajectory readers that modify and/or analyze the current simulation frame. See
TrajConverter
,TrajAnalyzer
, andTrajConverterAnalyzer
for more details. These structures are primarily for internal use in thegroan_rs
crate. - Introduced center of geometry/mass calculation not taking PBC into consideration (
System::group_get_center_naive
,System::group_get_com_naive
,AtomIterable::get_center_naive
,AtomIterable::get_com_naive
). - Bug fix: Regex operators can now be used in regular expression blocks without raising an
InvalidOperator
error. - Bug fix: Bonds are now properly loaded for TIP3P and similar water models from TPR files.
- Breaking change:
XdrFile::open_xdr
is no longer public.
v0.8.2
v0.8.1
v0.8.0
Version 0.8.0
Reading structures from TPR files
- In addition to system topology and simulation box, the positions, velocities, and forces of atoms, and intermolecular bonds can now also be read from TPR files.
Reworked and expanded Atom iterators
- All custom iterators over atoms now implement one of two traits:
MasterAtomIterator
andMasterMutAtomIterator
, depending on whether they provide references or mutable references to atoms. - All mutable atom iterators can now call
MasterMutAtomIterator::translate
andMasterMutAtomIterator::wrap
methods which translate and wrap, respectively, the atoms of the iterator. - All immutable atom iterators can now call
MasterAtomIterator::get_center
andMasterAtomIterator::get_com
methods to calculate the center of geometry and center of mass, respectively, of the atoms of the iterator. This is useful for the calculation of the local center of mass in the system. - Iterators over atoms of the system can now be constructed directly from selection queries using
System::selection_iter
(for iteration over immutable atoms) andSystem::selection_iter_mut
(for iteration over mutable atoms). This allows selecting atoms without adding groups to the system. - All custom iterators over atoms now implement
Debug
andClone
.
Labeled atoms
- Individual atoms can now be labeled with strings using
System::label_atom
andSystem::select_and_label
. - Labeled atoms can be accessed using their labels via
System::get_labeled_atom_as_ref
,System::get_labeled_atom_as_mut
, andSystem::get_labeled_atom_copy
. - You can iterate through labeled atoms using
System::labeled_atoms_iter
andSystem::labeled_atoms_iter_mut
. - Labeled atoms can be selected using the Groan Selection Language (
label 'atom X'
).
GridMap structure
- Implemented the
GridMap
structure for easier analysis of properties of planar surfaces such as membranes. GridMap
is a generic 2D array that can be navigated using coordinates of the molecular system.
Serde feature
- Serde support was added for
FileType
,Dimension
,Sphere
,Rectangular
,Cylinder
, andTriangularPrism
. - All (de)serializable
groan_rs
structures/enums now deny unknown fields.
Other changes
- Breaking change: The
Group::name_is_valid
function has been moved to theauxiliary
module and is no longer public. - Breaking change: Renamed several functions for consistency with commonly used terminology:
System::get_atoms_as_ref_mut
->System::get_atoms_as_mut
System::get_groups_as_ref_mut
->System::get_groups_as_mut
System::get_box_as_ref_mut
->System::get_box_as_mut
System::get_atom_as_ref_mut
->System::get_atom_as_mut
- Breaking change:
System::get_atoms_as_mut
,System::get_groups_as_mut
,System::group_remove
, andSystem::group_rename
are no longer public (and also no longer marked as unsafe). Users should not be able to add/remove atoms or groups or change the properties and names of groups. Changing properties of atoms is still allowed, but it is better done usingSystem::atoms_iter_mut
. - Implemented
System::traj_iter_map_reduce
for simple, embarrassingly parallel iteration through simulation trajectories (requires theparallel
feature). - Implemented
System::group_intersection
, allowing direct creation of groups that are intersections of other groups. - Implemented
System::from_file_with_format
, allowing direct specification of the input file format. - When writing 'gro' and 'pdb' files, large coordinates can no longer overflow the space allocated for them in the file format, and instead, an error is returned.
- Made internal changes to the
ProgressPrinter
, potentially allowing it to be used in a multithreaded environment (untested). - Added unchecked (and unsafe) variants of
System::get_atom_*
methods.
v0.7.1
Version 0.7.1
- Bug fix: GSL queries containing non-ASCII characters should no longer cause panic.
tpr_io::read_tpr
is now a public function.TrajReadOpen
trait is now included ingroan_rs::prelude
.- Replaced the
crossbeam_utils
crate with features from standard library.
v0.7.0
Version 0.7.0
Reading TPR files
- Implemented basic reading of TPR files using the
minitpr
crate. TheSystem::from_file
function can now recognize and parse TPR files. - TPR files can also be explicitly read using the
tpr_io::read_tpr
function (import withuse groan_rs::io::tpr_io
). - Currently, only the system name, simulation box dimensions, and the topology of the system (atoms and bonds) are being parsed.
- Atom positions, velocities, and forces are not read from the TPR file by
groan_rs
. All atoms in a system created by parsing a TPR file will have undefined positions and velocities. - Reading intermolecular bonds and groups from TPR files is not currently supported.
Reading and writing PQR files
- The
System::from_file
function now supports reading whitespace-delimited PQR files. - PQR files can also be explicitly read using the
pqr_io::read_pqr
function (import withuse groan_rs::io::pqr_io
). - PQR files can be written with user-specified precision using the
System::write_pqr
andSystem::group_write_pqr
functions.
TrajConcatenator
structure
- All trajectory readers implementing certain traits (refer to
trajectory_readers.md
for more information) can now be concatenated using theSystem::traj_cat_iter
. - During concatenation, duplicate frames from trajectory boundaries are removed, allowing for simple iteration through simulation trajectories that directly follow each other.
- The
System::xtc_cat_iter
andSystem::trr_cat_iter
functions are provided for direct concatenation of XTC and TRR files, respectively. - Basic methods associated with trajectory readers, such as
with_range
,with_step
, orprint_progress
, can be applied to the concatenation iterator. - The
TrajConcatenator
structure ensures that the trajectory range is correctly identified even if it spans multiple trajectory files and that step iteration properly handles trajectory boundaries.
Replaced custom Vector3D
implementation with faster Vector3
from nalgebra
crate
- Breaking change: When
Vector3D::to_unit
is applied to a vector with a length (magnitude) of zero, its fields are now set toNaN
instead of the previously used0.0
.
Restructuring of the module system
- Breaking change: The
Select
structure is now located directly in thegroan_rs::select
module, not ingroan_rs::selections::select
. - Breaking change: The
System
structure is now located directly in thegroan_rs::system
module, not ingroan_rs::system::general
. This change does not affec users who utilizegroan_rs::prelude
.
serde
feature
- Added a new feature,
serde
, which provides serialization and deserialization for severalgroan_rs
structures, namely Vector3D, SimBox, Atom, AtomContainer, AtomBlock, Group, System, and Select. - Select can be deserialized from a valid Groan Selection Language (GSL) query and serialized into a valid GSL query.
- This feature is not enabled by default and must be activated by using
cargo add groan_rs --features serde
or by addinggroan_rs = { version = "0.7.0", features = ["serde"] }
to yourCargo.toml
file. - Note that automated tests for serialization and deserialization currently only use the YAML file format, but other formats supported by the
serde
crate should also work.
parallel
feature
- Introduced a new feature,
parallel
, which contains functions that can run on multiple threads. - Activate with
cargo add groan_rs --features parallel
or by addinggroan_rs = { version = "0.7.0", features = ["parallel"] }
. - Currently, only a parallelized version of
System::guess_bonds
, calledSystem::guess_bonds_parallel
, has been introduced.
Other changes
- Breaking change: The
parse_query
function fromcrate::selections::select
has been transformed into an associated function of theSelect
structure and should now be called asSelect::parse_query
. - Added a basic implementation of the
TriangularPrism
shape, which implements theShape
trait. - Added a method,
System::group_create_from_select
, allowing groups to be created directly fromSelect
structures. - Clarified changes in the order of groups when removing or renaming a group from the System.
v0.6.2
v0.6.1
Version 0.6.1
- Bug fix: When setting
ProgressPrinter
to write into a file, the printer did not start a new line once iteration was finished and instead printed new line into standard output. This has been now fixed. ProgressPrinter
can be now set to NOT start a new line upon finishing the iteration through the trajectory (seeProgressPrinter::with_newline_at_end
).
v0.6.0
Version 0.6.0
Simulation box is now an optional property of the system
- Breaking change: The simulation box is now an optional property of the system.
- This change affects the return type of various functions that access the simulation box.
- High-level methods of the
System
structure now return errors if they require a simulation box and it is not present.
Undefined atom positions no longer cause panic
- Breaking change: Higher-level
System
andAtom
methods no longer panic when encountering an atom with an undefined position; instead, they return a recoverable error.
Assigning and guessing elements and bonds
- Added the
Elements
structure, which defines properties of supported elements. - The
Elements
structure can be constructed from a YAML file containing element definitions by callingElements::from_file
. - Default properties of the elements supported by
groan_rs
are stored insrc/config/elements.yaml
. A defaultElements
structure, containing elements and their properties from this YAML file, can be constructed usingElements::default
. - The
Elements
structure can be updated usingElements::update
. In this case, anotherElements
structure must be provided, specifying the changes to be made to the originalElements
structure. - Elements can be guessed for the atoms of the system using
System::guess_elements
. - Bonds can now be guessed for the system using
System::guess_bonds
. This requires van der Waals radii to be assigned to individual atoms. Van der Waals radii can be guessed based on the elements.
Changes to the Atom
structure
- New optional fields added:
mass
,element_name
,element_symbol
,vdw
,expected_max_bonds
, andexpected_min_bonds
:mass
specifies the mass of the atom.element_name
specifies the name of the element assigned to this atom.element_symbol
specifies the symbol of the element.vdw
specifies the van der Waals radius used to guess bonds between atoms.expected_max_bonds
specifies the expected maximum number of bonds this atom may form.expected_min_bonds
specifies the expected minimum number of bonds this atom forms.
- Methods have been added to utilize and access these new fields.
Changes to the Groan Selection Language
- Breaking change: The macro
@hydrogen
is no longer supported. Useelement name hydrogen
instead. - Bug fix: Invalid queries containing a command in parentheses followed by anything other than a binary operator (e.g.,
(name CA CB) resname LYS
) no longer cause a panic but instead return a proper error. - Atoms can now be selected based on their element name or element symbol (
element name carbon
orelement symbol C
). This requires atoms to have assigned elements. - Atoms that are part of the same molecule can now be selected using the
molecule with
operator. For example,molecule with serial 13
will select all atoms that are part of the same molecule as the atom with number 13. This requires the system to have topology information.
Center of mass calculations
- Introduced
System::group_get_com
for calculating the center of mass of a group of atoms using the Bai and Breen algorithm. Note that all atoms in the target group must have mass information. - Introduced
System::atoms_center_mass
as an alternative toSystem::atoms_center
but using center of mass instead of center of geometry.
Other changes
- Breaking change: The
System::set_mol_references
method is no longer public. - Added more tests for the basic
Atom
get_*
,set_*
,reset_*
, andwith_*
functions. - Documentation examples no longer repeat that you have to use
groan_rs::prelude::*
. - Added
Atom::distance_naive
for calculating the distance between atoms without considering periodic boundary conditions. - Bug fix:
Vector3D::wrap_coordinate
andVector3D::min_image
now panic ifbox_len
is 0 instead of looping indefinitely. - The
System::group_get_center
function has been refactored and may return a result that is not binary identical to previous versions. - Introduced
System::group_isempty
function for checking whether a target group of atoms is empty.
v0.5.0
Version 0.5.0
Important BREAKING CHANGES affecting the entire groan_rs
library
- Fields
position
,velocity
, andforce
in theAtom
structure are now of typeOption<Vector3D>
.Atom::new
initializes these values toNone
. UseAtom::with_position
,Atom::with_velocity
, orAtom::with_force
to set them.- Accessor methods (
Atom::get_position
, etc.) now returnOption<&Vector3D>
. - Distance functions require all atoms to have position information; absence leads to panic.
- When writing files, undefined positions (and velocities) are output as 0.0 in all dimensions.
- Reading xtc trajectories sets
velocity
andforce
of all atoms toNone
. - Atoms without
position
are excluded from geometric shape calculations in(Mut)FilterAtomIterator
andSystem::group_create_from_geometry
. System::has_forces
,System::has_velocities
,System::has_positions
returntrue
only if all atoms have the respective property.- A position with x = 0.0, y = 0.0, z = 0.0 is now considered valid. However, atoms without positions are still written with 0.0 coordinates.
Other changes to the Atom
structure
- New optional fields
charge
andbonded
added:charge
: Specifies the atom's charge.bonded
: Contains indices of atoms bonded to the atom.- Methods added to use and access
charge
andbonded
. Atom::wrap
method introduced for wrapping the atom into the simulation box.
AtomContainer
structure
- Breaking Change: Introduction of
AtomContainer
:- Describes a collection of atoms in the
System
structure. Group
structure and all atom iterators reworked to useAtomContainer
.- Many methods associated with
Group
removed/renamed/rewritten.
- Describes a collection of atoms in the
Reading and writing PDB files
- Breaking Change:
System::write_pdb
andSystem::group_write_pdb
now require an argument for connectivity information. - Potentially Breaking Change: Reading of PDB files now stops at
ENDMDL
orEND
.END
keyword is written correctly at the end of files. - Connectivity section can now be read with
System::add_bonds_from_pdb
and written withSystem::write_pdb
/System::group_write_pdb
.
Reading systems with non-orthogonal simulation boxes
- Support added for reading/writing systems with non-orthogonal simulation boxes from/to PDB, XTC, and TRR files.
New System
connectivity methods
- New methods introduced:
System::add_bond
: Adds a bond between atoms.System::bonded_atoms_iter
andSystem::bonded_atoms_iter_mut
: Iterates through bonded atoms.System::has_bonds
: Checks for available connectivity information.System::molecule_iter
andSystem::molecule_iter_mut
: Iterates through atoms in the same molecule.System::make_molecules_whole
: Fixes molecules broken at periodic boundaries.
Quality-of-Life improvements
ProgressPrinter
introduced for trajectory reading progress. Activated viaTrajMasterRead::print_progress
.
Other changes
- Breaking Change: Atom access methods (
System::get_atom_as_ref
, etc.) now use index instead ofgmx_atom_number
. - Breaking Change:
System::from_file
returnsResult<Self, Box<dyn Error + Send + Sync>>
for threading compatibility. System::has_duplicate_atom_numbers
: Checks for duplicate atom numbers.System::residues_renumber
: Renumbers residues in the system.System::atoms_wrap
andSystem::group_wrap
: Wraps atoms into the simulation box.System::atoms_distance
: Calculates distance between two atoms.- Panic groan errors now specify the originating function.