Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lpratalimaffei committed Dec 27, 2024
1 parent ac8ada2 commit fba5174
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions automol/graph/_3super_func_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def assign_grps(self, gra):
# assign base groups
for key, fct in BASE_GRP_DCT.items():
self.sup_grps[key] = self.grp_fct_dct[fct]
base_grps_0 = list(itertools.chain(*[grp for grp in self.sup_grps.values() if len(grp) > 0]))
base_grps_0 = list(itertools.chain(*[
grp for grp in self.sup_grps.values() if len(grp) > 0]))
# assign substituents
subs_fct_dct = {}
for key, fct in SUBSTITUENTS_GRP_DCT.items():
Expand All @@ -135,13 +136,16 @@ def assign_grps(self, gra):

# if the atoms of the substituent are part of (any) base group: skip
for grp in sub_grps:
if not any(all(atm in basei for atm in grp if atm in heavy_atms) for basei in base_grps_0):
if not any(all(
atm in basei for atm in grp if atm in heavy_atms)
for basei in base_grps_0):
sub_grps_eff += (grp,)
# intersection base+sub becomes the new base_grps;
# filter by bond type, e.g., C-C, C-O..
# with bonded_grps only: fails for OCH3
# (CH2-O bonded to an aromatic would work too)
base_grps = bonded_grps_checksymb(gra, base_grps, sub_grps_eff, "C", sub[0])
base_grps = bonded_grps_checksymb(
gra, base_grps, sub_grps_eff, "C", sub[0])
# add to dct
self.sup_grps[comp_grp] = base_grps

Expand Down Expand Up @@ -197,14 +201,15 @@ def bonded_grps_checksymb(gra, grps1, grps2, symb1, symb2):
grp2 = tuple(
atm for atm in grp2 if atm in heavy_atms and atm not in grp1
)
possible_bonds = list(itertools.product(grp1, grp2)) + list(itertools.product(grp2, grp1))
possible_bonds = list(itertools.product(grp1, grp2))
possible_bonds += list(itertools.product(grp2, grp1))
effective_bonds = list(
bond for bond in possible_bonds if frozenset(bond) in gra[1].keys()
)
if len(tuple(set(effective_bonds).intersection(correct_bonds))) > 0:
grp = grp1 + grp2
if sorted(grp) not in [sorted(grpi) for grpi in grps] and grp2 not in assigned_grps2:
if (sorted(grp) not in [sorted(grpi) for grpi in grps]
and grp2 not in assigned_grps2):
grps += (grp,)
assigned_grps2 += (grp2,)

return grps
return grps

0 comments on commit fba5174

Please sign in to comment.