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')
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')
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))