Serialization¶
-
class
scine_molassembler.
JsonSerialization
¶ Class representing a compact JSON serialization of a molecule
>>> # Demonstrate a serialize-deserialize loop >>> spiro = io.experimental.from_smiles("C12(CCCC1)CCC2") >>> serializer = JsonSerialization(spiro) >>> bson_format = JsonSerialization.BinaryFormat.BSON >>> spiro_as_bson = serializer.to_binary(bson_format) >>> bson_in_b64 = serializer.base_64_encode(spiro_as_bson) >>> reverted_bson = JsonSerialization.base_64_decode(bson_in_b64) >>> serializer = JsonSerialization(reverted_bson, bson_format) >>> reverted = serializer.to_molecule() >>> reverted == spiro # Compare the deserialized molecule True
-
__init__
(*args, **kwargs)¶ Overloaded function.
__init__(self: scine_molassembler.JsonSerialization, json_string: str) -> None
Parse a JSON molecule serialization
__init__(self: scine_molassembler.JsonSerialization, molecule: scine_molassembler.Molecule) -> None
Serialize a molecule into JSON
__init__(self: scine_molassembler.JsonSerialization, bytes: bytes, binary_format: scine_molassembler.JsonSerialization.BinaryFormat) -> None
Parse a binary JSON molecule serialization
-
class
BinaryFormat
¶ Specifies the type of JSON binary format
Members:
CBOR : Compact Binary Object Representation
BSON : Binary JSON
MsgPack : MsgPack
UBJSON : Universal Binary JSON
-
BSON
= BinaryFormat.BSON¶
-
CBOR
= BinaryFormat.CBOR¶
-
MsgPack
= BinaryFormat.MsgPack¶
-
UBJSON
= BinaryFormat.UBJSON¶
-
property
name
¶ handle) -> str
- Type
(self
-
-
static
base_64_decode
(base_64_string: str) → bytes¶ Decode base-64 string into binary
-
static
base_64_encode
(binary: bytes) → str¶ Encode binary format as base-64 string
-
standardize
(self: scine_molassembler.JsonSerialization) → scine_molassembler.JsonSerialization¶ Standardize the internal JSON serialization (only for canonical molecules)
-
to_binary
(self: scine_molassembler.JsonSerialization, binary_format: scine_molassembler.JsonSerialization.BinaryFormat) → bytes¶ Serialize a molecule into a binary format
-
to_molecule
(self: scine_molassembler.JsonSerialization) → scine_molassembler.Molecule¶ Construct a molecule from the serialization
-
to_string
(self: scine_molassembler.JsonSerialization) → str¶ Dump the JSON serialization into a string
-