Skip to content

Commit

Permalink
Add chemical identity comparison to Molecule
Browse files Browse the repository at this point in the history
  • Loading branch information
mliu49 committed May 9, 2018
1 parent 43f3c1f commit 004f591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rmgpy/molecule/molecule.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ cdef class Molecule(Graph):
cdef str _inchi
cdef str _smiles

cpdef bint is_equal(self, Molecule other)

cpdef bint is_same(self, other)

cpdef addAtom(self, Atom atom)

cpdef addBond(self, Bond bond)
Expand Down
9 changes: 9 additions & 0 deletions rmgpy/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,15 @@ def is_equal(self,other):
else:
return self.isIsomorphic(other)

def is_same(self, other):
"""
Chemical identity comparison via InChI strings.
"""
if self.multiplicity == other.multiplicity and self.InChI == other.InChI:
return True
else:
return False

def __str__(self):
"""
Return a human-readable string representation of the object.
Expand Down

0 comments on commit 004f591

Please sign in to comment.