Skip to content

Commit

Permalink
Patch bug fixed (#24)
Browse files Browse the repository at this point in the history
* new reactor

* fix

* skip

* prepare patterns to molecules mapping for patching

* fixes

* todo

* product

* now reactor returns reactions

* mapping generator fixed.
remap fixed

* optimised.

* reactors docs

* fix

* fix

* fix

* fix

* logging info added

* fixed

* fixed

* patch bug fixed

* options for single reactions added

* include Reactor into docs

* fixes

* fixes
  • Loading branch information
Pandylandy authored and Ramil Nugmanov committed Apr 1, 2019
1 parent 34624b9 commit 143a0f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CGRtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
from .reactor import *


__all__ = ['CGRpreparer', 'CGRreactor']
__all__ = ['CGRpreparer', 'CGRreactor', 'Reactor']
14 changes: 10 additions & 4 deletions CGRtools/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,20 @@ def __init__(self, template, delete_atoms=False):
self.__reactor = CGRreactor(template, delete_atoms)
self.__patterns = [QueryContainer(r) for r in reactants]

def __call__(self, structures, limit=0, skip_intersection=True):
def __call__(self, structures, limit=1, skip_intersection=True):
if any(not isinstance(structure, MoleculeContainer) for structure in structures):
raise TypeError('only list of Molecules possible')
if self.__single:
patch = self.__reactor(structures[0])
patch = self.__reactor(structures[0], limit, skip_intersection)
if limit == 1 and patch:
if self.__split:
return ReactionContainer(reactants=structures, products=patch.split())
return ReactionContainer(reactants=structures, products=[patch])
if self.__split:
return ReactionContainer(reactants=structures, products=patch.split())
return ReactionContainer(reactants=structures, products=[patch])
g = (ReactionContainer(reactants=structures, products=x.split()) for x in patch)
else:
g = (ReactionContainer(reactants=structures, products=[x]) for x in patch)
return list(g) if limit > 1 else g
else:
structures = self.__remap(structures)
mapping = self.__get_mapping(structures)
Expand Down

0 comments on commit 143a0f1

Please sign in to comment.