PDBIO
indeed expects a full structure. The trick to saving only a subset of that structure is using a Select
class. If you override any of the default methods (accept_chain
, accept_residue
, etc.) you can override which aspects of the SMCRA hierarchy are saved.
from Bio import PDB
class OnlyACAResideus(PDB.Select):
def accept_residue(self, res):
return res in residuesACA
io = PDBIO()
# Presumably, you still have the structure, but you can unfold it like so:
struct = PDB.Selection.unfold_entities(residuesACA, 'S')[0]
io.set_structure(struct)
io.save("struct.pdb", select=OnlyACAResidues())