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

Doing further developments, over time. #22

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2b4dc4a
Fix readme.
andrewtarzia Dec 14, 2024
3ddabfe
Fix readme.
andrewtarzia Dec 15, 2024
6800803
Fix readme.
andrewtarzia Dec 15, 2024
58fffc6
Refactoring from tscram.
andrewtarzia Dec 16, 2024
c4828ef
Comment on unused code. Change method name.
andrewtarzia Dec 16, 2024
542845f
Add bb config control.
andrewtarzia Dec 16, 2024
22cc232
Refactoring from tscram.
andrewtarzia Dec 16, 2024
76a6719
Update module.
andrewtarzia Dec 16, 2024
fae1a95
Add warnings to old algorithm.
andrewtarzia Dec 16, 2024
ebaef89
Write new, custom topology building block permutation function.
andrewtarzia Dec 16, 2024
8629597
Make accessible function for aligning ditopic bbs.
andrewtarzia Dec 17, 2024
f487f44
Bug fix for ditopic bbs.
andrewtarzia Dec 17, 2024
21beaa4
Fix name.
andrewtarzia Dec 17, 2024
da3f95b
Minor.
andrewtarzia Dec 17, 2024
5900299
Update deps.
andrewtarzia Dec 17, 2024
47e3ded
Update docs.
andrewtarzia Dec 17, 2024
893e680
Refactoring.
andrewtarzia Dec 18, 2024
f25e592
Update docs.
andrewtarzia Dec 18, 2024
533832e
Improve wasted overlaps in bb dict generation.
andrewtarzia Dec 18, 2024
7cf0010
Minor.
andrewtarzia Dec 18, 2024
bb46fb2
Add new graph using new algorithm for 3-types.
andrewtarzia Dec 19, 2024
aee33d3
Add a step to optimiser, which seems to improve results.
andrewtarzia Dec 19, 2024
aad0257
New graph set.
andrewtarzia Dec 29, 2024
6461cb4
Minor.
andrewtarzia Dec 29, 2024
0138295
Allow custom number of components.
andrewtarzia Dec 29, 2024
ddb5935
Add forcefield dict.
andrewtarzia Jan 4, 2025
60afa01
Update steric six bead.
andrewtarzia Jan 4, 2025
079021d
Add potential name.
andrewtarzia Jan 4, 2025
9e42b7c
Update comment.
andrewtarzia Jan 5, 2025
ebe5750
Refactor energy per bb.
andrewtarzia Jan 5, 2025
d0b836a
Add steric precursor.
andrewtarzia Jan 5, 2025
d4d3409
Update the neighbour process.
andrewtarzia Jan 5, 2025
20809e5
Add initialisation from ff.
andrewtarzia Jan 5, 2025
2e1817c
Update miniconda action version.
andrewtarzia Jan 17, 2025
8802342
Ruff fixes.
andrewtarzia Jan 17, 2025
8611516
Try fix workflow.
andrewtarzia Jan 17, 2025
db525ca
Try fix workflow.
andrewtarzia Jan 17, 2025
f80788a
Add mypy.ini for rdkit issue.
andrewtarzia Jan 17, 2025
c2d126a
Add mypy.ini and use it properly, some mypy fixes, WIP.
andrewtarzia Jan 17, 2025
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
20 changes: 6 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,20 @@ jobs:
- run: "pip install -e '.[dev]'"
- run: ruff format --check .
pytest:
# https://ericmjl.github.io/blog/2021/12/30/better-conda-environments-on-github-actions/
runs-on: ubuntu-22.04

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3

with:
auto-update-conda: true
miniforge-variant: Mambaforge
channels: conda-forge,defaults
miniforge-version: latest
python-version: 3.11
activate-environment: pytest
use-mamba: true

- name: Build environment
run: |
Expand All @@ -68,24 +64,20 @@ jobs:
run: pytest

build-test:
# https://ericmjl.github.io/blog/2021/12/30/better-conda-environments-on-github-actions/
runs-on: ubuntu-22.04

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3

with:
auto-update-conda: true
miniforge-variant: Mambaforge
channels: conda-forge,defaults
miniforge-version: latest
python-version: 3.11
activate-environment: buildtest
use-mamba: true

- name: Build environment
run: |
Expand Down
34 changes: 17 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Overview
========

:mod:`cgexplore` or ``cgx`` is a general toolkit built on
``cgexplore`` or ``cgx`` is a general toolkit built on
`stk <https://stk.readthedocs.io/en/stable/>`_ for constructing,
optimising and exploring molecular coarse-grained models.

Expand All @@ -20,7 +20,7 @@ optimising and exploring molecular coarse-grained models.
Installation
============

