MMTF-C++
The C++ language MMTF libraries
Loading...
Searching...
No Matches
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. Class cannot be copied as it contains unique pointers to msgpack data. 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 > const &vec_in)
 
std::vector< char > encodeStringVector (std::vector< std::string > const &in_sv, int32_t const CHAIN_LEN)
 
std::vector< char > encodeRunLengthChar (std::vector< char > const &in_cv)
 
std::vector< char > encodeRunLengthDeltaInt (std::vector< int32_t > int_vec)
 
std::vector< char > encodeRunLengthFloat (std::vector< float > const &floats_in, int32_t const multiplier)
 
std::vector< char > encodeDeltaRecursiveFloat (std::vector< float > const &floats_in, int32_t const multiplier)
 
std::vector< char > encodeRunLengthInt8 (std::vector< int8_t > const &int8_vec)
 
void decodeFromMapDecoder (StructureData &data, MapDecoder &mapDecoder)
 Decode an MMTF data structure from a mapDecoder.
 
void decodeFromBuffer (StructureData &data, const char *buffer, size_t size)
 Decode an MMTF data structure from a byte buffer.
 
template<typename Stream>
void decodeFromStream (StructureData &data, Stream &stream)
 Decode an MMTF data structure from a stream.
 
void decodeFromFile (StructureData &data, const std::string &filename)
 Decode an MMTF data structure from an existing file.
 
void mapDecoderFromBuffer (MapDecoder &mapDecoder, const char *buffer, std::size_t size)
 Get a mapDecoder for un-decoded MMTF data.
 
template<typename Stream>
void mapDecoderFromStream (MapDecoder &mapDecoder, Stream &stream)
 Get a mapDecoder into an un-decoded MMTF data.
 
void mapDecoderFromFile (MapDecoder &mapDecoder, const std::string &filename)
 Get a mapDecoder into an un-decoded MMTF data.
 
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.
 
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.
 
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.
 
void compressGroupList (StructureData &data)
 Eliminate redundant groups from groupList.
 
std::string getVersionString ()
 Get string representation of MMTF spec version implemented here.
 
bool isVersionSupported (const std::string &version_string)
 Check if version is supported (minor revisions ok, major ones not)
 
template<typename T>
getDefaultValue ()
 Get default value for given type.
 
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<>
bool isDefaultValue (const std::map< std::string, msgpack::object > &value)
 
template<typename T>
void setDefaultValue (T &value)
 Set default value to given type.
 
bool is_polymer (const unsigned int chain_index, const std::vector< Entity > &entity_list)
 Check if chain is a polymer chain.
 
bool is_hetatm (const char *type)
 Check if group type consists of HETATM atoms.
 
bool is_hetatm (const unsigned int chain_index, const std::vector< Entity > &entity_list, const GroupType &group_type)
 Preferred way to check if group consists of hetatm atoms.
 
template<>
bool isDefaultValue (const std::string &value)
 
template<>
bool isDefaultValue (const std::map< std::string, msgpack::object > &value)
 

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

◆ decodeFromMapDecoder()

void mmtf::decodeFromMapDecoder ( StructureData & data,
MapDecoder & mapDecoder )
inline

Decode an MMTF data structure from a mapDecoder.

Parameters
[out]dataMMTF data structure to be filled
[in]mapDecoderMapDecoder holding raw mmtf data
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 from start to end before decoding it! Use decodeFromBuffer if you wish to use just part of the stream.

Parameters
[out]dataMMTF data structure to be filled
[in]streamStream that holds mmtf data
Template Parameters
StreamAny stream type compatible to std::istream
Exceptions
mmtf::DecodeErrorif an error occured

◆ encodeDeltaRecursiveFloat()

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

Encode Delta Recursive Float encoding (type 10)

Parameters
[in]floats_inVector of floats to encode
[in]multiplierMultiplier to convert float to int
Returns
Char vector of encoded bytes

◆ encodeFourByteInt()

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

Encode 4 bytes to int encoding (type 4)

Parameters
[in]vec_inVector of ints to encode
Returns
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
Char vector of encoded bytes

◆ encodeRunLengthChar()

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

Encode Run Length Char encoding (type 6)

