Skip to content

Commit

Permalink
Am fixup (#671)
Browse files Browse the repository at this point in the history
Solves issues with intra_substitutionS_cyclization and
halocarbene_recombination. Tests were added as well.
  • Loading branch information
alongd committed Jun 11, 2023
2 parents df3c323 + fb1d4c2 commit 8a2c8e5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arc/mapping/driver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def test_map_abstractions(self):
rxn1 = ARCReaction(r_species=[r_1, r_2], p_species=[p_1, p_2])
rxn1.determine_family(self.rmgdb)
atom_map = rxn1.atom_map
#expected: [0,2,3,4,1,5,[6,7],[6,7],[8,9,10],[8,9,10],[8,9,10],11,12]
#expected: [0, 2, 3, 4, 1, 5, [6, 7], [6, 7], [8, 9, 10], [8, 9, 10], [8, 9, 10], 11, 12]
self.assertEqual(atom_map[:6], [0,2,3,4,1,5])
self.assertIn(atom_map[6],[6,7])
self.assertIn(atom_map[7], [6, 7])
Expand Down
2 changes: 1 addition & 1 deletion arc/mapping/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def r_cut_p_cut_isomorphic(reactant, product):
"""
res1 = generate_resonance_structures(object_=reactant.mol.copy(deep=True), save_order = True)
for res in res1:
if product.mol.is_isomorphic(res, save_order=True):
if res.fingerprint == product.mol.fingerprint or product.mol.is_isomorphic(res, save_order=True):
return True
return False

Expand Down
2 changes: 2 additions & 0 deletions arc/mapping/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ def test_r_cut_p_cut_isomorphic(self):
p_cuts.remove(p_cut)
break
self.assertEqual(len(p_cuts),0)
self.assertTrue(r_cut_p_cut_isomorphic(ARCSpecies(label="r1", smiles="F[C]F", multiplicity=1),
ARCSpecies(label="r1", smiles="F[C]F", multiplicity=3)))

def test_pairing_reactants_and_products_for_mapping(self):
smiles = ["[F]", "C[CH]C", "[CH3]"]
Expand Down
28 changes: 28 additions & 0 deletions arc/reaction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,34 @@ def test_get_atom_map(self):
rxn = ARCReaction(reactants=['SO2(T)'], products=['SO2(S)'], r_species=[r_1], p_species=[p_1])
self.assertEqual(rxn.atom_map[0], 1)
self.assertTrue(check_atom_map(rxn))
# F[C]F + [CH3] <=> F[C](F)C
r1_xyz = {'symbols': ('F', 'C', 'F'),
'isotopes': (19, 12, 19),
'coords': ((-1.304203748543047, 0.3204330512721478, 0.0),
(-1.9140293120972295e-09, -6.455569423898419e-09, 0.0),
(1.304203750457077, -0.32043304481658, 0.0))}
r2_xyz = {'symbols': ('C', 'H', 'H', 'H'),
'isotopes': (12, 1, 1, 1),
'coords': ((3.3746019998564553e-09, 5.828827384106545e-09, -4.859105107686622e-09),
(1.0669051052331406, -0.17519582095514982, 0.05416492980439295),
(-0.6853171627400634, -0.8375353626879753, -0.028085652887100996),
(-0.3815879458676787, 1.0127311778142964, -0.026079272058187608))}
p1_xyz = {'symbols': ('F', 'C', 'F', 'C', 'H', 'H', 'H'),
'isotopes': (19, 12, 19, 12, 1, 1, 1),
'coords': ((1.119619553527753, 1.4683016995266238, -0.4256355476700406),
(0.7853078782246593, 0.21618941405118694, -0.04988462642839442),
(1.7521918404307653, -0.6690180410121276, 0.2699297634217041),
(-0.6404114764644544, -0.17821988481768988, 0.034782780206236624),
(-0.7526348686344194, -1.2468644821661592, -0.16730131057453498),
(-1.2335484316315908, 0.3780341245687702, -0.6961093474225755),
(-1.0305244954526513, 0.03157716984946183, 1.0342182884675877))}
rxn = ARCReaction(r_species=[ARCSpecies(label="r1", smiles="F[C]F", xyz=r1_xyz),
ARCSpecies(label="r2", smiles="[CH3]", xyz=r2_xyz)],
p_species=[ARCSpecies(label="p1", smiles="F[C](F)C", xyz=p1_xyz)])
self.assertIn(rxn.atom_map[:2], [[0, 1], [1, 0]])
self.assertEqual(rxn.atom_map[2], 2)
self.assertEqual(rxn.atom_map[3], 3)
self.assertIn(tuple(rxn.atom_map[4:]), list(permutations([4, 5, 6])))

@work_in_progress
def test_get_atom_map_wip(self):
Expand Down

0 comments on commit 8a2c8e5

Please sign in to comment.