Skip to content

Commit

Permalink
Merge pull request #193 from andrewtarzia/clean_deps
Browse files Browse the repository at this point in the history
Clean dependencies to save install time.
  • Loading branch information
andrewtarzia authored Dec 13, 2024
2 parents c39a56a + 73204e4 commit e18f096
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 114 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Build environment
run: |
conda activate pytest
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4 espaloma_charge
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install -e '.[dev]'
Expand All @@ -79,7 +79,7 @@ jobs:
- name: Build environment
run: |
conda activate pytest
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4 espaloma_charge
conda install -c conda-forge mdanalysis openbabel
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
Expand All @@ -104,7 +104,7 @@ jobs:
- name: Build environment
run: |
conda activate pytest
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4
conda install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4 espaloma_charge
conda install -c conda-forge mdanalysis openbabel
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Some optional dependencies are only available through conda:
# for OpenMM and espaloma charge
# note the temporary issue with rdkit versions and conda will overwrite pip
# installed software
mamba install openff-toolkit openmm openmmtools dgl rdkit==2024.3.4
mamba install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4 espaloma_charge
# for xtb
mamba install xtb
# for openbabel
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Some optional dependencies are only available through conda:
# for OpenMM and espaloma charge
# note the temporary issue with rdkit versions and conda will overwrite pip
# installed software
mamba install openff-toolkit openmm openmmtools dgl rdkit==2024.3.4
mamba install -c conda-forge openff-toolkit openmm openmmtools dgl rdkit==2024.3.4 espaloma_charge
# for xtb
mamba install xtb
# for openbabel
Expand Down
13 changes: 6 additions & 7 deletions examples/cage_openmm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def main() -> None:

# Settings.
force_field = ForceField("openff_unconstrained-2.1.0.offxml")
partial_charges = "espaloma-am1bcc"
temperature = 700 * openmm.unit.kelvin
friction = 10 / openmm.unit.picoseconds
time_step = 1 * openmm.unit.femtoseconds
Expand All @@ -55,15 +54,15 @@ def main() -> None:
stko.OpenMMForceField(
force_field=force_field,
restricted=True,
partial_charges_method=str(partial_charges),
partial_charges_method="espaloma-am1bcc",
),
# Unrestricted optimisation.
stko.OpenMMForceField(
# Load the openff-2.1.0 force field appropriate for
# vacuum calculations (without constraints)
force_field=force_field,
restricted=False,
partial_charges_method=partial_charges,
partial_charges_method="espaloma-am1bcc",
),
# Molecular dynamics, short for equilibration.
stko.OpenMMMD(
Expand All @@ -75,7 +74,7 @@ def main() -> None:
time_step=time_step,
),
random_seed=275,
partial_charges_method=partial_charges,
partial_charges_method="espaloma-am1bcc",
# Frequency here is not related to the num confs tested.
reporting_freq=100,
trajectory_freq=100,
Expand All @@ -86,7 +85,7 @@ def main() -> None:
conformer_optimiser=stko.OpenMMForceField(
force_field=force_field,
restricted=False,
partial_charges_method=partial_charges,
partial_charges_method="espaloma-am1bcc",
),
),
# Long MD, for collecting lowest energy conformers.
Expand All @@ -99,7 +98,7 @@ def main() -> None:
time_step=time_step,
),
random_seed=275,
partial_charges_method=partial_charges,
partial_charges_method="espaloma-am1bcc",
# Frequency here is not related to the num confs tested.
reporting_freq=100,
trajectory_freq=100,
Expand All @@ -111,7 +110,7 @@ def main() -> None:
conformer_optimiser=stko.OpenMMForceField(
force_field=force_field,
restricted=False,
partial_charges_method=partial_charges,
partial_charges_method="espaloma-am1bcc",
),
),
)
Expand Down
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ docs:
# Install development environment.
dev:
pip install -e '.[dev]'
mamba install -y -c conda-forge openff-toolkit openmm openmmtools rdkit==2024.3.4 dgl espaloma_charge
mamba install -y xtb
mamba install -y openbabel
mamba install -y mdanalysis