Parameters
[in]in_cvVector of chars to encode
Returns
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 to encode
Returns
Char vector of encoded bytes

◆ encodeRunLengthFloat()

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

Encode Run Length Float encoding (type 9)

Parameters
[in]floats_inVector of floats to encode
[in]multiplierMultiplier to convert float to int
Returns
Char vector of encoded bytes

◆ encodeRunLengthInt8()

std::vector< char > mmtf::encodeRunLengthInt8 ( std::vector< int8_t > const & int8_vec)
inline

Encode Run-Length 8bit int encoding (type 16)

Parameters
[in]int8_vecVector of ints to encode
Returns
Char vector of encoded bytes

◆ encodeStringVector()

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

Encode string vector encoding (type 5)

Parameters
[in]in_svVector of strings to encode
[in]CHAIN_LENMaximum length of string
Returns
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
Template Parameters
StreamAny stream type compatible to std::ostream

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() [1/2]

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

Check if group type consists of HETATM atoms.

Parameters
typeCharacter string of GroupType.chemCompType.
Returns
True if group consists of HETATM atoms.

Relevant threads:

Warning
Use the other is_hetatm function whenever possible. This one should only be used if you don't have info like an 'entity_list' to work with. This can return 'false' if you have an amino acid ligand.

◆ is_hetatm() [2/2]

bool mmtf::is_hetatm ( const unsigned int chain_index,
const std::vector< Entity > & entity_list,
const GroupType & group_type )
inline

Preferred way to check if group consists of hetatm atoms.

Parameters
chain_indexChain index of chain where atom belongs to.
entity_listStructureData.entityList with info on given chain.
group_typeGroupType of group where atom belongs to.
Returns
True if it is a HETATM.

Follows discussion in https://github.com/rcsb/mmtf/issues/28.

Used in StructureData.print to mark atoms as HETATM. This is a shorthand for is_hetatm(type) || !is_polymer(chain_index, entity_list).

Efficient code needing this information should preferably use the or statement above, precompute the is_polymer output for each chain and the is_hetatm(type) output for each group instead of calling this on each atom.

See also
is_polymer, is_hetatm

◆ is_polymer()

bool mmtf::is_polymer ( const unsigned int chain_index,
const std::vector< Entity > & entity_list )
inline

Check if chain is a polymer chain.

Parameters
chain_indexChain index of chain.
entity_listStructureData.entityList with info on given chain.
Returns
True if chain is a polymer chain.
Exceptions
mmtf::DecodeErrorif chain index doesn't appear in entity list.

◆ isDefaultValue() [1/6]

template<>
bool mmtf::isDefaultValue ( const std::map< std::string, msgpack::object > & value)
inline

◆ isDefaultValue() [2/6]

template<>
bool mmtf::isDefaultValue ( const std::map< std::string, msgpack::object > & value)
inline

◆ isDefaultValue() [3/6]

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

◆ isDefaultValue() [4/6]

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

◆ isDefaultValue() [5/6]

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

◆ isDefaultValue() [6/6]

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

◆ mapDecoderFromBuffer()

void mmtf::mapDecoderFromBuffer ( MapDecoder & mapDecoder,
const char * buffer,
std::size_t size )
inline

Get a mapDecoder for un-decoded MMTF data.

Parameters
[out]mapDecoderMapDecoder to hold raw mmtf data

Other parameters and behavior are as in decodeFromBuffer, but this doesn't decode the MMTF content.

◆ mapDecoderFromFile()

void mmtf::mapDecoderFromFile ( MapDecoder & mapDecoder,
const std::string & filename )
inline

Get a mapDecoder into an un-decoded MMTF data.

Parameters
[out]mapDecoderMapDecoder to hold raw mmtf data

Other parameters and behavior are as in decodeFromFile, but this doesn't decode the MMTF content.

◆ mapDecoderFromStream()

template<typename Stream>
void mmtf::mapDecoderFromStream ( MapDecoder & mapDecoder,
Stream & stream )
inline

Get a mapDecoder into an un-decoded MMTF data.

Parameters
[out]mapDecoderMapDecoder to hold raw mmtf data

Other parameters and behavior are as in decodeFromStream, but this doesn't decode the MMTF content.

◆ 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)