27
27
28
28
DefaultGuesser is a generic guesser class that has basic guessing methods.
29
29
This class is a general purpose guesser that can be used with most topologies,
30
- but being generic makes it the less accurate among all guessers.
30
+ but being generic makes it the least accurate among all guessers.
31
31
32
32
33
+ Guessing behavior
34
+ -----------------
35
+
36
+ This section describes how each attribute is guessed by the DefaultGuesser.
37
+
38
+ Masses
39
+ ~~~~~~
40
+
41
+ We first attempt to look up the mass of an atom based on its element if the
42
+ element TopologyAttr is available. If not, we attempt to lookup the mass based
43
+ on the atom type (``type``) TopologyAttr. If neither of these is available, we
44
+ attempt to guess the atom type based on the atom name (``name``) and then
45
+ lookup the mass based on the guessed atom type.
46
+
47
+
48
+ Types
49
+ ~~~~~
50
+
51
+ We attempt to guess the atom type based on the atom name (``name``).
52
+ The name is first stripped of any numbers and symbols, and then looked up in
53
+ the :data:`MDAnalysis.guesser.tables.atomelements` table. If the name is not
54
+ found, we continue checking variations of the name following the logic in
55
+ :meth:`DefaultGuesser.guess_atom_element`. Ultimately, if no match is found,
56
+ the first character of the stripped name is returned.
57
+
58
+ Elements
59
+ ~~~~~~~~
60
+
61
+ This follows the same method as guessing atom types.
62
+
63
+
64
+ Bonds
65
+ ~~~~~
66
+
67
+ Bonds are guessed based on the distance between atoms.
68
+ See :meth:`DefaultGuesser.guess_bonds` for more details.
69
+
70
+ Angles
71
+ ~~~~~~
72
+
73
+ Angles are guessed based on the bonds between atoms.
74
+ See :meth:`DefaultGuesser.guess_angles` for more details.
75
+
76
+ Dihedrals
77
+ ~~~~~~~~~
78
+
79
+ Dihedrals are guessed based on the angles between atoms.
80
+ See :meth:`DefaultGuesser.guess_dihedrals` for more details.
81
+
82
+ Improper Dihedrals
83
+ ~~~~~~~~~~~~~~~~~~
84
+
85
+ Improper dihedrals are guessed based on the angles between atoms.
86
+ See :meth:`DefaultGuesser.guess_improper_dihedrals` for more details.
87
+
88
+ Aromaticities
89
+ ~~~~~~~~~~~~~
90
+
91
+ Aromaticity is guessed using RDKit's GetIsAromatic method.
92
+ See :meth:`DefaultGuesser.guess_aromaticities` for more details.
93
+
33
94
34
95
35
96
@@ -70,6 +131,23 @@ class DefaultGuesser(GuesserBase):
70
131
You can use this guesser either directly through an instance, or through
71
132
the :meth:`~MDAnalysis.core.universe.Universe.guess_TopologyAttrs` method.
72
133
134
+ Parameters
135
+ ----------
136
+ universe : Universe
137
+ The Universe to apply the guesser on
138
+ box : np.ndarray, optional
139
+ The box of the Universe. This is used for bond guessing.
140
+ vdwradii : dict, optional
141
+ Dict relating atom types: vdw radii. This is used for bond guessing
142
+ fudge_factor : float, optional
143
+ The factor by which atoms must overlap each other to be considered
144
+ a bond. Larger values will increase the number of bonds found. [0.55]
145
+ lower_bound : float, optional
146
+ The minimum bond length. All bonds found shorter than this length
147
+ will be ignored. This is useful for parsing PDB with altloc records
148
+ where atoms with altloc A and B may be very close together and
149
+ there should be no chemical bond between them. [0.1]
150
+
73
151
Examples
74
152
--------
75
153
to guess bonds for a universe::
@@ -84,8 +162,23 @@ class DefaultGuesser(GuesserBase):
84
162
"""
85
163
context = 'default'
86
164
87
- def __init__ (self , universe , ** kwargs ):
88
- super ().__init__ (universe , ** kwargs )
165
+ def __init__ (
166
+ self ,
167
+ universe ,
168
+ box = None ,
169
+ vdwradii = None ,
170
+ fudge_factor = 0.55 ,
171
+ lower_bound = 0.1 ,
172
+ ** kwargs
173
+ ):
174
+ super ().__init__ (
175
+ universe ,
176
+ box = box ,
177
+ vdwradii = vdwradii ,
178
+ fudge_factor = fudge_factor ,
179
+ lower_bound = lower_bound ,
180
+ ** kwargs
181
+ )
89
182
self ._guesser_methods = {
90
183
'masses' : self .guess_masses ,
91
184
'types' : self .guess_types ,
@@ -212,8 +305,19 @@ def guess_types(self, atom_types=None, indices_to_guess=None):
212
305
def guess_atom_element (self , atomname ):
213
306
"""Guess the element of the atom from the name.
214
307
215
- Looks in dict to see if element is found, otherwise it uses the first
216
- character in the atomname. The table comes from CHARMM and AMBER atom
308
+ First all numbers and symbols are stripped from the name.
309
+ Then the name is looked up in the
310
+ :data:`MDAnalysis.guesser.tables.atomelements` table.
311
+ If the name is not found, we remove the last character or
312
+ first character from the name and check the table for both,
313
+ with a preference for removing the last character. If the name is
314
+ still not found, we iteratively continue to remove the last character
315
+ or first character until we find a match. If ultimately no match
316
+ is found, the first character of the stripped name is returned.
317
+
318
+ If the input name is an empty string, an empty string is returned.
319
+
320
+ The table comes from CHARMM and AMBER atom
217
321
types, where the first character is not sufficient to determine the
218
322
atom type. Some GROMOS ions have also been added.
219
323
@@ -270,26 +374,11 @@ def guess_bonds(self, atoms=None, coords=None):
270
374
271
375
Parameters
272
376
----------
273
- atoms : AtomGroup
274
- atoms for which bonds should be guessed
275
- fudge_factor : float, optional
276
- The factor by which atoms must overlap eachother to be considered a
277
- bond. Larger values will increase the number of bonds found. [0.55]
278
- vdwradii : dict, optional
279
- To supply custom vdwradii for atoms in the algorithm. Must be a
280
- dict of format {type:radii}. The default table of van der Waals
281
- radii is hard-coded as :data:`MDAnalysis.guesser.tables.vdwradii`.
282
- Any user defined vdwradii passed as an argument will supercede the
283
- table values. [``None``]
284
- lower_bound : float, optional
285
- The minimum bond length. All bonds found shorter than this length
286
- will be ignored. This is useful for parsing PDB with altloc records
287
- where atoms with altloc A and B maybe very close together and
288
- there should be no chemical bond between them. [0.1]
289
- box : array_like, optional
290
- Bonds are found using a distance search, if unit cell information
291
- is given, periodic boundary conditions will be considered in the
292
- distance search. [``None``]
377
+ atoms: AtomGroup
378
+ atoms for which bonds should be guessed
379
+ coords: np.ndarray, optional
380
+ coordinates of the atoms. If not provided, the coordinates
381
+ of the ``atoms`` in the universe are used.
293
382
294
383
Returns
295
384
-------
0 commit comments