From 76a1be5b6eba7dc2ebf681b4404937f8a279b2ec Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 12 Aug 2023 08:20:00 +0800 Subject: [PATCH 1/2] fix: enabling error without packages installed --- MolecularNodes/assembly/cif.py | 5 +++-- MolecularNodes/assembly/mmtf.py | 5 ++--- MolecularNodes/assembly/pdb.py | 5 +++-- MolecularNodes/load.py | 6 ++++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/MolecularNodes/assembly/cif.py b/MolecularNodes/assembly/cif.py index 2aac84a18..8022ffee9 100644 --- a/MolecularNodes/assembly/cif.py +++ b/MolecularNodes/assembly/cif.py @@ -1,7 +1,6 @@ import numpy as np import itertools -import biotite.structure.io.pdbx as pdbx -import biotite + from . import AssemblyParser @@ -13,10 +12,12 @@ def __init__(self, mmtf_file): def list_assemblies(self): + import biotite.structure.io.pdbx as pdbx return list(pdbx.list_assemblies(self._file).keys()) def get_transformations(self, assembly_id): + import biotite assembly_gen_category = self._file.get_category( "pdbx_struct_assembly_gen", expect_looped=True ) diff --git a/MolecularNodes/assembly/mmtf.py b/MolecularNodes/assembly/mmtf.py index fa7ce7262..013453ebb 100644 --- a/MolecularNodes/assembly/mmtf.py +++ b/MolecularNodes/assembly/mmtf.py @@ -1,9 +1,6 @@ import numpy as np -import biotite.structure.io.mmtf as mmtf -import biotite from . import AssemblyParser - class MMTFAssemblyParser(AssemblyParser): ### Implementation adapted from ``biotite.structure.io.mmtf.assembly`` @@ -12,10 +9,12 @@ def __init__(self, mmtf_file): def list_assemblies(self): + import biotite.structure.io.mmtf as mmtf return mmtf.list_assemblies(self._file) def get_transformations(self, assembly_id): + import biotite # Find desired assembly selected_assembly = None if not "bioAssemblyList" in self._file: diff --git a/MolecularNodes/assembly/pdb.py b/MolecularNodes/assembly/pdb.py index e4a3d99d7..8e423d976 100644 --- a/MolecularNodes/assembly/pdb.py +++ b/MolecularNodes/assembly/pdb.py @@ -1,6 +1,5 @@ import numpy as np -import biotite.structure.io.mmtf as mmtf -import biotite +# import biotite.structure.io.mmtf as mmtf from . import AssemblyParser @@ -16,6 +15,7 @@ def list_assemblies(self): def get_transformations(self, assembly_id): + import biotite # Get lines containing transformations for assemblies remark_lines = self._file.get_remark(350) if remark_lines is None: @@ -102,6 +102,7 @@ def _parse_transformations(lines): *REMARK* 290 or 350. Return as array of matrices and vectors respectively """ + import biotite # Each transformation requires 3 lines for the (x,y,z) components if len(lines) % 3 != 0: raise biotite.InvalidFileError("Invalid number of transformation vectors") diff --git a/MolecularNodes/load.py b/MolecularNodes/load.py index 483fe9993..4bc023dfa 100644 --- a/MolecularNodes/load.py +++ b/MolecularNodes/load.py @@ -1,7 +1,7 @@ import requests import io from pathlib import Path -from biotite import InvalidFileError + import bpy import numpy as np from . import coll @@ -88,6 +88,7 @@ def molecule_rcsb( setup_nodes = True, cache_dir = None, ): + from biotite import InvalidFileError start = time.process_time() mol, file = open_structure_rcsb( pdb_code = pdb_code, @@ -138,7 +139,7 @@ def molecule_local( default_style = 0, setup_nodes = True ): - + from biotite import InvalidFileError import biotite.structure as struc import os @@ -221,6 +222,7 @@ def open_structure_rcsb(pdb_code, cache_dir = None, include_bonds = True): import biotite.structure.io.mmtf as mmtf import biotite.database.rcsb as rcsb + file = mmtf.MMTFFile.read(rcsb.fetch(pdb_code, "mmtf", target_path = cache_dir)) # returns a numpy array stack, where each array in the stack is a model in the From a92ba612b6656c422571e0029de550a91e027189 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 12 Aug 2023 08:21:14 +0800 Subject: [PATCH 2/2] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1b0b483c5..8980b6ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ build/* coverage.xml .coverage *.npz +*.log