Skip to content

Commit

Permalink
Fixes error with several ring double bonds (duartegroup#87)
Browse files Browse the repository at this point in the history
* Add fix for ring building

* Correct typo in ReactionFormationFalied 

* Add tests
  • Loading branch information
t-young31 authored Oct 27, 2021
1 parent ec957fa commit 545583f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion autode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- Merge when tests pass
"""

__version__ = '1.1.1'
__version__ = '1.1.2'


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion autode/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class XYZfileWrongFormat(Exception):
pass


class ReactionFormationFalied(Exception):
class ReactionFormationFailed(Exception):
pass


Expand Down
6 changes: 3 additions & 3 deletions autode/reactions/reaction_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from autode.exceptions import ReactionFormationFalied
from autode.exceptions import ReactionFormationFailed
from autode.log import logger


Expand Down Expand Up @@ -43,11 +43,11 @@ def classify(reactants, products):

elif len(reactants) == 0:
logger.critical('Reaction had no reactants – cannot form a reaction')
raise ReactionFormationFalied
raise ReactionFormationFailed

elif len(products) == 0:
logger.critical('Reaction had no products – cannot form a reaction')
raise ReactionFormationFalied
raise ReactionFormationFailed

else:
logger.critical('Unsupported reaction type')
Expand Down
2 changes: 1 addition & 1 deletion autode/smiles/atom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def reset_onto(self, points, coord):
# Take a copy of the template coordinates to rotate and delete
site_coords = np.copy(self.template_site_coords)

if len(site_coords) == len(points):
if len(site_coords) == len(points) or len(points) == 0:
logger.info('No reset needed - sites were all occupied')
return

Expand Down
18 changes: 18 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Changelog
=========

1.1.2
--------
----------

Bugfixes

Usability improvements/Changes
******************************
- Fixes typo in :code:`autode.exceptions.ReactionFormationFalied`

Bug Fixes
*********

- Fixes a bug where rings containing mostly double bonds failed to build with :code:`autode.smiles.builder.Builder`
- Fixes using XTB as a high-level method with the xtb-gaussian wrapper (thanks @kjelljorner)



1.1.1
--------
----------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
extra_link_args=["-std=c++11"])]

setup(name='autode',
version='1.1.1',
version='1.1.2',
packages=['autode',
'autode.conformers',
'autode.pes',
Expand Down
15 changes: 12 additions & 3 deletions tests/test_reactions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from autode.reactions.reaction_types import classify
from autode.exceptions import ReactionFormationFalied
from autode.reactions.reaction_types import classify, Addition
from autode.exceptions import ReactionFormationFailed
import pytest


Expand All @@ -23,11 +23,20 @@ def test_classify():
assert rearrangement.name == 'rearrangement'

# Needs to have at least some reactants and products
with pytest.raises(ReactionFormationFalied):
with pytest.raises(ReactionFormationFailed):
_ = classify([], [])

with pytest.raises(ReactionFormationFailed):
_ = classify([0], [])

with pytest.raises(ReactionFormationFailed):
_ = classify([], [0])

# 3 -> 3 reactions are not currently supported
with pytest.raises(NotImplementedError):
_ = classify([0, 1, 2], [3, 4, 5])


def test_equality():

assert Addition == Addition
6 changes: 6 additions & 0 deletions tests/test_smiles_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,9 @@ def test_cis_dihedral_force():

# Distance between the end carbons needs to be smaller than the trans
assert 2.0 < builder.distance(0, 3) < 3.1


def test_many_ring_double_bonds():

assert built_molecule_is_reasonable(smiles=r'C1=C\N=C/C=N\C=C/C/1')
assert built_molecule_is_reasonable(smiles=r'C1=CC=C/N=N\C=C1')

0 comments on commit 545583f

Please sign in to comment.