# Run code checks.
check:
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ maintainers = [
dependencies = [
# Remove pin once openmm infrastructure is safely moved to >= 2.
"numpy < 2",
"rdkit != 2024.3.5",
# Pinned while rdkit changes stk results.
"rdkit == 2024.3.4",
"stk",
"networkx",
"rmsd",
"espaloma-charge",
]
requires-python = ">=3.11"
dynamic = ["version"]
Expand Down Expand Up @@ -59,8 +59,6 @@ line-length = 79
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN101",
"ANN102",
"ANN401",
"COM812",
"ISC001",
Expand Down Expand Up @@ -137,5 +135,6 @@ module = [
"openmmforcefields.*",
"rmsd.*",
"espaloma_charge.*",
"traitlets.*",
]
ignore_missing_imports = true
152 changes: 76 additions & 76 deletions src/stko/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,99 +126,99 @@
"""Type parameter matching :class:`stk.ConstructedMolecule` or subclasses."""

__all__ = [
"functional_groups",
"molecule_analysis",
"OrcaExtractor",
"OpenBabelEnergy",
"OrcaEnergy",
"PlanarityCalculator",
"MMFFEnergy",
"UFFEnergy",
"EnergyResults",
"ConstructedMoleculeTorsionResults",
"TorsionResults",
"XTBResults",
"RmsdCalculator",
"RmsdMappedCalculator",
"KabschRmsdCalculator",
"ShapeCalculator",
"OrcaResults",
"PlanarityResults",
"RmsdResults",
"ShapeResults",
"ConstructedMoleculeTorsionCalculator",
"MatchedTorsionCalculator",
"TorsionCalculator",
"XTBExtractor",
"XTBEnergy",
"Du",
"PositionedAtom",
"MDAnalysis",
"ZMatrix",
"MoleculeSplitter",
"MoleculeTransformer",
"Network",
"UnitCell",
"cap_absolute_value",
"get_approximate_cell_size",
"get_from_parameters",
"TopologyExtractor",
"TopologyInfo",
"Torsion",
"TorsionInfo",
"Aligner",
"AlignmentPotential",
"Collapser",
"CollapserMC",
"GulpUFFMDOptimizer",
"GulpUFFOptimizer",
"MacroModelForceField",
"MacroModelMD",
"Optimizer",
"OptimizerSequence",
"OptWriterSequence",
"TryCatchOptimizer",
"NullOptimizer",
"ETKDG",
"MMFF",
"UFF",
"MetalOptimizer",
"MAEExtractor",
"get_metal_atoms",
"move_generated_macromodel_files",
"mol_from_mae_file",
"XTB",
"XTBFF",
"XTBCREST",
"XTBFF",
"XTBFFCREST",
"Aligner",
"AlignmentPotential",
"CalculatorError",
"Collapser",
"CollapserMC",
"ConstructedMoleculeT",
"MoleculeT",
"OpenBabel",
"OpenMMForceField",
"OpenMMMD",
"OpenMMEnergy",
"WrapperNotInstalledError",
"DifferentMoleculeError",
"DifferentAtomError",
"InputError",
"PathError",
"ConstructedMoleculeTorsionCalculator",
"ConstructedMoleculeTorsionResults",
"ConvergenceError",
"CalculatorError",
"ConversionError",
"DifferentAtomError",
"DifferentMoleculeError",
"Du",
"EnergyResults",
"ExpectedMetalError",
"ForceFieldError",
"ForceFieldSetupError",
"GulpUFFMDOptimizer",
"GulpUFFOptimizer",
"InputError",
"InvalidSolventError",
"KabschRmsdCalculator",
"LewisStructureError",
"MAEExtractor",
"MDAnalysis",
"MMFFEnergy",
"MacroModelForceField",
"MacroModelMD",
"MatchedTorsionCalculator",
"MetalOptimizer",
"MoleculeSplitter",
"MoleculeT",
"MoleculeTransformer",
"Network",
"NotCompletedError",
"NotStartedError",
"SettingConflictError",
"InvalidSolventError",
"NullOptimizer",
"OpenBabel",
"OpenBabelEnergy",
"OpenMMEnergy",
"OpenMMForceField",
"OpenMMMD",
"OptWriterSequence",
"Optimizer",
"OptimizerError",
"get_torsion_info_angles",
"OptimizerSequence",
"OrcaEnergy",
"OrcaExtractor",
"OrcaResults",
"PathError",
"PlanarityCalculator",
"PlanarityResults",
"PositionedAtom",
"RmsdCalculator",
"RmsdMappedCalculator",
"RmsdResults",
"SettingConflictError",
"ShapeCalculator",
"ShapeResults",
"TopologyExtractor",
"TopologyInfo",
"Torsion",
"TorsionCalculator",
"TorsionInfo",
"TorsionResults",
"TryCatchOptimizer",
"UFFEnergy",
"UnitCell",
"WrapperNotInstalledError",
"XTBEnergy",
"XTBExtractor",
"XTBResults",
"ZMatrix",
"calculate_angle",
"calculate_dihedral",
"vector_angle",
"unit_vector",
"is_valid_xtb_solvent",
"cap_absolute_value",
"functional_groups",
"get_approximate_cell_size",
"get_atom_distance",
"get_from_parameters",
"get_metal_atoms",
"get_torsion_info_angles",
"is_valid_xtb_solvent",
"mol_from_mae_file",
"molecule_analysis",
"move_generated_macromodel_files",
"unit_vector",
"vector_angle",
]
4 changes: 2 additions & 2 deletions src/stko/_internal/molecular/periodic/unitcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ def with_cell_from_cif(self, filename: Path | str) -> Self:
with filename.open() as f:
lines = f.readlines()

for targ in targets:
for targ, target_string in targets.items():
for line in lines:
# Avoid running through the rest.
if targets[targ] in cell_info:
if target_string in cell_info:
break
splits = line.rstrip().split(" ")
if splits[0] == targ:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ def calculate(self, molecule: stk.Molecule) -> dict[str, list[float]]:
}

fg_results = {}
for pot_fg in fg_definitions:
fg_cls = fg_definitions[pot_fg]
for pot_fg, fg_cls in fg_definitions.items():
fg_results[pot_fg] = fg_cls.measure(molecule)

return fg_results
7 changes: 2 additions & 5 deletions src/stko/_internal/optimizers/collapser.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,7 @@ def _get_cent_to_lb_vector(
"""Returns dict of long bond atom to bb centroid vectors."""
position_matrix = mol.get_position_matrix()
centroid_to_lb_vectors: dict[tuple[int, int], tuple[float]] = {}
for bb in bb_centroids:
cent = bb_centroids[bb]
for bb, cent in bb_centroids.items():
for b_atom_ids in long_bond_infos:
for atom_id in b_atom_ids:
(atom_info,) = mol.get_atom_infos( # type: ignore[attr-defined]
Expand Down Expand Up @@ -614,9 +613,7 @@ def _compute_potential(
long_bond_infos: dict[tuple[int, int], stk.BondInfo],
) -> float:
system_potential = self._compute_non_bonded_potential(mol)
for long_bond_ids in long_bond_infos:
long_bond = long_bond_infos[long_bond_ids]

for long_bond in long_bond_infos.values():
system_potential += self._bond_potential(
distance=self._get_bond_length(
mol=mol,
Expand Down
Loading

0 comments on commit e18f096

Please sign in to comment.