BioSimSpace.Convert#

The Convert package contains tools for converting between different molecular representations. Due to the different way that molecules are represented, full round trip conversion isn’t yet possible. For example, starting with a BioSimSpace system object, you perform multiple conversions and end up back with a list of BioSimSpace molecules, i.e. those in the original system. Where possible, we try to return converted objects as the smallest possible object, i.e. a single residue molecule will be returned as a residue, a single atom residue will be returned as an atom. As always, you can use the native functionality of the returned object to convert to a different object if desired.

We currently only support conversion to an OpenMM context from specific BioSimSpace and Sire objects. At present the conversion is one-way only.

Functions#

smiles(smiles_string[, add_hydrogens, ...])

Generate a BioSimSpace Molecule froma SMILES string.

supportedFormats()

Return a list of the supported formats.

to(obj[, format, property_map])

Convert an object to a specified format.

toBioSimSpace(obj[, property_map])

Convert an object to BioSimSpace format.

toOpenMM(obj[, property_map])

Convert an object to OpenMM format.

toRDKit(obj[, property_map])

Convert an object to RDKit format.

toSire(obj[, property_map])

Convert an object to Sire format.

Examples

Load a system and convert to various formats.

import BioSimSpace as BSS

files = BSS.IO.expand(
    BSS.tutorialUrl(),
    ["ala.crd", "ala.top"],
    ".bz2"
)
system = BSS.IO.readMolecules(files)

# Convert to Sire format.
sire_system = BSS.Convert.to(system, "sire")

# Convert to RDKit format.
rdkit_mols = BSS.Convert.to(system, "rdkit")

# Convert a molecule to Sire format.
sire_mol = BSS.Convert.to(system[0], "sire")

# Convert a molecule to RDKit format.
rdkit_mol = BSS.Convert.to(system[0], "rdkit")

# Convert a residue to Sire format.
sire_res = BSS.Convert.to(system[0].getResidues()[0], "sire")

# Convert a residue to RDKit format. (This will return a single
# residue RDMol.)
rdkit_res = BSS.Convert.to(system[0].getResidues()[0], "rdkit")

# Convert an atom to Sire format.
sire_atom = BSS.Convert.to(system[0].getAtoms()[0], "sire")

# Convert an atom to RDKit format. (This will return a single
# atom RDMol.)
sire_atom = BSS.Convert.to(system[0].getAtoms()[0], "rdkit")

# Conversions can be chained, for example.
bss_mols = BSS.Convert.to(
    BSS.Convert.to(
        BSS.Convert.to(system, "sire"),
        "rdkit"
    ),
    "biosimspace"
)