:mod:`cgexplore` can be installed with pip:
``cgexplore`` can be installed with pip:

.. code-block:: bash

Expand All @@ -33,18 +33,18 @@ With dependancies `openmm <https://openmm.org/>`_ and `openmmtools <https://open
mamba install openmm openmmtools


Then, update directory structure in `env_set.py` if using example code.
Then, update directory structure in ``env_set.py`` if using example code.


The library implements some analysis that uses `Shape 2.1`. Follow the
The library implements some analysis that uses ``Shape 2.1``. Follow the
instructions to download and installed at
`Shape <https://www.iqtc.ub.edu/uncategorised/program-for-the-stereochemical-analysis-of-molecular-fragments-by-means-of-continous-shape-measures-and-associated-tools/>`_


Developer Setup
---------------

To develop with :mod:`cgexplore`, you can clone the repo and use
To develop with ``cgexplore``, you can clone the repo and use
`just <https://github.com/casey/just>`_ to setup the dev environment:

.. code-block:: bash
Expand All @@ -57,7 +57,7 @@ Usage

**To reproduce data in DOI:
`10.1039/D3SC03991A <https://doi.org/10.1039/D3SC03991A>`_**:
Download the source code from `first_paper_example - presubmission`
Download the source code from ``first_paper_example - presubmission``
release from ``Releases``.I do not guarantee that running the example code
on the current version will work. However, with each pull request a test is run
as a GitHub Action connected to this
Expand All @@ -68,26 +68,26 @@ convention has changed and force field xml files should provide the
appropriate information for mapping angles to models.


* The directory `cgexplore` contains the actual source code for the package.
* The directory `first_paper_example` contains the code for `10.1039/D3SC03991A <https://doi.org/10.1039/D3SC03991A>`_.
* `generate_XX.py` generates cage structures for different topology sets
* `env_set.py` sets a specific environment for file outputs
* `plot_XX.py` produces images and figures, and performs analysis
* The directory ``cgexplore`` contains the actual source code for the package.
* The directory ``first_paper_example`` contains the code for `10.1039/D3SC03991A <https://doi.org/10.1039/D3SC03991A>`_.
* ``generate_XX.py`` generates cage structures for different topology sets
* ``env_set.py`` sets a specific environment for file outputs
* ``plot_XX.py`` produces images and figures, and performs analysis

.. important::
**Warning**: If you have a CUDA-capable GPU and attempt to use CUDA in the
first example, you may get `NaN` errors due to the torsion restriction for
first example, you may get ``NaN`` errors due to the torsion restriction for
angles at 180 degrees, which cause problematic forces. This will be handled
in future versions of the code. And logically, I would suggest removing the
torsion restriction for those angles. The `platform` can be handled through
this argument in `build_building_blocks` and `build_populations`, which I
currently set to `None`, meaning `OpenMM` will decide for itself.
torsion restriction for those angles. The ``platform`` can be handled through
this argument in ``build_building_blocks`` and ``build_populations``, which I
currently set to ``None``, meaning ``OpenMM`` will decide for itself.


How To Cite
===========

If you use ``stk`` please cite
If you use ``cgexplore`` please cite

https://github.com/andrewtarzia/CGExplore

Expand All @@ -98,7 +98,7 @@ and
Publications using CGExplore
============================

* Using stk for constructing larger numbers of coarse-grained models: `Systematic exploration of accessible topologies of cage molecules via minimalistic models`__
* Using stk for constructing larger numbers of coarse-grained models: `Systematic exploration of accessible topologies of cage molecules via minimalistic models <https://doi.org/10.1039/D3SC03991A>`_.


Acknowledgements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cgexplore.atomistic.extract\_ditopic\_ensemble
==============================================

.. currentmodule:: cgexplore.atomistic

.. autofunction:: extract_ditopic_ensemble

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cgexplore.atomistic.get\_ditopic\_aligned\_bb
=============================================

.. currentmodule:: cgexplore.atomistic

.. autofunction:: get_ditopic_aligned_bb
3 changes: 2 additions & 1 deletion docs/source/_autosummary/cgexplore.atomistic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ cgexplore.atomistic
:nosignatures:

cgx_optimisation_sequence
extract_ensemble
extract_ditopic_ensemble
get_ditopic_aligned_bb
run_conformer_analysis


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cgexplore.scram.HomolepticTopologyIterator
==========================================
cgexplore.molecular.SixBead
===========================

.. currentmodule:: cgexplore.scram
.. currentmodule:: cgexplore.molecular

.. autoclass:: HomolepticTopologyIterator
.. autoclass:: SixBead
:members:
:inherited-members:
:undoc-members:
Expand Down
25 changes: 25 additions & 0 deletions docs/source/_autosummary/cgexplore.molecular.StericSixBead.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cgexplore.molecular.StericSixBead
=================================

