Bonders and deleters #293
-
Hi, I really like the idea behind bonders and deleters but find myself losing atoms in the process of creating a linear polymer with 2 building blocks containing carboxylic acids and alcohols. For example, below is some sample code from the stk Docs. I was hoping for esters but have lost the carbonyl. Any suggestions? Thanks! alcohol_factory = stk.AlcoholFactory( carboxylic_acid_factory = stk.CarboxylicAcidFactory( polymer = stk.ConstructedMolecule( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @mathersrob! Sorry for the delay in reply. If you would like to create esters try the following code: # alcohol functional group string is [*][O][H]
# see (https://stk.readthedocs.io/en/latest/stk.molecular.functional_groups.factories.alcohol_factory.html)
alcohol_factory = stk.AlcoholFactory(
# The index of the oxygen atom is 1 in the functional group string
bonders=(1, ),
# The index of the hydrogen atom in the
# functional group string is 2 .
deleters=(2, ),
)
bb1 = stk.BuildingBlock(
smiles='OCCCCO',
functional_groups=(alcohol_factory, ),
)
# carboxylic acid functional group string is [*][C](=[O])[O][H]
# see (https://stk.readthedocs.io/en/latest/stk.molecular.functional_groups.factories.carboxylic_acid_factory.html)
carboxylic_acid_factory = stk.CarboxylicAcidFactory(
# The index of the carbon atom in the functional
# group string is 1.
bonders=(1, ),
# The index of the non-carbonyl oxygen atom and
# hydrogen atoms in the functional
# group string are 3 and 4, respectively
deleters=(3, 4),
)
bb2 = stk.BuildingBlock(
smiles='OC(=O)CC(=O)O',
functional_groups=(carboxylic_acid_factory, ),
)
polymer = stk.ConstructedMolecule(
topology_graph=stk.polymer.Linear(
building_blocks=(bb1, bb2),
repeating_unit='AB',
num_repeating_units=6,
optimizer=stk.Collapser(scale_steps=False),
),
) I'll explain a bit about how / why this works. For the For the Hope this helps a bit, let me know if you run into any other issues and if you think the docs could be improved in some way. |
Beta Was this translation helpful? Give feedback.
Hi @mathersrob! Sorry for the delay in reply. If you would like to create esters try the following code: