Skip to content

Commit

Permalink
fix some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed May 24, 2024
1 parent a4ca10e commit 3e879fd
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 47 deletions.
2 changes: 1 addition & 1 deletion molecularnodes/blender/bones.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_bones(positions, chain_ids, name="armature"):
try:
pos_a = position
pos_b = positions[i + 1, :]
except:
except IndexError:
continue

bone_name = f"mn_armature_{i}"
Expand Down
13 changes: 13 additions & 0 deletions molecularnodes/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@
from .wwpdb import fetch
from .local import load
from .retrieve import download

__all__ = [
CIF,
BCIF,
PDB,
SDF,
CellPack,
StarFile,
MDAnalysisSession,
fetch,
load,
download,
]
13 changes: 6 additions & 7 deletions molecularnodes/io/parse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
A subpackge which provides classes for parsing the different macromolecular data formats.
"""

from .pdbx import CIF, BCIF

# from .bcif import BCIF
# from .cif import CIF
from .pdb import PDB
from .cellpack import CellPack
from .star import StarFile
from .sdf import SDF
from .mda import MDAnalysisSession
from .mrc import MRC
from .pdb import PDB
from .pdbx import BCIF, CIF
from .sdf import SDF
from .star import StarFile

__all__ = [CIF, BCIF, PDB, CellPack, StarFile, SDF, MDAnalysisSession, MRC]
4 changes: 0 additions & 4 deletions molecularnodes/ui/func.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import bpy
from ..blender import nodes


def build_menu(layout, items):
for item in items:
# print(item)
Expand Down
16 changes: 9 additions & 7 deletions tests/test_density.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import molecularnodes as mn
import importlib
import itertools

import bpy
import pytest
import numpy as np
import itertools
import pytest

import molecularnodes as mn

from .constants import data_dir
from .utils import sample_attribute, NumpySnapshotExtension
from .utils import NumpySnapshotExtension, sample_attribute

try:
import pyopenvdb
except ImportError:
if not importlib.util.find_spec("pyopenvdb"):
pytest.skip("pyopenvdb not installed", allow_module_level=True)

mn.unregister()
Expand Down
11 changes: 7 additions & 4 deletions tests/test_mda.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import bpy
import os

import bpy
import pytest

import molecularnodes as mn
from . import utils
from molecularnodes.io.md import HAS_mda
from molecularnodes.blender.obj import get_attribute
from molecularnodes.io.md import HAS_mda


if HAS_mda:
import MDAnalysis as mda
import numpy as np

from .constants import data_dir
from .utils import remove_all_molecule_objects, sample_attribute, NumpySnapshotExtension
from .utils import NumpySnapshotExtension, remove_all_molecule_objects, sample_attribute


@pytest.mark.skipif(not HAS_mda, reason="MDAnalysis is not installed")
Expand Down
1 change: 0 additions & 1 deletion tests/test_mol_sdf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import molecularnodes as mn
import molecularnodes.blender as bl
import pytest
import bpy

from .constants import data_dir, attributes
from .utils import sample_attribute, NumpySnapshotExtension
Expand Down
2 changes: 0 additions & 2 deletions tests/test_obj.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import bpy
import numpy as np
import molecularnodes as mn
from .utils import sample_attribute


def test_creat_obj():
Expand Down
12 changes: 4 additions & 8 deletions tests/test_pdbx.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import random

import molecularnodes as mn
import numpy as np

import random
from .constants import data_dir
from .utils import NumpySnapshotExtension, sample_attribute
from .utils import sample_attribute


def test_ss_label_to_int():
examples = ["TURN_TY1_P68", "BEND64", "HELX_LH_PP_P9", "STRN44"]
assert [3, 3, 1, 2] == [mn.io.parse.cif._ss_label_to_int(x) for x in examples]


def test_get_ss_from_mmcif(snapshot_custom: NumpySnapshotExtension):
def test_get_ss_from_mmcif(snapshot_custom):
mol = mn.io.load(data_dir / "1cd3.cif")

# mol2, fil2 = mn.io.fetch('1cd3')

random.seed(6)
random_idx = random.sample(range(len(mol)), 100)

# assert (mol.sec_struct == mol2.sec_struct)[random_idx].all()

assert snapshot_custom == mol.array.sec_struct[random_idx]


Expand Down
18 changes: 5 additions & 13 deletions tests/test_star.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import molecularnodes as mn
import bpy
import pytest
from scipy.spatial.transform import Rotation as R
import starfile
from scipy.spatial.transform import Rotation as R

import molecularnodes as mn

from .constants import data_dir

mn.unregister()
mn.register()

try:
import pyopenvdb

SKIP = False
except ImportError:
SKIP = True


@pytest.mark.parametrize("type", ["cistem", "relion"])
def test_starfile_attributes(type):
Expand Down Expand Up @@ -58,8 +54,6 @@ def test_categorical_attributes():


def test_micrograph_conversion():
from pathlib import Path

file = data_dir / "cistem.star"
ensemble = mn.io.star.load(file)
tiff_path = data_dir / "montage.tiff"
Expand Down Expand Up @@ -91,8 +85,6 @@ def test_micrograph_loading():

@pytest.mark.skipif(SKIP, reason="Test may segfault on GHA")
def test_rehydration(tmp_path):
import bpy

bpy.ops.wm.read_homefile()
ensemble = mn.io.star.load(data_dir / "cistem.star")
bpy.ops.wm.save_as_mainfile(filepath=str(tmp_path / "test.blend"))
Expand Down

0 comments on commit 3e879fd

Please sign in to comment.