def test_geometry_failed(self): self.conformer.fate = (dataset_pb2.Conformer.FATE_DISCARDED_OTHER) got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 1) self.assertEqual(got[0].count_attempted_conformers, 1) self.assertEqual(got[0].count_failed_geometry_optimization, 1)
def test_calculation_success(self, swap_order): self.conformer.fate = dataset_pb2.Conformer.FATE_SUCCESS self.conformer.bond_topologies.append(self.conformer.bond_topologies[0]) self.conformer.bond_topologies[-1].bond_topology_id = 123 self.conformer.bond_topologies[0].is_starting_topology = True if swap_order: self._swap_bond_topologies() got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 2) # We don't actually care about the order, but this is what comes out right # now. self.assertEqual(got[0].bond_topology.bond_topology_id, 123) self.assertEqual(got[0].count_attempted_conformers, 0) self.assertEqual(got[0].count_kept_geometry, 0) self.assertEqual(got[0].count_calculation_success, 0) self.assertEqual(got[0].count_detected_match_success, 1) self.assertEqual(got[1].bond_topology.bond_topology_id, 618451) self.assertEqual(got[1].count_attempted_conformers, 1) self.assertEqual(got[1].count_kept_geometry, 1) self.assertEqual(got[1].count_calculation_success, 1) self.assertEqual(got[1].count_detected_match_success, 0)
def test_missing_calculation(self): self.conformer.fate = dataset_pb2.Conformer.FATE_NO_CALCULATION_RESULTS got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 1) self.assertEqual(got[0].count_attempted_conformers, 1) self.assertEqual(got[0].count_kept_geometry, 1) self.assertEqual(got[0].count_missing_calculation, 1)
def test_dup_diff(self): self.conformer.fate = ( dataset_pb2.Conformer.FATE_DUPLICATE_DIFFERENT_TOPOLOGY) got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 1) self.assertEqual(got[0].count_attempted_conformers, 1) self.assertEqual(got[0].count_duplicates_different_topology, 1)
def test_dup_same(self): self.conformer.fate = dataset_pb2.Conformer.FATE_DUPLICATE_SAME_TOPOLOGY got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 1) self.assertEqual(got[0].bond_topology.bond_topology_id, self.conformer.bond_topologies[0].bond_topology_id) self.assertEqual(got[0].count_attempted_conformers, 1) self.assertEqual(got[0].count_duplicates_same_topology, 1)
def to_keyed_bond_topology_summary(conformer): """Outputs BondTopologySummary for conformer. Args: conformer: dataset_pb2.Conformer Yields: bond topology id, BondTopologySummary """ for summary in smu_utils_lib.conformer_to_bond_topology_summaries(conformer): yield summary.bond_topology.bond_topology_id, summary
def test_no_starting_topology(self): self.conformer.fate = dataset_pb2.Conformer.FATE_SUCCESS self.conformer.bond_topologies.append(self.conformer.bond_topologies[0]) self.conformer.bond_topologies[-1].bond_topology_id = 123 got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 2) # We don't actually care about the order, but this is what comes out right # now. self.assertEqual(got[0].bond_topology.bond_topology_id, 618451) self.assertEqual(got[0].count_detected_match_success, 1) self.assertEqual(got[1].bond_topology.bond_topology_id, 123) self.assertEqual(got[1].count_detected_match_success, 1)
def test_calculation_with_error(self): self.conformer.fate = dataset_pb2.Conformer.FATE_CALCULATION_WITH_ERROR self.conformer.bond_topologies.append(self.conformer.bond_topologies[0]) self.conformer.bond_topologies[-1].bond_topology_id = 123 got = list( smu_utils_lib.conformer_to_bond_topology_summaries(self.conformer)) self.assertLen(got, 2) # We don't actually care about the order, but this is what comes out right # now. self.assertEqual(got[0].bond_topology.bond_topology_id, 123) self.assertEqual(got[0].count_attempted_conformers, 0) self.assertEqual(got[0].count_kept_geometry, 0) self.assertEqual(got[0].count_calculation_with_error, 0) self.assertEqual(got[0].count_detected_match_with_error, 1) self.assertEqual(got[1].bond_topology.bond_topology_id, self.conformer.bond_topologies[0].bond_topology_id) self.assertEqual(got[1].count_attempted_conformers, 1) self.assertEqual(got[1].count_kept_geometry, 1) self.assertEqual(got[1].count_calculation_with_error, 1) self.assertEqual(got[1].count_detected_match_with_error, 0)