Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions dimsim/_db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""A database tracking lowest-energy coordinates for a packed box of a given (physical property or compute) target."""
17 changes: 17 additions & 0 deletions dimsim/_db/get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sqlite3


def get_record(db_path: str, record_id: str) -> tuple[str, float]:
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

cursor.execute("SELECT filename, energy FROM records WHERE id = ?", (record_id,))
row = cursor.fetchone()

conn.close()

if row is None:
raise KeyError(f"No record found with id={record_id!r}")

filename, energy = row
return filename, energy
11 changes: 11 additions & 0 deletions dimsim/_db/insert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sqlite3


def insert_record(db_path: str, record_id: str, filename: str, energy: float):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

cursor.execute("INSERT INTO records (id, filename, energy) VALUES (?, ?, ?)", (record_id, filename, energy))

conn.commit()
conn.close()
19 changes: 19 additions & 0 deletions dimsim/_db/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sqlite3


def create_database(db_path: str):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

# not sure if we should be tracking file name (easy enough, brittle)
# or storing the full 3-D coordinates in the database
cursor.execute("""
CREATE TABLE IF NOT EXISTS records (
id TEXT PRIMARY KEY CHECK(length(id) = 16),
filename TEXT NOT NULL,
energy REAL NOT NULL
)
""")

conn.commit()
conn.close()
10 changes: 10 additions & 0 deletions dimsim/compute/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import parsl

from dimsim._db.start import create_database
from dimsim.compute.apps import (
minimize_energy,
prepare_openmm_system,
Expand All @@ -24,6 +25,8 @@ def __init__(self, base_dir, parsl_config):

parsl.load(parsl_config)

self.low_energy_database = create_database(str(pathlib.Path(self.base_dir) / "minima.db"))

def _submit_compute(
self,
compute_config: BaseComputeConfig,
Expand All @@ -50,15 +53,21 @@ def _submit_compute(
# trajectory_dcd = File(f"{job_dir}/trajectory.dcd")

# 1. pack from compute config
# TODO: Short-circuit if a packed topolgoy already exists
pack_future = prepare_packed_topology(compute_config, job_dir)

# 2. set up openmm system
# TODO: Also short-circuit here
setup_future = prepare_openmm_system(pack_future, job_dir)

# 3. (for now ...) get minimized energy
# TODO: Short-circuit here too
# TODO: Store the resulting energy into the database, as a starting point
minimize_future = minimize_energy(setup_future, job_dir)

# 4. run equilibration step
# TODO: Short-circuit here too
# TODO: Store resulting energy into the database
equilibration_future = run_equilibration(
compute_config=compute_config,
equilibration_config=None,
Expand All @@ -67,6 +76,7 @@ def _submit_compute(
)

# 5. run "production" step
# TODO: Store resulting energy into the database
production_future = run_production(
compute_config=compute_config,
production_config=None,
Expand Down