RMF
Toggle main menu visibility
TraverseHelper.h
Go to the documentation of this file.
1
/**
2
* \file RMF/TraverseHelper.h
3
* \brief A helper class for managing data when traversing an RMF.
4
*
5
* Copyright 2007-2022 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef RMF_TRAVERSE_HELPER_H
10
#define RMF_TRAVERSE_HELPER_H
11
12
#include <RMF/config.h>
13
#include "
CoordinateTransformer.h
"
14
#include "
Nullable.h
"
15
#include <
RMF/decorator/physics.h
>
16
#include <
RMF/decorator/sequence.h
>
17
#include <
RMF/decorator/shape.h
>
18
#include <
RMF/decorator/alternatives.h
>
19
#include <memory>
20
21
RMF_ENABLE_WARNINGS
22
23
namespace
RMF
{
24
25
class
TraverseHelper
;
26
typedef
std::vector<TraverseHelper> TraverseHelpers;
27
28
//! Track common data that one needs to keep as one traverses the hierarchy.
29
/** Things like residue index, chain id, and the local reference frame are all
30
properties of the path taken to reach a given node when traversing. This
31
class helps keep track of them.
32
33
Feel free to request that other data types be added.
34
35
\note In the case of non-default resolution with alternatives nodes, the
36
node this inherits from may not be the one you visited. So you should just
37
pass this object when you need to access the node.
38
*/
39
class
RMFEXPORT TraverseHelper :
public
NodeConstHandle {
40
struct
Index :
public
RMF_LARGE_UNORDERED_MAP<NodeID, unsigned int> {};
41
std::shared_ptr<Index> active_;
42
struct
Data {
43
decorator::ChainFactory
chain_factory_;
44
decorator::ResidueFactory
residue_factory_;
45
decorator::ReferenceFrameFactory
reference_frame_factory_;
46
decorator::ColoredFactory
colored_factory_;
47
decorator::AlternativesFactory
alternatives_factory_;
48
decorator::StateFactory
state_factory_;
49
decorator::CopyFactory
copy_factory_;
50
int
state_filter_;
51
CoordinateTransformer
coordinate_transformer_;
52
Vector3
color_;
53
int
residue_index_;
54
std::string residue_type_;
55
std::string chain_id_;
56
std::string molecule_name_;
57
unsigned
int
state_;
58
int
copy_index_;
59
double
resolution_;
60
Data(NodeConstHandle root, std::string molecule_name,
double
resolution,
61
int
state_filter);
62
};
63
std::shared_ptr<Data> data_;
64
65
void
visit_impl(NodeConstHandle n);
66
67
//! Return an updated TraverseHelper after inspecting the passed node.
68
TraverseHelper visit(NodeConstHandle n)
const
;
69
70
public
:
71
TraverseHelper() {}
72
TraverseHelper(NodeConstHandle root, std::string molecule_name,
73
double
resolution = 10000,
int
state_filter = -1);
74
75
//! Get the current chain id or None.
76
Nullable<String>
get_chain_id
()
const
{
77
return
Nullable<String>
(data_->chain_id_);
78
}
79
80
//! Get the current residue index or None.
81
Nullable<Int>
get_residue_index
()
const
{
82
return
Nullable<Int>
(data_->residue_index_);
83
}
84
85
//! Get the current residue type or None.
86
Nullable<String>
get_residue_type
()
const
{
87
return
Nullable<String>
(data_->residue_type_);
88
}
89
90
//! Get the current molecule name or None.
91
std::string
get_molecule_name
()
const
{
return
data_->molecule_name_; }
92
93
//! Get the current color or None.
94
Nullable<Vector3>
get_rgb_color
()
const
{
95
return
Nullable<Vector3>
(data_->color_);
96
}
97
98
//! Get the current state or 0.
99
unsigned
int
get_state_index
()
const
{
return
data_->state_; }
100
101
//! Get the current copy index or None.
102
Nullable<Int>
get_copy_index
()
const
{
103
return
Nullable<Int>
(data_->copy_index_);
104
}
105
106
Vector3
get_global_coordinates(
const
Vector3
&v) {
107
return
data_->coordinate_transformer_.get_global_coordinates(v);
108
}
109
110
//! Set that the current node is displayed and return its index.
111
unsigned
int
set_is_displayed
();
112
113
bool
get_is_displayed(
NodeID
n) {
return
active_->find(n) != active_->end(); }
114
115
//! Return a unique id for the current particle.
116
unsigned
int
get_index
(
NodeID
n)
const
;
117
118
//! Return other nodes to traverse.
119
TraverseHelpers
get_children
()
const
;
120
};
121
122
}
/* namespace RMF */
123
124
RMF_DISABLE_WARNINGS
125
126
#endif
/* RMF_TRAVERSE_HELPER_H */
CoordinateTransformer.h
Declare the RMF::CoordinateTransformer class.
Nullable.h
A helper class for allowing nice return of possibly null values.
alternatives.h
Helper functions for manipulating RMF files.
RMF::CoordinateTransformer
Transform coordinates into the global reference frame.
Definition
CoordinateTransformer.h:30
RMF::Nullable
Return a possibly null value.
Definition
Nullable.h:29
RMF::TraverseHelper
Track common data that one needs to keep as one traverses the hierarchy.
Definition
TraverseHelper.h:39
RMF::TraverseHelper::get_residue_type
Nullable< String > get_residue_type() const
Get the current residue type or None.
Definition
TraverseHelper.h:86
RMF::TraverseHelper::get_children
TraverseHelpers get_children() const
Return other nodes to traverse.
RMF::TraverseHelper::get_index
unsigned int get_index(NodeID n) const
Return a unique id for the current particle.
RMF::TraverseHelper::get_residue_index
Nullable< Int > get_residue_index() const
Get the current residue index or None.
Definition
TraverseHelper.h:81
RMF::TraverseHelper::get_rgb_color
Nullable< Vector3 > get_rgb_color() const
Get the current color or None.
Definition
TraverseHelper.h:94
RMF::TraverseHelper::get_state_index
unsigned int get_state_index() const
Get the current state or 0.
Definition
TraverseHelper.h:99
RMF::TraverseHelper::set_is_displayed
unsigned int set_is_displayed()
Set that the current node is displayed and return its index.
RMF::TraverseHelper::get_copy_index
Nullable< Int > get_copy_index() const
Get the current copy index or None.
Definition
TraverseHelper.h:102
RMF::TraverseHelper::get_molecule_name
std::string get_molecule_name() const
Get the current molecule name or None.
Definition
TraverseHelper.h:91
RMF::TraverseHelper::get_chain_id
Nullable< String > get_chain_id() const
Get the current chain id or None.
Definition
TraverseHelper.h:76
RMF::decorator::AlternativesFactory
Definition
alternatives.h:75
RMF::decorator::ChainFactory
Definition
sequence.h:472
RMF::decorator::ColoredFactory
Definition
shape.h:96
RMF::decorator::CopyFactory
Definition
sequence.h:1120
RMF::decorator::ReferenceFrameFactory
Definition
physics.h:1176
RMF::decorator::ResidueFactory
Definition
sequence.h:135
RMF::decorator::StateFactory
Definition
sequence.h:1242
RMF
The namespace for all functionality in the library.
Definition
BufferConstHandle.h:21
RMF::Vector3
Vector< 3U > Vector3
Definition
types.h:48
RMF::NodeID
ID< NodeTag > NodeID
Definition
ID.h:106
physics.h
Helper functions for manipulating RMF files.
sequence.h
Helper functions for manipulating RMF files.
shape.h
Helper functions for manipulating RMF files.