lukasturcani / stk

A Python library which allows construction and manipulation of complex molecules, as well as automatic molecular design and the creation of molecular databases.
https://stk.readthedocs.io/
MIT License
252 stars 48 forks source link

Add a MolecularGraph TopologyGraph subclass. #203

Open lukasturcani opened 4 years ago

andrewtarzia commented 4 years ago

API example from discussion with @lukasturcani

# React the amine functional groups during construction.
bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
# React the aldehyde functional groups during construction.
bb2 = stk.BuildingBlock('O=CCCC=O', [stk.AldehydeFactory()])

# Perform reaction.
# No node positions, but edges need to be defined.
bb1_plus_bb2 = stk.ConstructedMolecule(
    topology_graph=stk.graph.MolecularGraph(
        nodes={
            0: stk.graph.Node(bb1, position=[0, 0, 0]), 
            1: stk.graph.Node(bb2, position=[0, 0, 0]),
        },
        edges=(
            stk.graph.Edge(
                FG1=stk.graph.FGRef(bb_id=0, fg_id=0),
                FG2=stk.graph.FGRef(bb_id=1, fg_id=0),
            ), 
        reaction_factory=stk.reaction_factory.CoolShit(),
        ),
    ),
    reaction=??
)