MMTF-C++
The C++ language MMTF libraries
|
Go to the documentation of this file.
12 #ifndef MMTF_ENCODER_H
13 #define MMTF_ENCODER_H
36 const std::string& filename, int32_t coord_divider = 1000,
37 int32_t occupancy_b_factor_divider = 100,
38 int32_t chain_name_max_length = 4);
48 template <
typename Stream>
49 inline void encodeToStream(
const StructureData& data, Stream& stream,
50 int32_t coord_divider = 1000, int32_t occupancy_b_factor_divider = 100,
51 int32_t chain_name_max_length = 4);
62 inline std::map<std::string, msgpack::object>
63 encodeToMap(
const StructureData& data, msgpack::zone& m_zone,
64 int32_t coord_divider = 1000, int32_t occupancy_b_factor_divider = 100,
65 int32_t chain_name_max_length = 4);
71 const std::string& filename, int32_t coord_divider,
72 int32_t occupancy_b_factor_divider, int32_t chain_name_max_length) {
74 std::ofstream ofs(filename.c_str(), std::ios::binary | std::ios::out );
76 throw EncodeError(
"Could not open >" + filename +
"< for writing, exiting.");
79 occupancy_b_factor_divider, chain_name_max_length);
82 template <
typename Stream>
84 int32_t coord_divider, int32_t occupancy_b_factor_divider,
85 int32_t chain_name_max_length) {
87 msgpack::pack(stream,
encodeToMap(data, _zone, coord_divider,
88 occupancy_b_factor_divider, chain_name_max_length));
91 inline std::map<std::string, msgpack::object>
93 int32_t coord_divider, int32_t occupancy_b_factor_divider,
94 int32_t chain_name_max_length) {
96 throw mmtf::EncodeError(
"mmtf EncoderError, StructureData does not have Consistent data... exiting!");
100 std::map<std::string, msgpack::object> data_map;
102 data_map[
"mmtfVersion"] = msgpack::object(data.
mmtfVersion, m_zone);
103 data_map[
"mmtfProducer"] = msgpack::object(data.
mmtfProducer, m_zone);
105 data_map[
"spaceGroup"] = msgpack::object(data.
spaceGroup, m_zone);
108 data_map[
"structureId"] = msgpack::object(data.
structureId, m_zone);
111 data_map[
"title"] = msgpack::object(data.
title, m_zone);
114 data_map[
"depositionDate"] = msgpack::object(data.
depositionDate, m_zone);
117 data_map[
"releaseDate"] = msgpack::object(data.
releaseDate, m_zone);
125 data_map[
"experimentalMethods"] =
130 data_map[
"altLocList"] =
138 data_map[
"bondOrderList"] =
142 data_map[
"secStructList"] =
146 data_map[
"numBonds"] = msgpack::object(data.
numBonds, m_zone);
147 data_map[
"numAtoms"] = msgpack::object(data.
numAtoms, m_zone);
148 data_map[
"numGroups"] = msgpack::object(data.
numGroups, m_zone);
149 data_map[
"numChains"] = msgpack::object(data.
numChains, m_zone);
150 data_map[
"numModels"] = msgpack::object(data.
numModels, m_zone);
154 data_map[
"groupsPerChain"] = msgpack::object(data.
groupsPerChain, m_zone);
155 data_map[
"chainsPerModel"] = msgpack::object(data.
chainsPerModel, m_zone);
167 data_map[
"resolution"] = msgpack::object(data.
resolution, m_zone);
170 data_map[
"rFree"] = msgpack::object(data.
rFree, m_zone);
173 data_map[
"rWork"] = msgpack::object(data.
rWork, m_zone);
186 data_map[
"unitCell"] = msgpack::object(data.
unitCell, m_zone);
189 data_map[
"groupList"] = msgpack::object(data.
groupList, m_zone);
192 data_map[
"bioAssemblyList"] = msgpack::object(data.
bioAssemblyList, m_zone);
196 data_map[
"entityList"] = msgpack::object(data.
entityList, m_zone);
200 data_map[
"ncsOperatorList"] = msgpack::object(data.
ncsOperatorList, m_zone);
void encodeToStream(const StructureData &data, Stream &stream, int32_t coord_divider=1000, int32_t occupancy_b_factor_divider=100, int32_t chain_name_max_length=4)
Encode an MMTF data structure into a stream.
Definition: encoder.hpp:83
std::vector< int32_t > sequenceIndexList
Definition: structure_data.hpp:186
std::vector< float > unitCell
Definition: structure_data.hpp:154
std::vector< char > encodeInt8ToByte(std::vector< int8_t > vec_in)
Definition: binary_encoder.hpp:240
std::vector< float > bFactorList
Definition: structure_data.hpp:178
std::vector< float > occupancyList
Definition: structure_data.hpp:181
float rWork
Definition: structure_data.hpp:166
int32_t numChains
Definition: structure_data.hpp:170
Top level MMTF data container.
Definition: structure_data.hpp:151
void encodeToFile(const StructureData &data, const std::string &filename, int32_t coord_divider=1000, int32_t occupancy_b_factor_divider=100, int32_t chain_name_max_length=4)
Encode an MMTF data structure into a file.
Definition: encoder.hpp:70
float resolution
Definition: structure_data.hpp:164
int32_t numBonds
Definition: structure_data.hpp:167
std::vector< float > xCoordList
Definition: structure_data.hpp:175
std::vector< float > yCoordList
Definition: structure_data.hpp:176
std::vector< int32_t > groupsPerChain
Definition: structure_data.hpp:189
std::vector< int32_t > chainsPerModel
Definition: structure_data.hpp:190
std::vector< GroupType > groupList
Definition: structure_data.hpp:172
std::vector< std::vector< float > > ncsOperatorList
Definition: structure_data.hpp:160
std::map< std::string, msgpack::object > encodeToMap(const StructureData &data, msgpack::zone &m_zone, int32_t coord_divider=1000, int32_t occupancy_b_factor_divider=100, int32_t chain_name_max_length=4)
Encode an MMTF data structure into a map of msgpack objects.
Definition: encoder.hpp:92
std::string spaceGroup
Definition: structure_data.hpp:155
std::vector< int32_t > groupTypeList
Definition: structure_data.hpp:183
float rFree
Definition: structure_data.hpp:165
std::string structureId
Definition: structure_data.hpp:156
std::vector< int32_t > bondAtomList
Definition: structure_data.hpp:173
std::vector< char > encodeRunLengthChar(std::vector< char > in_cv)
Definition: binary_encoder.hpp:279
std::vector< int8_t > secStructList
Definition: structure_data.hpp:184
std::vector< Entity > entityList
Definition: structure_data.hpp:162
bool isDefaultValue(const T &value)
Definition: structure_data.hpp:373
std::vector< char > insCodeList
Definition: structure_data.hpp:185
std::vector< int32_t > atomIdList
Definition: structure_data.hpp:179
int32_t numAtoms
Definition: structure_data.hpp:168
std::vector< char > altLocList
Definition: structure_data.hpp:180
std::vector< char > encodeRunLengthFloat(std::vector< float > floats_in, int32_t multiplier)
Definition: binary_encoder.hpp:305
std::vector< int32_t > groupIdList
Definition: structure_data.hpp:182
bool hasConsistentData(bool verbose=false, uint32_t chain_name_max_length=4) const
Check consistency of structural data.
Definition: structure_data.hpp:458
std::vector< char > encodeRunLengthDeltaInt(std::vector< int32_t > int_vec)
Definition: binary_encoder.hpp:293
std::vector< BioAssembly > bioAssemblyList
Definition: structure_data.hpp:161
std::vector< char > encodeFourByteInt(std::vector< int32_t > vec_in)
Definition: binary_encoder.hpp:250
std::string mmtfProducer
Definition: structure_data.hpp:153
std::vector< std::string > experimentalMethods
Definition: structure_data.hpp:163
int32_t numGroups
Definition: structure_data.hpp:169
std::vector< float > zCoordList
Definition: structure_data.hpp:177
Exception thrown when failing during encoding.
Definition: errors.hpp:31
std::vector< std::string > chainNameList
Definition: structure_data.hpp:188
std::vector< char > encodeStringVector(std::vector< std::string > in_sv, int32_t CHAIN_LEN)
Definition: binary_encoder.hpp:261
int32_t numModels
Definition: structure_data.hpp:171
std::string depositionDate
Definition: structure_data.hpp:158
std::vector< int8_t > bondOrderList
Definition: structure_data.hpp:174
Definition: binary_decoder.hpp:24
std::vector< std::string > chainIdList
Definition: structure_data.hpp:187
std::string title
Definition: structure_data.hpp:157
std::vector< char > encodeDeltaRecursiveFloat(std::vector< float > floats_in, int32_t multiplier)
Definition: binary_encoder.hpp:319
std::string releaseDate
Definition: structure_data.hpp:159
std::string mmtfVersion
Definition: structure_data.hpp:152