Skip to content

Commit

Permalink
optional infer_bonds for convert and writeMMTF
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Jan 24, 2024
1 parent 6b81e9c commit 3038446
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions prody/atomic/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def toBioPythonStructure(self, header=None, **kwargs):
:arg csets: coordinate set indices, default is all coordinate sets
:arg infer_bonds: whether to infer new bonds
:type infer_bonds: bool
"""
try:
from Bio.PDB.Structure import Structure
Expand All @@ -308,6 +310,10 @@ def toBioPythonStructure(self, header=None, **kwargs):
if csets is None:
csets = range(self.numCoordsets())

infer_bonds = kwargs.get('infer_bonds', False)
if infer_bonds:
self.inferBonds()

structure_builder = StructureBuilder()
structure_builder.init_structure(self.getTitle())
if header is not None:
Expand Down
6 changes: 4 additions & 2 deletions prody/proteins/mmtffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ def writeMMTF(filename, atoms, csets=None, autoext=True, **kwargs):
'to solve the problem.')

header = kwargs.get('header', None)
infer_bonds = kwargs.get('infer_bonds', False)

if autoext and not filename.lower().endswith('.mmtf'):
filename += '.mmtf'

structure = atoms.toBioPythonStructure(header=header, csets=csets)
structure = atoms.toBioPythonStructure(header=header, csets=csets,
infer_bonds=infer_bonds)
io=MMTFIO()
io.set_structure(structure)
io.save(filename)
io.save(filename, num_bonds=atoms.numBonds())
return filename

0 comments on commit 3038446

Please sign in to comment.