Skip to content

AtomGroup.guess_bonds misleading documentation, could pass in fudge_factor #2395

@lilyminium

Description

@lilyminium

Expected behavior

def guess_bonds(self, vdwradii=None):
"""Guess bonds that exist within this :class:`AtomGroup` and add them to
the underlying :attr:`~AtomGroup.universe`.
Parameters
----------
vdwradii : dict, optional
Dict relating atom types: vdw radii

AtomGroup.guess_bonds guesses bonds, only.

Actual behavior

It guesses bonds, angles, and dihedrals.

If the method is going to guess angles, it could guess improper dihedrals too from the angles.

Code to reproduce the behavior

Show us how to reproduce the failiure. If you can, use trajectory files from the test data.

from ..topology.core import guess_bonds, guess_angles, guess_dihedrals
from .topologyattrs import Bonds, Angles, Dihedrals
def get_TopAttr(u, name, cls):
"""either get *name* or create one from *cls*"""
try:
return getattr(u._topology, name)
except AttributeError:
attr = cls([])
u.add_TopologyAttr(attr)
return attr
# indices of bonds
box = self.dimensions if self.dimensions.all() else None
b = guess_bonds(self.atoms, self.atoms.positions, vdwradii=vdwradii, box=box)
bondattr = get_TopAttr(self.universe, 'bonds', Bonds)
bondattr.add_bonds(b, guessed=True)
a = guess_angles(self.bonds)
angleattr = get_TopAttr(self.universe, 'angles', Angles)
angleattr.add_bonds(a, guessed=True)
d = guess_dihedrals(self.angles)
diheattr = get_TopAttr(self.universe, 'dihedrals', Dihedrals)
diheattr.add_bonds(d)

Currently version of MDAnalysis

  • Which version are you using? current develop branch

Also

It would be useful to be able to pass in fudge_factor and lower_bound kwargs to this method (to pass onto guessers.guess_bonds)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions