Skip to content
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

Define set_rdkit_ring_dihedrals and make test #767

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JintaoWu98
Copy link
Member

This PR introduces a new helper function, set_rdkit_ring_dihedrals, to the converter.py module. This function allows for setting dihedral angles in a ring structure using RDKit, facilitating the manipulation of molecular conformations.

Copy link

codecov bot commented Sep 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.12%. Comparing base (fb16f4a) to head (ecb1262).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #767      +/-   ##
==========================================
+ Coverage   74.09%   74.12%   +0.03%     
==========================================
  Files         101      101              
  Lines       28005    28038      +33     
  Branches     5860     5863       +3     
==========================================
+ Hits        20751    20784      +33     
  Misses       5786     5786              
  Partials     1468     1468              
Flag Coverage Δ
74.12% <100.00%> (+0.03%) ⬆️
unittests 74.12% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alongd
Copy link
Member

alongd commented Dec 7, 2024

@JintaoWu98, what's the status of this PR? I don't see the new function being used, would you like to wait with it?

@@ -1121,6 +1126,76 @@
return num_comb


def plot_ring_torsion_angles(conformers, plot_path=None, tolerance=15):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
os.makedirs(plot_path)
try:
plt.savefig(ring_plot_path, bbox_inches='tight')
except FileNotFoundError:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
arc/species/conformers.py Fixed Show fixed Hide fixed
torsion_0_indexed = [[tor - 0 for tor in sub_torsion] for sub_torsion in torsion]
ring_length = len(torsion_0_indexed)
head = torsion_0_indexed[0][0]
for torsion in torsion_0_indexed:

Check notice

Code scanning / CodeQL

Nested loops with same variable Note

Nested for statement uses loop variable 'torsion' of enclosing
for statement
.

# Remove the bond to open the ring
rd_mol_noH = Chem.RWMol(rd_mol_noH)
rd_mol_noH.RemoveBond(atom_map[ring_head], atom_map[ring_tail])

Check failure

Code scanning / CodeQL

Unhashable object hashed Error

This
instance
of
list
is unhashable.
rdMT.SetDihedralDeg(conf_noH, *torsion_noH, dihedral)
# Re-add the bond to close the ring
rd_mol_noH.AddBond(
atom_map[ring_head], atom_map[ring_tail], rd_mol.GetBondBetweenAtoms(ring_head, ring_tail).GetBondType()

Check failure

Code scanning / CodeQL

Unhashable object hashed Error

This
instance
of
list
is unhashable.
mol = b_mol if b_mol is not None else s_mol
_, rd_mol = converter.rdkit_conf_from_mol(mol, xyz_original)

xyz_final = converter.set_rdkit_ring_dihedrals(rd_mol, ring_head, ring_tail, torsions, dihedrals)

Check failure

Code scanning / CodeQL

Wrong number of arguments in a call Error

Call to
function set_rdkit_ring_dihedrals
with too few arguments; should be no fewer than 6.
arc/species/conformers.py Fixed Show fixed Hide fixed
if plot_path is not None:
arc.plotter.plot_torsion_angles(torsion_angles, torsions_sampling_points, wells_dict=wells_dict,
plot_path=plot_path)
ring_angle_data = arc.plotter.plot_ring_torsion_angles(conformers=conformers, plot_path=plot_path)
# Process the ring angle data
if ring_angle_data:

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'ring_angle_data' may be used before it is initialized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants