Skip to content

Commit

Permalink
Merge pull request #82 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Incorrect coordinates from PubChem
  • Loading branch information
seamm authored Oct 1, 2024
2 parents 985d037 + 4678630 commit 48e3573
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.10.1 -- Bugfix: Incorrect coordinates from PubChem
* Fixed bug where the coordinates from PubChem were accidentally the 2-D rather than
3-D coordinates.

2024.8.17 -- Bugfix: current configuration not updated properly
* Existing instances of systems did not correctly update when the default
configuration was changed. This is release fixes the problem.
Expand Down
3 changes: 2 additions & 1 deletion molsystem/pubchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def PC_from_identifier(self, identifier, namespace="detect", fallback=None):

for namespace in namespaces:
response = requests.get(
f"{pug_url}/compound/{namespace}/{url_quote(identifier)}/SDF"
f"{pug_url}/compound/{namespace}/{url_quote(identifier)}/"
"SDF?record_type=3d"
)
if response.status_code == 200:
self.from_sdf_text(response.text)
Expand Down
34 changes: 34 additions & 0 deletions tests/test_pubchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,37 @@ def test_from_name(configuration):
if name != correct:
print(name)
assert name == correct


def test_coordinates_from_name(configuration):
"""Get the system from a name"""
correct = [
[0.0, 0.0, 0.0],
[-0.4417, 0.2906, 0.8711],
[0.7256, 0.6896, -0.1907],
[0.4875, -0.8701, 0.2089],
]

configuration.PC_from_identifier("ammonia")

coordinates = configuration.coordinates
if coordinates != correct:
print(coordinates)
assert coordinates == correct


def test_coordinates_from_smiles(configuration):
"""Get the system from SMILES"""
correct = [
[0.0, 0.0, 0.0],
[-0.4417, 0.2906, 0.8711],
[0.7256, 0.6896, -0.1907],
[0.4875, -0.8701, 0.2089],
]

configuration.PC_from_identifier("N", namespace="smiles")

coordinates = configuration.coordinates
if coordinates != correct:
print(coordinates)
assert coordinates == correct

0 comments on commit 48e3573

Please sign in to comment.