Skip to content

Commit

Permalink
Merge branch 'master' into code_quality
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf-meyer committed Apr 27, 2023
2 parents 7af1055 + 1c39c62 commit 000fd53
Show file tree
Hide file tree
Showing 13 changed files with 383 additions and 224 deletions.
1 change: 1 addition & 0 deletions docs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dependencies:
- pandas
- scikit-learn
- beautifulsoup4
- networkx
2 changes: 1 addition & 1 deletion docs/source/Informatics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Molecular Revised Autocorrelations
Revised Autocorrelations for MOFs
---------------------------------

Documentation for MOFs is coming soon!
Documentation for RACs coming soon!
4 changes: 2 additions & 2 deletions molSimplify/Classes/ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def percent_buried_vol(self, radius=3.5, gridspec=0.1,
return percent_buried


def ligand_breakdown(mol, flag_loose=False, BondedOct=False, silent=True):
def ligand_breakdown(mol, flag_loose=False, BondedOct=False, silent=True, transition_metals_only=True):
"""Extract axial and equatorial components of a octahedral complex.
Parameters
Expand All @@ -287,7 +287,7 @@ def ligand_breakdown(mol, flag_loose=False, BondedOct=False, silent=True):
"""
# this function takes an octahedral
# complex and returns ligands
metal_index = mol.findMetal()[0]
metal_index = mol.findMetal(transition_metals_only=transition_metals_only)[0]
bondedatoms = mol.getBondedAtomsSmart(metal_index, oct=True)
# print('!!!!!boundatoms', bondedatoms)
# print('from get oct' + str(bondedatoms))
Expand Down
47 changes: 43 additions & 4 deletions molSimplify/Classes/mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,13 @@ def convert2OBMol2(self, force_clean=False, ignoreX=False):
#####
obConversion.SetOutFormat('mol2')
ss = obConversion.WriteString(OBMol)
# Update atom types from OBMol
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>BOND')[0].split('\n')[:-1]
# Update atom types from OBMol.
if "UNITY_ATOM_ATTR" in ss: # If this section is present, it will be before the @<TRIPOS>BOND section.
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>UNITY_ATOM_ATTR')[0].split('\n')[:-1]
else:
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>BOND')[0].split('\n')[:-1]
for i, line in enumerate(lines):
if '.' in line.split()[5]:
self.atoms[i].name = line.split()[5].split('.')[1]
Expand Down Expand Up @@ -1273,6 +1277,41 @@ def apply_ffopt(self, constraints=False, ff='uff'):
self.convert2mol3D()
return en

def apply_ffopt_list_constraints(self, list_constraints=False, ff='uff'):
"""
Apply forcefield optimization to a given mol3D class.
Differs from apply_ffopt in that one can specify constrained atoms as a list.
Parameters
----------
list_constraints : list of int, optional
List of atom indices to employ cartesian constraints before ffopt.
ff : str, optional
Force field to be used in openbabel. Default is UFF.
Returns
-------
energy : float
Energy of the ffopt in kJ/mol.
"""
forcefield = openbabel.OBForceField.FindForceField(ff)
constr = openbabel.OBFFConstraints()
if list_constraints:
for catom in list_constraints:
# Openbabel uses a 1 index instead of a 0 index.
constr.AddAtomConstraint(catom+1)
self.convert2OBMol()
forcefield.Setup(self.OBMol, constr)
if self.OBMol.NumHvyAtoms() > 10:
forcefield.ConjugateGradients(200)
else:
forcefield.ConjugateGradients(50)
forcefield.GetCoordinates(self.OBMol)
en = forcefield.Energy()
self.convert2mol3D()
return en

def findcloseMetal(self, atom0):
"""
Find the nearest metal to a given atom3D class.
Expand Down Expand Up @@ -4978,7 +5017,7 @@ def read_smiles(self, smiles, ff="mmff94", steps=2500):

def get_smiles(self, canonicalize=False, use_mol2=False) -> str:
"""
Read a smiles string and convert it to a mol3D class instance.
Returns the SMILES string representing the mol3D object.
Parameters
----------
Expand Down

0 comments on commit 000fd53

Please sign in to comment.