[BioPython] extracting a single model from PDB file

Thomas Hamelryck thamelry at binf.ku.dk
Mon Feb 27 11:49:31 EST 2006


On Mon, February 27, 2006 5:35 pm, Iddo Friedberg wrote:
> Hi,
>
>
> Does anyone have code for extracting a single model from a PDB file, and
> then printing it as another PDB-like file?

Something like this will work:

class ModelSelect(Select):
    def __init__(self, model_id):
        self.model_id=model_id
    def accept_model(self, model):
        if model.get_id()==self.model_id:
            return 1
        else:
            return 0

# Select model 0 for output
ms0=ModelSelect(0)

io=PDBIO()
io.set_structure(structure)
io.save("out.pdb", select=ms0)

Cheers,

-Thomas



More information about the BioPython mailing list