-
Notifications
You must be signed in to change notification settings - Fork 14
/
strucs_context.hpp
107 lines (87 loc) · 4.28 KB
/
strucs_context.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/// \file
/// \brief The strucs_context class header
/// \copyright
/// CATH Tools - Protein structure comparison tools such as SSAP and SNAP
/// Copyright (C) 2011, Orengo Group, University College London
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _CATH_TOOLS_SOURCE_FILE_STRUCS_CONTEXT_H
#define _CATH_TOOLS_SOURCE_FILE_STRUCS_CONTEXT_H
#include "chopping/chopping_type_aliases.hpp"
#include "common/type_aliases.hpp" // for str_vec
#include "exception/invalid_argument_exception.hpp"
#include "file/name_set/name_set_list.hpp"
#include "file/pdb/pdb_list.hpp" // for pdb_list
namespace cath {
namespace file {
/// \brief Store the context of structures: the PDBs, IDs and any regions
class strucs_context final {
private:
/// \brief The PDBs of the structures
file::pdb_list pdbs;
/// \brief The IDs of the structures
name_set_list name_sets;
/// \brief The key regions of each structure to which this refers (or none where it refers to all of a structure)
chop::region_vec_opt_vec regions;
public:
strucs_context(file::pdb_list,
name_set_list,
chop::region_vec_opt_vec);
const file::pdb_list & get_pdbs() const;
const name_set_list & get_name_sets() const;
const chop::region_vec_opt_vec & get_regions() const;
strucs_context & set_pdbs(const file::pdb_list &);
};
size_t get_num_entries(const strucs_context &);
/// \brief Ctor for strucs_context
inline strucs_context::strucs_context(pdb_list arg_pdbs, ///< The PDBs of the structures
name_set_list arg_name_sets, ///< The IDs of the structures
chop::region_vec_opt_vec arg_regions ///< The key regions of each structure to which this refers (or none where it refers to all of a structure)
) : pdbs { std::move( arg_pdbs ) },
name_sets { std::move( arg_name_sets ) },
regions { std::move( arg_regions ) } {
if ( pdbs.size() != name_sets.size() || pdbs.size() != regions.size() ) {
BOOST_THROW_EXCEPTION(common::invalid_argument_exception("Cannot construct a strucs_context with inconsistent numbers of PDBs / names / regions"));
}
}
/// \brief Getter for the PDBs of the structures
inline const file::pdb_list & strucs_context::get_pdbs() const {
return pdbs;
}
/// \brief Getter for the IDs of the structures
inline const name_set_list & strucs_context::get_name_sets() const {
return name_sets;
}
/// \brief Getter for the key regions of each structure to which this refers (or none where it refers to all of a structure)
inline const chop::region_vec_opt_vec & strucs_context::get_regions() const {
return regions;
}
/// \brief Set the PDBs to the specified PDBs
inline strucs_context & strucs_context::set_pdbs(const file::pdb_list &arg_pdbs ///< The PDBs to set
) {
if ( arg_pdbs.size() != get_num_entries( *this ) ) {
BOOST_THROW_EXCEPTION(common::invalid_argument_exception("Cannot set an inconsistent number of PDBs in a strucs_context"));
}
pdbs = arg_pdbs;
return *this;
}
/// \brief Get the number of entries in the specified strucs_context
inline size_t get_num_entries(const strucs_context &arg_strucs_context ///< The strucs_context to query
) {
return arg_strucs_context.get_name_sets().size();
}
file::pdb_list get_restricted_pdbs(const strucs_context &);
} // namespace file
} // namespace cath
#endif