-
Notifications
You must be signed in to change notification settings - Fork 23
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
Small atom mapping debugging #740
Open
kfir4444
wants to merge
3
commits into
main
Choose a base branch
from
am_fixups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+42
−26
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
from arc.species import ARCSpecies | ||
from arc.species.conformers import determine_chirality | ||
from arc.species.converter import compare_confs, sort_xyz_using_indices, translate_xyz, xyz_from_data, xyz_to_str | ||
from arc.species.vectors import calculate_angle, calculate_dihedral_angle, calculate_distance, get_delta_angle | ||
from arc.species.vectors import calculate_angle, calculate_dihedral_angle, calculate_distance, get_delta_angle, VectorsError | ||
from numpy import unique | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -856,17 +856,23 @@ | |
heavy_atom_1_index = atoms_1.index(heavy_atom_1) | ||
for rotor_dict in spc_1.rotors_dict.values(): | ||
if heavy_atom_1_index in [rotor_dict['torsion'][1], rotor_dict['torsion'][2]]: | ||
atom_map = add_adjacent_hydrogen_atoms_to_map_based_on_a_specific_torsion( | ||
spc_1=spc_1, | ||
spc_2=spc_2, | ||
heavy_atom_1=heavy_atom_1, | ||
heavy_atom_2=heavy_atom_2, | ||
torsion=rotor_dict['torsion'], | ||
atom_map=atom_map, | ||
find_torsion_end_to_map=True, | ||
) | ||
success = True | ||
break | ||
try: | ||
atom_map = add_adjacent_hydrogen_atoms_to_map_based_on_a_specific_torsion( | ||
spc_1=spc_1, | ||
spc_2=spc_2, | ||
heavy_atom_1=heavy_atom_1, | ||
heavy_atom_2=heavy_atom_2, | ||
torsion=rotor_dict['torsion'], | ||
atom_map=atom_map, | ||
find_torsion_end_to_map=True, | ||
) | ||
success = True | ||
break | ||
except VectorsError: | ||
# Trying to map a linear torsion | ||
# but the torsion is undefined, since v1 x v2 = 0 if v1 || v2 | ||
# using other internal coordinates to map the hydrogens. | ||
continue | ||
# 3. Check for a pseudo-torsion (may involve multiple bonds) with heavy_atom_1 as a pivot. | ||
if not success: | ||
pseudo_torsion = list() | ||
|
@@ -883,17 +889,23 @@ | |
pseudo_torsion = [atoms_1.index(atom) for atom in [hydrogen_1, heavy_atom_1, atom_1_3, atom_1_4]] | ||
break | ||
if len(pseudo_torsion): | ||
atom_map = add_adjacent_hydrogen_atoms_to_map_based_on_a_specific_torsion( | ||
spc_1=spc_1, | ||
spc_2=spc_2, | ||
heavy_atom_1=heavy_atom_1, | ||
heavy_atom_2=heavy_atom_2, | ||
torsion=pseudo_torsion[::-1], | ||
atom_map=atom_map, | ||
find_torsion_end_to_map=False, | ||
) | ||
success = True | ||
break | ||
try: | ||
atom_map = add_adjacent_hydrogen_atoms_to_map_based_on_a_specific_torsion( | ||
spc_1=spc_1, | ||
spc_2=spc_2, | ||
heavy_atom_1=heavy_atom_1, | ||
heavy_atom_2=heavy_atom_2, | ||
torsion=pseudo_torsion[::-1], | ||
atom_map=atom_map, | ||
find_torsion_end_to_map=False, | ||
) | ||
success = True | ||
break | ||
except VectorsError: | ||
# Trying to map a linear torsion | ||
# but the torsion is undefined, since v1 x v2 = 0 if v1 || v2 | ||
# using other internal coordinates to map the hydrogens. | ||
continue | ||
# 4. Check by angles and bond lengths (search for 2 consecutive heavy atoms). | ||
if not success: | ||
atom_1_3, angle_1, bond_length_1 = None, None, None | ||
|
@@ -1117,8 +1129,12 @@ | |
bool: ``True`` if they are isomorphic, ``False`` otherwise. | ||
""" | ||
res1 = generate_resonance_structures(object_=reactant.mol.copy(deep=True), save_order = True) | ||
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 would recommend to modify the |
||
for res in res1: | ||
if res.fingerprint == product.mol.fingerprint or product.mol.is_isomorphic(res, save_order=True): | ||
if res1 is not None: | ||
for res in res1: | ||
if res.fingerprint == product.mol.fingerprint or product.mol.is_isomorphic(res, save_order=True): | ||
return True | ||
else: | ||
if reactant.mol.fingerprint == product.mol.fingerprint or product.mol.is_isomorphic(reactant.mol.copy(deep=True), save_order=True): | ||
return True | ||
return False | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this fix solve the issue or skips it? We could consider using a different atom instead of the last atom in the torsion