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
2 changes: 1 addition & 1 deletion src/bundles/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ REST_SUBDIRS = add_charge addh alignment_algs alignment_headers \
interfaces items_inspection io label iupac \
kvfinder lighting_gui list_info log looking_glass maestro \
map map_data map_eraser map_filter map_fit map_series \
markers mask match_maker mcopy mcp_server md_crds \
markers mask match_maker mcopy mcp_server mdanalysis \
medical_toolbar meeting minimize mlp model_series \
mmcif mmtf model_archive model_panel modeller \
mol2 mole morph mouse_modes movie mutation_scores nmrstar \
Expand Down
43 changes: 23 additions & 20 deletions src/bundles/md_crds/src/read_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import traceback

import numpy as np

from chimerax.atomic import AtomicStructure
from chimerax.io import open_input
from .util import determine_element_from_mass, prep_coords
Expand Down Expand Up @@ -140,8 +142,6 @@ def read_dump(session, path, model):
tokens = stream.readline().split()
print("LAMMPS dump format: ", tokens[2:])
index_id = tokens.index('id')-2
index_type = tokens.index('type')-2
index_mol = tokens.index('mol')-2
index_x = tokens.index('x')-2
index_y = tokens.index('y')-2
index_z = tokens.index('z')-2
Expand All @@ -152,24 +152,27 @@ def read_dump(session, path, model):

while not done:

coords_list.append([])
session.logger.status(f"LAMMPS dump: {i}")
tmp = np.empty((num_atoms, 4), dtype=np.float64)

for j in range(num_atoms):
# FIXME: handle dump format other than id type mol x y z
tokens = stream.readline().split()
id = int(tokens[index_id])
type = int(tokens[index_type])
mol = int(tokens[index_mol])
x,y,z = float(tokens[index_x]),float(tokens[index_y]),float(tokens[index_z])
coords_list[i].append([id,x,y,z])

coords_list[i].sort(key=lambda atom:atom[0])
i += 1
if stream.readline():
for j in range(8): stream.readline()
else:
done = True

coords = array(coords_list, dtype=float64)[:,:,1:]
for j in range(num_atoms):
tokens = stream.readline().split()
tmp[j, 0] = int(tokens[index_id])
tmp[j, 1] = float(tokens[index_x])
tmp[j, 2] = float(tokens[index_y])
tmp[j, 3] = float(tokens[index_z])

idx = np.argsort(tmp[:, 0])
tmp[:] = tmp[idx]
coords_list.append(tmp[:, 1:4])
i += 1

if stream.readline():
for _ in range(8):
stream.readline()
else:
done = True

coords = np.array(coords_list, dtype=np.float64)
stream.close()
return num_atoms, coords
1 change: 1 addition & 0 deletions src/bundles/mdanalysis/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../Makefile.bundle
17 changes: 17 additions & 0 deletions src/bundles/mdanalysis/cxtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from chimerax.core.commands import run
run(session, "open test-data/chimera_test.pdb; open test-data/chimera_test.xtc structureModel #1")
if session.models[0].num_coordsets != 21:
raise SystemExit("Expected chimera_test.xtc to produce 21 coordinate sets; actually produced %s"
% session.models[0].num_coordsets)
run(session, "close; open test-data/start.pdb; open test-data/test.dcd structureModel #1")
if session.models[0].num_coordsets != 2:
raise SystemExit("Expected chimera_test.xtc to produce 2 coordinate sets; actually produced %s"
% session.models[0].num_coordsets)
run(session, "close; open test-data/gly.psf coords test-data/gly.xtc")
if session.models[0].num_coordsets != 4:
raise SystemExit("Expected gly.xtc to produce 4 coordinate sets; actually produced %s"
% session.models[0].num_coordsets)
run(session, "close; open test-data/gly.data coords test-data/gly.dump")
if session.models[0].num_coordsets != 4:
raise SystemExit("Expected gly.dump to produce 4 coordinate sets; actually produced %s"
% session.models[0].num_coordsets)
174 changes: 174 additions & 0 deletions src/bundles/mdanalysis/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
[build-system]
requires = ["ChimeraX-BundleBuilder>=1.4.0", "ChimeraX-Core ~=1.0"]
build-backend = "chimerax.bundle_builder.cx_pep517"

