Skip to content

Commit

Permalink
Merge pull request #18 from MDAnalysis/parser-and-tests
Browse files Browse the repository at this point in the history
Extend tests for OpenBabelParser
  • Loading branch information
lunamorrow authored Oct 8, 2024
2 parents f35c093 + 5a13779 commit cb7466e
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 195,238 deletions.
11 changes: 6 additions & 5 deletions mda_openbabel_converter/OpenBabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def __init__(self, filename: OBMol, **kwargs):
if filename.NumConformers() == 1:
coordinates = np.array([
[(coords := atom.GetVector()).GetX(),
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
dtype=np.float32)
else:
# multiple conformers, such as for a trajectory
Expand All @@ -63,16 +63,17 @@ def __init__(self, filename: OBMol, **kwargs):
for atom in OBMolAtomIter(filename):
coordinates_inner = np.array([
[(coords := atom.GetVector()).GetX(),
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
dtype=np.float32)
coordinates[conf_id] = coordinates_inner
# no coordinates present
if not np.any(coordinates):
warnings.warn("No coordinates found in the OBMol")
coordinates = np.empty((1, n_atoms, 3), dtype=np.float32)
coordinates[:] = np.nan
super(OpenBabelReader, self).__init__(coordinates, order='fac', **kwargs)
super(OpenBabelReader, self).__init__(coordinates,
order='fac', **kwargs)

class OpenBabelConverter(ConverterBase):
"""
Expand Down
1 change: 0 additions & 1 deletion mda_openbabel_converter/OpenBabelParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def parse(self, **kwargs):
resid = atom.GetResidue()
resnums.append(resid.GetNum())
resnames.append(resid.GetName())
chainids.append(resid.GetChain())
icodes.append(resid.GetInsertionCode())

aromatics.append(atom.IsAromatic())
Expand Down
Loading

0 comments on commit cb7466e

Please sign in to comment.