def test_classify(): # Can do this with integers are in classify there is no check on their # contents, only their length addition = classify([0, 0], [0]) assert addition.name == 'addition' dissociation = classify([0], [0, 0]) assert dissociation.name == 'dissociation' substitution = classify([0, 0], [0, 0]) assert substitution.name == 'substitution' elimination = classify([0, 0], [0, 0, 0]) assert elimination.name == 'elimination' rearrangement = classify([0], [0]) assert rearrangement.name == 'rearrangement' # Needs to have at least some reactants and products with pytest.raises(ReactionFormationFalied): _ = classify([], []) _ = classify([0], []) _ = classify([], [0]) # 3 -> 3 reactions are not currently supported with pytest.raises(NotImplementedError): _ = classify([0, 1, 2], [3, 4, 5])
def __init__(self, *args, name='reaction', solvent_name=None, smiles=None, temp=298.15): """ Reaction containing reactants and products. reaction.reactant is the reactant complex which is the same as reacs[0] if there is only reactant Arguments: args (autode.species.Molecule) or (str): Reactant and Product objects or a SMILES string of the whole reaction name (str): solvent_name (str): smiles (str): temp (float): Temperature in Kelvin """ logger.info(f'Generating a Reaction object for {name}') self.name = name self.reacs = [mol for mol in args if isinstance(mol, Reactant)] self.prods = [mol for mol in args if isinstance(mol, Product)] # If there is only one string argument assume it's a SMILES if len(args) == 1 and type(args[0]) is str: smiles = args[0] if smiles is not None: self._init_from_smiles(smiles) self.reactant, self.product = None, None self.ts, self.tss = None, None self.type = reaction_types.classify(self.reacs, self.prods) self.solvent = get_solvent(solvent_name=solvent_name) self.temp = float(temp) self._check_solvent() self._check_balance()
def test_classify(): # Can do this with integers are in classify there is no check on their # contents, only their length addition = classify([0, 0], [0]) assert addition.name == 'addition' dissociation = classify([0], [0, 0]) assert dissociation.name == 'dissociation' substitution = classify([0, 0], [0, 0]) assert substitution.name == 'substitution' elimination = classify([0, 0], [0, 0, 0]) assert elimination.name == 'elimination' rearrangement = classify([0], [0]) assert rearrangement.name == 'rearrangement' with pytest.raises(ReactionFormationFalied): classify([], [])