Skip to content

Commit

Permalink
Query update!
Browse files Browse the repository at this point in the history
added not in ring atom mark.
  • Loading branch information
stsouko committed Mar 20, 2021
1 parent c6248b7 commit ec181a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CGRtools/containers/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def _validate_rings(rings):
if rings is None:
rings = ()
elif isinstance(rings, int):
if rings < 3:
raise ValueError('rings should be greater or equal 3')
if rings < 3 and rings != 0:
raise ValueError('rings should be greater or equal 3. ring equal to zero is no ring atom mark')
rings = (rings,)
elif isinstance(rings, (tuple, list)):
if not all(isinstance(n, int) for n in rings):
Expand Down
24 changes: 18 additions & 6 deletions CGRtools/periodictable/element/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ def __eq__(self, other):
return False
if self.hybridization and other.hybridization not in self.hybridization:
return False
if self.ring_sizes and set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
if self.ring_sizes:
if self.ring_sizes[0]:
if set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
elif other.ring_sizes: # not in ring expected
return False
if self.implicit_hydrogens and other.implicit_hydrogens not in self.implicit_hydrogens:
return False
if self.heteroatoms and other.heteroatoms not in self.heteroatoms:
Expand Down Expand Up @@ -287,8 +291,12 @@ def __eq__(self, other):
return False
if self.hybridization and other.hybridization not in self.hybridization:
return False
if self.ring_sizes and set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
if self.ring_sizes:
if self.ring_sizes[0]:
if set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
elif other.ring_sizes: # not in ring expected
return False
if self.implicit_hydrogens and other.implicit_hydrogens not in self.implicit_hydrogens:
return False
if self.heteroatoms and other.heteroatoms not in self.heteroatoms:
Expand Down Expand Up @@ -332,8 +340,12 @@ def __eq__(self, other):
return False
if self.hybridization and other.hybridization not in self.hybridization:
return False
if self.ring_sizes and set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
if self.ring_sizes:
if self.ring_sizes[0]:
if set(self.ring_sizes).isdisjoint(other.ring_sizes):
return False
elif other.ring_sizes: # not in ring expected
return False
if self.implicit_hydrogens and other.implicit_hydrogens not in self.implicit_hydrogens:
return False
if self.heteroatoms and other.heteroatoms not in self.heteroatoms:
Expand Down

0 comments on commit ec181a9

Please sign in to comment.