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

Updates for QCFractal 0.54 and OFFTK 0.16 #277

Merged
merged 22 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 24.3.0
rev: 24.4.0
hooks:
- id: black
files: ^openff
Expand All @@ -32,3 +32,5 @@ repos:
- id: nbqa-flake8
args:
- '--select=F'
default_language_version:
python: python3.11
2 changes: 1 addition & 1 deletion devtools/conda-envs/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:

- qcengine >=0.25
- qcelemental >=0.25.1
- qcfractal =0.53
- qcfractal >=0.54
- qcarchivetesting
- qcportal

Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/psi4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:

- qcengine >=0.25
- qcelemental >=0.25.1
- qcfractal =0.53
- qcfractal >=0.54
- qcarchivetesting
- qcportal

Expand Down
16 changes: 14 additions & 2 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ Releases follow the ``major.minor.micro`` scheme recommended by

Releases are given with dates in DD-MM-YYYY format.

## Current development
<!--## Version / Date DD-MM-YYYY -->
## 0.51.0 / 23-04-2024

### Behaviors changed

* [PR #277:] Changes the behavior of the `max_states` named argument to `workflow_components.EnumerateProtomers`. Previously this could return anywhere from `1` to `max_states+2`, but now it can return `1` to `max_states+1` (depending on whether the backend includes the input in the protomers that are generated).

### Bugfixes

* [PR #277:] Updates for QCPortal 0.54 (#275) and OpenFF Toolkit 0.16 (#278) [@bennybp @mattwthompson @j-wags]


## 0.50.3 / 24-03-2024

### Bugfixes

Expand All @@ -21,7 +33,6 @@ Releases are given with dates in DD-MM-YYYY format.

* [PR #270:] Speed up `TorsionDriveResultCollection.to_records` by batching requests [@ntBre]

<!--## Version / Date DD-MM-YYYY -->
## 0.50.2 / 24-01-2024

### New Features
Expand Down Expand Up @@ -111,6 +122,7 @@ For more information on this release, see https://github.com/openforcefield/open
[PR #260:]: https://github.com/openforcefield/openff-qcsubmit/pull/260
[PR #268:]: https://github.com/openforcefield/openff-qcsubmit/pull/268
[PR #270:]: https://github.com/openforcefield/openff-qcsubmit/pull/270
[PR #277:]: https://github.com/openforcefield/openff-qcsubmit/pull/277

[@jthorton]: https://github.com/jthorton
[@dotsdl]: https://github.com/dotsdl
Expand Down
2 changes: 1 addition & 1 deletion openff/qcsubmit/_tests/results/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def mock_torsion_drive_result_collection(
),
),
),
initial_molecules_ids_=[
initial_molecules_ids=[
i + 1
for i in range(
molecules[address][int(entry.record_id) - 1].n_conformers
Expand Down
2 changes: 1 addition & 1 deletion openff/qcsubmit/_tests/results/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def test_torsion_smirnoff_coverage(public_client, monkeypatch):
),
),
id=entry.record_id,
initial_molecules_=[],
initial_molecules=[],
status=RecordStatusEnum.complete,
is_service=False,
created_on=datetime.datetime(2022, 4, 21, 0, 0, 0),
Expand Down
6 changes: 3 additions & 3 deletions openff/qcsubmit/_tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_componentresult_str():
)


def test_componetresult_deduplication_standard():
def test_componentresult_deduplication_standard():
"""
Test the components results ability to deduplicate molecules.
"""
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_componetresult_deduplication_standard():
assert len(result.filtered) == 0


def test_componetresult_directory():
def test_componentresult_directory():
"""
Test loading up some molecules from a directory of files.
"""
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_componetresult_directory():
pytest.param("hdf5-example.hdf5", id="HDF5 file"),
],
)
def test_componetresult_input_file(file_name):
def test_componentresult_input_file(file_name):
"""
Test loading up some molecules from an input file
"""
Expand Down
1 change: 1 addition & 0 deletions openff/qcsubmit/_tests/test_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ def test_invalid_cmiles(fulltest_client, factory_type, result_collection_type):
entries[0].attributes[
"canonical_isomeric_explicit_hydrogen_mapped_smiles"
] = "[H:4][C:2](=[O:1])[OH:3]"
ds._cache_data.update_entries(entries)
results = result_collection_type.from_datasets(datasets=ds)
assert results.n_molecules == 1
with pytest.warns(UserWarning, match="invalid CMILES"):
Expand Down
35 changes: 34 additions & 1 deletion openff/qcsubmit/_tests/test_workflow_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,40 @@ def test_enumerating_protomers_apply():

assert mol in result.molecules
# this means that the parent molecule was included
assert result.n_molecules == 3
assert result.n_molecules == 2

# Test that the input is always in the output, even when it
# wouldn't have been generated as a possible protomer
enumerate_protomers = workflow_components.EnumerateProtomers(max_states=1)
weird_mol = Molecule.from_smiles("[N-]([H])[H]")

result = enumerate_protomers.apply(
[
weird_mol,
],
processors=1,
toolkit_registry=GLOBAL_TOOLKIT_REGISTRY,
)

assert weird_mol in result.molecules
# this means that the parent molecule was included
assert result.n_molecules == 2

# Test that the deduplication works (this molecule has exactly 4 protomers,
# so asking for up to 5 states should yield 4)
enumerate_protomers = workflow_components.EnumerateProtomers(max_states=5)
mol = Molecule.from_smiles("Oc2ccc(c1ccncc1)cc2")
result = enumerate_protomers.apply(
[
mol,
],
processors=1,
toolkit_registry=GLOBAL_TOOLKIT_REGISTRY,
)

assert mol in result.molecules
# this means that the parent molecule was included
assert result.n_molecules == 4


def test_coverage_filter_remove():
Expand Down
2 changes: 1 addition & 1 deletion openff/qcsubmit/utils/smirnoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def combine_openff_molecules(molecules: List[Molecule]) -> Molecule:

master_mol = copy.deepcopy(molecules.pop(0))
conformers = [*master_mol.conformers]
master_mol._conformers = []
master_mol._conformers = None
index_map = {}
for molecule in molecules:
for atom in molecule.atoms:
Expand Down
2 changes: 1 addition & 1 deletion openff/qcsubmit/utils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _create_openeye_pdf(molecules: List[Molecule], file_name: str, columns: int)
# now we load the molecules
for off_mol in molecules:
off_mol = copy.deepcopy(off_mol)
off_mol._conformers = []
off_mol._conformers = None
off_mol.name = None

cell = report.NewCell()
Expand Down
5 changes: 4 additions & 1 deletion openff/qcsubmit/workflow_components/state_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _apply(
self, molecules: List[Molecule], toolkit_registry: ToolkitRegistry
) -> ComponentResult:
"""
Enumerate the formal charges of the molecule.
Enumerate the protonation states of the molecule.

Parameters:
molecules: The list of molecules the component should be applied on.
Expand All @@ -212,6 +212,9 @@ def _apply(
Returns:
A [ComponentResult][qcsubmit.datasets.ComponentResult] instance containing information about the molecules
that passed and were filtered by the component and details about the component which generated the result.
Note that the input molecule is guaranteed to be included in this output, which in some cases may cause the
number of molecules in the result to be one greater than max_states, or may cause a molecule in the results
to have multiple conformers.

Important:
This is only possible using Openeye so far, if openeye is not available this step will fail.
Expand Down
9 changes: 6 additions & 3 deletions openff/qcsubmit/workflow_components/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def n_impropers(self) -> int:

class ComponentResult:
"""
Class to contain molecules after the execution of a workflow component this automatically applies de-duplication to
Class to contain molecules after the execution of a workflow component. This automatically applies de-duplication to
the molecules. For example if a molecule is already in the molecules list it will not be added but any conformers
will be kept and transferred.

Expand Down Expand Up @@ -760,7 +760,10 @@ def add_molecule(self, molecule: off.Molecule) -> bool:
new_conf = unit.Quantity(new_conformer, unit.angstrom)

# check if the conformer is already on the molecule
for old_conformer in self._molecules[molecule_hash].conformers:
old_conformers = self._molecules[molecule_hash].conformers
if old_conformers is None:
old_conformers = []
for old_conformer in old_conformers:
if old_conformer.tolist() == new_conf.tolist():
break
else:
Expand All @@ -772,7 +775,7 @@ def add_molecule(self, molecule: off.Molecule) -> bool:
else:
if molecule.n_conformers == 0:
# make sure this is a list to avoid errors
molecule._conformers = []
molecule._conformers = None
self._molecules[molecule_hash] = molecule
return False

Expand Down
Loading