* lukasturcani Fixed an bug occurs when a `ConstructedMolecule` is also used as a `BuildingBlock`, and both are deposited in a `ConstructedMoleculeMongoDb`. For example, if you constructed a polymer, and then used it to construct a rotaxane, and deposited both the polymer and the rotaxane into a `ConstructedMoleculeMongoDb`, in that order, the structure of the polymer in the `ConstructedMoleculeMongoDb` would be corrupted, because it would not have canonical atom ordering. Now, whenever `with_canonical_atom_ordering` is called on a `ConstructedMolecule`, the building blocks in the `ConstructedMolecule`, will also have canonical atom ordering, this was not the case previously.
Example of code where the bug would have occurred
python
import stk
import pymongo
client = pymongo.MongoClient()
cdb = stk.ConstructedMoleculeMongoDb(
mongo_client=client,
database='reorganization-test',
)
polymer = stk.ConstructedMolecule(
topology_graph=stk.polymer.Linear(
building_blocks=(
stk.BuildingBlock(
smiles='BrCCBr',
functional_groups=[stk.BromoFactory()],
),
),
repeating_unit='A',
num_repeating_units=2,
),
)
cycle = stk.ConstructedMolecule(
topology_graph=stk.macrocycle.Macrocycle(
building_blocks=(
stk.BuildingBlock(
smiles='BrCCCCBr',
functional_groups=[stk.BromoFactory()],
),
),
repeating_unit='A',
num_repeating_units=5,
),
)
rotaxane = stk.ConstructedMolecule(
topology_graph=stk.rotaxane.NRotaxane(
axle=stk.BuildingBlock.init_from_molecule(polymer),
cycles=(
stk.BuildingBlock.init_from_molecule(cycle),
),
repeating_unit='A',
num_repeating_units=4,
),
)
cdb.put(polymer)
cdb.put(cycle)
Depositing the rotaxane corrupts the position matrix of the polymer and cycle,
because it deposits them without canonical atom ordering.
cdb.put(rotaxane)