Skip to content

Commit 699421e

Browse files
authored
Update guessing.rst
- address @RMeli comments - minor grammar fixes - moved note on radii guessing to explicit rst note
1 parent d08031e commit 699421e

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

doc/source/guessing.rst

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ Topology attributes can be guessed at Universe creation by passing in topology a
3333
u.atoms.bonds
3434
3535
36-
In general, guessing at Universe creation works very similarly to guessing using the guess_TopologyAttrs interface documented below. The main difference is that passing guesser-specific keyword arguments such as ``fudge_factor`` and ``vdwradii`` into Universe creation is **now deprecated and will be removed in version 3.0**. Instead, we recommend specifying these arguments through an explicit call to the :ref:`guess_TopologyAttrs <guess-topologyAttrs>` method.
36+
In general, guessing at Universe creation works very similarly to guessing using the guess_TopologyAttrs interface documented below. The main difference is that passing guesser-specific keyword arguments such as ``fudge_factor`` and ``vdwradii`` into Universe creation is **now deprecated and will be removed in version 3.0**. Instead, we recommend specifying these arguments through an explicit call to the :ref:`guess_TopologyAttrs method<guess-topologyAttrs>`.
3737

3838
.. _guess-topologyAttrs:
3939

40-
Guessing using the guess_TopologyAttrs interface
41-
================================================
40+
Guessing using the ``guess_TopologyAttrs()`` interface
41+
======================================================
4242

43-
Topology attributes can also be guessed after Universe creation using the :meth:`~MDAnalysis.core.universe.Universe.guess_TopologyAttrs` method. The ``to_guess``, ``force_guess``, and ``context`` keywords are used to specify which attributes to guess, which attributes to forcibly re-guess, and which guesser to use, respectively. These three keywords perform the same way here as they do in Universe creation.
43+
Topology attributes can also be guessed after :class:`~MDAnalysis.core.universe.Universe` creation using the :meth:`~MDAnalysis.core.universe.Universe.guess_TopologyAttrs` method. The ``to_guess``, ``force_guess``, and ``context`` keywords are used to specify which attributes to guess, which attributes to forcibly re-guess, and which guesser to use, respectively. These three keywords perform the same way here as they do in Universe creation.
4444

45-
As with Universe creation, the :ref:`DefaultGuesser <default-guesser>` is used as the default ``context``. The following example demonstrates how to guess atom types and masses after Universe creation.
45+
As with :class:`Universe` creation, the :ref:`DefaultGuesser <default-guesser>` is used as the default ``context``. The following example demonstrates how to guess atom types and masses after Universe creation.
4646

4747
.. ipython:: python
4848
@@ -51,12 +51,12 @@ As with Universe creation, the :ref:`DefaultGuesser <default-guesser>` is used a
5151
u.atoms.types
5252
5353
54-
The context can be specified either using a string (e.g. ``"default"``) or an already created Guesser object. It may be convenient to pass in an already-created Guesser object if there are particular keywords you want to use in guessing methods, such as the ``fudge_factor``, ``vdwradii`` or ``lower_bound`` keywords for controlling bond guessing. However, if additional keyword arguments are passed into ``guess_TopologyAttrs``, they will **replace** any existing arguments inside the guesser.
54+
The context can be specified either using a string (e.g., ``"default"``) or an already created *Guesser* object (which will have been derived from the base class :class:`~MDAnalysis.guesser.base.GuesserBase`). It may be convenient to pass in an already-created *Guesser* object (such as the :class:`~MDAnalysis.guesser.default_guesser.DefaultGuesser`) if there are particular keywords you want to use in guessing methods, such as the ``fudge_factor``, ``vdwradii`` or ``lower_bound`` keywords for controlling bond guessing. However, if additional keyword arguments are passed into ``guess_TopologyAttrs``, they will **replace** any existing arguments inside the guesser.
5555

5656
.. ipython:: python
5757
5858
from MDAnalysis.guesser import DefaultGuesser
59-
from MDAnalysis.tests.datafiles import CONECT
59+
from MDAnalysis.tests.datafiles import CONECT # example data file
6060
6161
u = mda.Universe(CONECT)
6262
guesser = DefaultGuesser(u, fudge_factor=1.2)
@@ -77,7 +77,7 @@ MDAnalysis will preferentially read topology attributes from file instead of re-
7777

7878
.. note::
7979

