mda_openbabel_converter.OpenBabel

OpenBabel molecule I/O — mda_openbabel_converter.OpenBabel

Read coordinates data from an OpenBabel openbabel.openbabel.OBMol with OpenBabelReader into an MDAnalysis Universe. Convert it back to a openbabel.openbabel.OBMol with OpenBabelConverter.

Example

To read an OpenBabel OBMol and then convert the AtomGroup back to an OpenBabel OBMol:

>>> from openbabel import openbabel as ob
>>> import MDAnalysis as mda
>>> obconversion = ob.OBConversion()
>>> obconversion.SetInFormat("pdb")
>>> mol = ob.OBMol()
>>> obconversion.ReadFile(mol, "1crn.pdb")
>>> u = mda.Universe(mol)
>>> u
<Universe with 327 atoms>
>>> u.trajectory
<OpenBabelReader with 1 frame of 327 atoms>
>>> u.atoms.convert_to("OPENBABEL")
<openbabel.openbabel.OBMol object at 0x7fcebb958148>

Warning

The OpenBabel converter is currently experimental and may not work as expected for all molecules.

Classes

class mda_openbabel_converter.OpenBabel.OpenBabelReader(filename: OBMol, **kwargs)[source]

Coordinate reader for OpenBabel.

Inherits from MemoryReader and converts OpenBabel OBMol Coordinates to a MDAnalysis Trajectory which is used to build a Universe. This reader does NOT work in the reverse direction.

See mda_openbabel_converter.OpenBabel.OpenBabelConverter for MDAnalysis Universe to OpenBabel OBMol conversion.

units = {'length': 'Angstrom', 'time': None}

dict with units of of time and length (and velocity, force, … for formats that support it)

class mda_openbabel_converter.OpenBabel.OpenBabelConverter[source]

Inherits from ConverterBase and converts a MDAnalysis Universe to an OpenBabel OBMol. This converter does NOT work in the opposite direction.

See mda_openbabel_converter.OpenBabelReader for OpenBabel OBMol to MDAnalysis Universe conversion.

convert(obj, **kwargs)[source]

Converts AtomGroup to OBMol

Classes

OpenBabelConverter()

Inherits from ConverterBase and converts a MDAnalysis Universe to an OpenBabel OBMol.

OpenBabelReader(filename, **kwargs)

Coordinate reader for OpenBabel.