[Biopython] Save custom structure...

Peter biopython at maubp.freeserve.co.uk
Wed Jan 6 15:10:01 UTC 2010


2010/1/6 Yasser Almeida Hernández <pedro.al at fenhi.uh.cu>:
> I used the "add" method in the Residue class for add the atom object to the
> residue. That's right that i need a structure object, but how i build this
> object "de novo" and a how add a new residue on it???

I've not tried that myself, so I don't have any suggestions beyond
looking over the documentation - or even the Bio.PDB code itself.

> I used the StructureBuilder class with the init_* methods (model, chain,
> residue etc.) and then the get_structure method, but it doesn't work:
>
> # EXPERIMENTAL CODE
> res.add(contact)   # Add a atom to the residue of interest
>
> output_structure = StructureBuilder.StructureBuilder()
> output_structure.init_structure('OUT_STRUCT')
>
> output_structure.init_model(0)
> output_structure.init_chain('X')
> output_structure.get_structure()

Note that the get_structure() call returns a structure, but you
are ignoring the return value.

> output_structure[0]['X'].add(res)
> io = PDBIO()
> io.set_structure(output_structure)
> pdb_out_filename = "cont_res_plus_contact.pdb"
> io.save(pdb_out_filename, output_structure)

You code snippet is incomplete - which makes it harder to
try to follow what you are doing. It is missing all the import
statements and the definition of the res variable.

> I'm processing a hundred of pdb files, and i need this code for write
> residues and atoms in different conformational states...

Perhaps I had misunderstood - I thought you were starting
with a given PDB file, and wanted to select some particular
residues/atoms, and output a new partial PDB file with just
those bits. That should work using a Select class to create
a sub-structure from the original full structure from parsing
the original PDF file. i.e You don't need to create a new
structure object "de novo".

Peter




More information about the Biopython mailing list