|
Pteros
2.0
Molecular modeling library for human beings!
|
37 #include <Eigen/Dense>
38 #include "pteros/core/atom.h"
39 #include "pteros/core/force_field.h"
40 #include "pteros/core/periodic_box.h"
41 #include "pteros/core/typedefs.h"
42 #include "pteros/core/atom_handler.h"
53 std::vector<Eigen::Vector3f>
coord;
55 std::vector<Eigen::Vector3f>
vel;
57 std::vector<Eigen::Vector3f>
force;
65 bool has_vel()
const {
return !
vel.empty(); }
66 bool has_force()
const {
return !
force.empty(); }
69 void swap(
int i,
int j);
99 friend class SystemBuilder;
110 System(std::string fname);
160 void rearrange(
const std::vector<std::string>& sel_strings);
165 void rearrange(
const std::vector<Selection>& sel_vec);
172 void rearrange(
const std::vector<std::string>& begin_strings,
const std::vector<std::string>& end_strings);
179 void rearrange(
const std::vector<Selection>& begin_vec,
const std::vector<Selection>& end_vec);
188 void keep(
const std::string& sel_str);
194 void remove(
const std::string& sel_str);
203 void distribute(
const Selection sel, Vector3i_const_ref ncopies, Matrix3f_const_ref shift);
241 Selection select(std::string str,
int fr = 0);
242 Selection operator()(std::string str,
int fr = 0);
245 Selection operator()(
int ind1,
int ind2);
247 Selection select(
const std::vector<int>& ind);
248 Selection operator()(
const std::vector<int>& ind);
250 Selection select(std::vector<int>::iterator it1,
251 std::vector<int>::iterator it2);
252 Selection operator()(std::vector<int>::iterator it1,
253 std::vector<int>::iterator it2);
255 Selection select(
const std::function<
void(
const System&,
int,std::vector<int>&)>& callback,
int fr = 0);
256 Selection operator()(
const std::function<
void(
const System&,
int,std::vector<int>&)>& callback,
int fr = 0);
277 void load(std::string fname,
281 std::function<
bool(
System*,
int)> on_frame = 0);
290 bool load(
const std::unique_ptr<FileHandler> &handler,
292 std::function<
bool(
System*,
int)> on_frame = 0);
294 void write(std::string fname,
int b=-1,
int e=-1)
const;
296 void write(
const std::unique_ptr<FileHandler>& handler, FileContent what,
int b=-1,
int e=-1)
const;
301 std::vector<std::pair<std::string, Selection> >
load_gromacs_ndx(std::string fname);
333 void set_filter(std::vector<int>::iterator it1,
334 std::vector<int>::iterator it2);
375 inline float&
time(
int fr=0){
return traj[fr].time; }
378 inline const float&
time(
int fr=0)
const {
return traj[fr].time; }
381 inline Eigen::Vector3f&
xyz(
int ind,
int fr=0){
return traj[fr].coord[ind]; }
384 inline const Eigen::Vector3f&
xyz(
int ind,
int fr=0)
const {
return traj[fr].coord[ind]; }
387 inline Eigen::Vector3f&
vel(
int ind,
int fr=0){
return traj[fr].vel[ind]; }
390 inline const Eigen::Vector3f&
vel(
int ind,
int fr=0)
const {
return traj[fr].vel[ind]; }
393 inline Eigen::Vector3f&
force(
int ind,
int fr=0){
return traj[fr].force[ind]; }
396 inline const Eigen::Vector3f&
force(
int ind,
int fr=0)
const {
return traj[fr].force[ind]; }
402 inline const Atom&
atom(
int ind)
const {
return atoms[ind]; }
415 AtomIterator atoms_end(){
return atoms.end(); }
416 std::vector<Frame>::iterator traj_begin(){
return traj.begin(); }
417 std::vector<Frame>::iterator traj_end(){
return traj.end(); }
419 AtomHandler operator[](
const std::pair<int,int>& ind_fr);
437 Selection
atoms_dup(
const std::vector<int>& ind);
440 Selection
atoms_add(
const std::vector<Atom>& atm,
441 const std::vector<Eigen::Vector3f>& crd);
457 Selection
atom_add_1h(
int target,
int at1,
int at2,
int at3,
float dist=0.109,
bool pbc=
true);
460 Selection
atom_add_2h(
int target,
int at1,
int at2,
float dist=0.109,
bool pbc=
true);
463 Selection
atom_add_3h(
int target,
int at1,
float dist=0.109,
bool pbc=
true);
473 void wrap(
int fr, Array3i_const_ref pbc = fullPBC);
482 float distance(
int i,
int j,
int fr, Array3i_const_ref pbc = fullPBC)
const;
485 float angle(
int i,
int j,
int k,
int fr, Array3i_const_ref pbc = fullPBC)
const;
488 float dihedral(
int i,
int j,
int k,
int l,
int fr, Array3i_const_ref pbc = fullPBC)
const;
499 bool force_field_ready(){
return force_field.
ready;}
526 const std::vector<float>& dist,
527 std::vector<Eigen::Vector2f>* pair_en=
nullptr);
535 std::vector<Atom> atoms;
538 std::vector<Frame> traj;
544 std::vector<int> filter;
546 std::string filter_text;
549 void filter_coord(
int fr);
Selection class.
Definition: selection.h:65
void frame_delete(int b=0, int e=-1)
Delete specified range of frames.
Definition: system.cpp:427
void load(std::string fname, int b=0, int e=-1, int skip=0, std::function< bool(System *, int)> on_frame=0)
Read structure, trajectory or topology from file.
Definition: system.cpp:135
float time
Timestamp.
Definition: system.h:61
Selection append(const System &sys)
Append other system to this one Returns selection corresponding to appended atoms.
Definition: system.cpp:821
void wrap(int fr, Array3i_const_ref pbc=fullPBC)
Wrap all system to the periodic box for given frame.
Definition: system.cpp:1233
Selection select_all() const
Convenience functions to select all.
Definition: system.cpp:1153
virtual ~System()
Destructor.
Definition: system.cpp:411
const Eigen::Vector3f & xyz(int ind, int fr=0) const
Read only access for given coordinate of given frame.
Definition: system.h:384
Atom & atom(int ind)
Read/Write access for given atom.
Definition: system.h:399
void clear_force()
Delete forces from all frames.
Definition: system.cpp:536
Selection atom_add_3h(int target, int at1, float dist=0.109, bool pbc=true)
Add 3 hydrogens to target atom according to positions of single adjacent atom assuming tetrahedral sy...
Definition: system.cpp:789
float distance(int i, int j, int fr, Array3i_const_ref pbc=fullPBC) const
Get distance between two atoms for given frame (periodic in given dimensions if needed).
Definition: system.cpp:1189
const Eigen::Vector3f & vel(int ind, int fr=0) const
Read only access for given velocity of given frame.
Definition: system.h:390
void rearrange(const std::vector< std::string > &sel_strings)
Rearranges the atoms in the order of provided selection strings.
Definition: system.cpp:930
Eigen::Vector3f & xyz(int ind, int fr=0)
Read/Write access for given coordinate of given frame.
Definition: system.h:381
Eigen::Vector2f get_energy_for_list(const std::vector< Eigen::Vector2i > &pairs, const std::vector< float > &dist, std::vector< Eigen::Vector2f > *pair_en=nullptr)
Low level energy evaluation function Returns total energy Individual pair energies could be returned ...
Definition: system.cpp:1252
float dihedral(int i, int j, int k, int l, int fr, Array3i_const_ref pbc=fullPBC) const
Get dihedral angle in degrees between three atoms for given frame (periodic in given dimensions if ne...
Definition: system.cpp:1211
int num_frames() const
Returns the number of frames in selection.
Definition: system.h:213
float angle(int i, int j, int k, int fr, Array3i_const_ref pbc=fullPBC) const
Get angle in degrees between three atoms for given frame (periodic in given dimensions if needed).
Definition: system.cpp:1198
Selection atoms_dup(const std::vector< int > &ind)
Adds new atoms, which are duplicates of existing ones by index. Atoms are placed at the end of the sy...
Definition: system.cpp:541
void sort_by_resindex()
Sorts atoms by resindex arranging atoms with the same resindexes into contigous pieces.
Definition: system.cpp:495
void clear()
Clears the system and prepares for loading completely new structure.
Definition: system.cpp:85
ForceField & get_force_field()
Returns internal Force_field object.
Definition: system.h:502
void frame_swap(int fr1, int fr2)
Swaps two specified frames.
Definition: system.cpp:448
The system of atoms.
Definition: system.h:93
std::vector< Eigen::Vector3f > force
Forces of atoms.
Definition: system.h:57
void atoms_delete(const std::vector< int > &ind)
Delete the set of atoms by indexes.
Definition: system.cpp:610
void frame_append(const Frame &fr)
Appends provided frame to trajectory.
Definition: system.cpp:472
AtomIterator atoms_begin()
Iterators and indexing {.
Definition: system.h:414
PeriodicBox & box(int fr=0)
Read/write access for periodic box for given frame.
Definition: system.h:369
void set_filter(std::string str)
Filters narrow set of atoms and coordinates which are loaded from data files.
Definition: system.cpp:367
int frame_dup(int fr)
Duplicates given frame and adds it to the end of frame vector.
Definition: system.cpp:413
Selection atoms_add(const std::vector< Atom > &atm, const std::vector< Eigen::Vector3f > &crd)
Adds new atoms from supplied vectors of atoms and coordinates. Atoms are placed at the end of the sys...
Definition: system.cpp:576
const PeriodicBox & box(int fr=0) const
Read only access for periodic box for given frame.
Definition: system.h:372
void frame_copy(int fr1, int fr2)
Copy all frame data from fr1 to fr2. Fr2 is overwritten!
Definition: system.cpp:420
float & time(int fr=0)
Read/Write access to the time stamp of given frame.
Definition: system.h:375
const Frame & frame(int fr) const
Get read only reference for given frame.
Definition: system.h:408
System & operator=(const System &other)
Assignment operator.
Definition: system.cpp:75
void keep(const std::string &sel_str)
Keep only atoms given by selection string.
Definition: system.cpp:1036
Auxilary type used to incapsulate the atom and its current coordinates Used internally in Selection::...
Definition: atom_handler.h:49
std::vector< Eigen::Vector3f > vel
Velocities of atoms.
Definition: system.h:55
std::vector< std::pair< std::string, Selection > > load_gromacs_ndx(std::string fname)
Load Gromacs .ndx file and crease selections acording to it from existing system Returns a vector of ...
Definition: system.cpp:333
Eigen::Vector3f & force(int ind, int fr=0)
Read/Write access for given force of given frame.
Definition: system.h:393
Frame & frame(int fr)
Get read/write reference for given frame.
Definition: system.h:405
void distribute(const Selection sel, Vector3i_const_ref ncopies, Matrix3f_const_ref shift)
Creates multiple copies of selection in the system and distributes them in a grid given by 3 translat...
Definition: system.cpp:1066
void clear_vel()
Delete velocities from all frames.
Definition: system.cpp:531
Force field parameters of the system.
Definition: force_field.h:53
System()
Default constructor.
Definition: system.cpp:51
void atom_swap(int i, int j)
Swap two atoms.
Definition: system.cpp:712
Selection atom_add_2h(int target, int at1, int at2, float dist=0.109, bool pbc=true)
Add two hydrogens to target atom according to positions of 2 adjacent atoms assuming tetrahedral symm...
Definition: system.cpp:755
PeriodicBox box
Periodic box.
Definition: system.h:59
const Eigen::Vector3f & force(int ind, int fr=0) const
Read only access for given force of given frame.
Definition: system.h:396
std::vector< Eigen::Vector3f > coord
Coordinates of atoms.
Definition: system.h:53
const Atom & atom(int ind) const
Read only access for given atom.
Definition: system.h:402
void atom_move(int i, int j)
Move atom i to other position. Atom is inserted instead of atom j, shift is performed towards previou...
Definition: system.cpp:650
Class encapsulating all operations with arbitrary triclinic periodic boxes This class stores the peri...
Definition: periodic_box.h:43
Eigen::Vector3f & vel(int ind, int fr=0)
Read/Write access for given velocity of given frame.
Definition: system.h:387
Selection parser class.
Definition: selection_parser.h:59
int num_atoms() const
Returns the number of atoms in selection.
Definition: system.h:216
Selection atom_clone(int source)
Duplicate single target atom and puts it immediately after the source.
Definition: system.cpp:705
Definition of single trajectory frame.
Definition: system.h:51
void remove(const std::string &sel_str)
Remove atoms given by selection string.
Definition: system.cpp:1050
Selection atom_add_1h(int target, int at1, int at2, int at3, float dist=0.109, bool pbc=true)
Add single hydrogen to target atom according to positions of 3 adjacent atoms assuming tetrahedral sy...
Definition: system.cpp:724
void assign_resindex(int start=0)
Assign unique resindexes This is usually done automatically upon loading a structure from file.
Definition: system.cpp:476
std::vector< std::pair< std::string, int > > rearrange_by_resname()
Rearranges the atoms in the alphabetical order of residue names.
Definition: system.cpp:1013
Class which represents a single atom.
Definition: atom.h:39
void swap(int i, int j)
Swap atoms i and j taking care of v and f.
Definition: system.cpp:1284
bool ready
Is the force field properly set up?
Definition: force_field.h:89
const float & time(int fr=0) const
Read only access to the time stamp of given frame.
Definition: system.h:378