.. currentmodule:: cgexplore.molecular

.. autoclass:: StericSixBead
:members:
:inherited-members:
:undoc-members:
:show-inheritance:




.. rubric:: Methods

.. autosummary::
:nosignatures:







2 changes: 2 additions & 0 deletions docs/source/_autosummary/cgexplore.molecular.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ cgexplore.molecular
LinearPrecursor
Precursor
PrecursorGenerator
SixBead
SpindryConformer
SquarePrecursor
StericSixBead
ThreeC0Arm
ThreeC1Arm
ThreeC2Arm
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cgexplore.scram.BuildingBlockConfiguration
==========================================

.. currentmodule:: cgexplore.scram

.. autoclass:: BuildingBlockConfiguration
:members:
:inherited-members:
:undoc-members:
:show-inheritance:




.. rubric:: Methods

.. autosummary::
:nosignatures:

~BuildingBlockConfiguration.get_building_block_dictionary
~BuildingBlockConfiguration.get_hashable_bbidx_dict





.. rubric:: Attributes

.. autosummary::

~BuildingBlockConfiguration.idx
~BuildingBlockConfiguration.building_block_idx_map
~BuildingBlockConfiguration.building_block_idx_dict


Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ cgexplore.scram.IHomolepticTopologyIterator
.. autosummary::
:nosignatures:

~IHomolepticTopologyIterator.get_graphs
~IHomolepticTopologyIterator.count_graphs
~IHomolepticTopologyIterator.get_num_building_blocks
~IHomolepticTopologyIterator.get_vertex_prototypes
~IHomolepticTopologyIterator.yield_graphs



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cgexplore.scram.get\_custom\_bb\_configurations
===============================================

.. currentmodule:: cgexplore.scram

.. autofunction:: get_custom_bb_configurations
3 changes: 2 additions & 1 deletion docs/source/_autosummary/cgexplore.scram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ cgexplore.scram
:template: class.rst
:nosignatures:

BuildingBlockConfiguration
Constructed
HomolepticTopologyIterator
IHomolepticTopologyIterator
TopologyCode
TopologyIterator
Expand All @@ -33,6 +33,7 @@ cgexplore.scram
:toctree:
:nosignatures:

get_custom_bb_configurations
get_potential_bb_dicts
graph_optimise_cage
optimise_cage
Expand Down
29 changes: 6 additions & 23 deletions first_paper_example/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ def analyse_cage(
lig_shape_measures = liga_shape.calculate(l_shape_mol)
l_shape_mol.write(shape_molfile2)

# Always want to extract target torions if present.
g_measure = cgx.analysis.GeomMeasure(
# Always want to extract target torions if present, in toff, they
# are no in the forcefield, so cannot use
# `GeomMeasure.from_forcefield`.
target_torsions=(
cgx.terms.TargetTorsion(
search_string=("b1", "a1", "c1", "a1", "b1"),
Expand Down Expand Up @@ -429,25 +431,6 @@ def xc_map(tstr: str) -> int:
}[tstr]


def stoich_map(tstr: str) -> int:
"""Stoichiometry maps to the number of building blocks."""
return {
"2P3": 5,
"4P6": 10,
"4P62": 10,
"6P9": 15,
"8P12": 20,
"2P4": 6,
"3P6": 9,
"4P8": 12,
"4P82": 12,
"6P12": 18,
"8P16": 24,
"12P24": 36,
"6P8": 14,
}[tstr]


def cltypetopo_to_colormap() -> dict[str, dict]:
"""Convert label."""
return {
Expand Down Expand Up @@ -670,9 +653,9 @@ def data_to_array(json_files, output_dir: pathlib.Path) -> pd.DataFrame:

if row["optimised"]:
row["strain_energy"] = res_dict["fin_energy_kjmol"]
row["energy_per_bb"] = res_dict["fin_energy_kjmol"] / stoich_map(
t_str
)
row["energy_per_bb"] = res_dict[
"fin_energy_kjmol"
] / cgx.topologies.stoich_map(t_str)
for force_title in res_dict["fin_energy_decomp"]:
if force_title in (
"CMMotionRemover_kJ/mol",
Expand Down
3 changes: 1 addition & 2 deletions first_paper_example/plot_cages.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,7 @@ def webapp_csv(
logging.info("running webapp_csv")

github_base_url = (
"https://github.com/andrewtarzia/cgmodels/blob/main/"
"cg_model_jul2023/"
"https://github.com/andrewtarzia/cgmodels/blob/main/cg_model_jul2023/"
)
github_selfsort_url = github_base_url + "self_sort_outcomes/"

Expand Down
Loading
Loading