Skip to content

Commit 0ce2b94

Browse files
authored
Merge branch 'main' into main
2 parents d014764 + 0276802 commit 0ce2b94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1898
-1932
lines changed

docs/examples/examples.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
- title: EvolutionaryScale.ai
2+
description: Images and videos created for the EvolutionScale.ai landing page
3+
path: https://www.evolutionaryscale.ai/
4+
image: https://imgur.com/2zXf8ng.png
5+
16
- title: Your Operating System |Eukaryotic Transcription
27
author: Clockwork
38
description: 🧬How does your DNA actually become who you are? Let's go on the incredible journey it takes to transcribe your DNA into mRNA.

docs/generate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import bpy
21
import pathlib
32

4-
import molecularnodes as mn
3+
import bpy
54
import nodepad
65

6+
import molecularnodes as mn
7+
78
DOCS_FOLDER = pathlib.Path(__file__).resolve().parent
89

910
# load the data file which contains all of the nodes to build docs for
10-
bpy.ops.wm.open_mainfile(filepath=mn.utils.MN_DATA_FILE)
11+
bpy.ops.wm.open_mainfile(filepath=str(mn.assets.MN_DATA_FILE))
1112

1213

1314
header = """---
@@ -56,14 +57,14 @@
5657
file.write(
5758
"### Residue Names\n\n" "| Name | Integer |\n" "|----------:|:------------|\n"
5859
)
59-
for name, res in mn.data.residues.items():
60+
for name, res in mn.assets.data.residues.items():
6061
file.write(f"| {name} | `{res['res_name_num']}::Int` |\n")
6162
file.write("\n")
6263
file.write("\n")
6364

6465
file.write(
6566
"### Atom Names\n\n" "| Name | Integer |\n" "|----------:|:------------|\n"
6667
)
67-
for name, value in mn.data.atom_names.items():
68+
for name, value in mn.assets.data.atom_names.items():
6869
file.write(f"| {name} | `{value}::Int` |\n")
6970
file.write("\n")

molecularnodes/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from .addon import register, unregister
1+
from . import assets, blender, color, session, ui
2+
from .assets import template
23
from .entities import fetch, parse
3-
from . import color, blender
4+
from .ui.addon import register, unregister
45

56
try:
67
from .scene import Canvas

molecularnodes/assets/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from pathlib import Path
2+
3+
from .template import install, uninstall
4+
from . import data
5+
6+
ASSET_DIR = Path(__file__).resolve().parent
7+
ADDON_DIR = ASSET_DIR.parent
8+
MN_DATA_FILE = ASSET_DIR / "MN_data_file_4.2.blend"
File renamed without changes.

molecularnodes/assets/template.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import shutil
2+
from pathlib import Path
3+
import bpy
4+
5+
6+
SUBFOLDER = "Molecular Nodes"
7+
8+
9+
def is_installed():
10+
base_path = Path(
11+
bpy.utils.user_resource(
12+
"SCRIPTS", path=str(Path("startup") / "bl_app_templates_user"), create=False
13+
)
14+
)
15+
molecular_nodes_path = base_path / "Molecular Nodes"
16+
return molecular_nodes_path.exists()
17+
18+
19+
def install():
20+
base_path = Path(
21+
bpy.utils.user_resource(
22+
"SCRIPTS", path=str(Path("startup") / "bl_app_templates_user"), create=True
23+
)
24+
)
25+
26+
base_path.mkdir(parents=True, exist_ok=True)
27+
path_app_templates = base_path / SUBFOLDER
28+
path_app_templates.mkdir(parents=True, exist_ok=True)
29+
startup_file = Path(__file__).parent / "template/startup.blend"
30+
shutil.copy(startup_file, path_app_templates)
31+
bpy.utils.refresh_script_paths()
32+
33+
34+
def uninstall():
35+
for folder in bpy.utils.app_template_paths():
36+
path = Path(folder).absolute() / SUBFOLDER
37+
if "Molecular Nodes" not in str(path):
38+
continue
39+
40+
if path.exists():
41+
shutil.rmtree(path)
42+
bpy.utils.refresh_script_paths()

molecularnodes/blender/material.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from bpy.types import Material
22
from databpy.material import append_from_blend
3-
from ..utils import MN_DATA_FILE
3+
from ..assets import MN_DATA_FILE
44

55
MATERIAL_NAMES = [
66
"MN Default",
@@ -13,7 +13,7 @@
1313

1414
def append(name: str) -> Material:
1515
"Append a material from the MN_DATA_FILE."
16-
return append_from_blend(name, MN_DATA_FILE)
16+
return append_from_blend(name, str(MN_DATA_FILE))
1717

1818

1919
def add_all_materials() -> None:

molecularnodes/blender/nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414

1515
from .. import color, utils
16-
from ..utils import MN_DATA_FILE
16+
from ..assets import MN_DATA_FILE
1717
from . import material, mesh
1818

1919
NODE_WIDTH = 180
@@ -214,8 +214,8 @@ def swap(node: bpy.types.GeometryNode, tree: str | bpy.types.GeometryNodeTree) -
214214

215215
def append(name: str, link: bool = False) -> bpy.types.GeometryNodeTree:
216216
"Append a GN node from the MN data file"
217-
GN_TREES_PATH = os.path.join(MN_DATA_FILE, "NodeTree")
218-
return append_from_blend(name, filepath=GN_TREES_PATH, link=link)
217+
GN_TREES_PATH = MN_DATA_FILE / "NodeTree"
218+
return append_from_blend(name, filepath=str(GN_TREES_PATH), link=link)
219219

220220

221221
def MN_micrograph_material():
@@ -360,7 +360,7 @@ def create_starting_node_tree(
360360
coll_frames: bpy.types.Collection | None = None,
361361
style: str = "spheres",
362362
name: str | None = None,
363-
color: str = "common",
363+
color: str | None = "common",
364364
material: str = "MN Default",
365365
is_modifier: bool = True,
366366
):

molecularnodes/entities/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from . import molecule, trajectory, interaction
22
from .base import EntityType, MolecularEntity
3-
from .density import MN_OT_Import_Map
43
from .ensemble import CellPack, Ensemble, StarFile
5-
from .ensemble.ui import MN_OT_Import_Cell_Pack, MN_OT_Import_Star_File
64
from .molecule import BCIF, CIF, PDB, SDF, Molecule
75
from .molecule.pdb import PDB
86
from .molecule.pdbx import BCIF, CIF
97
from .molecule.sdf import SDF
10-
from .molecule.ui import fetch, load_local, parse
8+
from .molecule.io import fetch, load_local, parse
119
from .trajectory import OXDNA, Trajectory
1210
from .trajectory.dna import MN_OT_Import_OxDNA_Trajectory
1311

@@ -21,4 +19,4 @@
2119
+ trajectory.CLASSES
2220
+ molecule.CLASSES
2321
+ interaction.CLASSES
24-
)
22+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .ui import MN_OT_Import_Map, load
1+
from .io import load
22
from .mrc import MRC
33
from .base import Density

0 commit comments

Comments
 (0)