Пример #1
0
    def testSulfurConstraint(self):
        """
        Test that we can constrain the max number of sulfur atoms.
        """
        mol1 = Molecule(SMILES='CS')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='SCS')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #2
0
    def testCarbonConstraint(self):
        """
        Test that we can constrain the max number of carbon atoms.
        """
        mol1 = Molecule(SMILES='CC')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCC')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #3
0
    def testCarbonConstraint(self):
        """
        Test that we can constrain the max number of carbon atoms.
        """
        mol1 = Molecule(SMILES='CC')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCC')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #4
0
    def testSiliconConstraint(self):
        """
        Test that we can constrain the max number of silicon atoms.
        """
        mol1 = Molecule(SMILES='[SiH4]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[SiH3][SiH3]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #5
0
    def testRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons.
        """
        mol1 = Molecule(SMILES='[CH2][CH2]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[CH2][CH][CH2]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #6
0
    def testHeavyConstraint(self):
        """
        Test that we can constrain the max number of heavy atoms.
        """
        mol1 = Molecule(SMILES='CCO')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCN=O')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #7
0
    def testHeavyConstraint(self):
        """
        Test that we can constrain the max number of heavy atoms.
        """
        mol1 = Molecule(SMILES='CCO')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCN=O')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #8
0
    def testRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons.
        """
        mol1 = Molecule(SMILES='[CH2][CH2]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[CH2][CH][CH2]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #9
0
    def testSulfurConstraint(self):
        """
        Test that we can constrain the max number of sulfur atoms.
        """
        mol1 = Molecule(SMILES='CS')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='SCS')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #10
0
    def testSiliconConstraint(self):
        """
        Test that we can constrain the max number of silicon atoms.
        """
        mol1 = Molecule(SMILES='[SiH4]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[SiH3][SiH3]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #11
0
    def testNitrogenConstraint(self):
        """
        Test that we can constrain the max number of nitrogen atoms.
        """
        mol1 = Molecule(SMILES='CN')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='NCN')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #12
0
    def testNitrogenConstraint(self):
        """
        Test that we can constrain the max number of nitrogen atoms.
        """
        mol1 = Molecule(SMILES='CN')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='NCN')
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #13
0
    def testExplicitlyAllowedMolecules(self):
        """
        Test that we can explicitly allow molecules in species constraints.
        """
        mol = Molecule(SMILES='CCCC')
        self.assertTrue(failsSpeciesConstraints(mol))

        self.rmg.speciesConstraints['explicitlyAllowedMolecules'] = [Molecule(SMILES='CCCC')]
        self.assertFalse(failsSpeciesConstraints(mol))
Пример #14
0
    def testExplicitlyAllowedMolecules(self):
        """
        Test that we can explicitly allow molecules in species constraints.
        """
        mol = Molecule(SMILES='CCCC')
        self.assertTrue(failsSpeciesConstraints(mol))

        self.rmg.speciesConstraints['explicitlyAllowedMolecules'] = [
            Molecule(SMILES='CCCC')
        ]
        self.assertFalse(failsSpeciesConstraints(mol))
Пример #15
0
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
Пример #16
0
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
Пример #17
0
    def testCarbeneConstraint(self):
        """
        Test that we can constrain the max number of singlet carbenes.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u0 p1 c0 {1,S} {4,S}
4 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #18
0
    def testCarbeneConstraint(self):
        """
        Test that we can constrain the max number of singlet carbenes.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u0 p1 c0 {1,S} {4,S}
4 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #19
0
    def testCarbeneRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons with a carbene.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u1 p0 c0 {1,S} {4,S} {5,S}
4 H u0 p0 c0 {3,S}
5 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #20
0
    def testCarbeneRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons with a carbene.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u1 p0 c0 {1,S} {4,S} {5,S}
4 H u0 p0 c0 {3,S}
5 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #21
0
    def testIsotopeConstraint(self):
        """
        Test that we can constrain the max number of isotopic atoms.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 H u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 D u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #22
0
    def testIsotopeConstraint(self):
        """
        Test that we can constrain the max number of isotopic atoms.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 H u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 D u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Пример #23
0
    def testConstraintsNotLoaded(self, mock_logging):
        """
        Test what happens when constraints are not loaded.
        """
        # Reset module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = None

        mol = Molecule(SMILES='C')

        self.assertFalse(failsSpeciesConstraints(mol))

        mock_logging.debug.assert_called_with('Species constraints could not be found.')

        # Restore module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = self.rmg
Пример #24
0
    def testConstraintsNotLoaded(self, mock_logging):
        """
        Test what happens when constraints are not loaded.
        """
        # Reset module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = None

        mol = Molecule(SMILES='C')

        self.assertFalse(failsSpeciesConstraints(mol))

        mock_logging.debug.assert_called_with(
            'Species constraints could not be found.')

        # Restore module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = self.rmg