Skip to content

Commit

Permalink
Merge pull request #289 from BradyAJohnston/288-enabling-error
Browse files Browse the repository at this point in the history
fix: enabling error without `biotite` installed
  • Loading branch information
BradyAJohnston authored Aug 12, 2023
2 parents 3de6ae9 + a92ba61 commit 227fb0a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ build/*
coverage.xml
.coverage
*.npz
*.log
5 changes: 3 additions & 2 deletions MolecularNodes/assembly/cif.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import itertools
import biotite.structure.io.pdbx as pdbx
import biotite

from . import AssemblyParser


Expand All @@ -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
)
Expand Down
5 changes: 2 additions & 3 deletions MolecularNodes/assembly/mmtf.py
Original file line number Diff line number Diff line change
@@ -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``

Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions MolecularNodes/assembly/pdb.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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:
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions MolecularNodes/load.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -138,7 +139,7 @@ def molecule_local(
default_style = 0,
setup_nodes = True
):

from biotite import InvalidFileError
import biotite.structure as struc
import os

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 227fb0a

Please sign in to comment.