Esempio n. 1
0
 def testFromOldAdjacencyList1(self):
     """
     Test we can read an old style adjacency list with implicit hydrogens 1
     """
     adjList = """
     1 O 0 
     """  # should be Water
     molecule = Molecule().fromAdjacencyList(adjList)  
     self.assertEqual(molecule.getFormula(), 'H2O')
Esempio n. 2
0
 def testFromIntermediateAdjacencyList1(self):
     """
     Test we can read an intermediate style adjacency list with implicit hydrogens 1
     """
     adjList = """
     1 O 0 2
     """  # should be Water
     molecule = Molecule().fromAdjacencyList(adjList, saturateH=True)  
     self.assertEqual(molecule.getFormula(), 'H2O')
Esempio n. 3
0
 def testFromOldAdjacencyList1(self):
     """
     Test we can read an old style adjacency list with implicit hydrogens 1
     """
     adjList = """
     1 O 0 
     """  # should be Water
     molecule = Molecule().fromAdjacencyList(adjList)  
     self.assertEqual(molecule.getFormula(), 'H2O')
Esempio n. 4
0
 def testFromIntermediateAdjacencyList1(self):
     """
     Test we can read an intermediate style adjacency list with implicit hydrogens 1
     """
     adjList = """
     1 O 0 2
     """  # should be Water
     molecule = Molecule().fromAdjacencyList(adjList, saturateH=True)  
     self.assertEqual(molecule.getFormula(), 'H2O')
Esempio n. 5
0
 def testPickle(self):
     """
     Test that a Molecule object can be successfully pickled and
     unpickled with no loss of information.
     """
     molecule0 = Molecule().fromSMILES('C=CC=C[CH2]C')
     molecule0.updateAtomTypes()
     molecule0.updateConnectivityValues()
     import cPickle
     molecule = cPickle.loads(cPickle.dumps(molecule0))
     
     self.assertEqual(len(molecule0.atoms), len(molecule.atoms))
     self.assertEqual(molecule0.getFormula(), molecule.getFormula())
     self.assertTrue(molecule0.isIsomorphic(molecule))
     self.assertTrue(molecule.isIsomorphic(molecule0))
Esempio n. 6
0
    def testPickle(self):
        """
        Test that a Molecule object can be successfully pickled and
        unpickled with no loss of information.
        """
        molecule0 = Molecule().fromSMILES('C=CC=C[CH2]C')
        molecule0.updateAtomTypes()
        molecule0.updateConnectivityValues()
        import cPickle
        molecule = cPickle.loads(cPickle.dumps(molecule0))

        self.assertEqual(len(molecule0.atoms), len(molecule.atoms))
        self.assertEqual(molecule0.getFormula(), molecule.getFormula())
        self.assertTrue(molecule0.isIsomorphic(molecule))
        self.assertTrue(molecule.isIsomorphic(molecule0))