Skip to content

Commit

Permalink
add docstring and rename get_assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Aug 2, 2023
1 parent 73087bc commit 84155af
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
15 changes: 15 additions & 0 deletions MolecularNodes/assembly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
"""
2 changes: 1 addition & 1 deletion MolecularNodes/assembly/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion MolecularNodes/assembly/mmtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion MolecularNodes/assembly/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions MolecularNodes/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 121 in MolecularNodes/load.py

View check run for this annotation

Codecov / codecov/patch

MolecularNodes/load.py#L120-L121

Added lines #L120 - L121 were not covered by tests

Expand All @@ -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

Check warning on line 148 in MolecularNodes/load.py

View check run for this annotation

Codecov / codecov/patch

MolecularNodes/load.py#L147-L148

Added lines #L147 - L148 were not covered by tests

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

Expand Down
Binary file modified tests/data/md_ppr/.first_5_frames.xtc_offsets.npz
Binary file not shown.

0 comments on commit 84155af

Please sign in to comment.