Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic guesser features #3753

Merged
merged 295 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 118 commits
Commits
Show all changes
295 commits
Select commit Hold shift + click to select a range
60b24c1
Update core.py
aya9aladdin Jul 23, 2022
ce68bd1
Update core.py
aya9aladdin Jul 23, 2022
ae862fc
Update core.py
aya9aladdin Jul 23, 2022
c5d3453
Merge branch 'develop' into guesser-basics
aya9aladdin Jul 23, 2022
f6053dc
Update core.py
aya9aladdin Jul 23, 2022
bb04030
remove guessing from parser
aya9aladdin Jul 25, 2022
91f0d08
Update universe.py
aya9aladdin Jul 25, 2022
2a013f1
Update universe.py
aya9aladdin Jul 25, 2022
93ffc3f
Update base.py
aya9aladdin Jul 25, 2022
bf41f72
Update core.py
aya9aladdin Jul 25, 2022
9cd3460
Update tables.py
aya9aladdin Jul 25, 2022
ca1f871
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Jul 25, 2022
6d48520
Parsers modification / guess_bond update
aya9aladdin Jul 26, 2022
4f2782f
aa
aya9aladdin Jul 26, 2022
6661c36
plural attr
aya9aladdin Jul 26, 2022
8b0cec5
Update __init__.py
aya9aladdin Jul 27, 2022
5a9ed58
Update __init__.py
aya9aladdin Jul 27, 2022
b28f09a
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Jul 27, 2022
6fe79ac
Merge branch 'develop' into guesser-basics
aya9aladdin Jul 27, 2022
fc4ec30
Rename DefaultGuesser.py to defaultGuesser.py
aya9aladdin Jul 27, 2022
ede16ca
Update DefaultGuesser.py
aya9aladdin Jul 27, 2022
76275a3
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Jul 27, 2022
f7bbbe6
Update package/MDAnalysis/core/universe.py
aya9aladdin Jul 28, 2022
f1a09bb
complete baseGuesser + removing rank + upgrading parts of code accord…
aya9aladdin Aug 1, 2022
4dc0ada
remove assigning atomtypes to names in PDBParser
aya9aladdin Aug 1, 2022
770b4ce
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Aug 1, 2022
2c92aa0
resolve automatic guessing empty universe
aya9aladdin Aug 4, 2022
5125953
Update PQRParser.py
aya9aladdin Aug 4, 2022
b0a0ee2
..
aya9aladdin Aug 4, 2022
c2f1f9a
Update default_guesser.py
aya9aladdin Aug 4, 2022
6b2c4c7
Update universe.py
aya9aladdin Aug 4, 2022
0c9e78d
Update universe.py
aya9aladdin Aug 4, 2022
bf2463f
Update universe.py
aya9aladdin Aug 4, 2022
c159461
Update universe.py
aya9aladdin Aug 4, 2022
2039be7
Update universe.py
aya9aladdin Aug 4, 2022
6b6c07b
Update universe.py
aya9aladdin Aug 4, 2022
2ceeec6
Update universe.py
aya9aladdin Aug 4, 2022
4679c18
modify guess_atoms to resolve errors
aya9aladdin Aug 4, 2022
5f81d3e
Update universe.py
aya9aladdin Aug 4, 2022
60cedfc
Update universe.py
aya9aladdin Aug 4, 2022
a7ea8da
Update universe.py
aya9aladdin Aug 4, 2022
18c86f8
Update universe.py
aya9aladdin Aug 4, 2022
3d996c4
modifying bond guessing to not break default behavior
aya9aladdin Aug 5, 2022
23932ca
update guess angles and dihedrals
aya9aladdin Aug 5, 2022
1d988de
modifying parser checking
aya9aladdin Aug 5, 2022
75e7b81
Update universe.py
aya9aladdin Aug 5, 2022
baa3e0b
Update universe.py
aya9aladdin Aug 5, 2022
54b2a64
Update universe.py
aya9aladdin Aug 5, 2022
c85a593
pep style
aya9aladdin Aug 5, 2022
2bd7fff
Update universe.py
aya9aladdin Aug 5, 2022
81c5382
pep
aya9aladdin Aug 5, 2022
78365bd
pep
aya9aladdin Aug 5, 2022
97a3d6b
pep
aya9aladdin Aug 5, 2022
c796eee
pep
aya9aladdin Aug 5, 2022
63d6fe1
Update universe.py
aya9aladdin Aug 5, 2022
8748515
pep
aya9aladdin Aug 5, 2022
c010d47
pep
aya9aladdin Aug 5, 2022
b6fa523
pep
aya9aladdin Aug 5, 2022
ba3e733
Update default_guesser.py
aya9aladdin Aug 5, 2022
3711962
pep
aya9aladdin Aug 5, 2022
10b8c03
Update tables.py
aya9aladdin Aug 5, 2022
c0f826f
Update tables.py
aya9aladdin Aug 5, 2022
636e4bc
pep
aya9aladdin Aug 5, 2022
752f05e
Update universe.py
aya9aladdin Aug 5, 2022
d0e2a8a
Update universe.py
aya9aladdin Aug 5, 2022
986335e
handeling TXYZParser special behavior of guessing masses from names n…
aya9aladdin Aug 5, 2022
b80edec
Update universe.py
aya9aladdin Aug 6, 2022
438ac52
Update universe.py
aya9aladdin Aug 6, 2022
5d6772c
remove guessed attributes test from parsers
aya9aladdin Aug 6, 2022
0dcca86
remove guessed attributes tests from parsers tests
aya9aladdin Aug 6, 2022
1a74cfd
remove guessed attributes tests from parsers tests
aya9aladdin Aug 6, 2022
eba975c
updating test
aya9aladdin Aug 6, 2022
45f90ef
remove tpr from topology cjecking
aya9aladdin Aug 8, 2022
ca525ad
transfer parser checkpoints to guess_topology_attr
aya9aladdin Aug 17, 2022
05a7623
Update universe.py
aya9aladdin Aug 17, 2022
9318bf2
passing all existing tests
aya9aladdin Aug 17, 2022
0297954
reordering some checkpoints
aya9aladdin Aug 18, 2022
2c88dd0
fix openmm and rdkit tests
aya9aladdin Aug 19, 2022
d1516d0
openmm
aya9aladdin Aug 19, 2022
99c8684
addin guess_topology_attr tests
aya9aladdin Aug 19, 2022
0f4fb3d
modify warning msg
aya9aladdin Aug 19, 2022
0d999f1
adding unit test
aya9aladdin Aug 21, 2022
c6431c0
Update base.py
aya9aladdin Aug 21, 2022
1e4395c
Update base.py
aya9aladdin Aug 21, 2022
23d627b
redirect table import to guesser packagr
aya9aladdin Aug 22, 2022
d77e14f
fix txyz parser checkpoint in guess_masses
aya9aladdin Aug 22, 2022
ba1d392
Update default_guesser.py
aya9aladdin Aug 22, 2022
8aaa305
rename file
aya9aladdin Aug 22, 2022
b120594
adding tests
aya9aladdin Aug 22, 2022
0901cb3
Update test_base.py
aya9aladdin Aug 22, 2022
c9dfa0b
adding universe test
aya9aladdin Aug 22, 2022
72e62f0
unit tests modification
aya9aladdin Aug 22, 2022
d2f0ec6
remove unused error checking
aya9aladdin Aug 22, 2022
3ba87de
adding more tests to pass codcov
aya9aladdin Aug 22, 2022
6a819b9
Delete .coverage.Aya-MacBook.11217.035601
aya9aladdin Aug 22, 2022
f3669df
Update test_encore.py
aya9aladdin Aug 22, 2022
044bc74
add more tests
aya9aladdin Aug 23, 2022
4a821e1
updating some messages
aya9aladdin Aug 26, 2022
ed05187
Update test_openmm_parser.py
aya9aladdin Aug 26, 2022
1032019
update documents
aya9aladdin Aug 26, 2022
7b0041c
Update test_openmm_parser.py
aya9aladdin Aug 26, 2022
2fe59fa
Update test_openmm_parser.py
aya9aladdin Aug 26, 2022
5d6550e
opemmm test
aya9aladdin Aug 27, 2022
6a1e4c5
Update default_guesser.py
aya9aladdin Aug 27, 2022
25aaf73
BaseGuesser documentation
aya9aladdin Aug 27, 2022
501e397
DefaultGuesser documentation
aya9aladdin Aug 27, 2022
d9a65a7
bond guessing + updating guessing API code + minor updates
aya9aladdin Sep 10, 2022
4395f6f
style fixes
aya9aladdin Sep 10, 2022
c234e75
Update universe.py
aya9aladdin Sep 10, 2022
fdb296c
fixing openmm parser message typos
aya9aladdin Sep 10, 2022
c4b200d
Update testsuite/MDAnalysisTests/converters/test_rdkit_parser.py
aya9aladdin Sep 12, 2022
a9b4354
Update testsuite/MDAnalysisTests/guesser/test_default_guesser.py
aya9aladdin Sep 12, 2022
965cd72
Update testsuite/MDAnalysisTests/core/test_universe.py
aya9aladdin Sep 12, 2022
6338a8e
restore table.py default style
aya9aladdin Sep 12, 2022
4324f72
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Sep 12, 2022
17fded8
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 17, 2022
4c29a39
pep styling
aya9aladdin Sep 17, 2022
9fa7b32
Update test_default_guesser.py
aya9aladdin Sep 17, 2022
f450c6f
pep styling
aya9aladdin Sep 17, 2022
f6b9b97
Apply suggestions from code review
aya9aladdin Sep 17, 2022
460d2f5
typos fixing
aya9aladdin Sep 17, 2022
af84927
adding partial guessing + parser tests + noValue topologyattr
aya9aladdin Sep 21, 2022
002e1d6
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 21, 2022
390ae37
Apply suggestions from code review
aya9aladdin Sep 21, 2022
a5c303c
Update base.py
aya9aladdin Sep 21, 2022
b01b092
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Sep 21, 2022
61831f8
Update bat.py
aya9aladdin Sep 21, 2022
7f638fb
Update bat.py
aya9aladdin Sep 21, 2022
cd37c19
Update bat.py
aya9aladdin Sep 21, 2022
71e9a2b
Update bat.py
aya9aladdin Sep 21, 2022
084ab13
removing test skipping
aya9aladdin Sep 21, 2022
fa9128a
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 21, 2022
991070c
update txyz
aya9aladdin Sep 21, 2022
62c43cd
variable names update + partial guessing updates
aya9aladdin Sep 25, 2022
314b31c
Apply suggestions from code review
aya9aladdin Sep 26, 2022
0dcbacd
Adding docstring
aya9aladdin Sep 27, 2022
9a230a4
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Sep 27, 2022
f82bdcf
fix typo in topology tests + add element to ITPParser
aya9aladdin Sep 28, 2022
6f6f634
Added tests for BaseGuesser + updating guess_Attr()
aya9aladdin Sep 30, 2022
40ef1ed
update docstring of guess_attr
aya9aladdin Sep 30, 2022
9222d96
removed parser checking for auto-guessing
aya9aladdin Oct 12, 2022
b712a77
restoring old style
aya9aladdin Oct 12, 2022
8724bba
Apply suggestions from code review
aya9aladdin Oct 12, 2022
0abb069
removing autopep8 effect
aya9aladdin Oct 12, 2022
c1b05ba
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Oct 12, 2022
02d62b1
add comment to bat.py::_sort_atoms_by_mass
aya9aladdin Oct 12, 2022
710df7d
Update OpenMM.py
aya9aladdin Oct 12, 2022
d7cb653
Update universe.py
aya9aladdin Oct 13, 2022
5f6a6f3
passing empty attribute indices for partial guessing
aya9aladdin Oct 14, 2022
f12e5f1
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Oct 14, 2022
d76362b
updating docstring
aya9aladdin Oct 15, 2022
a8ba36c
Merge branch 'MDAnalysis:develop' into guesser-basics
aya9aladdin Oct 15, 2022
49c803c
solve universe unpickle issue
aya9aladdin Oct 15, 2022
f816441
Update test_h5md.py
aya9aladdin Oct 15, 2022
e1347a7
override is_value_missing for Masses class
aya9aladdin Oct 18, 2022
3ebce3f
default guesser pdep8 upates
aya9aladdin Oct 18, 2022
10cad41
pep8 updates
aya9aladdin Oct 18, 2022
626cb39
pep8 updates
aya9aladdin Oct 18, 2022
b476301
remove unrelated analysis module tests
aya9aladdin Oct 18, 2022
3fbdc46
remove line from test_encore.py
aya9aladdin Oct 18, 2022
7b42095
remove autopep8 effect from testpositionaveraging.py
aya9aladdin Oct 19, 2022
21aae8e
Update test_positionaveraging.py
aya9aladdin Oct 19, 2022
3e5a9e9
add guesser tests + pep8 updates
aya9aladdin Oct 19, 2022
98d91fe
restore universe.Merge docstring formatting
aya9aladdin Oct 19, 2022
78654e5
remove autopep8 effect from universe.py
aya9aladdin Oct 19, 2022
a954aee
remove autopep8 effect from universe.py
aya9aladdin Oct 19, 2022
dfb3761
Apply suggestions from code review
aya9aladdin Oct 19, 2022
3df1d9b
removing autopep8 effect from irrelevant parts + adding pep styles
aya9aladdin Oct 19, 2022
e273d68
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Oct 19, 2022
4ad3948
finishing pep8 styling
aya9aladdin Oct 19, 2022
1518729
docstring updates
aya9aladdin Oct 19, 2022
d1e27e3
restore a useful autopep8 change
aya9aladdin Oct 20, 2022
348f62d
add guessing elements from masses to DefaultGuesser
aya9aladdin Oct 20, 2022
e2c03cd
Update test_default_guesser.py
aya9aladdin Oct 20, 2022
ad50c17
added tests to DefaultGuesser and GuesserBasics
aya9aladdin Oct 20, 2022
7663a5b
Update base.py
aya9aladdin Oct 20, 2022
aece5bc
update docstring
aya9aladdin Oct 23, 2022
6175b37
Update topology_modules.rst
aya9aladdin Oct 23, 2022
52fcb41
Merge branch 'develop' into guesser-basics
aya9aladdin Jan 28, 2023
a463561
Revert "Merge branch 'develop' into guesser-basics"
aya9aladdin Jan 28, 2023
d67c921
Revert "Revert "Merge branch 'develop' into guesser-basics""
aya9aladdin Jan 28, 2023
492ccd7
Revert "Revert "Merge branch 'develop' into guesser-basics""
aya9aladdin Jan 29, 2023
f50a7b1
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Jan 29, 2023
3dc7535
silencing guessing processes in some tests
aya9aladdin Feb 20, 2023
2e8d863
silencing guessing process in irrelevant tests
aya9aladdin Feb 25, 2023
a22afc0
style fixations
aya9aladdin Feb 26, 2023
0285dd1
fix styling
aya9aladdin Feb 26, 2023
476444e
style fixations
aya9aladdin Feb 26, 2023
3c3df98
add guesser context + removing styling errors in ITP
aya9aladdin Mar 3, 2023
6be3ec4
Update universe.py
aya9aladdin Mar 3, 2023
7b0ce2e
copy method of Guesser class
aya9aladdin Mar 3, 2023
aaf1d08
Update universe.py
aya9aladdin Mar 3, 2023
1fd7d69
pass universe context to serialisation methods
aya9aladdin Mar 3, 2023
e29d3e6
Update universe.py
aya9aladdin Mar 3, 2023
f64ca1d
update changelog and versionchanged
aya9aladdin Mar 10, 2023
c0ff781
Merge branch 'develop' into guesser-basics
aya9aladdin Mar 10, 2023
58a0d75
docstring error
aya9aladdin Mar 10, 2023
2291a4d
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Mar 10, 2023
21950f6
typo fixing
aya9aladdin Mar 10, 2023
e7c0241
Update CHANGELOG
aya9aladdin Mar 10, 2023
c0ce6e0
Merge branch 'develop' into guesser-basics
aya9aladdin Apr 27, 2023
b776f09
Update groups.py
aya9aladdin Apr 28, 2023
1d8e2cd
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 10, 2023
fc18d4f
updating CHANGELOG + versionchanged doc
aya9aladdin Sep 10, 2023
06211cc
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 12, 2023
240af1c
improving guess_attr + updating changelog
aya9aladdin Sep 12, 2023
ff71b1a
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 17, 2023
2aeb0fc
removed types from FHIAMSParser and XYZParser
aya9aladdin Sep 17, 2023
7580855
Update CHANGELOG
aya9aladdin Sep 17, 2023
202d62a
added DefaultGuesser tests
aya9aladdin Sep 24, 2023
27fcf3b
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 24, 2023
5c5c684
Merge branch 'develop' into guesser-basics
aya9aladdin Nov 6, 2023
5ccd1d1
Update package/CHANGELOG
aya9aladdin Dec 27, 2023
b343d11
Update package/CHANGELOG
aya9aladdin Dec 27, 2023
b3f292d
Merge branch 'develop' into guesser-basics
aya9aladdin Dec 27, 2023
8dc935b
Apply suggestions from code review
aya9aladdin Dec 27, 2023
51c75a6
silencing auto guessing in coordinates tests
aya9aladdin Dec 27, 2023
e1e5b3e
applying @lilyminium suggestions
aya9aladdin Dec 27, 2023
68580ea
applying @lilyminium code review suggesitions
aya9aladdin Jan 6, 2024
6da8ca8
removed guessed_types/masses tests
aya9aladdin Jan 6, 2024
5d505a4
Apply suggestions from code review
aya9aladdin Feb 1, 2024
934d7e6
Merge branch 'develop' into guesser-basics
aya9aladdin Feb 1, 2024
c7ca389
removed guessed_types/masses + unnecessary imports
aya9aladdin Feb 1, 2024
14a6ed2
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Feb 1, 2024
bd12db2
fixed test_itp typo + removed guessed_attrs errors
aya9aladdin Feb 1, 2024
88bb017
Adding more tests
aya9aladdin Feb 1, 2024
40c7632
Merge branch 'develop' into guesser-basics
aya9aladdin Mar 16, 2024
28aeb6a
adding guesser tests
aya9aladdin Mar 16, 2024
da15709
adding tests for DefaultGuesser
aya9aladdin Mar 16, 2024
83ee7f5
adding final tests + styling
aya9aladdin Mar 25, 2024
c67dc3a
Removing old modules + updating CHANGELOG
aya9aladdin Mar 26, 2024
ca43651
Merge branch 'develop' into guesser-basics
aya9aladdin Mar 26, 2024
67ad49e
fix importing error
aya9aladdin Mar 26, 2024
5ee7bae
Merge branch 'guesser-basics' of https://github.com/aya9aladdin/mdana…
aya9aladdin Mar 26, 2024
817cab1
removing guessing part from topology docs
aya9aladdin Mar 26, 2024
6f60435
updating docs
aya9aladdin Mar 30, 2024
a946156
Merge branch 'develop' into guesser-basics
aya9aladdin Mar 31, 2024
ba9deaf
Merge branch 'develop' into guesser-basics
aya9aladdin Apr 17, 2024
fc0ebe6
Apply suggestions from code review
aya9aladdin Apr 21, 2024
4976166
fixing styling
aya9aladdin Apr 26, 2024
77fb208
fixing styling issue + rdkitparser tests
aya9aladdin May 19, 2024
eeaf35a
Apply LAST suggestions from code review
aya9aladdin Sep 17, 2024
80a1b74
Merge branch 'develop' into guesser-basics
aya9aladdin Sep 17, 2024
8986a97
- removed guessing types from masses
aya9aladdin Sep 17, 2024
c0b833e
Update CHANGELOG
aya9aladdin Sep 17, 2024
00dff7c
Update universe.py
aya9aladdin Sep 17, 2024
1c15f21
Merge branch 'develop' into guesser-basics
IAlibay Sep 29, 2024
7cc0341
Update package/CHANGELOG
IAlibay Oct 17, 2024
c225f75
Merge remote-tracking branch 'upstream/develop' into guesser-basics
lilyminium Oct 19, 2024
e7ddaaf
Merge branch 'develop' into guesser-basics
lilyminium Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/MDAnalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
_TOPOLOGY_ATTRS = {} # {attrname: cls}
_TOPOLOGY_TRANSPLANTS = {} # {name: [attrname, method, transplant class]}
_TOPOLOGY_ATTRNAMES = {} # {lower case name w/o _ : name}

