Skip to content

Commit

Permalink
Fix conformer generation array typing and update CI (#97)
Browse files Browse the repository at this point in the history
* remove oe from examples ci

* add alkane labelling as test

* expand mapped smiles allowed values

* add back ambertools

* set openeye to false in ci

* fix conformer array typing

* rm accidental data

* try just explicitly specifying ambertools

* update docs env

* just get away with docs env?

* update CHANGELOG
  • Loading branch information
lilyminium committed Mar 22, 2024
1 parent 7cbbc7f commit dab0350
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
python-version: ["3.9", "3.10", "3.11"]
pydantic-version: ["2"]
include-rdkit: [true]
include-openeye: [true]
include-openeye: [false]
include-dgl: [true]
exclude:
# broken OpenMM build for Mac on 3.10
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ jobs:
# broken OpenMM build for Mac on 3.10
- os: "macOS-latest"
python-version: "3.10"
# no dgl for 3.12 yet on Mac
- include-dgl: true
python-version: "3.12"
# Can't support 3.12 on Mac yet
- python-version: "3.12"
os: "macOS-latest"
# no openeye for 3.12 yet
- include-openeye: true
Expand Down Expand Up @@ -191,7 +190,6 @@ jobs:
conda activate openff-nagl
conda list
mamba env update --name openff-nagl --file devtools/conda-envs/test_env_dgl_false.yaml
mamba env update --name openff-nagl --file devtools/conda-envs/docs_env.yaml
python --version
python -m pip install . --no-deps
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ The rules for this file:
* accompany each entry with github issue/PR number (Issue #xyz)
-->

## v0.3.6 -- 2024-03-22

### Authors
- @lilyminium

### Fixed
- Fixed typing of conformer generation from RDKit (PR #97)

## v0.3.5 -- 2024-03-21

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

# chemistry
- openff-toolkit-base ==0.11.1
- openff-toolkit-base >=0.11.1
- openff-units
- pydantic <2.0
- rdkit
Expand Down
2 changes: 0 additions & 2 deletions devtools/conda-envs/examples_env.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: openff-nagl-test
channels:
- openeye
- conda-forge
- defaults
dependencies:
Expand All @@ -25,7 +24,6 @@ dependencies:
- openff-recharge
- pydantic <3
- rdkit
- openeye-toolkits

# database
- pyarrow
Expand Down
1 change: 1 addition & 0 deletions devtools/conda-envs/test_env_dgl_false.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- pydantic <3
- rdkit
- scipy
- ambertools

# database
- pyarrow
Expand Down
1 change: 1 addition & 0 deletions devtools/conda-envs/test_env_dgl_true.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- pydantic <3
- rdkit
- scipy
- ambertools

# database
- pyarrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion openff/nagl/label/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def apply(
conformers = np.ravel([
conformer.m_as(unit.angstrom)
for conformer in mol.conformers
])
]).astype(float)
data[self.conformer_column].append(conformers)
data[self.n_conformer_column].append(len(mol.conformers))

Expand Down
59 changes: 58 additions & 1 deletion openff/nagl/tests/label/test_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,63 @@ def test_label_with_conformers_on_fly(self, small_dataset):
columns = ["mapped_smiles", "conformers", "n_conformers", "charges"]
assert small_dataset.dataset.schema.names == columns

def test_label_alkane_dataset(self):
# test conformer generation and labelling
# as in examples

training_alkanes = [
'C',
'CC',
'CCC',
'CCCC',
'CC(C)C',
'CCCCC',
'CC(C)CC',
'CCCCCC',
'CC(C)CCC',
'CC(CC)CC',
]

training_dataset = LabelledDataset.from_smiles(
"training_data",
training_alkanes,
mapped=False,
overwrite_existing=True,
)
training_df = training_dataset.to_pandas()
assert training_df.mapped_smiles[0] in (
"[H:2][C:1]([H:3])([H:4])[H:5]",
"[C:1]([H:2])([H:3])([H:4])[H:5]"
)

label_conformers = LabelConformers(
# create a new 'conformers' with output conformers
conformer_column="conformers",
# create a new 'n_conformers' with number of conformers
n_conformer_column="n_conformers",
n_conformer_pool=500, # initially generate 500 conformers
n_conformers=10, # prune to max 10 conformers
rms_cutoff=0.05,
)

label_am1_charges = LabelCharges(
charge_method="am1-mulliken", # AM1
# use previously generate conformers instead of new ones
use_existing_conformers=True,
# use the 'conformers' column as input for charge assignment
conformer_column="conformers",
# write generated charges to 'target-am1-charges' column
charge_column="target-am1-charges",
)

labellers = [
label_conformers, # generate initial conformers,
label_am1_charges,
]

training_dataset.apply_labellers(labellers)



class TestLabelMultipleDipoles:

Expand Down Expand Up @@ -174,4 +231,4 @@ def test_apply_label(self, dataset_with_conformers_and_charges):

calculated_esps = pydict["esps"]
for esps, lengths in zip(calculated_esps, calculated_esp_lengths):
assert len(esps) == sum(lengths)
assert len(esps) == sum(lengths)

0 comments on commit dab0350

Please sign in to comment.