-
Notifications
You must be signed in to change notification settings - Fork 24
Several more atom mapping improvements #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1154d76
56d9143
a729e78
37b1411
657c15c
f12b3c1
40d6e5d
3c744d7
3be335d
b5e959b
d1d0c25
d25323f
86a243e
708d1f5
970bd46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,12 +285,14 @@ def identify_superimposable_candidates(fingerprint_1: dict[int, dict[str, str | | |
| of species 1, values are potentially mapped atom indices of species 2. | ||
| """ | ||
| candidates = list() | ||
| for key_1 in fingerprint_1.keys(): | ||
| for key_2 in fingerprint_2.keys(): | ||
| # Try all combinations of heavy atoms. | ||
| result = iterative_dfs(fingerprint_1, fingerprint_2, key_1, key_2) | ||
| if result is not None: | ||
| candidates.append(result) | ||
| if not fingerprint_1: | ||
| return [] | ||
| key_1 = list(fingerprint_1.keys())[0] | ||
| for key_2 in fingerprint_2.keys(): | ||
| # Try all combinations of heavy atoms. | ||
| result = iterative_dfs(fingerprint_1, fingerprint_2, key_1, key_2) | ||
| if result is not None: | ||
| candidates.append(result) | ||
| return prune_identical_dicts(candidates) | ||
|
|
||
|
|
||
|
|
@@ -382,14 +384,7 @@ def prune_identical_dicts(dicts_list: list[dict]) -> list[dict]: | |
| """ | ||
| new_dicts_list = list() | ||
| for new_dict in dicts_list: | ||
| unique_ = True | ||
| for existing_dict in new_dicts_list: | ||
| if unique_: | ||
| for new_key, new_val in new_dict.items(): | ||
| if new_key not in existing_dict.keys() or new_val == existing_dict[new_key]: | ||
| unique_ = False | ||
| break | ||
| if unique_: | ||
| if new_dict not in new_dicts_list: | ||
| new_dicts_list.append(new_dict) | ||
| return new_dicts_list | ||
|
|
||
|
|
@@ -1195,11 +1190,18 @@ def pairing_reactants_and_products_for_mapping(r_cuts: list[ARCSpecies], | |
| list[tuple[ARCSpecies,ARCSpecies]]: A list of paired reactant and products, to be sent to map_two_species. | ||
| """ | ||
| pairs: list[tuple[ARCSpecies, ARCSpecies]] = list() | ||
| for react in r_cuts: | ||
| r_res = [generate_resonance_structures_safely(react.mol, save_order=True) or [react.mol] for react in r_cuts] | ||
| for i, react in enumerate(r_cuts): | ||
| res1 = r_res[i] | ||
| for idx, prod in enumerate(p_cuts): | ||
| if r_cut_p_cut_isomorphic(react, prod): | ||
| pairs.append((react, prod)) | ||
| p_cuts.pop(idx) | ||
| found = False | ||
| for res in res1: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can res1 be
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment wasn't addressed. take a look?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it was see L#1193 |
||
| if res.fingerprint == prod.mol.fingerprint or prod.mol.is_isomorphic(res, save_order=True): | ||
| pairs.append((react, prod)) | ||
| p_cuts.pop(idx) | ||
| found = True | ||
| break | ||
| if found: | ||
| break | ||
| return pairs | ||
|
|
||
|
|
@@ -1460,7 +1462,10 @@ def copy_species_list_for_mapping(species: list["ARCSpecies"]) -> list["ARCSpeci | |
| Returns: | ||
| list[ARCSpecies]: The copied species list. | ||
| """ | ||
| copies = [spc.copy() for spc in species] | ||
| copies = list() | ||
| for spc in species: | ||
| new_spc = ARCSpecies(label=spc.label, mol=spc.mol.copy(deep=True), xyz=spc.get_xyz(), keep_mol=True) | ||
| copies.append(new_spc) | ||
| for copy, spc in zip(copies, species): | ||
| for atom1, atom2 in zip(copy.mol.atoms, spc.mol.atoms): | ||
| atom1.label = atom2.label | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.