def atom_type(self, mol, atom_id): atom = mol.atoms[atom_id] atom_type = get_atomtype(atom, mol.get_bonds(atom)) if atom_type is None: return atom_type else: return atom_type.label
def check_partial_charge(atom): """ Checks whether the partial charge attribute of the atom checks out with the theoretical one: """ if atom.symbol == 'X': return # because we can't check it. valence = PeriodicSystem.valence_electrons[atom.symbol] order = atom.get_total_bond_order() theoretical = valence - order - atom.radical_electrons - 2 * atom.lone_pairs if not (-0.301 < atom.charge - theoretical < 0.301): # It should be 0, but -0.1 is caused by a Hydrogen bond raise InvalidAdjacencyListError( 'Invalid valency for atom {symbol} ({type}) with {radicals} unpaired electrons, ' '{lone_pairs} pairs of electrons, {charge} charge, and bonds [{bonds}].' .format(symbol=atom.symbol, type=get_atomtype(atom, atom.edges).label, radicals=atom.radical_electrons, lone_pairs=atom.lone_pairs, charge=atom.charge, bonds=','.join([ str(bond.order) for bond in atom.bonds.values() ])))