def testSulfurTypes(self): """ Test that getAtomType() returns appropriate sulfur atom types. """ self.assertEqual(getAtomType(self.mol4.atoms[8], self.mol4.getBonds(self.mol4.atoms[8])).label, 'Ss') self.assertEqual(getAtomType(self.mol4.atoms[9], self.mol4.getBonds(self.mol4.atoms[9])).label, 'Sd')
def testOxygenTypes(self): """ Test that getAtomType() returns appropriate oxygen atom types. """ self.assertEqual(getAtomType(self.mol1.atoms[1], self.mol1.getBonds(self.mol1.atoms[1])).label, 'Os') self.assertEqual(getAtomType(self.mol1.atoms[2], self.mol1.getBonds(self.mol1.atoms[2])).label, 'Od')
def testNoneTypes(self): """ Test that getAtomType() returns appropriate NoneTypes. """ self.assertIsNone(getAtomType(self.mol5.atoms[0], self.mol5.getBonds(self.mol5.atoms[0]))) self.assertIsNone(getAtomType(self.mol6.atoms[0], self.mol6.getBonds(self.mol6.atoms[0]))) self.assertIsNone(getAtomType(self.mol7.atoms[0], self.mol7.getBonds(self.mol7.atoms[0]))) self.assertIsNone(getAtomType(self.mol8.atoms[0], self.mol8.getBonds(self.mol8.atoms[0])))
def testSiliconTypes(self): """ Test that getAtomType() returns appropriate silicon atom types. """ self.assertEqual(getAtomType(self.mol4.atoms[2], self.mol4.getBonds(self.mol4.atoms[2])).label, 'Sis') self.assertEqual(getAtomType(self.mol4.atoms[3], self.mol4.getBonds(self.mol4.atoms[3])).label, 'Sid') self.assertEqual(getAtomType(self.mol4.atoms[4], self.mol4.getBonds(self.mol4.atoms[4])).label, 'Sidd') self.assertEqual(getAtomType(self.mol4.atoms[6], self.mol4.getBonds(self.mol4.atoms[6])).label, 'Sit') self.assertEqual(getAtomType(self.mol4.atoms[1], self.mol4.getBonds(self.mol4.atoms[1])).label, 'SiO')
def atomType(self, mol, atomID): atom = mol.atoms[atomID] type = getAtomType(atom, mol.getBonds(atom)) if type is None: return type else: return type.label
def updateAtomTypes(self, logSpecies=True, raiseException=True): """ Iterate through the atoms in the structure, checking their atom types to ensure they are correct (i.e. accurately describe their local bond environment) and complete (i.e. are as detailed as possible). If `raiseException` is `False`, then the generic atomType 'R' will be prescribed to any atom when getAtomType fails. Currently used for resonance hybrid atom types. """ #Because we use lonepairs to match atomtypes and default is -100 when unspecified, #we should update before getting the atomtype. self.updateLonePairs() for v in self.vertices: if not isinstance(v, Atom): continue try: v.atomType = getAtomType(v, v.edges) except AtomTypeError: if logSpecies: logging.error( "Could not update atomtypes for this fragment:\n{0}". format(self.toAdjacencyList())) if raiseException: raise v.atomType = atomTypes['R']
def testCarbonTypes(self): """ Test that getAtomType() returns appropriate carbon atom types. """ self.assertEqual(getAtomType(self.mol1.atoms[0], self.mol1.getBonds(self.mol1.atoms[0])).label, 'Cs') self.assertEqual(getAtomType(self.mol1.atoms[4], self.mol1.getBonds(self.mol1.atoms[4])).label, 'Cd') self.assertEqual(getAtomType(self.mol1.atoms[5], self.mol1.getBonds(self.mol1.atoms[5])).label, 'Cdd') self.assertEqual(getAtomType(self.mol1.atoms[7], self.mol1.getBonds(self.mol1.atoms[7])).label, 'Ct') self.assertEqual(getAtomType(self.mol1.atoms[3], self.mol1.getBonds(self.mol1.atoms[3])).label, 'CO') self.assertEqual(getAtomType(self.mol2.atoms[0], self.mol2.getBonds(self.mol2.atoms[0])).label, 'Cb')
def testHydrogenType(self): """ Test that getAtomType() returns the hydrogen atom type. """ self.assertEqual(getAtomType(self.mol3.atoms[0], self.mol3.getBonds(self.mol3.atoms[0])).label, 'H')