From 54b0c947fd34029aee03b4d7982ef1394dfc7ba5 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 20 Mar 2024 16:38:31 -0600 Subject: [PATCH] Changed IBIS passing to Polymerizationreactor.propagate() from class-based to instance-based (allows for custom init args) --- polymerist/rdutils/reactions/reactors.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/polymerist/rdutils/reactions/reactors.py b/polymerist/rdutils/reactions/reactors.py index 5dadd89..d45b716 100644 --- a/polymerist/rdutils/reactions/reactors.py +++ b/polymerist/rdutils/reactions/reactors.py @@ -124,12 +124,10 @@ class CondensationReactor(Reactor): @dataclass class PolymerizationReactor(Reactor): '''Reactor which exhaustively generates monomers fragments according to a given a polymerization mechanism''' - def propagate(self, monomers : Iterable[RDMol], fragment_strategy_type : Type[IBIS]=ReseparateRGroups, clear_map_nums : bool=True) -> Generator[tuple[list[RDMol], list[RDMol]], None, None]: + def propagate(self, monomers : Iterable[RDMol], fragment_strategy : IBIS=ReseparateRGroups(), clear_map_nums : bool=True) -> Generator[tuple[list[RDMol], list[RDMol]], None, None]: '''Keep reacting and fragmenting a pair of monomers until all reactive sites have been reacted Returns fragment pairs at each step of the chain propagation process''' - ibis = fragment_strategy_type() # initialize fragmenter class reactants = monomers # initialize reactive pair with monomers - while True: # check if the reactants can be applied under the reaction template try: intermediates = self.react(reactants, repetitions=1, clear_props=False) # can't clear properties yet, otherwise intermonomer bond finder would have nothing to go off of @@ -144,7 +142,7 @@ def propagate(self, monomers : Iterable[RDMol], fragment_strategy_type : Type[IB fragments.extend( # list extension preserves insertion order at each step rdprops.clear_atom_props(fragment, in_place=False) # essential to avoid reaction mapping info from prior steps from contaminating future ones - for fragment in ibis.produce_fragments( + for fragment in fragment_strategy.produce_fragments( product, product_info=self.rxn_schema.product_info_maps[i], separate=True