libcootapi
 
Loading...
Searching...
No Matches
/opt/mambaforge/envs/bioconda/conda-bld/coot-headless_1766554005715/work/api/validation-information.hh
1#ifndef VALIDATION_INFORMATION_HH
2#define VALIDATION_INFORMATION_HH
3
4#include <vector>
5#include "analysis/stats.hh"
6#include "residue-validation-information.hh"
7
8namespace coot {
9
10 class chain_validation_information_t {
11 public:
12 std::string chain_id;
13 std::vector<residue_validation_information_t> rviv;
14 chain_validation_information_t() {}
15 explicit chain_validation_information_t(const std::string &chain_id_in) : chain_id(chain_id_in) {}
16 void add(const residue_validation_information_t &rvi) {
17 add_residue_validation_information(rvi);
18 }
19 void add_residue_validation_information(const residue_validation_information_t &rvi) {
20 rviv.push_back(rvi);
21 }
22 };
23
24 class validation_information_min_max_t {
25 public:
26 bool is_set;
27 double min;
28 double max;
29 validation_information_min_max_t() : is_set(false), min(0), max(0) {}
30 validation_information_min_max_t(const double &min_in, const double &max_in) : is_set(true), min(min_in), max(max_in) {}
31 };
32
33#ifdef EMSCRIPTEN
34#else
35 // values for type:
36 enum graph_data_type { UNSET, DENSITY, DISTORTION, ENERGY, PROBABILITY, CORRELATION, LOG_PROBABILITY, TORSION_ANGLE };
37#endif
38
39 class validation_information_t {
40 public:
41 std::string name;
43 std::vector<chain_validation_information_t> cviv;
44
45#ifdef EMSCRIPTEN
46 std::string type;
47 validation_information_t() : min_max(validation_information_min_max_t()), type("UNSET") {}
48 validation_information_t(const std::string &gdt, const validation_information_min_max_t &min_max_in) : min_max(min_max_in), type(gdt) {}
49#else
50 enum graph_data_type type;
51 validation_information_t() : min_max(validation_information_min_max_t()), type(UNSET) {}
52 validation_information_t(graph_data_type gdt, const validation_information_min_max_t &min_max_in) : min_max(min_max_in), type(gdt) {}
53#endif
54
55 unsigned int get_index_for_chain(const std::string &chain_id) {
56 for (unsigned int i=0; i<cviv.size(); i++) {
57 if (chain_id == cviv[i].chain_id)
58 return i;
59 }
61 cviv.push_back(cvi);
62 return cviv.size() -1;
63 }
64 void add_residue_validation_information(const residue_validation_information_t &rvi, const std::string &chain_id) {
65 unsigned int idx = get_index_for_chain(chain_id);
66 cviv[idx].add_residue_validation_information(rvi);
67 }
68 // one presumes that the chain id of this cvi does not match any current items in the cviv.
69 void add(const chain_validation_information_t &cvi) {
70 cviv.push_back(cvi);
71 }
73 bool empty() const { return cviv.empty(); }
75 void set_min_max() {
76 unsigned int n = 0;
77 double min = 9999999999999;
78 double max = -9999999999999;
79 for (const auto &chain : cviv) {
80 for (const auto &res : chain.rviv) {
81 n++;
82 if (res.function_value < min) min = res.function_value;
83 if (res.function_value > max) max = res.function_value;
84 }
85 }
86 if (n > 0) {
87 min_max.min = min;
88 } else {
89 min_max.max = max;
90 }
91 }
92
95 // 20230402-PE this function is in-line only because it is inconvenient at the moment to add
96 // a new source file to the repo
97
99
100 for (unsigned int i=0; i<cviv.size(); i++) {
101 const auto &cvi = cviv[i];
102 for (unsigned int j=0; j<cvi.rviv.size(); j++) {
103 const auto &rvi = cvi.rviv[j];
104 s.add(rvi.function_value);
105 }
106 }
107 return s;
108 }
109 };
110
111}
112
113#endif // VALIDATION_INFORMATION_HH
Definition validation-information.hh:10
Definition residue-validation-information.hh:8
Definition stats.hh:38
Definition validation-information.hh:24
bool empty() const
return true of there are no data
Definition validation-information.hh:73
void set_min_max()
set the min and max for the graph - internal use.
Definition validation-information.hh:75
stats::single get_stats() const
get the stats for the data in this validation container
Definition validation-information.hh:94