MMTF-C++
The C++ language MMTF libraries
mmtf Namespace Reference

Data Structures

class  BinaryDecoder
 Helper class to decode msgpack binary into a vector. More...
 
struct  BioAssembly
 Data store for the biological assembly annotation. More...
 
class  BondAdder
 Helper class for adding bonds to a group-redundant system. More...
 
class  DecodeError
 Exception thrown when failing during decoding. More...
 
class  EncodeError
 Exception thrown when failing during encoding. More...
 
struct  Entity
 Entity type. More...
 
struct  GroupType
 Group (residue) level data store. More...
 
class  MapDecoder
 Helper class to decode msgpack maps into object fields. More...
 
struct  StructureData
 Top level MMTF data container. More...
 
struct  Transform
 Transformation definition for a set of chains. More...
 

Functions

std::vector< char > encodeInt8ToByte (std::vector< int8_t > vec_in)
 
std::vector< char > encodeFourByteInt (std::vector< int32_t > vec_in)
 
std::vector< char > encodeStringVector (std::vector< std::string > in_sv, int32_t CHAIN_LEN)
 
std::vector< char > encodeRunLengthChar (std::vector< char > in_cv)
 
std::vector< char > encodeRunLengthDeltaInt (std::vector< int32_t > int_vec)
 
std::vector< char > encodeRunLengthFloat (std::vector< float > floats_in, int32_t multiplier)
 
std::vector< char > encodeDeltaRecursiveFloat (std::vector< float > floats_in, int32_t multiplier)
 
void decodeFromBuffer (StructureData &data, const char *buffer, size_t size)
 Decode an MMTF data structure from a byte buffer. More...
 
template<typename Stream >
void decodeFromStream (StructureData &data, Stream &stream)
 Decode an MMTF data structure from a stream. More...
 
void decodeFromFile (StructureData &data, const std::string &filename)
 Decode an MMTF data structure from an existing file. More...
 
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. More...
 
template<typename Stream >
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. More...
 
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. More...
 
void compressGroupList (StructureData &data)
 Eliminate redundant groups from groupList. More...
 
std::string getVersionString ()
 Get string representation of MMTF spec version implemented here. More...
 
bool isVersionSupported (const std::string &version_string)
 Check if version is supported (minor revisions ok, major ones not) More...
 
template<typename T >
getDefaultValue ()
 Get default value for given type. More...
 
template<typename T >
bool isDefaultValue (const T &value)
 
template<typename T >
bool isDefaultValue (const std::vector< T > &value)
 
template<>
bool isDefaultValue (const std::string &value)
 
template<typename T >
void setDefaultValue (T &value)
 Set default value to given type. More...
 
bool is_hetatm (const char *type)
 Check if type is hetatm. More...
 

Function Documentation

◆ compressGroupList()

void mmtf::compressGroupList ( StructureData data)
inline

Eliminate redundant groups from groupList.

Modifies groupList and groupTypeList

Parameters
[in,out]dataConsistent system

◆ decodeFromBuffer()

void mmtf::decodeFromBuffer ( StructureData data,
const char *  buffer,
size_t  size 
)
inline

Decode an MMTF data structure from a byte buffer.

Parameters
[out]dataMMTF data structure to be filled
[in]bufferFile contents
[in]sizeSize of buffer
Exceptions
mmtf::DecodeErrorif an error occured

◆ decodeFromFile()

void mmtf::decodeFromFile ( StructureData data,
const std::string &  filename 
)
inline

Decode an MMTF data structure from an existing file.

Parameters
[out]dataMMTF data structure to be filled
[in]filenamePath to file to load
Exceptions
mmtf::DecodeErrorif an error occured

◆ decodeFromStream()

template<typename Stream >
void mmtf::decodeFromStream ( StructureData data,
Stream &  stream 
)
inline

Decode an MMTF data structure from a stream.

Note that the full stream is read until the end before decoding it!

Parameters
[out]dataMMTF data structure to be filled
[in]streamAny stream type compatible to std::ostream
Exceptions
mmtf::DecodeErrorif an error occured

◆ encodeDeltaRecursiveFloat()

std::vector< char > mmtf::encodeDeltaRecursiveFloat ( std::vector< float >  floats_in,
int32_t  multiplier 
)
inline

encode Delta Recursive Float encoding (type 10)

Parameters
[in]floats_invector of ints
[in]multiplierfloat multiplier
Returns
cv char vector of encoded bytes

◆ encodeFourByteInt()

std::vector< char > mmtf::encodeFourByteInt ( std::vector< int32_t >  vec_in)
inline

