Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
8a85b0e
Use `rdkit` for SSSR and RCs (bug fix + Python upgrade)
JacksonBurns May 25, 2025
ac8e2ac
relax version constraint in setup
JacksonBurns May 25, 2025
7a77d41
move ring functions from graph to molecule
jonwzheng Jul 7, 2025
0d8bf57
update unit tests
jonwzheng Jul 7, 2025
457b9bb
move all functions that previously called get_relevant_cycles or get_…
jonwzheng Jul 7, 2025
920c38d
update cython definition for graph
jonwzheng Jul 7, 2025
612ac4b
update molecule cython file with new functions
jonwzheng Jul 7, 2025
1fb79d5
update molecule to make an Atom list rather than indices
jonwzheng Jul 7, 2025
c392a05
try remove_h in get_relevant_cycles
jonwzheng Jul 8, 2025
c9e08cc
call GetSymmSSSR on RDKit Mol object rather than Molecule
jonwzheng Jul 16, 2025
0a74ca5
Adjust ring matching logic to avoid SSSR on Graph
jonwzheng Jul 16, 2025
d0ed78b
add checks if species is electron
jonwzheng Jul 16, 2025
9a08a57
remove some tests that appear backwards-incompatible with new RDKit a…
jonwzheng Jul 16, 2025
97ab22a
get sample molecule instead of group for SSSR
jonwzheng Jul 17, 2025
dbd5414
add vdW bond support for RDKit molecules
jonwzheng Jul 17, 2025
d39b37e
remove RDKit mol sanitization
jonwzheng Jul 17, 2025
2360153
move test_get_largest_ring from Graph to Molecule
jonwzheng Jul 17, 2025
9762e79
add electron check for loading from adj list
jonwzheng Jul 17, 2025
1f9a331
try save order for ring perception
jonwzheng Jul 17, 2025
cd2edc9
try preserve atom order for ring perception
jonwzheng Jul 18, 2025
3a39487
only partially sanitize RDKit molecules
jonwzheng Jul 18, 2025
7b56dfe
make test_make_sample_molecule test logic more clear
jonwzheng Jul 18, 2025
582d4ff
remove erroneously malformed sanitize arg
jonwzheng Jul 18, 2025
96a6047
Revert "remove some tests that appear backwards-incompatible with new…
jonwzheng Jul 18, 2025
005f320
add support for RDKit fragment atom w/ dummy molecule
jonwzheng Jul 22, 2025
f220727
fix pesky type error in rdkit mol creation due to type cython coercion
jonwzheng Jul 22, 2025
a70dbf4
update test_get_largest_ring
jonwzheng Jul 23, 2025
def4cc1
fix error in test_Get_all_polycyclic_vertices
jonwzheng Jul 23, 2025
df4c905
make rdkit parsing more lenient with weird bond orders
jonwzheng Jul 23, 2025
eff09eb
Modify sanitization to accommodate kekulization
jonwzheng Jul 24, 2025
f3f8f48
update scipy simps to sipmson
jonwzheng Jul 24, 2025
cd29569
remove python3.12 from CI for now
jonwzheng Jul 24, 2025
49e6439
make QM molecule partial sanitized with RDKit
jonwzheng Jul 24, 2025
b560569
update setup.py to also exclude python 3.12
jonwzheng Jul 24, 2025
1bbe6ae
added a test for drawing bidentates with charge separation
kirkbadger18 Jul 24, 2025
f46967c
Make rdkit default for draw coordinate generation
jonwzheng Jul 25, 2025
cd0b287
add ion test cases to drawTest
jonwzheng Jul 25, 2025
c178b95
remove pyrdl from conda recipe as well
JacksonBurns Aug 4, 2025
2ce4c49
add more python versions to conda build
JacksonBurns Aug 4, 2025
f9643b6
Make fragment code compatible with RDKit changes
jonwzheng Aug 4, 2025
ded1ca8
Fix fragment error due to non-default return type
jonwzheng Aug 4, 2025
7eb0510
add missing remove_h=False required flag to fragment to_rdkit_mol calls
jonwzheng Aug 4, 2025
d6b6fb0
fix test_to_rdkit_mol because default args were changed
jonwzheng Aug 4, 2025
8363fbd
update test expectted return type
JacksonBurns Aug 5, 2025
3b17aed
Revert "update test expectted return type"
JacksonBurns Aug 5, 2025
612e2a8
set default
JacksonBurns Aug 5, 2025
13f7c89
Double-check SSSR to_rdkit_mol for fragment compat
jonwzheng Aug 5, 2025
f4048a7
Change debug level of RDKit-related warnings
jonwzheng Aug 26, 2025
222f0ed
Fix ring unit test that was testing nothing.
rwest Oct 8, 2025
cbbe331
Add a unit test for identify_ring_membership for a big ring.
rwest Oct 8, 2025
5d4db45
Rewrite identfy_ring_membership() to use FastFindRings
rwest Oct 9, 2025
0bdc941
More extensive testing for test_ring_perception
rwest Oct 9, 2025
842c072
Fix error in fragment exception handling.
rwest Oct 9, 2025
167a53c
Replace identify_ring_membership algorithm with existing is_vertex_in…
rwest Oct 9, 2025
f816436
Renamed get_symmetrized_smallest_set_of_smallest_rings and related me…
rwest Oct 9, 2025
4360a52
Temporary: add deprecation warnings and re-enable ring methods.
rwest Oct 9, 2025
2e290b0
Revert "Temporary: add deprecation warnings and re-enable ring methods."
rwest Oct 9, 2025
55cb7df
Use get_symmetrized_smallest_set_of_smallest_rings in many places.
rwest Oct 10, 2025
abb83bf
Create unit test for get_symmetrized_smallest_set_of_smallest_rings()
rwest Oct 10, 2025
7351d9c
Use get_symmetrized_smallest_set_of_smallest_rings in more places.
rwest Oct 10, 2025
7c56cc6
Change get_relevant_cycles test, now that it has been removed.
rwest Oct 10, 2025
c3e5912
Using get_symmetrized_smallest_set_of_smallest_rings in more places.
rwest Oct 11, 2025
48175e9
Delete test_cycle_list_order_relevant_cycles test.
rwest Oct 11, 2025
daacfec
Fix sanitization issue in to_rdkit_mol
rwest Oct 11, 2025
86e1a39
Make detect_cutting_label a static method.
rwest Oct 11, 2025
824da40
Change to_rdkit_mol bond handling. Add ignore_bond_order option.
rwest Oct 11, 2025
1776c3c
When doing ring detection, don't pass bond orders to RDKit.
rwest Oct 11, 2025
1b9d31c
Revert "Change debug level of RDKit-related warnings"
rwest Oct 11, 2025
328c0ec
Possible simplification of to_rdkit_mol for cutting labels.
rwest Oct 11, 2025
92740de
Simplify and optimize cutting label lookup in to_rdkit_mol.
rwest Oct 11, 2025
ff9506b
Fragment.to_rdkit_mol now respects some kwargs instead of printing wa…
rwest Oct 12, 2025
135fd1c
Ring finding code doesn't need to cope with unwanted mappings from to…
rwest Oct 12, 2025
8715ef1
Tweak to MoleculeDrawer: don't bother making a Geometry object.
rwest Oct 12, 2025
043e78e
use sssr instead of symmsssr
JacksonBurns Dec 11, 2025
93bdede
disable build isolation for compat with py 3.10 and 3.11
JacksonBurns Dec 11, 2025
8c87e83
explicitly disable build isolation
JacksonBurns Dec 11, 2025
3cc4470
upper bound python version
JacksonBurns Dec 11, 2025
ae3c879
the `mac0s-13` runner no longer exists
JacksonBurns Dec 11, 2025
880f89a
refactor to use getsssr, see extended
JacksonBurns Dec 12, 2025
7b4c616
update header
JacksonBurns Dec 12, 2025
cb3229c
reminder to self: engage brain before adding attributes
JacksonBurns Dec 12, 2025
3f679bb
change attr setting
JacksonBurns Dec 12, 2025
7681c5f
update header for cache so attribute is allocated
JacksonBurns Dec 12, 2025
d682217
fix pytest syntax
JacksonBurns Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ requirements:
- conda-forge::gprof2dot
- conda-forge::numdifftools
- conda-forge::quantities !=0.16.0,!=0.16.1
- conda-forge::ringdecomposerlib-python
- rmg::pydas >=1.0.3
- rmg::pydqed >=1.0.3
- rmg::symmetry
Expand Down Expand Up @@ -114,7 +113,6 @@ requirements:
- conda-forge::gprof2dot
- conda-forge::numdifftools
- conda-forge::quantities !=0.16.0,!=0.16.1
- conda-forge::ringdecomposerlib-python
- rmg::pydas >=1.0.3
- rmg::pydqed >=1.0.3
- rmg::symmetry
Expand Down Expand Up @@ -165,7 +163,6 @@ test:
- conda-forge::gprof2dot
- conda-forge::numdifftools
- conda-forge::quantities !=0.16.0,!=0.16.1
- conda-forge::ringdecomposerlib-python
- rmg::pydas >=1.0.3
- rmg::pydqed >=1.0.3
- rmg::symmetry
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
os: [macos-13, macos-latest, ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
os: [macos-latest, ubuntu-latest]
include-rms: ["", "with RMS"]
exclude:
- os: macos-13 # GitHub's runners just aren't up to the task of installing Julia
include-rms: 'with RMS'
runs-on: ${{ matrix.os }}
name: Python ${{ matrix.python-version }} ${{ matrix.os }} Build and Test ${{ matrix.include-rms }}
# skip scheduled runs from forks
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/conda_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-latest]
os: [ubuntu-latest, macos-latest]
numpy-version: ["1.26"]
python-version: ["3.9"]
python-version: ["3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.os }} Python ${{ matrix.python-version }} Numpy ${{ matrix.numpy-version }}
defaults:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clean-solver:

install:
@ python utilities.py check-pydas
python -m pip install -vv -e .
python -m pip install --no-build-isolation -vv -e .

q2dtor:
@ echo -e "\nInstalling Q2DTor...\n"
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies:
- conda-forge::rdkit >=2022.09.1

# Python tools
- conda-forge::python >=3.9 # leave as GEQ so that GitHub actions can add EQ w/o breaking (contradictory deps)
- conda-forge::python >=3.9,<3.12 # leave as GEQ so that GitHub actions can add EQ w/o breaking (contradictory deps)
- conda-forge::setuptools <80
- conda-forge::coverage
- conda-forge::cython >=0.25.2,<3.1
Expand All @@ -84,7 +84,6 @@ dependencies:
# bug in quantities, see:
# https://github.com/ReactionMechanismGenerator/RMG-Py/pull/2694#issuecomment-2489286263
- conda-forge::quantities !=0.16.0,!=0.16.1
- conda-forge::ringdecomposerlib-python

# packages we maintain
- rmg::pydas >=1.0.3
Expand Down
6 changes: 3 additions & 3 deletions rmgpy/data/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def is_ring_partial_matched(ring, matched_group):
else:
submol_ring, _ = convert_ring_to_sub_molecule(ring)
sssr = submol_ring.get_smallest_set_of_smallest_rings()
sssr_grp = matched_group.get_smallest_set_of_smallest_rings()
sssr_grp = matched_group.make_sample_molecule().get_smallest_set_of_smallest_rings()
if sorted([len(sr) for sr in sssr]) == sorted([len(sr_grp) for sr_grp in sssr_grp]):
return False
else:
Expand All @@ -483,7 +483,7 @@ def bicyclic_decomposition_for_polyring(polyring):
"""

submol, _ = convert_ring_to_sub_molecule(polyring)
sssr = submol.get_deterministic_sssr()
sssr = submol.get_smallest_set_of_smallest_rings()

ring_pair_with_common_atoms_list = []
ring_occurances_dict = {}
Expand Down Expand Up @@ -555,7 +555,7 @@ def split_bicyclic_into_single_rings(bicyclic_submol):
Splits a given bicyclic submolecule into two individual single
ring submolecules (a list of `Molecule`s ).
"""
sssr = bicyclic_submol.get_deterministic_sssr()
sssr = bicyclic_submol.get_smallest_set_of_smallest_rings()

return [convert_ring_to_sub_molecule(sssr[0])[0],
convert_ring_to_sub_molecule(sssr[1])[0]]
Expand Down
2 changes: 1 addition & 1 deletion rmgpy/molecule/adjlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def to_adjacency_list(atoms, multiplicity, metal='', facet='', label=None, group
# numbers if doesn't work
try:
adjlist += bond.get_order_str()
except ValueError:
except (ValueError, TypeError):
adjlist += str(bond.get_order_num())
adjlist += '}'

Expand Down
2 changes: 1 addition & 1 deletion rmgpy/molecule/converter.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cimport rmgpy.molecule.molecule as mm
cimport rmgpy.molecule.element as elements


cpdef to_rdkit_mol(mm.Molecule mol, bint remove_h=*, bint return_mapping=*, bint sanitize=*, bint save_order=?)
cpdef to_rdkit_mol(mm.Molecule mol, bint remove_h=*, bint return_mapping=*, object sanitize=*, bint save_order=?, bint ignore_bond_orders=?)

cpdef mm.Molecule from_rdkit_mol(mm.Molecule mol, object rdkitmol, bint raise_atomtype_exception=?)

Expand Down
69 changes: 42 additions & 27 deletions rmgpy/molecule/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import cython
# Assume that rdkit is installed
from rdkit import Chem
from rdkit.Chem.rdchem import KekulizeException, AtomKekulizeException
# Test if openbabel is installed
try:
from openbabel import openbabel
Expand All @@ -49,55 +50,61 @@
from rmgpy.exceptions import DependencyError


def to_rdkit_mol(mol, remove_h=True, return_mapping=False, sanitize=True, save_order=False):
def to_rdkit_mol(mol, remove_h=True, return_mapping=False, sanitize=True,
save_order=False, ignore_bond_orders=False):
"""
Convert a molecular structure to a RDKit rdmol object. Uses
`RDKit <https://rdkit.org/>`_ to perform the conversion.
Perceives aromaticity and, unless remove_h==False, removes Hydrogen atoms.

If return_mapping==True then it also returns a dictionary mapping the
atoms to RDKit's atom indices.

If ignore_bond_orders==True, all bonds are converted to unknown bonds, and
sanitization is skipped. This is helpful when all you want is ring perception,
for example. Must also set sanitize=False.
"""
from rmgpy.molecule.fragment import Fragment
if ignore_bond_orders and sanitize:
raise ValueError("If ignore_bond_orders is True, sanitize must be False")
from rmgpy.molecule.fragment import Fragment, CuttingLabel
# Sort the atoms before converting to ensure output is consistent
# between different runs
if not save_order:
mol.sort_atoms()
atoms = mol.vertices
rd_atom_indices = {} # dictionary of RDKit atom indices
label_dict = {} # store label of atom for Framgent
label_dict = {} # For fragment cutting labels. Key is rdkit atom index, value is label string
rdkitmol = Chem.rdchem.EditableMol(Chem.rdchem.Mol())
for index, atom in enumerate(mol.vertices):
if atom.element.symbol == 'X':
rd_atom = Chem.rdchem.Atom('Pt') # not sure how to do this with linear scaling when this might not be Pt
elif atom.element.symbol in ['R', 'L']:
rd_atom = Chem.rdchem.Atom(0)
else:
rd_atom = Chem.rdchem.Atom(atom.element.symbol)
if atom.element.isotope != -1:
rd_atom.SetIsotope(atom.element.isotope)
rd_atom.SetNumRadicalElectrons(atom.radical_electrons)
rd_atom.SetFormalCharge(atom.charge)
if atom.element.symbol == 'C' and atom.lone_pairs == 1 and mol.multiplicity == 1: rd_atom.SetNumRadicalElectrons(
2)
if atom.element.symbol == 'C' and atom.lone_pairs == 1 and mol.multiplicity == 1:
rd_atom.SetNumRadicalElectrons(2)
rdkitmol.AddAtom(rd_atom)
if remove_h and atom.symbol == 'H':
pass
else:
rd_atom_indices[atom] = index

# Check if a cutting label is present. If preserve this so that it is added to the SMILES string
# Fragment's representative species is Molecule (with CuttingLabel replaced by Si but label as CuttingLabel)
# so we use detect_cutting_label to check atom.label
_, cutting_label_list = Fragment().detect_cutting_label(atom.label)
if cutting_label_list != []:
saved_index = index
label = atom.label
if label in label_dict:
label_dict[label].append(saved_index)
else:
label_dict[label] = [saved_index]
# Save cutting labels to add to the SMILES string
if atom.label and atom.label in ('R', 'L'):
label_dict[index] = atom.label

rd_bonds = Chem.rdchem.BondType
orders = {'S': rd_bonds.SINGLE, 'D': rd_bonds.DOUBLE, 'T': rd_bonds.TRIPLE, 'B': rd_bonds.AROMATIC,
'Q': rd_bonds.QUADRUPLE}
# no vdW bond in RDKit, so "ZERO" or "OTHER" might be OK
orders = {'S': rd_bonds.SINGLE, 'D': rd_bonds.DOUBLE,
'T': rd_bonds.TRIPLE, 'B': rd_bonds.AROMATIC,
'Q': rd_bonds.QUADRUPLE, 'vdW': rd_bonds.ZERO,
'H': rd_bonds.HYDROGEN, 'R': rd_bonds.UNSPECIFIED,
None: rd_bonds.UNSPECIFIED}
# Add the bonds
for atom1 in mol.vertices:
for atom2, bond in atom1.edges.items():
Expand All @@ -106,23 +113,31 @@ def to_rdkit_mol(mol, remove_h=True, return_mapping=False, sanitize=True, save_o
index1 = atoms.index(atom1)
index2 = atoms.index(atom2)
if index1 < index2:
order_string = bond.get_order_str()
order = orders[order_string]
if ignore_bond_orders:
order = rd_bonds.UNSPECIFIED
else:
order_string = bond.get_order_str()
order = orders[order_string]
rdkitmol.AddBond(index1, index2, order)

# Make editable mol into a mol and rectify the molecule
rdkitmol = rdkitmol.GetMol()
if label_dict:
for label, ind_list in label_dict.items():
for ind in ind_list:
Chem.SetSupplementalSmilesLabel(rdkitmol.GetAtomWithIdx(ind), label)
for index, label in label_dict.items():
Chem.SetSupplementalSmilesLabel(rdkitmol.GetAtomWithIdx(index), label)
for atom in rdkitmol.GetAtoms():
if atom.GetAtomicNum() > 1:
atom.SetNoImplicit(True)
if sanitize:
Chem.SanitizeMol(rdkitmol)
if remove_h:
rdkitmol = Chem.RemoveHs(rdkitmol, sanitize=sanitize)
rdkitmol = Chem.RemoveHs(rdkitmol, sanitize=False) # skip sanitization here, do it later if requested
if sanitize == True:
Chem.SanitizeMol(rdkitmol)
elif sanitize == "partial":
try:
Chem.SanitizeMol(rdkitmol, sanitizeOps=Chem.SANITIZE_ALL ^ Chem.SANITIZE_PROPERTIES)
except (KekulizeException, AtomKekulizeException):
logging.warning("Kekulization failed; sanitizing without Kekulize")
Chem.SanitizeMol(rdkitmol, sanitizeOps=Chem.SANITIZE_ALL ^ Chem.SANITIZE_PROPERTIES ^ Chem.SANITIZE_KEKULIZE)

if return_mapping:
return rdkitmol, rd_atom_indices
return rdkitmol
Expand Down
75 changes: 36 additions & 39 deletions rmgpy/molecule/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def clear(self):
self.surface = None
self.cr = None

def draw(self, molecule, file_format, target=None):
def draw(self, molecule, file_format, target=None, use_rdkit=True):
"""
Draw the given `molecule` using the given image `file_format` - pdf, svg, ps, or
png. If `path` is given, the drawing is saved to that location on disk. The
Expand All @@ -165,6 +165,9 @@ def draw(self, molecule, file_format, target=None):
This function returns the Cairo surface and context used to create the
drawing, as well as a bounding box for the molecule being drawn as the
tuple (`left`, `top`, `width`, `height`).

If `use_rdkit` is True, then the RDKit 2D coordinate generation is used to generate the coordinates.
If `use_rdkit` is False, then the molecule is drawn using our (deprecated) original algorithm.
"""

# The Cairo 2D graphics library (and its Python wrapper) is required for
Expand Down Expand Up @@ -219,13 +222,13 @@ def draw(self, molecule, file_format, target=None):
if molecule.contains_surface_site():
try:
self._connect_surface_sites()
self._generate_coordinates()
self._generate_coordinates(use_rdkit=use_rdkit)
self._disconnect_surface_sites()
except AdsorbateDrawingError as e:
self._disconnect_surface_sites()
self._generate_coordinates(fix_surface_sites=False)
self._generate_coordinates(fix_surface_sites=False, use_rdkit=use_rdkit)
else:
self._generate_coordinates()
self._generate_coordinates(use_rdkit=use_rdkit)
self._replace_bonds(old_bond_dictionary)

# Generate labels to use
Expand Down Expand Up @@ -341,7 +344,7 @@ def _find_ring_groups(self):
if not found:
self.ringSystems.append([cycle])

def _generate_coordinates(self, fix_surface_sites=True):
def _generate_coordinates(self, fix_surface_sites=True, use_rdkit=True):
"""
Generate the 2D coordinates to be used when drawing the current
molecule. The function uses rdKits 2D coordinate generation.
Expand Down Expand Up @@ -372,15 +375,35 @@ def _generate_coordinates(self, fix_surface_sites=True):
self.coordinates[1, :] = [0.5, 0.0]
return self.coordinates

# Decide whether we can use RDKit or have to generate coordinates ourselves
for atom in self.molecule.atoms:
if atom.charge != 0:
use_rdkit = False
break
else: # didn't break
use_rdkit = True
if use_rdkit == True:
# Use RDKit 2D coordinate generation:
# Generate the RDkit molecule from the RDkit molecule, saving mapping
# in order to match the atoms in the rdmol with the atoms in the
# RMG molecule (which is required to extract coordinates).
rdmol, rd_atom_idx = self.molecule.to_rdkit_mol(remove_h=False,
return_mapping=True,
sanitize="partial")

AllChem.Compute2DCoords(rdmol)

# Extract the coordinates from each atom.
rd_conformer = rdmol.GetConformer(0)
for atom in atoms:
index = rd_atom_idx[atom]
point = rd_conformer.GetAtomPosition(index)
coordinates[index, :] = [point.x * 0.6, point.y * 0.6]

# RDKit generates some molecules more vertically than horizontally,
# Especially linear ones. This will reflect any molecule taller than
# it is wide across the line y=x
ranges = np.ptp(coordinates, axis=0)
if ranges[1] > ranges[0]:
temp = np.copy(coordinates)
coordinates[:, 0] = temp[:, 1]
coordinates[:, 1] = temp[:, 0]

if not use_rdkit:
else:
logging.warning("Using deprecated molecule drawing algorithm; undesired behavior may occur. Consider using use_rdkit=True.")
if len(self.cycles) > 0:
# Cyclic molecule
backbone = self._find_cyclic_backbone()
Expand Down Expand Up @@ -438,32 +461,6 @@ def _generate_coordinates(self, fix_surface_sites=True):
# minimize likelihood of overlap
self._generate_neighbor_coordinates(backbone)

else:
# Use RDKit 2D coordinate generation:

# Generate the RDkit molecule from the RDkit molecule, use geometry
# in order to match the atoms in the rdmol with the atoms in the
# RMG molecule (which is required to extract coordinates).
self.geometry = Geometry(None, None, self.molecule, None)

rdmol, rd_atom_idx = self.geometry.rd_build()
AllChem.Compute2DCoords(rdmol)

# Extract the coordinates from each atom.
for atom in atoms:
index = rd_atom_idx[atom]
point = rdmol.GetConformer(0).GetAtomPosition(index)
coordinates[index, :] = [point.x * 0.6, point.y * 0.6]

# RDKit generates some molecules more vertically than horizontally,
# Especially linear ones. This will reflect any molecule taller than
# it is wide across the line y=x
ranges = np.ptp(coordinates, axis=0)
if ranges[1] > ranges[0]:
temp = np.copy(coordinates)
coordinates[:, 0] = temp[:, 1]
coordinates[:, 1] = temp[:, 0]

# For surface species
if fix_surface_sites and self.molecule.contains_surface_site():
if len(self.molecule.atoms) == 1:
Expand Down
2 changes: 1 addition & 1 deletion rmgpy/molecule/filtration.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def aromaticity_filtration(mol_list, features):
# Look for structures that don't have standard SDSDSD bond orders
for mol in other_list:
# Check all 6 membered rings
rings = [ring for ring in mol.get_relevant_cycles() if len(ring) == 6]
rings = [ring for ring in mol.get_smallest_set_of_smallest_rings() if len(ring) == 6]
for ring in rings:
bond_list = mol.get_edges_in_cycle(ring)
bond_orders = ''.join([bond.get_order_str() for bond in bond_list])
Expand Down
Loading
Loading