forked from enviPath/enviPy
[FIX] Fixed Search Output, Legacy API Model Endpoint, Handle ObjectsDoesNotExists in views (#297)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#297
This commit is contained in:
@ -1353,12 +1353,13 @@ class SimpleAmbitRule(SimpleRule):
|
||||
def get_rule_identifier(self) -> str:
|
||||
return "simple-rule"
|
||||
|
||||
def apply(self, smiles):
|
||||
def apply(self, smiles, *args, **kwargs):
|
||||
return FormatConverter.apply(
|
||||
smiles,
|
||||
self.smirks,
|
||||
reactant_filter_smarts=self.reactant_filter_smarts,
|
||||
product_filter_smarts=self.product_filter_smarts,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@property
|
||||
@ -1388,8 +1389,8 @@ class SimpleAmbitRule(SimpleRule):
|
||||
class SimpleRDKitRule(SimpleRule):
|
||||
reaction_smarts = models.TextField(blank=False, null=False, verbose_name="SMIRKS")
|
||||
|
||||
def apply(self, smiles):
|
||||
return FormatConverter.apply(smiles, self.reaction_smarts)
|
||||
def apply(self, smiles, *args, **kwargs):
|
||||
return FormatConverter.apply(smiles, self.reaction_smarts, **kwargs)
|
||||
|
||||
def _url(self):
|
||||
return "{}/simple-rdkit-rule/{}".format(self.package.url, self.uuid)
|
||||
@ -1410,10 +1411,10 @@ class ParallelRule(Rule):
|
||||
def srs(self) -> QuerySet:
|
||||
return self.simple_rules.all()
|
||||
|
||||
def apply(self, structure):
|
||||
def apply(self, structure, *args, **kwargs):
|
||||
res = list()
|
||||
for simple_rule in self.srs:
|
||||
res.extend(simple_rule.apply(structure))
|
||||
res.extend(simple_rule.apply(structure, **kwargs))
|
||||
|
||||
return list(set(res))
|
||||
|
||||
@ -1518,11 +1519,11 @@ class SequentialRule(Rule):
|
||||
def srs(self):
|
||||
return self.simple_rules.all()
|
||||
|
||||
def apply(self, structure):
|
||||
def apply(self, structure, *args, **kwargs):
|
||||
# TODO determine levels or see java implementation
|
||||
res = set()
|
||||
for simple_rule in self.srs:
|
||||
res.union(set(simple_rule.apply(structure)))
|
||||
res.union(set(simple_rule.apply(structure, **kwargs)))
|
||||
return res
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user