80-
In cases where the attribute is only present for *some* atoms in the file (e.g. a patchy element column in a PDB), MDAnalysis will only guess the attribute for atoms where it is not present in the file.
80+
In cases where the attribute is only present for *some* atoms in the file (e.g. a patchy element column in a PDB), MDAnalysis will only guess the attribute for atoms where it is not present in the file.
8181

8282
To force MDAnalysis to re-guess a TopologyAttr, pass in the attribute to the ``force_guess`` keyword. This will force MDAnalysis to guess the attribute even if it is present in the file.
8383

@@ -93,7 +93,7 @@ Guessing bonds, angles, and torsions
9393

9494
Whereas most attributes are guessed at the atom, residue, or segment level, guessing topology objects such as bonds, angles, dihedrals and impropers behaves somewhat differently, and interacts with the ``force_guess`` keyword specially.
9595

96-
Specifically, if these connectivity attributes are guessed, they are by default guessed *additively*. Therefore, if bonds and other objects are guessed twice, the bonds of the second guess are added on. Below, we see the number of bonds increase when guessed again with a looser criteria.
96+
Specifically, if these connectivity attributes are guessed, they are by default guessed **additively**. Therefore, if bonds and other objects are guessed twice, **the bonds of the second guess are added on.** Below, we see the number of bonds increase when guessed again with a looser criteria.
9797

9898
.. ipython:: python
9999
@@ -105,23 +105,23 @@ Specifically, if these connectivity attributes are guessed, they are by default
105105
print(len(u.bonds))
106106
107107
108-
However, the number of bonds doesn't change when the bonds are guessed again with a stricter criteria -- no new bonds are found.
108+
However, the **number of bonds doesn't change when the bonds are guessed again with stricter criteria** -- no new bonds are found (and also no bonds are removed either, even if they do not match the new criteria):
109109

110110
.. ipython:: python
111111
112112
u.guess_TopologyAttrs(to_guess=["bonds"], fudge_factor=0.5) # stricter
113113
print(len(u.bonds))
114114
115115
116-
Moreover, bonds are unique, so if the bonds are guessed again with a same criteria, the guessed bonds doesn't change.
116+
Moreover, bonds are unique, so if the bonds are guessed again with the same criteria, the guessed bonds don't change:
117117

118118
.. ipython:: python
119119
120120
u.guess_TopologyAttrs(to_guess=["bonds"], fudge_factor=0.5) # same
121121
print(len(u.bonds))
122122
123123
124-
However, if you want to forcibly overwrite all existing bonds, angles, dihedrals or impropers, you can pass the object to the ``force_guess`` keyword. This will remove all existing objects of that type before guessing. Below, we see the number of bonds has shrunk when guessed with stricter criteria.
124+
However, if you want to forcibly overwrite all existing bonds, angles, dihedrals or impropers, you can pass the object to the ``force_guess`` keyword. This will **remove all existing objects of that type before guessing.** Below, we see the number of bonds has shrunk when guessed with stricter criteria:
125125

126126
.. ipython:: python
127127
@@ -133,9 +133,13 @@ However, if you want to forcibly overwrite all existing bonds, angles, dihedrals
133133
Order of guessing
134134
-----------------
135135

136-
The order of the attributes guessed can matter in some cases. For example, bond guessing with the DefaultGuesser relies on looking up the vdW radii of the atoms involved by their atom ``type``. (**Note: this behaviour will likely change to looking up by element in version 3.0**). That means that for file formats where the atom ``type`` is not a valid element, the atom ``type`` must be forcefully re-guessed for bond-guessing to work.
136+
The order of the attributes guessed can matter in some cases. For example, bond guessing with the :class:`~MDAnalysis.guesser.default_guesser.DefaultGuesser` relies on looking up the vdW radii of the atoms involved by their atom ``type``. That means that for file formats where the atom ``type`` is not a valid element, the atom ``type`` must be forcefully re-guessed for bond-guessing to work.
137+
138+
.. note::
139+
140+
The behaviour of looking up radii by *type* will likely change to looking up by *element* in version 3.0.
137141

138-
Therefore the following will not work due to the types encoded in the PSF file:
142+
Therefore the following will not work (in MDAnalysis < 3.0) due to the types encoded in the PSF file:
139143

140144
.. ipython:: python
141145
:okexcept:

0 commit comments

Comments
 (0)