Pteros  2.0
Molecular modeling library for human beings!
contacts_finder.h
1 /*
2  *
3  * This source code is part of
4  * ******************
5  * *** Pteros ***
6  * ******************
7  * molecular modeling library
8  *
9  * Copyright (c) 2009-2013, Semen Yesylevskyy
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of Artistic License:
13  *
14  * Please note, that Artistic License is slightly more restrictive
15  * then GPL license in terms of distributing the modified versions
16  * of this software (they should be approved first).
17  * Read http://www.opensource.org/licenses/artistic-license-2.0.php
18  * for details. Such license fits scientific software better then
19  * GPL because it prevents the distribution of bugged derivatives.
20  *
21 */
22 
23 #ifndef CONTACTS_FINDER_H
24 #define CONTACTS_FINDER_H
25 
26 #include <iostream>
27 #include <string>
28 #include <set>
29 #include <map>
30 #include "pteros/pteros.h"
31 #include "pteros/analysis/trajectory_processor.h"
32 #include "pteros/analysis/options.h"
34 
35 namespace pteros {
36 
37 enum Contacts_def {CUT_OFF, VDW_RADII};
38 
39 typedef std::pair<int,int> Index_pair;
40 
41 struct Atom_contact_info {
42  float prob; // Probability of formation
43  std::vector<Index_pair> life_times; // First value - formation, second - duration
44  float mean_lifetime;
45  float mean_energy;
46 };
47 
48 struct Residue_contact_info {
49  float prob; // Probability of formation
50  std::set<Index_pair> atom_contacts; // Indexes of atom contacts
51  float mean_energy;
52 };
53 
54 struct Per_atom_stat {
55  float prob;
56  std::set<int> partners;
57 };
58 
59 struct Per_residue_stat {
60  float prob;
61  std::set<int> partners;
62 };
63 
64 typedef std::map<Index_pair,Atom_contact_info> Atom_contacts_t;
65 typedef std::map<Index_pair,Residue_contact_info> Res_contacts_t;
66 typedef std::map<int,Per_atom_stat> Per_atom_t;
67 typedef std::map<int,Per_residue_stat> Per_res_t;
68 
69 struct Selections_pair {
70  Selection sel1;
71  Selection sel2;
72  Atom_contacts_t atom_contacts;
73  Res_contacts_t res_contacts;
74  Per_atom_t per_atom_stats;
75  Per_res_t per_res_stats;
76  std::vector<int> atom_contacts_num;
77  std::vector<int> res_contacts_num;
78  std::vector<float> energy;
79  float mean_energy;
80 };
81 
82 class Contacts_finder: public Consumer {
83  public:
84  Contacts_finder(Trajectory_processor& proc, const Options& opt);
85 
86  void create(Trajectory_processor& proc, const Options& opt);
87 
89  //void print_info(std::ostream& out);
91  void save(std::ostream& out, bool human_readable=true);
93  void per_frame_stats(std::ostream& out);
95  static void print_help();
96 
97  private:
98  Options options;
99 
100  //------------------------------------
103  void process_frame(const Frame_info& info);
104  void pre_process();
105  void post_process(const Frame_info& info);
106  //------------------------------------
107 
108  // Aux list of raw contacts
109  std::vector<Eigen::Vector2i> clist;
110 
111  // Mapping of real time
112  std::map<int,float> real_time;
113 
114  // VDW radii
115  std::vector<float> VDW;
116 
117  // Pairs of selections to process
118  std::vector<Selections_pair> sel_pairs;
119  // Parameters
120  double dist; // Cut-off for grid searching
121  double vdw_gap; // Gap for VDE mode
122  bool is_periodic;
123  Contacts_def method;
124 
125  // All selection
126  Selection all;
127 };
128 
129 }
130 #endif
Pteros namespace.
Definition: options.cpp:32