forked from duartegroup/autodE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor exceptions (duartegroup#144)
* Add base exception * Fix typo
- Loading branch information
Showing
11 changed files
with
101 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,125 @@ | ||
class CalculationException(Exception): | ||
pass | ||
class AutodeException(Exception): | ||
"""Base autodE exception""" | ||
|
||
|
||
class AtomsNotFound(CalculationException): | ||
pass | ||
|
||
|
||
class NoAtomsInMolecule(Exception): | ||
pass | ||
|
||
# --------------------- Calculation exceptions -------------------------------- | ||
class CalculationException(AutodeException): | ||
"""Base calculation exception when an external autodE calculation fails""" | ||
|
||
class NoConformers(Exception): | ||
pass | ||
|
||
class AtomsNotFound(CalculationException): | ||
"""Exception for atomic coordinates/identities being found""" | ||
|
||
class FitFailed(Exception): | ||
pass | ||
|
||
class MethodUnavailable(CalculationException): | ||
"""Exception for an autodE wrapped method not being available""" | ||
|
||
class NoInputError(Exception): | ||
pass | ||
|
||
class UnsupportedCalculationInput(CalculationException): | ||
"""Exception for an autodE calculation input not being valid""" | ||
def __init__(self, message='Parameters not supported'): | ||
super().__init__(message) | ||
|
||
class MethodUnavailable(CalculationException): | ||
pass | ||
|
||
class NoInputError(CalculationException): | ||
"""Exception for a autodE calculation having no input e.g atoms""" | ||
|
||
class SolventUnavailable(Exception): | ||
pass | ||
|
||
class NoCalculationOutput(CalculationException): | ||
"""Exception for a calculation file that should exist not existing""" | ||
|
||
class UnbalancedReaction(Exception): | ||
pass | ||
|
||
class CouldNotGetProperty(CalculationException): | ||
"""Exception for where a property e.g. energy cannot be found in a | ||
calculation output file""" | ||
|
||
class UnsuppportedCalculationInput(CalculationException): | ||
def __init__(self, message='Parameters not supported'): | ||
super().__init__(message) | ||
def __init__(self, *args, name=None): | ||
if name is not None: | ||
super().__init__(f'Could not get {name}') | ||
|
||
else: | ||
super().__init__(*args) | ||
|
||
class SolventNotFound(Exception): | ||
pass | ||
|
||
# ----------------------------------------------------------------------------- | ||
class NoAtomsInMolecule(AutodeException): | ||
"""Exception for no atoms existing in a molecule""" | ||
|
||
class SolventsDontMatch(Exception): | ||
pass | ||
|
||
class NoConformers(AutodeException): | ||
"""Exception for no conformers being present in a molecule""" | ||
|
||
class BondsInSMILESAndGraphDontMatch(Exception): | ||
pass | ||
|
||
class SolventUnavailable(AutodeException): | ||
"""Exception for a solvent not being available for a calculation""" | ||
|
||
class XYZfileDidNotExist(Exception): | ||
pass | ||
|
||
class UnbalancedReaction(AutodeException): | ||
"""Exception for an autodE reaction not being balanced in e.g. N_atoms""" | ||
|
||
class XYZfileWrongFormat(Exception): | ||
pass | ||
|
||
class SolventNotFound(AutodeException): | ||
"""Exception for a solvent not being in the list of available solvents""" | ||
|
||
class ReactionFormationFailed(Exception): | ||
pass | ||
|
||
class SolventsDontMatch(AutodeException): | ||
"""Exception for where the solvent in reactants is different to products""" | ||
|
||
class NoClosestSpecies(Exception): | ||
pass | ||
|
||
class BondsInSMILESAndGraphDontMatch(AutodeException): | ||
"""Exception for a partially disjoint set of bonds in SMILES and a graph""" | ||
|
||
class NoMapping(Exception): | ||
pass | ||
|
||
class XYZfileDidNotExist(AutodeException, FileNotFoundError): | ||
"""Exception for an xyz file not existing""" | ||
|
||
class NoNormalModesFound(CalculationException): | ||
pass | ||
|
||
class XYZfileWrongFormat(AutodeException): | ||
"""Exception for an xyz being the wrong format""" | ||
|
||
class NoMolecularGraph(Exception): | ||
pass | ||
|
||
class ReactionFormationFailed(AutodeException): | ||
"""Exception for where a reaction cannot be built. e.g. if there are no | ||
reactants""" | ||
|
||
class NoCalculationOutput(CalculationException): | ||
pass | ||
|
||
class NoMapping(AutodeException): | ||
"""Exception for where there is no mapping/bijection between two graphs""" | ||
|
||
class RDKitFailed(Exception): | ||
pass | ||
|
||
class NoMolecularGraph(AutodeException): | ||
"""Exception for a molecule not having a set graph""" | ||
|
||
class InvalidSmilesString(Exception): | ||
pass | ||
|
||
class RDKitFailed(AutodeException): | ||
"""Exception for where RDKit fails to generate conformers""" | ||
|
||
class SMILESBuildFailed(Exception): | ||
pass | ||
|
||
class InvalidSmilesString(AutodeException): | ||
"""Exception for a SMILES string being invalid""" | ||
|
||
class FailedToSetRotationIdxs(Exception): | ||
pass | ||
|
||
class SMILESBuildFailed(AutodeException): | ||
"""Exception for where building an example 3D structure cannot be built | ||
from a SMILES string""" | ||
|
||
class FailedToAdjustAngles(Exception): | ||
pass | ||
|
||
class FailedToSetRotationIdxs(AutodeException): | ||
"""Exception for the atoms that need to be rotating in 3D building not | ||
being found""" | ||
|
||
class CouldNotGetProperty(CalculationException): | ||
def __init__(self, *args, name=None): | ||
if name is not None: | ||
super().__init__(f'Could not get {name}') | ||
|
||
else: | ||
super().__init__(*args) | ||
class FailedToAdjustAngles(AutodeException): | ||
"""Exception for when the internal angles in a ring cannot be adjusted""" | ||
|
||
|
||
class CannotSplitAcrossBond(Exception): | ||
class CannotSplitAcrossBond(AutodeException): | ||
"""A molecule cannot be partitioned by deleting one bond""" | ||
|
||
|
||
class CouldNotPlotSmoothProfile(Exception): | ||
pass | ||
class CouldNotPlotSmoothProfile(AutodeException): | ||
"""A smooth reaction profile cannot be plotted""" | ||
|
||
|
||
class TemplateLoadingFailed(Exception): | ||
pass | ||
class TemplateLoadingFailed(AutodeException): | ||
"""A template file was not in the correct format""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters