Class representing a compact JSON serialization of a molecule. More...
#include <Serialization.h>
Public Types | |
Public types | |
enum | BinaryFormat { CBOR, BSON, MsgPack, UBJSON } |
Binary formats that JSON can be encoded into and decoded from. | |
using | BinaryType = std::vector< std::uint8_t > |
Type used to represent binary JSON formats. | |
Public Member Functions | |
Special member functions | |
JsonSerialization (JsonSerialization &&other) noexcept | |
JsonSerialization & | operator= (JsonSerialization &&other) noexcept |
JsonSerialization (const JsonSerialization &other) | |
JsonSerialization & | operator= (const JsonSerialization &other) |
~JsonSerialization () | |
Constructors | |
JsonSerialization ()=delete | |
Construct a serialization from a JSON string. | |
JsonSerialization (const std::string &jsonString) | |
Construct a serialization from a JSON string. | |
JsonSerialization (const Molecule &molecule) | |
Construct a serialization from a Molecule. | |
JsonSerialization (const BinaryType &binary, BinaryFormat format) | |
Construct a serialization from a binary JSON format. | |
Conversions | |
operator std::string () const | |
Dump the unprettified JSON notation as a string. | |
operator Molecule () const | |
Deserialize the JSON serialization into a Molecule. | |
BinaryType | toBinary (BinaryFormat format) const |
Serialize the JSON serialization into a binary JSON format. | |
Modification | |
JsonSerialization & | standardize () |
Eliminate all notational freedom of the JSON serialization. More... | |
Static Public Member Functions | |
Static members | |
static std::string | base64Encode (const BinaryType &binary) |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant. More... | |
static BinaryType | base64Decode (const std::string &base64String) |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant. More... | |
static bool | base64EqualMolecules (const std::string &stringA, const std::string &stringB, BinaryFormat binaryFormat=BinaryFormat::CBOR) |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant. More... | |
static bool | equalDecisionLists (const std::string &listStringA, const std::string &listStringB) |
Compare two decision lists encoded as strings. More... | |
Private Attributes | |
std::unique_ptr< Impl > | pImpl_ |
Class representing a compact JSON serialization of a molecule.
The JSON representation, although principally human readable, is very compact. Keys are heavily shortened. Each Molecule JSON Object has the following structure:
* - a: List of AtomStereopermutator Objects * - a: Assignment index (key omitted if unassigned) * - c: Central index * - r: Ranking * - s: Sorted subtituents * - l: Ligands * - lr: Ranked ligands * - lnk: Links (key omitted if empty) * - s: Shape name index * - o:(optional) Position groups of the ligands * - b: List of BondStereopermutator Objects * - a: Assignment index (key omitted if unassigned) * - e: Edge on which it is placed * - c: Canonicalization state * - g: Graph Object * - Z: List of atomic numbers * - E: List of edges, each a List * - 0: Source vertex * - 1: Target vertex * - 2: Bond type index * - v: Library version List * - 0: Major * - 1: Minor * - 2: Patch *
For std::string - Molecule interconversions, you can implicitly call the converting operators:
For BinaryType - Molecule interconversions, only the implicit Molecule conversion operator is available since the binary JSON format must be specified:
|
static |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant.
|
static |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant.
|
static |
Compare two molecules/complexes encoded as base64 strings. The molecule order is irrelevant.
|
static |
Compare two decision lists encoded as strings.
The string format is expected to be
"(-100, -95, -90, 1):(10, 15, 20, 4);(1, 6, 11, 1)"
Multiple molecules have to be separated by ";". The molecule order is irrelevant.
JsonSerialization& Scine::Molassembler::JsonSerialization::standardize | ( | ) |
Eliminate all notational freedom of the JSON serialization.
The Molecule's JSON representation notational freedoms are removed:
Complexity \(\Theta(V + E + A + B)\)
std::logic_error | If the underlying molecule is not fully canonical. It makes zero sense to standardize the JSON representation if the molecule itself is not canonicalized since then JSON representation comparison will still not yield the same behavior as Molecule comparison. |