Skip to content

Commit

Permalink
behavior changed
Browse files Browse the repository at this point in the history
  • Loading branch information
stsouko committed Jan 15, 2021
1 parent eec679b commit 1993f7c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions CGRtools/algorithms/components/reaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Ramil Nugmanov <nougmanoff@protonmail.com>
# Copyright 2020, 2021 Ramil Nugmanov <nougmanoff@protonmail.com>
# Copyright 2020 Ravil Mukhametgaleev <sonic-mc@mail.ru>
# Copyright 2021 Timur Gimadiev <timur.gimadiev@gmail.com>
# This file is part of CGRtools.
#
# CGRtools is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -113,7 +114,7 @@ def extended_centers_list(self) -> Tuple[Tuple[int, ...], ...]:
out.append(tuple(fe))
return tuple(out)

def enumerate_centers(self) -> Iterator['ReactionContainer']:
def enumerate_centers(self: 'ReactionContainer') -> Iterator['ReactionContainer']:
"""
Get all possible single stage reactions from multistage.
Note multicomponent molecules (salts etc) can be treated incorrectly.
Expand Down Expand Up @@ -208,7 +209,7 @@ def enumerate_centers(self) -> Iterator['ReactionContainer']:
cp.meta.clear()
yield cp

def remove_reagents(self, keep_reagents=False):
def remove_reagents(self: 'ReactionContainer', *, keep_reagents: bool = False):
"""
Preprocess reaction according to mapping, using the following idea: molecules(each separated graph) will be
placed to reagents if it is not changed in the reaction (no bonds, charges reorders)
Expand Down Expand Up @@ -236,10 +237,14 @@ def remove_reagents(self, keep_reagents=False):
tmp.append(m)
reagents.discard(m)
tmp.extend(reagents)
reagents = tmp
reagents = tuple(tmp)
else:
reagents = ()
return self.__class__(reactants, products, reagents, self.meta)
self._ReactionContainer__reactants = tuple(reactants)
self._ReactionContainer__products = tuple(products)
self._ReactionContainer__reagents = reagents
self.flush_cache()
self.fix_positions()
raise MappingError("Reaction center is absent according to mapping")


Expand Down

0 comments on commit 1993f7c

Please sign in to comment.