From 84155afd189dc0e3792b327dc46734b781953804 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 2 Aug 2023 17:20:21 +0800 Subject: [PATCH] add docstring and rename get_assemblies --- MolecularNodes/assembly/__init__.py | 15 +++++++++++++++ MolecularNodes/assembly/cif.py | 2 +- MolecularNodes/assembly/mmtf.py | 2 +- MolecularNodes/assembly/pdb.py | 2 +- MolecularNodes/load.py | 6 +++--- .../md_ppr/.first_5_frames.xtc_offsets.npz | Bin 1060 -> 1060 bytes 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/MolecularNodes/assembly/__init__.py b/MolecularNodes/assembly/__init__.py index 73e8327b..94f5140b 100644 --- a/MolecularNodes/assembly/__init__.py +++ b/MolecularNodes/assembly/__init__.py @@ -32,4 +32,19 @@ def get_transformations(self, assembly_id): | | | translation vector | | | | list[tuple[ndarray, ndarray, ndarray]]] + """ + + @abstractmethod + def get_assemblies(self): + """ + Parse all the transformations for each assembly, returning a dictionary of + key:value pairs of assembly_id:transformations. The transformations list + comes from the `get_transformations(assembly_id)` method. + + Dictionary of all assemblies + | Assembly ID + | | List of transformations to create biological assembly. + | | | + dict{'1', list[transformations]} + """ \ No newline at end of file diff --git a/MolecularNodes/assembly/cif.py b/MolecularNodes/assembly/cif.py index 0aaea473..e858cb2b 100644 --- a/MolecularNodes/assembly/cif.py +++ b/MolecularNodes/assembly/cif.py @@ -73,7 +73,7 @@ def get_transformations(self, assembly_id): return transformations - def get_all_transformations(self): + def get_assemblies(self): assembly_dict = {} for assembly_id in self.list_assemblies(): assembly_dict[assembly_id] = self.get_transformations(assembly_id) diff --git a/MolecularNodes/assembly/mmtf.py b/MolecularNodes/assembly/mmtf.py index d812d775..790405e6 100644 --- a/MolecularNodes/assembly/mmtf.py +++ b/MolecularNodes/assembly/mmtf.py @@ -48,7 +48,7 @@ def get_transformations(self, assembly_id): return transformations - def get_all_transformations(self): + def get_assemblies(self): assembly_dict = {} for assembly_id in self.list_assemblies(): assembly_dict[assembly_id] = self.get_transformations(assembly_id) diff --git a/MolecularNodes/assembly/pdb.py b/MolecularNodes/assembly/pdb.py index d5cacfb4..d29639c4 100644 --- a/MolecularNodes/assembly/pdb.py +++ b/MolecularNodes/assembly/pdb.py @@ -88,7 +88,7 @@ def get_transformations(self, assembly_id): return transformations - def get_all_transformations(self): + def get_assemblies(self): assembly_dict = {} for assembly_id in self.list_assemblies(): assembly_dict[assembly_id] = self.get_transformations(assembly_id) diff --git a/MolecularNodes/load.py b/MolecularNodes/load.py index 1889b438..dad28915 100644 --- a/MolecularNodes/load.py +++ b/MolecularNodes/load.py @@ -116,7 +116,7 @@ def molecule_rcsb( try: parsed_assembly_file = assembly.mmtf.MMTFAssemblyParser(file) - mol_object['biological_assemblies'] = parsed_assembly_file.get_all_transformations() + mol_object['biological_assemblies'] = parsed_assembly_file.get_assemblies() except InvalidFileError: pass @@ -143,14 +143,14 @@ def molecule_local( if file_ext == '.pdb': mol, file = open_structure_local_pdb(file_path, include_bonds) try: - transforms = assembly.pdb.PDBAssemblyParser(file).get_all_transformations() + transforms = assembly.pdb.PDBAssemblyParser(file).get_assemblies() except InvalidFileError: transforms = None elif file_ext == '.pdbx' or file_ext == '.cif': mol, file = open_structure_local_pdbx(file_path, include_bonds) try: - transforms = assembly.cif.CIFAssemblyParser(file).get_all_transformations() + transforms = assembly.cif.CIFAssemblyParser(file).get_assemblies() except InvalidFileError: transforms = None diff --git a/tests/data/md_ppr/.first_5_frames.xtc_offsets.npz b/tests/data/md_ppr/.first_5_frames.xtc_offsets.npz index 6d5782272b1965243d31d4127557c4072b787349..baca5f9b645305b7e4d04d5d6d661664517e47fe 100644 GIT binary patch delta 37 pcmZ3&v4ms8Rz{YCleP*^-pRO$$?_^xb_SWsnuN2A68BA_a!A;CX04Q}2c>n+a