_GUESSERS = {}

# custom exceptions and warnings
from .exceptions import (
Expand Down
8 changes: 0 additions & 8 deletions package/MDAnalysis/converters/OpenMMParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

from ..topology.base import TopologyReaderBase
from ..topology.tables import SYMB2Z
from ..topology.guessers import guess_types, guess_masses
from ..core.topology import Topology
from ..core.topologyattrs import (
Atomids,
Expand Down Expand Up @@ -108,11 +107,6 @@ def _mda_topology_from_omm_topology(self, omm_topology):
-------
top : MDAnalysis.core.topology.Topology

Note
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we transplanting this back in? This behaviour can't change for the 2.x release of MDA.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the guessing behavior is transferred to the universe through the guess_topologyAttribute API without breaking default behavior

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To double check, we are removing this note because the default behaviour is equivalent to this note?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes indeed... the idea is this is no longer specific/happening inside the parser

----
When none of the elements are present in the openmm topolgy, their
atomtypes are guessed using their names and their masses are
then guessed using their atomtypes.

When partial elements are present, values from available elements
are used whereas the absent elements are assigned an empty string
Expand Down Expand Up @@ -192,8 +186,6 @@ def _mda_topology_from_omm_topology(self, omm_topology):
dtype=object)))

else:
atomtypes = guess_types(atomnames)
masses = guess_masses(atomtypes)
wmsg = ("Element information is missing for all the atoms. "
"Elements attribute will not be populated. "
"Atomtype attribute will be guessed using atom "
Expand Down
8 changes: 2 additions & 6 deletions package/MDAnalysis/converters/RDKitParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import numpy as np

from ..topology.base import TopologyReaderBase, change_squash
from ..topology import guessers
from ..core.topologyattrs import (
Atomids,
Atomnames,
Expand Down Expand Up @@ -97,9 +96,6 @@ class RDKitParser(TopologyReaderBase):
- RSChirality
- Segids

Guesses the following:
IAlibay marked this conversation as resolved.
Show resolved Hide resolved
- Atomtypes

Depending on RDKit's input, the following Attributes might be present:
- Charges
- Resnames
Expand Down Expand Up @@ -303,8 +299,8 @@ def parse(self, **kwargs):
if atomtypes:
attrs.append(Atomtypes(np.array(atomtypes, dtype=object)))
else:
atomtypes = guessers.guess_types(names)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the types used to be guessed rather than just assigned elements? The change looks reasonable to me, but I am worried there is a subtlety we may be missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all type guessing from parsers and transferred it to be guessed at the universe creation. For PDB, FIAMS, XYZP and RDKit parsers, I assigned the atomtypes to be either read from the file if not be assigned to elements, if not be assigned to names (as per issue #2931). but if we are not ready for this move I'll remove it no worries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK. I just wanted to avoid missing something. We should keep note of that and maybe have it a separate entry in the changelog.

We will also need to be careful with the tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To what extent does this change behaviour? Does this amount to a breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked the test for that yet. Hopefully, it should not be a problem, except... The one case I see that could break is if the type was guessed as CA because we historically have an alpha carbon type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not change the types that were guessed, the "CA" is guessed as a "C" in both develop and this PR:

import MDAnalysis as mda
from rdkit import Chem
u = mda.Universe.empty(1, 1, 1, trajectory=True)
u.atoms.positions = [[0, 0, 0]]
u.add_TopologyAttr("names", ["CA"])
u.atoms.write("ca.pdb")
rdmol = Chem.MolFromPDBFile("ca.pdb")
u2 = mda.Universe(rdmol)

u2.atoms.types and elements is "C", u2.atoms.names stays "CA".

attrs.append(Atomtypes(atomtypes, guessed=True))
atomtypes = elements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be upper case, since atomtypes are always upper case when guessed.

attrs.append(Atomtypes(atomtypes))

# Partial charges
if charges:
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/coordinates/PDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
from ..lib.util import store_init_arguments
from . import base
from .timestep import Timestep
from ..topology.core import guess_atom_element
from ..exceptions import NoDataError


Expand Down
22 changes: 11 additions & 11 deletions package/MDAnalysis/core/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3262,16 +3262,16 @@ def split(self, level):
return [self[levelindices == index] for index in
unique_int_1d(levelindices)]

def guess_bonds(self, vdwradii=None):
def guess_bonds(self, vdwradii=None, context='default'):
"""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


Dict relating atom types: vdw radii
context : string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
context : string
context : str

context of the universe
aya9aladdin marked this conversation as resolved.
Show resolved Hide resolved
See Also
--------
:func:`MDAnalysis.topology.guessers.guess_bonds`
Expand All @@ -3281,9 +3281,8 @@ def guess_bonds(self, vdwradii=None):
.. versionchanged:: 0.20.2
Now applies periodic boundary conditions when guessing bonds.
"""
from ..topology.core import guess_bonds, guess_angles, guess_dihedrals
from .topologyattrs import Bonds, Angles, Dihedrals

from ..guesser.base import get_guesser
def get_TopAttr(u, name, cls):
"""either get *name* or create one from *cls*"""
try:
Expand All @@ -3292,18 +3291,19 @@ def get_TopAttr(u, name, cls):
attr = cls([])
u.add_TopologyAttr(attr)
return attr

guesser = get_guesser(context, atoms=self.atoms,
positions=self.atoms.positions,
vdwradii=vdwradii, box=self.dimensions)
# indices of bonds
b = guess_bonds(self.atoms, self.atoms.positions,
vdwradii=vdwradii, box=self.dimensions)
b = guesser.guess_Attr('bonds')
bondattr = get_TopAttr(self.universe, 'bonds', Bonds)
bondattr._add_bonds(b, guessed=True)

a = guess_angles(self.bonds)
a = guesser.guess_Attr('angles', bonds=self.bonds)
angleattr = get_TopAttr(self.universe, 'angles', Angles)
angleattr._add_bonds(a, guessed=True)

d = guess_dihedrals(self.angles)
d = guesser.guess_Attr('dihedrals', angles=self.angles)
diheattr = get_TopAttr(self.universe, 'dihedrals', Dihedrals)
diheattr._add_bonds(d)

Expand Down
Loading