[project]
name = "ChimeraX-MDAnalysis"
version = "1.0.0"
license = { text = "Free for non-commercial use" }
authors = [{ name = "UCSF RBVI", email = "[email protected]" }]
description = "Molecular dynamics support using MDAnalysis"
dependencies = [
"ChimeraX-Core ~=1.0",
"ChimeraX-Atomic ~=1.22",
"ChimeraX-DataFormats ~=1.0",
"ChimeraX-OpenCommand ~=1.0",
"ChimeraX-SaveCommand ~=1.0",
"ChimeraX-UI ~=1.47",
"MDAnalysis>=2.0.0",
]
dynamic = ["classifiers", "requires-python"]

[project.readme]
content-type = "text"
text = """This bundle provides parsers for various molecular dynamics file formats using MDAnalysis."""

[project.urls]
Home = "https://www.rbvi.ucsf.edu/chimerax/"

[tool.chimerax]
min-session-version = 1
max-session-version = 1
module-name-override = "mdanalysis"
categories = ["Molecular Dynamics"]
classifiers = ["Development Status :: 4 - Beta"]

[tool.chimerax.manager."MD plotting"]
autostart = false

# --- Open Commands ---
[[tool.chimerax.provider."open command"]]
name = "psf"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "gro"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "data"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "dcd"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "xtc"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "trr"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "amber"
want-path = true

[[tool.chimerax.provider."open command"]]
name = "dump"
want-path = true

# --- Data Formats ---
[[tool.chimerax.provider."data formats"]]
name = "Protein structure file"
category = "Molecular structure"
nicknames = "psf"
suffixes = ".psf"
synopsis = "PSF topology"

[[tool.chimerax.provider."data formats"]]
name = "Gromacs structure"
category = "Molecular structure"
nicknames = "gro"
suffixes = ".gro"
synopsis = "Gromos87 structure"

[[tool.chimerax.provider."data formats"]]
name = "LAMMPS data"
category = "Molecular structure"
nicknames = "data"
suffixes = ".data"
default-for = ".data"
synopsis = "LAMMPS data format"

[[tool.chimerax.provider."data formats"]]
name = "DCD trajectory"
category = "Molecular trajectory"
nicknames = "dcd"
suffixes = ".dcd"
synopsis = "DCD trajectory"

[[tool.chimerax.provider."data formats"]]
name = "Gromacs XTC"
category = "Molecular trajectory"
nicknames = "xtc"
suffixes = ".xtc"
synopsis = "Gromacs compressed trajectory"

[[tool.chimerax.provider."data formats"]]
name = "Gromacs TRR"
category = "Molecular trajectory"
nicknames = "trr"
suffixes = ".trr"
synopsis = "Gromacs full-precision trajectory"

[[tool.chimerax.provider."data formats"]]
name = "Amber NetCDF"
category = "Molecular trajectory"
nicknames = "amber"
suffixes = ".nc"
synopsis = "Amber NetCDF trajectory"

[[tool.chimerax.provider."data formats"]]
name = "LAMMPS dump"
category = "Molecular trajectory"
nicknames = "dump"
suffixes = ".dump"
default-for = ".dump"
synopsis = "LAMMPS dump trajectory"

# --- Save Commands (Legacy support maintained) ---
[[tool.chimerax.provider."save command"]]
name = "dcd"

# --- MD Plotting ---
[[tool.chimerax.provider."MD plotting"]]
name = "distance"
num-atoms = "2"
text-format = "distance"

[[tool.chimerax.provider."MD plotting"]]
name = "angle"
num-atoms = "3"
text-format = "angle"
min-val = "0"
max-val = "180"

[[tool.chimerax.provider."MD plotting"]]
name = "torsion"
num-atoms = "4"
text-format = "angle"
min-val = "-180"
max-val = "180"

[[tool.chimerax.provider."MD plotting"]]
name = "surface"
ui-name = "SASA"
num-atoms = "0"
text-format = "%.1f"
exclude = "solution=true,ligands=true,metals=alkali"

[[tool.chimerax.provider."MD plotting"]]
name = "rmsd"
ui-name = "RMSD"
num-atoms = "0"
text-format = "%.2f"
need-ref-frame = true
exclude = "solution=true,hydrogens=true,ligands=false,metals=alkali"

[[tool.chimerax.provider."MD plotting"]]
name = "hbonds"
ui-name = "H-Bonds"
num-atoms = "0"
text-format = "%d"
Loading