Skip to content

Commit

Permalink
Merge branch 'jgreer/het_metrics' of github.com:ccpem/roodmus into jg…
Browse files Browse the repository at this point in the history
…reer/het_metrics
  • Loading branch information
JatGreer committed Apr 28, 2024
2 parents 79c125c + 990e66d commit 302c040
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 289 deletions.
41 changes: 41 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

python:
install:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html (optional)
- requirements: docs/requirements.txt
# Install our python package before building the docs
# - method: pip
# path: .

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx
sphinx-rtd-theme
4 changes: 4 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. autosummary::
:toctree: generated

roodmus
42 changes: 42 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration file for the Sphinx documentation builder.

# -- Project information

project = "Roodmus"
copyright = "2023, Joel Greer(UKRI), Tom Burnley (UKRI),\
Maarten Joosten (TU Delft), Arjen Jakobi (TU Delft)"
author = "Joel Greer, Maarten Joosten, Tom Burnley, Arjen Jakobi"

release = "0.2"
version = "0.0.28"

# -- General configuration

extensions = [
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
}
intersphinx_disabled_domains = ["std"]

templates_path = ["_templates"]

# -- Options for HTML output

html_theme = "sphinx_rtd_theme"

# -- Options for EPUB output
epub_show_urls = "footnote"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
4 changes: 4 additions & 0 deletions docs/source/explanation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
How Roodmus Works
=================

Information allowing you to be confident in how Roodmus works "behind-the-scenes".
4 changes: 4 additions & 0 deletions docs/source/how-to-guides.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
How To Guides
=============

How to use/extend Roodmus to do various tasks.
19 changes: 19 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Roodmus Docs
============

Roodmus is software for doing stuff...

.. note::

This project is under active development.

Contents
--------

.. toctree::

tutorials
how-to-guides
explanation
reference
api
4 changes: 4 additions & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Reference
=========

Useful reference information germane to Roodmus
4 changes: 4 additions & 0 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Tutorials
=========

How to use Roodmus utilities
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "roodmus"
version = "0.0.27"
version = "0.0.29"
authors = [
{ name="Joel Greer", email="[email protected]" },
{ name="Maarten Joosten", email="[email protected]" },
Expand Down Expand Up @@ -58,6 +58,7 @@ dependencies = [
"fqdn==1.5.1",
"fsspec==2023.1.0",
"gemmi==0.5.4",
"gemmi-program==0.6.5",
"glob2==0.7",
"guanaco==0.3.0",
"h5py==3.8.0",
Expand Down
23 changes: 12 additions & 11 deletions scripts/trace_md_through_latent.ipynb

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/roodmus/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import roodmus.heterogeneity.het_metrics
import roodmus.heterogeneity.latent_clustering
import roodmus.heterogeneity.het_ensemblecomparison
import roodmus.heterogeneity.remove_hydrogens

# import analysis.analyse_alignment

Expand Down Expand Up @@ -84,12 +85,14 @@ def main():
roodmus.heterogeneity.het_metrics,
roodmus.heterogeneity.latent_clustering,
roodmus.heterogeneity.het_ensemblecomparison,
roodmus.heterogeneity.remove_hydrogens,
]

module_helptext = [
"Sampling a molecular dynamics trajectory and saving the"
+ " conformations to PDB files.",
"Simulation of micrograph/tomogram dataset using Parakeet software.",
"Write out a particle stack using picked particle coordinates",
"Plot a comparison between the estimated CTF parameters and the"
+ " true values used in data generation.",
"Plot statistics from picking analyses and overlays of"
Expand All @@ -107,6 +110,7 @@ def main():
"Calculation of Jensen-Shannon divergence between ensembles"
+ " identified through clustering of MD trajectory(ies)"
+ " and/or clustering of latent spaces representing heterogeneity",
"Remove hydrogens from pdb file(s)",
]

for helptext, module in zip(module_helptext, modules):
Expand Down
69 changes: 26 additions & 43 deletions src/roodmus/heterogeneity/het_ensemblecomparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
import matplotlib.pyplot as plt

from roodmus.analysis.utils import load_data
from roodmus.heterogeneity.het_metrics import get_pdb_list
from roodmus.heterogeneity.het_metrics import (
get_pdb_list,
select_confs,
)

# import os
# import pandas as pd
Expand Down Expand Up @@ -398,21 +401,21 @@ def __init__(

def compute_ces_stats(self):
if self.ces:
self.ces_avg = np.average(
np.array(self.ces, dtype=float), axis=0
).tolist()
self.ces_stddev = np.std(
np.array(self.ces, dtype=float), axis=0
).tolist()
self.ces_avg = np.array(
np.average(np.array(self.ces, dtype=float), axis=0)[0][:][:]
)
self.ces_stddev = np.array(
np.std(np.array(self.ces, dtype=float), axis=0)[0][:][:]
)

def compute_dres_stats(self):
if self.dres:
self.dres_avg = np.average(
np.array(self.dres, dtype=float), axis=0
).tolist()
self.dres_stddev = np.std(
np.array(self.dres, dtype=float), axis=0
).tolist()
self.dres_avg = np.array(
np.average(np.array(self.dres, dtype=float), axis=0)[0][:][:]
)
self.dres_stddev = np.array(
np.std(np.array(self.dres, dtype=float), axis=0)[0][:][:]
)

def plot_ces_results(self):
cw = []
Expand Down Expand Up @@ -721,36 +724,16 @@ def main(args):
assert source == "MD" or source == "latent"

# get the conformation filenames
conformation_filenames = sorted(get_pdb_list(args.conformations_dir))
if args.n_confs and args.contiguous_confs:
if args.n_confs > len(conformation_filenames):
raise ValueError(
"Trying to sample {} confs from {} files!".format(
args.n_confs, len(conformation_filenames)
)
)
conformation_filenames = conformation_filenames[
args.first_conf : args.first_conf + args.n_confs
]
elif args.n_confs:
# get every nth sample depending on n_confs requested
if (len(conformation_filenames) - args.first_conf) < args.n_confs:
raise ValueError(
"Trying to sample {} confs from {} remaining! Error!".format(
args.n_confs,
len(conformation_filenames) - args.first_conf,
)
)
else:
sample_indices = np.arange(
args.first_conf,
len(conformation_filenames),
(len(conformation_filenames) - args.first_conf) / args.n_confs,
).astype(int)
conformation_filenames = np.array(
conformation_filenames, dtype=str
)[sample_indices].tolist()
assert len(conformation_filenames) > 0
conformation_filenames = get_pdb_list(
args.conformations_dir,
args.file_ext,
)
conformation_filenames = select_confs(
conformation_filenames,
args.n_confs,
args.first_conf,
args.contiguous_confs,
)

# TODO replace/update setting of these values
particle_diameter = 100 # approximate particle diameter in Angstroms
Expand Down
Loading

0 comments on commit 302c040

Please sign in to comment.