17#include "msgpack_encoders.hpp"
37 const std::string& filename, int32_t coord_divider = 1000,
38 int32_t occupancy_b_factor_divider = 100,
39 int32_t chain_name_max_length = 4);
50template <
typename Stream>
52 int32_t coord_divider = 1000, int32_t occupancy_b_factor_divider = 100,
53 int32_t chain_name_max_length = 4);
64inline std::map<std::string, msgpack::object>
66 int32_t coord_divider = 1000, int32_t occupancy_b_factor_divider = 100,
67 int32_t chain_name_max_length = 4);
73 const std::string& filename, int32_t coord_divider,
74 int32_t occupancy_b_factor_divider, int32_t chain_name_max_length) {
76 std::ofstream ofs(filename.c_str(), std::ios::binary | std::ios::out );
78 throw EncodeError(
"Could not open >" + filename +
"< for writing, exiting.");
81 occupancy_b_factor_divider, chain_name_max_length);
84template <
typename Stream>
86 int32_t coord_divider, int32_t occupancy_b_factor_divider,
87 int32_t chain_name_max_length) {
89 occupancy_b_factor_divider, chain_name_max_length));
92inline std::map<std::string, msgpack::object>
94 int32_t coord_divider, int32_t occupancy_b_factor_divider,
95 int32_t chain_name_max_length) {
97 throw mmtf::EncodeError(
"mmtf EncoderError, StructureData does not have Consistent data... exiting!");
101 std::map<std::string, msgpack::object> data_map;
103 data_map[
"mmtfVersion"] = msgpack::object(data.
mmtfVersion, m_zone);
104 data_map[
"mmtfProducer"] = msgpack::object(data.
mmtfProducer, m_zone);
106 data_map[
"spaceGroup"] = msgpack::object(data.
spaceGroup, m_zone);
109 data_map[
"structureId"] = msgpack::object(data.
structureId, m_zone);
112 data_map[
"title"] = msgpack::object(data.
title, m_zone);
115 data_map[
"depositionDate"] = msgpack::object(data.
depositionDate, m_zone);
118 data_map[
"releaseDate"] = msgpack::object(data.
releaseDate, m_zone);
126 data_map[
"experimentalMethods"] =
131 data_map[
"altLocList"] =
139 data_map[
"bondOrderList"] =
144 data_map[
"bondResonanceList"] =
148 data_map[
"secStructList"] =
152 data_map[
"numBonds"] = msgpack::object(data.
numBonds, m_zone);
153 data_map[
"numAtoms"] = msgpack::object(data.
numAtoms, m_zone);
154 data_map[
"numGroups"] = msgpack::object(data.
numGroups, m_zone);
155 data_map[
"numChains"] = msgpack::object(data.
numChains, m_zone);
156 data_map[
"numModels"] = msgpack::object(data.
numModels, m_zone);
160 data_map[
"groupsPerChain"] = msgpack::object(data.
groupsPerChain, m_zone);
161 data_map[
"chainsPerModel"] = msgpack::object(data.
chainsPerModel, m_zone);
173 data_map[
"resolution"] = msgpack::object(data.
resolution, m_zone);
176 data_map[
"rFree"] = msgpack::object(data.
rFree, m_zone);
179 data_map[
"rWork"] = msgpack::object(data.
rWork, m_zone);
192 data_map[
"unitCell"] = msgpack::object(data.
unitCell, m_zone);
195 data_map[
"groupList"] = msgpack::object(data.
groupList, m_zone);
198 data_map[
"bioAssemblyList"] = msgpack::object(data.
bioAssemblyList, m_zone);
202 data_map[
"entityList"] = msgpack::object(data.
entityList, m_zone);
206 data_map[
"ncsOperatorList"] = msgpack::object(data.
ncsOperatorList, m_zone);
210 data_map[
"bondProperties"] = msgpack::object(data.
bondProperties, m_zone);
213 data_map[
"atomProperties"] = msgpack::object(data.
atomProperties, m_zone);
216 data_map[
"groupProperties"] = msgpack::object(data.
groupProperties, m_zone);
219 data_map[
"chainProperties"] = msgpack::object(data.
chainProperties, m_zone);
222 data_map[
"modelProperties"] = msgpack::object(data.
modelProperties, m_zone);
225 data_map[
"extraProperties"] = msgpack::object(data.
extraProperties, m_zone);
Exception thrown when failing during encoding.
Definition errors.hpp:31
Definition binary_decoder.hpp:25
std::vector< char > encodeDeltaRecursiveFloat(std::vector< float > const &floats_in, int32_t const multiplier)
Definition binary_encoder.hpp:311
std::vector< char > encodeRunLengthChar(std::vector< char > const &in_cv)
Definition binary_encoder.hpp:274
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:72
std::vector< char > encodeInt8ToByte(std::vector< int8_t > vec_in)
Definition binary_encoder.hpp:235
std::vector< char > encodeRunLengthFloat(std::vector< float > const &floats_in, int32_t const multiplier)
Definition binary_encoder.hpp:298
std::vector< char > encodeFourByteInt(std::vector< int32_t > const &vec_in)
Definition binary_encoder.hpp:245
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:93
std::vector< char > encodeRunLengthInt8(std::vector< int8_t > const &int8_vec)
Definition binary_encoder.hpp:325
std::vector< char > encodeStringVector(std::vector< std::string > const &in_sv, int32_t const CHAIN_LEN)
Definition binary_encoder.hpp:256
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:85
bool isDefaultValue(const T &value)
Definition structure_data.hpp:409
std::vector< char > encodeRunLengthDeltaInt(std::vector< int32_t > int_vec)
Definition binary_encoder.hpp:286
Top level MMTF data container.
Definition structure_data.hpp:157
int32_t numBonds
Definition structure_data.hpp:173
std::string mmtfVersion
Definition structure_data.hpp:158
float rFree
Definition structure_data.hpp:171
std::vector< int32_t > sequenceIndexList
Definition structure_data.hpp:193
std::vector< char > altLocList
Definition structure_data.hpp:187
std::vector< int8_t > bondOrderList
Definition structure_data.hpp:180
std::string structureId
Definition structure_data.hpp:162
std::vector< int8_t > bondResonanceList
Definition structure_data.hpp:181
int32_t numGroups
Definition structure_data.hpp:175
std::vector< float > zCoordList
Definition structure_data.hpp:184
std::map< std::string, msgpack::object > chainProperties
Definition structure_data.hpp:202
int32_t numModels
Definition structure_data.hpp:177
std::vector< float > xCoordList
Definition structure_data.hpp:182
std::map< std::string, msgpack::object > groupProperties
Definition structure_data.hpp:201
std::vector< int32_t > groupsPerChain
Definition structure_data.hpp:196
std::vector< float > bFactorList
Definition structure_data.hpp:185
std::vector< int32_t > atomIdList
Definition structure_data.hpp:186
int32_t numChains
Definition structure_data.hpp:176
std::vector< std::string > chainIdList
Definition structure_data.hpp:194
std::string spaceGroup
Definition structure_data.hpp:161
std::vector< int32_t > groupIdList
Definition structure_data.hpp:189
std::string depositionDate
Definition structure_data.hpp:164
std::vector< int32_t > bondAtomList
Definition structure_data.hpp:179
std::map< std::string, msgpack::object > atomProperties
Definition structure_data.hpp:200
std::vector< GroupType > groupList
Definition structure_data.hpp:178
std::map< std::string, msgpack::object > extraProperties
Definition structure_data.hpp:204
std::vector< char > insCodeList
Definition structure_data.hpp:192
bool hasConsistentData(bool verbose=false, uint32_t chain_name_max_length=4) const
Check consistency of structural data.
Definition structure_data.hpp:572
float rWork
Definition structure_data.hpp:172
float resolution
Definition structure_data.hpp:170
std::string mmtfProducer
Definition structure_data.hpp:159
std::vector< std::vector< float > > ncsOperatorList
Definition structure_data.hpp:166
msgpack::zone msgpack_zone
Definition structure_data.hpp:198
std::vector< int32_t > chainsPerModel
Definition structure_data.hpp:197
std::vector< int32_t > groupTypeList
Definition structure_data.hpp:190
std::vector< BioAssembly > bioAssemblyList
Definition structure_data.hpp:167
std::vector< std::string > chainNameList
Definition structure_data.hpp:195
std::string releaseDate
Definition structure_data.hpp:165
std::vector< float > unitCell
Definition structure_data.hpp:160
std::vector< int8_t > secStructList
Definition structure_data.hpp:191
std::vector< Entity > entityList
Definition structure_data.hpp:168
std::map< std::string, msgpack::object > bondProperties
Definition structure_data.hpp:199
int32_t numAtoms
Definition structure_data.hpp:174
std::vector< float > occupancyList
Definition structure_data.hpp:188
std::vector< float > yCoordList
Definition structure_data.hpp:183
std::map< std::string, msgpack::object > modelProperties
Definition structure_data.hpp:203
std::vector< std::string > experimentalMethods
Definition structure_data.hpp:169
std::string title
Definition structure_data.hpp:163