encode 4 bytes to int encoding (type 4)

Parameters
[in]vec_invector of ints to encode
Returns
cv char vector of encoded bytes

◆ encodeInt8ToByte()

std::vector< char > mmtf::encodeInt8ToByte ( std::vector< int8_t >  vec_in)
inline

encode 8 bit int to bytes encoding (type 2)

Parameters
[in]vec_invector of ints to encode
Returns
cv char vector of encoded bytes

◆ encodeRunLengthChar()

std::vector< char > mmtf::encodeRunLengthChar ( std::vector< char >  in_cv)
inline

encode Run Length Char encoding (type 6)

Parameters
[in]in_cvvector for chars
Returns
cv char vector of encoded bytes

◆ encodeRunLengthDeltaInt()

std::vector< char > mmtf::encodeRunLengthDeltaInt ( std::vector< int32_t >  int_vec)
inline

encode Run Length Delta Int encoding (type 8)

Parameters
[in]int_vecvector of ints
Returns
cv char vector of encoded bytes

◆ encodeRunLengthFloat()

std::vector< char > mmtf::encodeRunLengthFloat ( std::vector< float >  floats_in,
int32_t  multiplier 
)
inline

encode Run Length Float encoding (type 9)

Parameters
[in]floats_invector of ints
[in]multiplierfloat multiplier
Returns
cv char vector of encoded bytes

◆ encodeStringVector()

std::vector< char > mmtf::encodeStringVector ( std::vector< std::string >  in_sv,
int32_t  CHAIN_LEN 
)
inline

encode string vector encoding (type 5)

Parameters
[in]in_svvector of strings
[in]CHAIN_LENmaximum length of string
Returns
cv char vector of encoded bytes

◆ encodeToFile()

void mmtf::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 
)
inline

Encode an MMTF data structure into a file.

Parameters
[in]dataMMTF data structure to be stored
[in]filenamePath to file to load
[in]coord_dividerDivisor for coordinates
[in]occupancy_b_factor_dividerDivisor for occupancy and b-factor
[in]chain_name_max_lengthMax. length for chain name strings
Exceptions
mmtf::EncodeErrorif an error occurred

Common settings for the divisors are the default values for a loss-less encoding and both set to 10 for a lossy variant.

◆ encodeToMap()

std::map< std::string, msgpack::object > mmtf::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 
)
inline

Encode an MMTF data structure into a map of msgpack objects.

Parameters
[in]dataMMTF data structure to be stored
[in]m_zonemsgpack::zone object to use
Returns
Object which can be modified and passed to msgpack::pack

Other parameters and behavior are as in encodeToFile, but this enables you to add additional fields before packing.

◆ encodeToStream()

template<typename Stream >
void mmtf::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 
)
inline

Encode an MMTF data structure into a stream.

Parameters
[in]dataMMTF data structure to be stored
[in]streamStream to encode to

Other parameters and behavior are as in encodeToFile, but this enables you to store the data to other types of storage.

◆ getDefaultValue()

template<typename T >
T mmtf::getDefaultValue ( )
inline

Get default value for given type.

◆ getVersionString()

std::string mmtf::getVersionString ( )
inline

Get string representation of MMTF spec version implemented here.

◆ is_hetatm()

bool mmtf::is_hetatm ( const char *  type)
inline

Check if type is hetatm.

Parameters
typecstring of group.chemCompType
Returns
True if is a HETATM Used when printing this struct, also all chemCompTypes are listed, but the non-HETATM ones are commented out for reference Relevant threads: https://github.com/rcsb/mmtf/issues/28 http://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v50.dic/Items/_chem_comp.type.html

◆ isDefaultValue() [1/3]

template<>
bool mmtf::isDefaultValue ( const std::string &  value)
inline

◆ isDefaultValue() [2/3]

template<typename T >
bool mmtf::isDefaultValue ( const std::vector< T > &  value)
inline

◆ isDefaultValue() [3/3]

template<typename T >
bool mmtf::isDefaultValue ( const T &  value)
inline
Returns
True if given value is default.
Template Parameters
TCan be any numeric type, vector of string

◆ isVersionSupported()

bool mmtf::isVersionSupported ( const std::string &  version_string)
inline

Check if version is supported (minor revisions ok, major ones not)

Returns
true if supported, false if not

◆ setDefaultValue()

template<typename T >
void mmtf::setDefaultValue ( T &  value)
inline

Set default value to given type.

Template Parameters
TCan be any numeric type (no need for vector or strings here)