def process(self, conformer): bt = conformer.bond_topologies[0] geom = conformer.optimized_geometry bonded = utilities.bonded(bt) natoms = len(bt.atoms) for a1 in range(0, natoms): atomic_number1 = smu_utils_lib.ATOM_TYPE_TO_ATOMIC_NUMBER[ bt.atoms[a1]] for a2 in range(a1 + 1, natoms): atomic_number2 = smu_utils_lib.ATOM_TYPE_TO_ATOMIC_NUMBER[ bt.atoms[a2]] # Do not process H-H pairs if atomic_number1 == 1 and atomic_number2 == 1: continue d = utilities.distance_between_atoms(geom, a1, a2) if d > MAX_DIST: continue discretized = int(d * utilities.DISTANCE_BINS) yield (min(atomic_number1, atomic_number2), int(bonded[a1, a2]), max(atomic_number1, atomic_number2), discretized), 1
def process(self, molecule): bt = molecule.bond_topologies[0] geom = molecule.optimized_geometry bonded = utilities.bonded(bt) natoms = len(bt.atoms) if molecule.properties.errors.fate != dataset_pb2.Properties.FATE_SUCCESS: return for a1 in range(0, natoms): atomic_number1 = smu_utils_lib.ATOM_TYPE_TO_ATOMIC_NUMBER[ bt.atoms[a1]] for a2 in range(a1 + 1, natoms): atomic_number2 = smu_utils_lib.ATOM_TYPE_TO_ATOMIC_NUMBER[ bt.atoms[a2]] # Do not process H-H pairs if atomic_number1 == 1 and atomic_number2 == 1: continue d = utilities.distance_between_atoms(geom, a1, a2) if d > MAX_DIST: continue discretized = int(d * utilities.DISTANCE_BINS) yield (min(atomic_number1, atomic_number2), int(bonded[a1, a2]), max(atomic_number1, atomic_number2), discretized), 1
def test_unit_z(self): coords = zero2() coords.atom_positions[1].z = 1.0 / smu_utils_lib.BOHR_TO_ANGSTROMS self.assertAlmostEqual(utilities.distance_between_atoms(coords, 0, 1), 1.0)
def test_zero_distance(self): coords = zero2() self.assertEqual(utilities.distance_between_atoms(coords, 0, 1), 0.0)