Pteros  2.0
Molecular modeling library for human beings!
pteros::Selection Class Reference

Selection class. More...

#include <atom_proxy.h>

Classes

class  iterator
 Random-access forward iterator for Selection. More...
 

Public Member Functions

Modification of existing selection
void append (const Selection &sel)
 Append another selection to this one.
 
void append (int ind)
 Append absolute index to selection.
 
void remove (const Selection &sel)
 Remove all atoms of sel from current selection.
 
void remove (int ind)
 Remove given absolute index from current selection.
 
void invert ()
 Inverts selection in place by selection those atoms which were not selected.
 
void set_system (const System &sys)
 Sets new system for selection. More...
 
void modify (std::string str, int fr=0)
 Modifies selection string in existing selection. More...
 
void modify (int ind1, int ind2)
 Modifies selection using the range of indexes.
 
void modify (const std::vector< int > &ind)
 Modifies selection using vector of indexes Vector may be in any order and may contain duplicates. More...
 
void modify (std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Modifies selection using pair of iterators to index vector Vector may be in any order and may contain duplicates. More...
 
void modify (const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Modifies selection using user-defined callback. More...
 
void modify (const System &sys, std::string str, int fr=0)
 Convenience function, which combines set_system and modify(str)
 
void modify (const System &sys, int ind1, int ind2)
 Convenience function, which combines set_system and modify(int,int)
 
void modify (const System &sys, const std::vector< int > &ind)
 Convenience function, which combines set_system and modify(vector<int>)
 
void modify (const System &sys, std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Convenience function, which combines set_system and modify(iter,iter)
 
void modify (const System &sys, const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Convenience function, which combines set_system and modify(callback)
 
void apply ()
 Recomputes selection without re-parsing selection text. More...
 
void update ()
 Recomputes selection completely. More...
 
void clear ()
 Clears selection and frees memory. More...
 
void append (const Selection &sel)
 Append another selection to this one.
 
void append (int ind)
 Append absolute index to selection.
 
void remove (const Selection &sel)
 Remove all atoms of sel from current selection.
 
void remove (int ind)
 Remove given absolute index from current selection.
 
void invert ()
 Inverts selection in place by selection those atoms which were not selected.
 
void set_system (const System &sys)
 Sets new system for selection. More...
 
void modify (std::string str, int fr=0)
 Modifies selection string in existing selection. More...
 
void modify (int ind1, int ind2)
 Modifies selection using the range of indexes.
 
void modify (const std::vector< int > &ind)
 Modifies selection using vector of indexes Vector may be in any order and may contain duplicates. More...
 
void modify (std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Modifies selection using pair of iterators to index vector Vector may be in any order and may contain duplicates. More...
 
void modify (const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Modifies selection using user-defined callback. More...
 
void modify (const System &sys, std::string str, int fr=0)
 Convenience function, which combines set_system and modify(str)
 
void modify (const System &sys, int ind1, int ind2)
 Convenience function, which combines set_system and modify(int,int)
 
void modify (const System &sys, const std::vector< int > &ind)
 Convenience function, which combines set_system and modify(vector<int>)
 
void modify (const System &sys, std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Convenience function, which combines set_system and modify(iter,iter)
 
void modify (const System &sys, const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Convenience function, which combines set_system and modify(callback)
 
void apply ()
 Recomputes selection without re-parsing selection text. More...
 
void update ()
 Recomputes selection completely. More...
 
void clear ()
 Clears selection and frees memory. More...
 
Sub-selections
Selection select (std::string str)
 Sub-selections allow selecting atoms inside existing selection (narrowing or refining existing selection in other terms). More...
 
Selection operator() (std::string str)
 
Selection select (int ind1, int ind2)
 Local selection indexes are used!
 
Selection operator() (int ind1, int ind2)
 
Selection select (const std::vector< int > &ind)
 Local selection indexes are used!
 
Selection operator() (const std::vector< int > &ind)
 
Selection select (std::string str)
 Sub-selections allow selecting atoms inside existing selection (narrowing or refining existing selection in other terms). More...
 
Selection operator() (std::string str)
 
Selection select (int ind1, int ind2)
 Local selection indexes are used!
 
Selection operator() (int ind1, int ind2)
 
Selection select (const std::vector< int > &ind)
 Local selection indexes are used!
 
Selection operator() (const std::vector< int > &ind)
 
Iterator access
std::vector< int >::const_iterator index_begin () const
 Get const iterator for begin of index.
 
std::vector< int >::const_iterator index_end () const
 Get const iterator for the end of index.
 
std::back_insert_iterator< std::vector< int > > index_back_inserter ()
 Get back_insert_iterator for index.
 
iterator begin ()
 Begin iterator.
 
iterator end ()
 End iterator.
 
std::vector< int >::const_iterator index_begin () const
 Get const iterator for begin of index.
 
std::vector< int >::const_iterator index_end () const
 Get const iterator for the end of index.
 
std::back_insert_iterator< std::vector< int > > index_back_inserter ()
 Get back_insert_iterator for index.
 
iterator begin ()
 Begin iterator.
 
iterator end ()
 End iterator.
 
Get and set functions
int get_frame () const
 Get current frame selection is pointing to.
 
void set_frame (int fr)
 Set current frame for selection. More...
 
Systemget_system () const
 Get pointer to the system, which is pointed by this selection.
 
std::string get_text () const
 Get selection text If selection is not textual returns generated index-based text "index i j k...".
 
std::vector< int > get_index () const
 Get vector of all indexes in selection.
 
std::vector< char > get_chain () const
 Get vector of all chains in selection.
 
void set_chain (const std::vector< char > &data)
 Set chains from supplied vector. More...
 
void set_chain (char data)
 Sets chain of all selected atoms to the same given value.
 
std::vector< char > get_unique_chain () const
 Get vector of unique chains in selection.
 
std::vector< int > get_resid () const
 Get vector of all resid's in selection. More...
 
std::vector< int > get_unique_resid () const
 Get vector of unique resid's in selection.
 
void set_resid (const std::vector< int > &data)
 Set resid's in selection from supplied vector. More...
 
void set_resid (int data)
 Sets resid of all selected atoms to the same given value.
 
std::vector< int > get_resindex () const
 Get vector of all resindexes in selection. More...
 
std::vector< int > get_unique_resindex () const
 Get vector of unique resindexes's in selection.
 
std::vector< std::string > get_name () const
 Get vector of all atom names in selection.
 
void set_name (const std::vector< std::string > &data)
 Set atom names in selection from supplied vector. More...
 
void set_name (std::string &data)
 Sets atom names of all selected atoms to the same given value.
 
std::vector< std::string > get_resname () const
 Get vector of all resnames in selection.
 
void set_resname (const std::vector< std::string > &data)
 Set resnames in selection from supplied vector. More...
 
void set_resname (std::string &data)
 Sets resnames of all selected atoms to the same given value.
 
Eigen::MatrixXf get_xyz () const
 Get coordinates of all atoms in this selection for the current frame.
 
void get_xyz (MatrixXf_ref res) const
 Get coordinates of all atoms in this selection for the current frame in existing matrix.
 
void set_xyz (MatrixXf_const_ref coord)
 Set coordinates of this selection for current frame.
 
std::vector< float > get_mass () const
 Get masses of all atoms in selection.
 
void set_mass (const std::vector< float > m)
 Set atom masses in selection to the values from supplied vector. More...
 
void set_mass (float data)
 Sets masses of all selected atoms to the same given value.
 
std::vector< float > get_beta () const
 Get beta.
 
void set_beta (std::vector< float > &data)
 Set beta in selection to the values from supplied vector. More...
 
void set_beta (float data)
 Sets beta of all selected atoms to the same given value.
 
std::vector< float > get_occupancy () const
 Get occupancy.
 
void set_occupancy (std::vector< float > &data)
 Set occupancy in selection to the values from supplied vector. More...
 
void set_occupancy (float data)
 Sets occupancy of all selected atoms to the same given value.
 
int get_frame () const
 Get current frame selection is pointing to.
 
void set_frame (int fr)
 Set current frame for selection. More...
 
Systemget_system () const
 Get pointer to the system, which is pointed by this selection.
 
std::string get_text () const
 Get selection text If selection is not textual returns generated index-based text "index i j k...".
 
std::vector< int > get_index () const
 Get vector of all indexes in selection.
 
std::vector< char > get_chain () const
 Get vector of all chains in selection.
 
void set_chain (const std::vector< char > &data)
 Set chains from supplied vector. More...
 
void set_chain (char data)
 Sets chain of all selected atoms to the same given value.
 
std::vector< char > get_unique_chain () const
 Get vector of unique chains in selection.
 
std::vector< int > get_resid () const
 Get vector of all resid's in selection. More...
 
std::vector< int > get_unique_resid () const
 Get vector of unique resid's in selection.
 
std::vector< std::string > get_unique_resname () const
 Get vector of unique resnames in selection.
 
void set_resid (const std::vector< int > &data)
 Set resid's in selection from supplied vector. More...
 
void set_resid (int data)
 Sets resid of all selected atoms to the same given value.
 
std::vector< int > get_resindex () const
 Get vector of all resindexes in selection. More...
 
std::vector< int > get_unique_resindex () const
 Get vector of unique resindexes's in selection.
 
std::vector< std::string > get_name () const
 Get vector of all atom names in selection.
 
void set_name (const std::vector< std::string > &data)
 Set atom names in selection from supplied vector. More...
 
void set_name (std::string &data)
 Sets atom names of all selected atoms to the same given value.
 
std::vector< std::string > get_resname () const
 Get vector of all resnames in selection.
 
void set_resname (const std::vector< std::string > &data)
 Set resnames in selection from supplied vector. More...
 
void set_resname (std::string &data)
 Sets resnames of all selected atoms to the same given value.
 
Eigen::MatrixXf get_xyz () const
 Get coordinates of all atoms in this selection for the current frame.
 
void get_xyz (MatrixXf_ref res) const
 Get coordinates of all atoms in this selection for the current frame in existing matrix.
 
void set_xyz (MatrixXf_const_ref coord)
 Set coordinates of this selection for current frame.
 
std::vector< float > get_mass () const
 Get masses of all atoms in selection.
 
void set_mass (const std::vector< float > m)
 Set atom masses in selection to the values from supplied vector. More...
 
void set_mass (float data)
 Sets masses of all selected atoms to the same given value.
 
std::vector< float > get_beta () const
 Get beta.
 
void set_beta (std::vector< float > &data)
 Set beta in selection to the values from supplied vector. More...
 
void set_beta (float data)
 Sets beta of all selected atoms to the same given value.
 
std::vector< float > get_occupancy () const
 Get occupancy.
 
void set_occupancy (std::vector< float > &data)
 Set occupancy in selection to the values from supplied vector. More...
 
void set_occupancy (float data)
 Sets occupancy of all selected atoms to the same given value.
 
std::vector< std::string > get_tag () const
 Get tags.
 
void set_tag (std::vector< std::string > &data)
 Set tags in selection to the values from supplied vector. More...
 
void set_tag (std::string data)
 Set tags of all selected atoms to the same given value.
 
Computing properties of selection
Eigen::Vector3f center (bool mass_weighted=false, bool periodic=false) const
 Get the center of selection. More...
 
void minmax (Vector3f_ref min, Vector3f_ref max) const
 Get minimal and maximal coordinates in selection.
 
float sasa (float probe_r=0.14, float *total_volume=nullptr, std::vector< float > *area_per_atom=nullptr, std::vector< float > *volume_per_atom=nullptr) const
 Get the SASA. Returns area and computes volume and per-atom values if asked.
 
Eigen::MatrixXf average_structure (int b=0, int e=-1) const
 Computes average structure over the range of frames.
 
Eigen::MatrixXf atom_traj (int ind, int b=0, int e=-1) const
 Extracts X,Y,Z for given atom index for specified range of frames (gets trajectory of given atom). More...
 
void inertia (Vector3f_ref moments, Matrix3f_ref axes, bool periodic=false) const
 Computes the central momens of inertia and principal axes of inertia. More...
 
float gyration (bool periodic=false) const
 Computes radius of gyration for selection. More...
 
float distance (int i, int j, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get distance between two atoms (periodic in given dimensions if needed). More...
 
float angle (int i, int j, int k, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get angle in degrees between three atoms (periodic in given dimensions if needed). More...
 
float dihedral (int i, int j, int k, int l, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get dihedral angle in degrees between three atoms (periodic in given dimensions if needed). More...
 
Eigen::Vector3f center (bool mass_weighted=false, bool periodic=false) const
 Get the center of selection. More...
 
void minmax (Vector3f_ref min, Vector3f_ref max) const
 Get minimal and maximal coordinates in selection.
 
float sasa (float probe_r=0.14, float *total_volume=nullptr, std::vector< float > *area_per_atom=nullptr, std::vector< float > *volume_per_atom=nullptr) const
 Get the SASA. Returns area and computes volume and per-atom values if asked.
 
Eigen::MatrixXf average_structure (int b=0, int e=-1) const
 Computes average structure over the range of frames.
 
Eigen::MatrixXf atom_traj (int ind, int b=0, int e=-1) const
 Extracts X,Y,Z for given atom index for specified range of frames (gets trajectory of given atom). More...
 
void inertia (Vector3f_ref moments, Matrix3f_ref axes, bool periodic=false) const
 Computes the central momens of inertia and principal axes of inertia. More...
 
float gyration (bool periodic=false) const
 Computes radius of gyration for selection. More...
 
float distance (int i, int j, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get distance between two atoms (periodic in given dimensions if needed). More...
 
float angle (int i, int j, int k, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get angle in degrees between three atoms (periodic in given dimensions if needed). More...
 
float dihedral (int i, int j, int k, int l, bool is_periodic=true, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Get dihedral angle in degrees between three atoms (periodic in given dimensions if needed). More...
 
Geometry transformation functions
void translate (Vector3f_const_ref v)
 Translate selection by given vector.
 
void rotate (int axis, float angle)
 Rotate selection around given axis relative to center of masses. More...
 
void rotate (int axis, float angle, Vector3f_const_ref pivot)
 Rotate selection around given axis relative to given pivot. More...
 
void rotate (Vector3f_const_ref direction, float angle, Vector3f_const_ref pivot)
 Rotate selection around given vector relative to given pivot. More...
 
void rotate (Matrix3f_const_ref m)
 Rotation with the given 3x3 rotation matrix around point (0,0,0)
 
void rotate (Vector3f_const_ref angles, Vector3f_const_ref pivot)
 Rotation by given angles around X, Y and Z with given pivot.
 
void wrap (Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Wraps whole selection to the periodic box.
 
void unwrap (Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Unwraps selection to make it whole if possible (without jumps over periodic box boundary). More...
 
int unwrap_bonds (float d=0.2, int leading_index=0, Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Unwraps selection to make it whole (without jumps over periodic box boundary). More...
 
Eigen::Affine3f principal_transform (bool is_periodic=false) const
 Get transform for orienting selection by principal axes. More...
 
void principal_orient (bool is_periodic=false)
 Orient molecule by its principal axes. More...
 
void translate (Vector3f_const_ref v)
 Translate selection by given vector.
 
void rotate (int axis, float angle)
 Rotate selection around given axis relative to center of masses. More...
 
void rotate (int axis, float angle, Vector3f_const_ref pivot)
 Rotate selection around given axis relative to given pivot. More...
 
void rotate (Vector3f_const_ref direction, float angle, Vector3f_const_ref pivot)
 Rotate selection around given vector relative to given pivot. More...
 
void rotate (Matrix3f_const_ref m)
 Rotation with the given 3x3 rotation matrix around point (0,0,0)
 
void rotate (Vector3f_const_ref angles, Vector3f_const_ref pivot)
 Rotation by given angles around X, Y and Z with given pivot.
 
void wrap (Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Wraps whole selection to the periodic box.
 
void unwrap (Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Unwraps selection to make it whole if possible (without jumps over periodic box boundary). More...
 
int unwrap_bonds (float d=0.2, int leading_index=0, Vector3i_const_ref dims=Eigen::Vector3i::Ones())
 Unwraps selection to make it whole (without jumps over periodic box boundary). More...
 
Eigen::Affine3f principal_transform (bool is_periodic=false) const
 Get transform for orienting selection by principal axes. More...
 
void principal_orient (bool is_periodic=false)
 Orient molecule by its principal axes. More...
 
File IO
void write (std::string fname, int b=-1, int e=-1)
 Write structure or trajectory for selection. More...
 
void write (const std::unique_ptr< Mol_file > &handler, Mol_file_content what, int b=-1, int e=-1)
 
void write (std::string fname, int b=-1, int e=-1)
 Write structure or trajectory for selection. More...
 
void write (const std::unique_ptr< Mol_file > &handler, Mol_file_content what, int b=-1, int e=-1)
 
Utility functions
int size () const
 Get the size of selection.
 
bool text_based () const
 Returns true if selection was created from text string and false if it was constructed 'by hand' by appending indexes or other selections.
 
bool coord_dependent () const
 Returns true if selection is coordinate-dependent and is able to recompute itself on the change of frame.
 
void flatten ()
 "Flattens" selection by removing coordinate dependence and making it not text-based. More...
 
int size () const
 Get the size of selection.
 
bool text_based () const
 Returns true if selection was created from text string and false if it was constructed 'by hand' by appending indexes or other selections.
 
bool coord_dependent () const
 Returns true if selection is coordinate-dependent and is able to recompute itself on the change of frame.
 
void flatten ()
 "Flattens" selection by removing coordinate dependence and making it not text-based. More...
 
std::string gromacs_ndx (std::string name)
 Returns a string formatted as Gromacs ndx file containing the current selection with given name. More...
 
Splitting selection into parts
void split_by_connectivity (float d, std::vector< Selection > &res, bool periodic=true)
 Split current selection into several selections according to the interatomic distances. More...
 
void split_by_residue (std::vector< Selection > &res)
 Split selection by residue index.
 
void split_by_chain (std::vector< Selection > &chains)
 Split selection by chain.
 
void split_by_contiguous_index (std::vector< Selection > &parts)
 Split selection into contiguous ranges of indexes.
 
void split_by_contiguous_residue (std::vector< Selection > &parts)
 Split selection into contiguous ranges of resindexes.
 
void each_residue (std::vector< Selection > &sel) const
 Selects each residue, which is referenced by selection. More...
 
void split_by_connectivity (float d, std::vector< Selection > &res, bool periodic=true)
 Split current selection into several selections according to the interatomic distances. More...
 
void split_by_residue (std::vector< Selection > &res)
 Split selection by residue index.
 
void split_by_chain (std::vector< Selection > &chains)
 Split selection by chain.
 
void split_by_contiguous_index (std::vector< Selection > &parts)
 Split selection into contiguous ranges of indexes.
 
void split_by_contiguous_residue (std::vector< Selection > &parts)
 Split selection into contiguous ranges of resindexes.
 
template<class F >
void split (std::vector< Selection > &parts, F callback)
 Split selection by the values returned by custom callback function. More...
 
void each_residue (std::vector< Selection > &sel) const
 Selects each residue, which is referenced by selection. More...
 
Inline accessors

Used to access the properties of particular atom in selection.

The ind passed to these functions is is the selection index, not the global system index. I.e. passing 10 will extract the property of atom with global index index[10]
All these function except Index could be used as lvalue, which means that it is possible to assign value to them. For example X(10) = 3.14 will assign the value 3.14 to the atom with global index index[10].

float & X (int ind)
 Extracts X for current frame.
 
const float & X (int ind) const
 
float & X (int ind, int fr)
 Extracts X for given frame frame fr.
 
const float & X (int ind, int fr) const
 
float & Y (int ind)
 Extracts Y for current frame.
 
const float & Y (int ind) const
 
float & Y (int ind, int fr)
 Extracts Y for given frame frame fr.
 
const float & Y (int ind, int fr) const
 
float & Z (int ind)
 Extracts Z for current frame.
 
const float & Z (int ind) const
 
float & Z (int ind, int fr)
 Extracts Z for given frame frame fr.
 
const float & Z (int ind, int fr) const
 
Eigen::Vector3f & XYZ (int ind)
 Extracts X,Y and Z for current frame.
 
const Eigen::Vector3f & XYZ (int ind) const
 
Eigen::Vector3f * XYZ_ptr (int ind) const
 Returns pointer to the coordinates of given atom for current frame. More...
 
Eigen::Vector3f & XYZ (int ind, int fr)
 Extracts X,Y and Z for given frame frame fr.
 
const Eigen::Vector3f & XYZ (int ind, int fr) const
 
int & Type (int ind)
 Extracts type.
 
const int & Type (int ind) const
 
std::string & Type_name (int ind)
 Extracts typename.
 
const std::string & Type_name (int ind) const
 
std::string & Resname (int ind)
 Extracts residue name.
 
const std::string & Resname (int ind) const
 
char & Chain (int ind)
 Extracts chain.
 
const char & Chain (int ind) const
 
std::string & Name (int ind)
 Extracts atom name.
 
const std::string & Name (int ind) const
 
float & Mass (int ind)
 Extracts atom mass.
 
const float & Mass (int ind) const
 
float & Charge (int ind)
 Extracts atom charge.
 
const float & Charge (int ind) const
 
float & Beta (int ind)
 Extracts B-factor.
 
const float & Beta (int ind) const
 
float & Occupancy (int ind)
 Extracts occupancy field.
 
const float & Occupancy (int ind) const
 
int & Resid (int ind)
 Extracts residue number.
 
const int & Resid (int ind) const
 
int & Index (int ind)
 Extracts atom index in the system, which is pointed by selection.
 
const int & Index (int ind) const
 
std::string & Tag (int ind)
 Extracts tag.
 
const std::string & Tag (int ind) const
 
pteros::AtomAtom_data (int ind)
 Extracts whole atom.
 
const pteros::AtomAtom_data (int ind) const
 
int & Resindex (int ind)
 Extracts resindex.
 
const int & Resindex (int ind) const
 
float VDW (int ind) const
 Computes VDW radius. Read only.
 
Periodic_boxBox ()
 Returns periodic box of the frame pointed by selection The same as: More...
 
const Periodic_boxBox () const
 
float & Time ()
 Returns time stamp of the frame pointed by selection The same as: More...
 
const float & Time () const
 
float & X (int ind)
 Extracts X for current frame.
 
const float & X (int ind) const
 
float & X (int ind, int fr)
 Extracts X for given frame frame fr.
 
const float & X (int ind, int fr) const
 
float & Y (int ind)
 Extracts Y for current frame.
 
const float & Y (int ind) const
 
float & Y (int ind, int fr)
 Extracts Y for given frame frame fr.
 
const float & Y (int ind, int fr) const
 
float & Z (int ind)
 Extracts Z for current frame.
 
const float & Z (int ind) const
 
float & Z (int ind, int fr)
 Extracts Z for given frame frame fr.
 
const float & Z (int ind, int fr) const
 
Eigen::Vector3f & XYZ (int ind)
 Extracts X,Y and Z for current frame.
 
const Eigen::Vector3f & XYZ (int ind) const
 
Eigen::Vector3f * XYZ_ptr (int ind) const
 Returns pointer to the coordinates of given atom for current frame. More...
 
Eigen::Vector3f & XYZ (int ind, int fr)
 Extracts X,Y and Z for given frame frame fr.
 
const Eigen::Vector3f & XYZ (int ind, int fr) const
 
int & Type (int ind)
 Extracts type.
 
const int & Type (int ind) const
 
std::string & Type_name (int ind)
 Extracts typename.
 
const std::string & Type_name (int ind) const
 
std::string & Resname (int ind)
 Extracts residue name.
 
const std::string & Resname (int ind) const
 
char & Chain (int ind)
 Extracts chain.
 
const char & Chain (int ind) const
 
std::string & Name (int ind)
 Extracts atom name.
 
const std::string & Name (int ind) const
 
float & Mass (int ind)
 Extracts atom mass.
 
const float & Mass (int ind) const
 
float & Charge (int ind)
 Extracts atom charge.
 
const float & Charge (int ind) const
 
float & Beta (int ind)
 Extracts B-factor.
 
const float & Beta (int ind) const
 
float & Occupancy (int ind)
 Extracts occupancy field.
 
const float & Occupancy (int ind) const
 
int & Resid (int ind)
 Extracts residue number.
 
const int & Resid (int ind) const
 
int & Index (int ind)
 Extracts atom index in the system, which is pointed by selection.
 
const int & Index (int ind) const
 
std::string & Tag (int ind)
 Extracts tag.
 
const std::string & Tag (int ind) const
 
pteros::AtomAtom_data (int ind)
 Extracts whole atom.
 
const pteros::AtomAtom_data (int ind) const
 
int & Resindex (int ind)
 Extracts resindex.
 
const int & Resindex (int ind) const
 
float VDW (int ind) const
 Computes VDW radius. Read only.
 
Periodic_boxBox ()
 Returns periodic box of the frame pointed by selection The same as: More...
 
const Periodic_boxBox () const
 
float & Time ()
 Returns time stamp of the frame pointed by selection The same as: More...
 
const float & Time () const
 

Constructors and operators

std::ostream & operator<< (std::ostream &os, const Selection &sel)
 
Selection operator| (const Selection &sel1, const Selection &sel2)
 Creates new Selection, which is the logical OR of two parent selections. More...
 
Selection operator& (const Selection &sel1, const Selection &sel2)
 Creates new Selection, which is the logical AND of two parent selections. More...
 
Selection operator- (const Selection &sel1, const Selection &sel2)
 Creates new Selection, by removing all atoms of sel2 from sel1. More...
 
std::ostream & operator<< (std::ostream &os, const Selection &sel)
 Writing selection to stream. More...
 
Selection operator| (const Selection &sel1, const Selection &sel2)
 Creates new Selection, which is the logical OR of two parent selections. More...
 
Selection operator& (const Selection &sel1, const Selection &sel2)
 Creates new Selection, which is the logical AND of two parent selections. More...
 
Selection operator- (const Selection &sel1, const Selection &sel2)
 Creates new Selection, by removing all atoms of sel2 from sel1. More...
 
 Selection ()
 Default constructor for absolutely empty selection.
 
 Selection (const System &sys)
 Associates selection with the system. More...
 
 Selection (const System &sys, std::string str, int fr=0)
 Main constructor. More...
 
 Selection (const System &sys, int ind1, int ind2)
 Constructor, which creates selection from the interval of indexes instead of selection string. More...
 
 Selection (const System &sys, const std::vector< int > &ind)
 Constructor from vector of indexes Vector may be in any order and may contain duplicates. More...
 
 Selection (const System &sys, std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Constructor from the pair of iterators to int sequence Sequence may be in any order and may contain duplicates. More...
 
 Selection (const System &sys, const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Constructor which takes user-defined callback Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes. More...
 
 Selection (const Selection &sel)
 Copy constructor.
 
virtual ~Selection ()
 Destructor.
 
Selectionoperator= (Selection sel)
 Assignment operator.
 
bool operator== (const Selection &other) const
 Equality operator Selection are compared by their indexes.
 
bool operator!= (const Selection &other) const
 Inequality operator Selection are compared by their indexes.
 
Atom_proxy operator[] (int ind) const
 Indexing operator. More...
 
Selection operator~ () const
 Creates new Selection, which is a logical negation of existing one. More...
 
 Selection ()
 Default constructor for absolutely empty selection.
 
 Selection (const System &sys)
 Associates selection with the system. More...
 
 Selection (const System &sys, std::string str, int fr=0)
 Main constructor. More...
 
 Selection (const System &sys, int ind1, int ind2)
 Constructor, which creates selection from the interval of indexes instead of selection string. More...
 
 Selection (const System &sys, const std::vector< int > &ind)
 Constructor from vector of indexes Vector may be in any order and may contain duplicates. More...
 
 Selection (const System &sys, std::vector< int >::iterator it1, std::vector< int >::iterator it2)
 Constructor from the pair of iterators to int sequence Sequence may be in any order and may contain duplicates. More...
 
 Selection (const System &sys, const std::function< void(const System &, int, std::vector< int > &)> &callback, int fr=0)
 Constructor which takes user-defined callback Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes. More...
 
 Selection (const Selection &sel)
 Copy constructor.
 
virtual ~Selection ()
 Destructor.
 
Selectionoperator= (Selection sel)
 Assignment operator.
 
bool operator== (const Selection &other) const
 Equality operator Selection are compared by their indexes.
 
bool operator!= (const Selection &other) const
 Inequality operator Selection are compared by their indexes.
 
Atom_proxy operator[] (int ind) const
 Indexing operator. More...
 
Selection operator~ () const
 Creates new Selection, which is a logical negation of existing one. More...
 

Fitting and RMSD functions

float rmsd (const Selection &sel1, const Selection &sel2)
 RMSD between two selections of the same size.
 
float rmsd (const Selection &sel1, int fr1, const Selection &sel2, int fr2)
 RMSD between two selections of the same size (for given frames) More...
 
void fit (Selection &sel1, const Selection &sel2)
 Fit two selection of the same size. sel1 is modified to be fit to sel2.
 
Eigen::Affine3f fit_transform (const Selection &sel1, const Selection &sel2)
 Returns fitting transformation for two given selections of the same size.
 
float rmsd (const Selection &sel1, const Selection &sel2)
 RMSD between two selections of the same size.
 
float rmsd (const Selection &sel1, int fr1, const Selection &sel2, int fr2)
 RMSD between two selections of the same size (for given frames) More...
 
void fit (Selection &sel1, const Selection &sel2)
 Fit two selection of the same size. sel1 is modified to be fit to sel2.
 
Eigen::Affine3f fit_transform (const Selection &sel1, const Selection &sel2)
 Returns fitting transformation for two given selections of the same size.
 
float rmsd (int fr) const
 RMSD between current and another frame.
 
float rmsd (int fr1, int fr2) const
 RMSD between two frames.
 
void fit_trajectory (int ref_frame=0, int b=0, int e=-1)
 Fit all frames in the trajectory to reference frame.
 
Eigen::Affine3f fit_transform (int fr1, int fr2) const
 Returns fit transformation between frames fr1 and fr2.
 
void fit (int fr1, int fr2)
 Fits frame fr1 to fr2.
 
void apply_transform (const Eigen::Affine3f &t)
 Apply fitting transformation.
 
float rmsd (int fr) const
 RMSD between current and another frame.
 
float rmsd (int fr1, int fr2) const
 RMSD between two frames.
 
void fit_trajectory (int ref_frame=0, int b=0, int e=-1)
 Fit specified frames in the trajectory to reference frame.
 
Eigen::Affine3f fit_transform (int fr1, int fr2) const
 Returns fit transformation between frames fr1 and fr2.
 
void fit (int fr1, int fr2)
 Fits frame fr1 to fr2.
 
void apply_transform (const Eigen::Affine3f &t)
 Apply fitting transformation.
 

Energy functions

Energy_components non_bond_energy (const Selection &sel1, const Selection &sel2, float cutoff, int fr, bool periodic)
 Non-bond energy between two selections computed within given interaction cut-off. More...
 
Energy_components non_bond_energy (const Selection &sel1, const Selection &sel2, float cutoff, int fr, bool periodic)
 Non-bond energy between two selections computed within given interaction cut-off. More...
 
Energy_components non_bond_energy (float cutoff=0.25, bool periodic=true) const
 Self-energy of selection computed within given interaction cut-off. More...
 
Energy_components non_bond_energy (float cutoff=0.25, bool periodic=true) const
 Self-energy of selection computed within given interaction cut-off. More...
 

Detailed Description

Selection class.

Selections are key objects in Pteros. Technically speaking the selection is just an array, which contains indexes of selected atoms in particlar system. Selection does not hold the copies of the atoms or their coordinates, it just points to them serving like a handy alias for certain subset of atoms. Thus selections may overlap arbitrarily. Selections are used to perform various operations on the group of selected atoms. The changes become immediately visible to all other selections, which point to some of changed atoms. Each selection is bound to particular System. There are neither 'parentless' selection nor the selections, which combine the atoms from different systems. Selections are created using the syntax, which is very similar to those used in VMD.

Constructor & Destructor Documentation

Selection::Selection ( const System sys)

Associates selection with the system.

Parameters
sys,Selectioncontent should be set later by calling modify().
Selection::Selection ( const System sys,
std::string  str,
int  fr = 0 
)

Main constructor.

Parameters
sysSystem pointed by this selection
strSelection string
Selection::Selection ( const System sys,
int  ind1,
int  ind2 
)

Constructor, which creates selection from the interval of indexes instead of selection string.

It is much faster then parsing corresponding string, but is limited to contigous interval of indexes.

Parameters
sysSystem pointed by this selection
ind1First index in interval
ind2Last index in interval (inclusive!)
Selection::Selection ( const System sys,
const std::vector< int > &  ind 
)

Constructor from vector of indexes Vector may be in any order and may contain duplicates.

Selection::Selection ( const System sys,
std::vector< int >::iterator  it1,
std::vector< int >::iterator  it2 
)

Constructor from the pair of iterators to int sequence Sequence may be in any order and may contain duplicates.

pteros::Selection::Selection ( const System sys,
const std::function< void(const System &, int, std::vector< int > &)> &  callback,
int  fr = 0 
)

Constructor which takes user-defined callback Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes.

Vector may be filled in any order and may contain duplicates.

Warning
Resulting selection is neither coordinate-dependent nor text-based. It will not recompute itself on the frame change even if it involves atom coordinates.
pteros::Selection::Selection ( const System sys)

Associates selection with the system.

Parameters
sys,Selectioncontent should be set later by calling modify().
pteros::Selection::Selection ( const System sys,
std::string  str,
int  fr = 0 
)

Main constructor.

Parameters
sysSystem pointed by this selection
strSelection string
pteros::Selection::Selection ( const System sys,
int  ind1,
int  ind2 
)

Constructor, which creates selection from the interval of indexes instead of selection string.

It is much faster then parsing corresponding string, but is limited to contigous interval of indexes.

Parameters
sysSystem pointed by this selection
ind1First index in interval
ind2Last index in interval (inclusive!)
pteros::Selection::Selection ( const System sys,
const std::vector< int > &  ind 
)

Constructor from vector of indexes Vector may be in any order and may contain duplicates.

pteros::Selection::Selection ( const System sys,
std::vector< int >::iterator  it1,
std::vector< int >::iterator  it2 
)

Constructor from the pair of iterators to int sequence Sequence may be in any order and may contain duplicates.

pteros::Selection::Selection ( const System sys,
const std::function< void(const System &, int, std::vector< int > &)> &  callback,
int  fr = 0 
)

Constructor which takes user-defined callback Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes.

Vector may be filled in any order and may contain duplicates.

Warning
Resulting selection is neither coordinate-dependent nor text-based. It will not recompute itself on the frame change even if it involves atom coordinates.

Member Function Documentation

Atom_proxy Selection::operator[] ( int  ind) const

Indexing operator.

Returns an Atom_proxy object, which incapsulates atom and its coordinates for current frame Can only be used as r-value (can not be assigned to) however individual fields of the proxy object are writable

Selection sel(sys,"name CA");
sel[1] = sel[0]; // ERROR! Can't assign to proxy object returned by []!
sel[0].Name() = "A"; // OK to write fields of proxy object

Main goal of [] operator is usage in range-based for loops:

Selection sel(sys,"name CA");
for(auto a: sel){
cout << a.Name() << " " << a.X() << endl;
}

Otherwise it is slower than conventional syntax like sel.Name(i)

Selection Selection::operator~ ( ) const

Creates new Selection, which is a logical negation of existing one.

Parent selection is not modified

void Selection::set_system ( const System sys)

Sets new system for selection.

Warning
This clears selection index and leaves it empty!
void Selection::modify ( std::string  str,
int  fr = 0 
)

Modifies selection string in existing selection.

Parameters
strNew value of selection text. Selection is re-parsed immediately with this new value.
void Selection::modify ( const std::vector< int > &  ind)

Modifies selection using vector of indexes Vector may be in any order and may contain duplicates.

void Selection::modify ( std::vector< int >::iterator  it1,
std::vector< int >::iterator  it2 
)

Modifies selection using pair of iterators to index vector Vector may be in any order and may contain duplicates.

void pteros::Selection::modify ( const std::function< void(const System &, int, std::vector< int > &)> &  callback,
int  fr = 0 
)

Modifies selection using user-defined callback.

Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes. Vector may be filled in any order and may contain duplicates.

Warning
Resulting selection is neither coordinate-dependent nor text-based. It will not recompute itself on the frame change even if it involves atom coordinates.
void Selection::apply ( )

Recomputes selection without re-parsing selection text.

Only makes sense for coordinate-dependent selections when the coordinates change. Called authomatically for coordinate-dependent selections by set_frame() If selection is not coordinate-dependent does nothing.

void Selection::update ( )

Recomputes selection completely.

May be used when new file is loaded into the system, or when atoms are created/deleted. Forces re-parsing of selection text. For non-textual selections does nothing.

void Selection::clear ( )

Clears selection and frees memory.

Selection is still assigned to its system after clearing. Subsequent call of modify() may populate it again.

Selection Selection::select ( std::string  str)

Sub-selections allow selecting atoms inside existing selection (narrowing or refining existing selection in other terms).

Sub-selections could be very useful in the following situation. Suppose that we need to create separate selections for N,C,CA and CB atoms of particular protein residue. With "normal" selections the following code could be used:

Selection sel_N(sys,"protein and resid 1 and name N");
Selection sel_C(sys,"protein and resid 1 and name C");
Selection sel_CA(sys,"protein and resid 1 and name CA");
Selection sel_CB(sys,"protein and resid 1 and name CB");

The problem with this code is that we are looping over all atoms in the system four times, ones in each selection. This is very inefficient since we only need to find our residue with "protein and resid 1" (one loop over all atoms) and then we need to search inside this residue four times (looping over ~10 atoms only). This problem is not apparent for small system but becomes very painful for the systems with millions of atoms. Subselections solve this problem:

Selection residue1(sys,"protein and resid 1");
auto sel_N = residue1.select("name N");
auto sel_C = residue1.select("name C");
auto sel_CA = residue1.select("name CA");
auto sel_CB = residue1.select("name CB");

Subselections inherit the system and frame from the parent. The search in sub-selections is performed over selected atoms of the parent only (the only exception from this rule are within selections which involve seacrh over all atoms by design).

void Selection::set_frame ( int  fr)

Set current frame for selection.

Note
If selection is coordinate-dependent it is re-evaluated by calling apply()
void Selection::set_chain ( const std::vector< char > &  data)

Set chains from supplied vector.

Note
Vector size must be the save as the size of selection.
vector< int > Selection::get_resid ( ) const

Get vector of all resid's in selection.

Warning
Same resid's could be present in different chains!
void Selection::set_resid ( const std::vector< int > &  data)

Set resid's in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
vector< int > Selection::get_resindex ( ) const

Get vector of all resindexes in selection.

Resindexes are unique regardless the number of the chains.

void Selection::set_name ( const std::vector< std::string > &  data)

Set atom names in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
void Selection::set_resname ( const std::vector< std::string > &  data)

Set resnames in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
void Selection::set_mass ( const std::vector< float >  m)

Set atom masses in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
void Selection::set_beta ( std::vector< float > &  data)

Set beta in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
void Selection::set_occupancy ( std::vector< float > &  data)

Set occupancy in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
Vector3f Selection::center ( bool  mass_weighted = false,
bool  periodic = false 
) const

Get the center of selection.

Parameters
mass_weightedUse mass-weighting
periodicAccount for periodic boundary conditions.
Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
MatrixXf Selection::atom_traj ( int  ind,
int  b = 0,
int  e = -1 
) const

Extracts X,Y,Z for given atom index for specified range of frames (gets trajectory of given atom).

Result is returned as MatrixXf, where i-th column is an XYZ vector for frame i.

void Selection::inertia ( Vector3f_ref  moments,
Matrix3f_ref  axes,
bool  periodic = false 
) const

Computes the central momens of inertia and principal axes of inertia.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
float Selection::gyration ( bool  periodic = false) const

Computes radius of gyration for selection.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
float Selection::distance ( int  i,
int  j,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get distance between two atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
float Selection::angle ( int  i,
int  j,
int  k,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get angle in degrees between three atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
float Selection::dihedral ( int  i,
int  j,
int  k,
int  l,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get dihedral angle in degrees between three atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
void Selection::rotate ( int  axis,
float  angle 
)

Rotate selection around given axis relative to center of masses.

Parameters
axisAxis of rotation 0=X, 1=Y, 2=Z
angleRotation angle in radians
void Selection::rotate ( int  axis,
float  angle,
Vector3f_const_ref  pivot 
)

Rotate selection around given axis relative to given pivot.

Parameters
axisAxis of rotation 0=X, 1=Y, 2=Z
angleRotation angle in radians
pivotRotation around this pivot
void Selection::rotate ( Vector3f_const_ref  direction,
float  angle,
Vector3f_const_ref  pivot 
)

Rotate selection around given vector relative to given pivot.

Parameters
directionRotate around this vector
angleRotation angle in radians
pivotRotation around this pivot
void Selection::unwrap ( Vector3i_const_ref  dims = Eigen::Vector3i::Ones())

Unwraps selection to make it whole if possible (without jumps over periodic box boundary).

The periodic center of mass is used as an anchor point.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension unwrap() will not work as expected and will not make selection "compact"!
int Selection::unwrap_bonds ( float  d = 0.2,
int  leading_index = 0,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
)

Unwraps selection to make it whole (without jumps over periodic box boundary).

based on preserving all bonds. This method works reliably in any case, but is much slower than unwrap()

Parameters
dMaximal bond length.
leading_indexIndex (in selection) of the reference atom, which doesn't move. Returns number of disconnected pieces after unwrapping. 1 means solid selection.
Eigen::Affine3f Selection::principal_transform ( bool  is_periodic = false) const

Get transform for orienting selection by principal axes.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get funny results if
Parameters
is_periodicis set to true.
void Selection::principal_orient ( bool  is_periodic = false)

Orient molecule by its principal axes.

The same as

Eigen::Affine3f tr = sel.principal_transform();
sel.apply_transform(tr);
Energy_components Selection::non_bond_energy ( float  cutoff = 0.25,
bool  periodic = true 
) const

Self-energy of selection computed within given interaction cut-off.

If cutoff is 0 or negative computes interaction of all atoms (very slow for large selections)

void Selection::write ( std::string  fname,
int  b = -1,
int  e = -1 
)

Write structure or trajectory for selection.

File type is determined by extension. Frames from b to e are written. If

Parameters
bis not set or -1 it means current frame If
eis not set or -1 it means the last frame
void Selection::flatten ( )

"Flattens" selection by removing coordinate dependence and making it not text-based.

Resulting selection is equivalent to plain set of indexes "index i1 i2 i3..." Useful to avoid recomputing selection on frame change when tracking given set of atoms

void Selection::split_by_connectivity ( float  d,
std::vector< Selection > &  res,
bool  periodic = true 
)

Split current selection into several selections according to the interatomic distances.

Each resulting selection is a group of atoms connected by distances less than d.

void Selection::each_residue ( std::vector< Selection > &  sel) const

Selects each residue, which is referenced by selection.

All selections for residues are placed into supplied vector. Handles multiple chains correctly.

Eigen::Vector3f* pteros::Selection::XYZ_ptr ( int  ind) const
inline

Returns pointer to the coordinates of given atom for current frame.

Used internally in Grid_searcher.

Periodic_box& pteros::Selection::Box ( )
inline

Returns periodic box of the frame pointed by selection The same as:

sel.get_system()->Box(sel.get_frame());

This is a convenience method. The same box is returnedby all selection which point to the same frame.

float& pteros::Selection::Time ( )
inline

Returns time stamp of the frame pointed by selection The same as:

sel.get_system()->Time(sel.get_frame());

This is a convenience method. The same time is returnedby all selection which point to the same frame.

Atom_proxy pteros::Selection::operator[] ( int  ind) const

Indexing operator.

Returns an Atom_proxy object, which incapsulates atom and its coordinates for current frame Can only be used as r-value (can not be assigned to) however individual fields of the proxy object are writable

Selection sel(sys,"name CA");
sel[1] = sel[0]; // ERROR! Can't assign to proxy object returned by []!
sel[0].Name() = "A"; // OK to write fields of proxy object

Main goal of [] operator is usage in range-based for loops:

Selection sel(sys,"name CA");
for(auto a: sel){
cout << a.Name() << " " << a.X() << endl;
}

Otherwise it is slower than conventional syntax like sel.Name(i)

Selection pteros::Selection::operator~ ( ) const

Creates new Selection, which is a logical negation of existing one.

Parent selection is not modified

void pteros::Selection::set_system ( const System sys)

Sets new system for selection.

Warning
This clears selection index and leaves it empty!
void pteros::Selection::modify ( std::string  str,
int  fr = 0 
)

Modifies selection string in existing selection.

Parameters
strNew value of selection text. Selection is re-parsed immediately with this new value.
void pteros::Selection::modify ( const std::vector< int > &  ind)

Modifies selection using vector of indexes Vector may be in any order and may contain duplicates.

void pteros::Selection::modify ( std::vector< int >::iterator  it1,
std::vector< int >::iterator  it2 
)

Modifies selection using pair of iterators to index vector Vector may be in any order and may contain duplicates.

void pteros::Selection::modify ( const std::function< void(const System &, int, std::vector< int > &)> &  callback,
int  fr = 0 
)

Modifies selection using user-defined callback.

Callback takes the system as first argument, target frame number as the second and the vector to be filled by selected atom indexes. Vector may be filled in any order and may contain duplicates.

Warning
Resulting selection is neither coordinate-dependent nor text-based. It will not recompute itself on the frame change even if it involves atom coordinates.
void pteros::Selection::apply ( )

Recomputes selection without re-parsing selection text.

Only makes sense for coordinate-dependent selections when the coordinates change. Called authomatically for coordinate-dependent selections by set_frame() If selection is not coordinate-dependent does nothing.

void pteros::Selection::update ( )

Recomputes selection completely.

May be used when new file is loaded into the system, or when atoms are created/deleted. Forces re-parsing of selection text. For non-textual selections does nothing.

void pteros::Selection::clear ( )

Clears selection and frees memory.

Selection is still assigned to its system after clearing. Subsequent call of modify() may populate it again.

Selection pteros::Selection::select ( std::string  str)

Sub-selections allow selecting atoms inside existing selection (narrowing or refining existing selection in other terms).

Sub-selections could be very useful in the following situation. Suppose that we need to create separate selections for N,C,CA and CB atoms of particular protein residue. With "normal" selections the following code could be used:

Selection sel_N(sys,"protein and resid 1 and name N");
Selection sel_C(sys,"protein and resid 1 and name C");
Selection sel_CA(sys,"protein and resid 1 and name CA");
Selection sel_CB(sys,"protein and resid 1 and name CB");

The problem with this code is that we are looping over all atoms in the system four times, ones in each selection. This is very inefficient since we only need to find our residue with "protein and resid 1" (one loop over all atoms) and then we need to search inside this residue four times (looping over ~10 atoms only). This problem is not apparent for small systems but becomes very painful for the systems with millions of atoms. Subselections solve this problem:

Selection residue1(sys,"protein and resid 1");
auto sel_N = residue1.select("name N");
auto sel_C = residue1.select("name C");
auto sel_CA = residue1.select("name CA");
auto sel_CB = residue1.select("name CB");

Subselections inherit the system and frame from the parent. The search in sub-selections is performed over selected atoms of the parent only (the only exception from this rule are within selections which involve seacrh over all atoms by design).

void pteros::Selection::set_frame ( int  fr)

Set current frame for selection.

Note
If selection is coordinate-dependent it is re-evaluated by calling apply()
void pteros::Selection::set_chain ( const std::vector< char > &  data)

Set chains from supplied vector.

Note
Vector size must be the save as the size of selection.
std::vector<int> pteros::Selection::get_resid ( ) const

Get vector of all resid's in selection.

Warning
Same resid's could be present in different chains!
void pteros::Selection::set_resid ( const std::vector< int > &  data)

Set resid's in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
std::vector<int> pteros::Selection::get_resindex ( ) const

Get vector of all resindexes in selection.

Resindexes are unique regardless the number of the chains.

void pteros::Selection::set_name ( const std::vector< std::string > &  data)

Set atom names in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
void pteros::Selection::set_resname ( const std::vector< std::string > &  data)

Set resnames in selection from supplied vector.

Note
Vector size must be the save as the size of selection.
void pteros::Selection::set_mass ( const std::vector< float >  m)

Set atom masses in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
void pteros::Selection::set_beta ( std::vector< float > &  data)

Set beta in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
void pteros::Selection::set_occupancy ( std::vector< float > &  data)

Set occupancy in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
void Selection::set_tag ( std::vector< std::string > &  data)

Set tags in selection to the values from supplied vector.

Note
Vector size must be the save as the size of selection.
Eigen::Vector3f pteros::Selection::center ( bool  mass_weighted = false,
bool  periodic = false 
) const

Get the center of selection.

Parameters
mass_weightedUse mass-weighting
periodicAccount for periodic boundary conditions.
Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
Eigen::MatrixXf pteros::Selection::atom_traj ( int  ind,
int  b = 0,
int  e = -1 
) const

Extracts X,Y,Z for given atom index for specified range of frames (gets trajectory of given atom).

Result is returned as MatrixXf, where i-th column is an XYZ vector for frame i.

void pteros::Selection::inertia ( Vector3f_ref  moments,
Matrix3f_ref  axes,
bool  periodic = false 
) const

Computes the central momens of inertia and principal axes of inertia.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
float pteros::Selection::gyration ( bool  periodic = false) const

Computes radius of gyration for selection.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get incorrect results if periodic is set to true. This is not checked automatically! In this case use one of unwrapping options first.
float pteros::Selection::distance ( int  i,
int  j,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get distance between two atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
float pteros::Selection::angle ( int  i,
int  j,
int  k,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get angle in degrees between three atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
float pteros::Selection::dihedral ( int  i,
int  j,
int  k,
int  l,
bool  is_periodic = true,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Get dihedral angle in degrees between three atoms (periodic in given dimensions if needed).

Note
This function takes selection indexes, not absolute indexes.
void pteros::Selection::rotate ( int  axis,
float  angle 
)

Rotate selection around given axis relative to center of masses.

Parameters
axisAxis of rotation 0=X, 1=Y, 2=Z
angleRotation angle in radians
void pteros::Selection::rotate ( int  axis,
float  angle,
Vector3f_const_ref  pivot 
)

Rotate selection around given axis relative to given pivot.

Parameters
axisAxis of rotation 0=X, 1=Y, 2=Z
angleRotation angle in radians
pivotRotation around this pivot
void pteros::Selection::rotate ( Vector3f_const_ref  direction,
float  angle,
Vector3f_const_ref  pivot 
)

Rotate selection around given vector relative to given pivot.

Parameters
directionRotate around this vector
angleRotation angle in radians
pivotRotation around this pivot
void pteros::Selection::unwrap ( Vector3i_const_ref  dims = Eigen::Vector3i::Ones())

Unwraps selection to make it whole if possible (without jumps over periodic box boundary).

The periodic center of mass is used as an anchor point.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension unwrap() will not work as expected and will not make selection "compact"!
int pteros::Selection::unwrap_bonds ( float  d = 0.2,
int  leading_index = 0,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
)

Unwraps selection to make it whole (without jumps over periodic box boundary).

based on preserving all bonds. This method works reliably in any case, but is much slower than unwrap()

Parameters
dMaximal bond length.
leading_indexLocal index of the reference atom, which doesn't move.
Returns
Number of disconnected pieces after unwrapping. 1 means solid selection.
Eigen::Affine3f pteros::Selection::principal_transform ( bool  is_periodic = false) const

Get transform for orienting selection by principal axes.

Warning
If the size of selection is larger than 1/2 of the box size in any dimension you will get funny results if
Parameters
is_periodicis set to true.
void pteros::Selection::principal_orient ( bool  is_periodic = false)

Orient molecule by its principal axes.

The same as

Eigen::Affine3f tr = sel.principal_transform();
sel.apply_transform(tr);
Energy_components pteros::Selection::non_bond_energy ( float  cutoff = 0.25,
bool  periodic = true 
) const

Self-energy of selection computed within given interaction cut-off.

If cutoff is 0 or negative computes interaction of all atoms (very slow for large selections)

void pteros::Selection::write ( std::string  fname,
int  b = -1,
int  e = -1 
)

Write structure or trajectory for selection.

File type is determined by extension. Frames from b to e are written. If

Parameters
bis not set or -1 it means current frame If
eis not set or -1 it means the last frame
void pteros::Selection::flatten ( )

"Flattens" selection by removing coordinate dependence and making it not text-based.

Resulting selection is equivalent to plain set of indexes "index i1 i2 i3..." Useful to avoid recomputing selection on frame change when tracking given set of atoms

string Selection::gromacs_ndx ( std::string  name)

Returns a string formatted as Gromacs ndx file containing the current selection with given name.

Warning
Indexex in Gromacs ndx are starting from 1! Thus one is added to all pteros indexes!
void pteros::Selection::split_by_connectivity ( float  d,
std::vector< Selection > &  res,
bool  periodic = true 
)

Split current selection into several selections according to the interatomic distances.

Each resulting selection is a group of atoms connected by distances less than d.

template<class F >
void pteros::Selection::split ( std::vector< Selection > &  parts,
callback 
)
inline

Split selection by the values returned by custom callback function.

Callback is called for each atom in selection (local index is passed as its second argument) Callback can return any type usable as a key of std::map. Selection is split into parts according to returned value.

void pteros::Selection::each_residue ( std::vector< Selection > &  sel) const

Selects each residue, which is referenced by selection.

All selections for residues are placed into supplied vector. Handles multiple chains correctly.

Eigen::Vector3f* pteros::Selection::XYZ_ptr ( int  ind) const
inline

Returns pointer to the coordinates of given atom for current frame.

Used internally in Grid_searcher.

Periodic_box& pteros::Selection::Box ( )
inline

Returns periodic box of the frame pointed by selection The same as:

sel.get_system()->Box(sel.get_frame());

This is a convenience method. The same box is returnedby all selection which point to the same frame.

float& pteros::Selection::Time ( )
inline

Returns time stamp of the frame pointed by selection The same as:

sel.get_system()->Time(sel.get_frame());

This is a convenience method. The same time is returnedby all selection which point to the same frame.

Friends And Related Function Documentation

Selection operator| ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, which is the logical OR of two parent selections.

Parent selections are not modified.

Selection operator& ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, which is the logical AND of two parent selections.

Parent selections are not modified.

Selection operator- ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, by removing all atoms of sel2 from sel1.

Parent selections are not modified.

Warning
This operator is not commutative!
float rmsd ( const Selection sel1,
int  fr1,
const Selection sel2,
int  fr2 
)
friend

RMSD between two selections of the same size (for given frames)

Parameters
sel1First selection
fr1Frame for first selection
sel2Second selection
fr2Frame for second selection
Energy_components non_bond_energy ( const Selection sel1,
const Selection sel2,
float  cutoff = 0.25,
int  fr = -1,
bool  periodic = true 
)
friend

Non-bond energy between two selections computed within given interaction cut-off.

If cutoff is 0 or negative computes all pairs of atoms (very slow for large selections) fr = -1 computes for current frame of selection 1.

std::ostream& operator<< ( std::ostream &  os,
const Selection sel 
)
friend

Writing selection to stream.

Outputs indexes as a space separated list

Selection operator| ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, which is the logical OR of two parent selections.

Parent selections are not modified.

Selection operator& ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, which is the logical AND of two parent selections.

Parent selections are not modified.

Selection operator- ( const Selection sel1,
const Selection sel2 
)
friend

Creates new Selection, by removing all atoms of sel2 from sel1.

Parent selections are not modified.

Warning
This operator is not commutative!
float rmsd ( const Selection sel1,
int  fr1,
const Selection sel2,
int  fr2 
)
friend

RMSD between two selections of the same size (for given frames)

Parameters
sel1First selection
fr1Frame for first selection
sel2Second selection
fr2Frame for second selection
Energy_components non_bond_energy ( const Selection sel1,
const Selection sel2,
float  cutoff = 0.25,
int  fr = -1,
bool  periodic = true 
)
friend

Non-bond energy between two selections computed within given interaction cut-off.

If cutoff is 0 or negative computes all pairs of atoms (very slow for large selections) fr = -1 computes for current frame of selection 1.


The documentation for this class was generated from the following files: