[Biopython] Write chains...
Peter
biopython at maubp.freeserve.co.uk
Fri Sep 11 09:33:09 UTC 2009
On Thu, Sep 10, 2009 at 10:07 PM, Yasser Almeida Hernandez
<pedro.al at fenhi.uh.cu> wrote:
> Hi all!!
>
> How can i write custom chains of a PDB.
> For example a protein have A, B, C and D chains and i want
> to write only the B and C chains....
>
> Thanks
You can do this with Bio.PDB - see pages 5 and 6 of the Bio.PDB
documentation:
http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf
i.e. Write a "Select class" which picks out only the chains you
want (implement this in the accept_chain method).
Here is a related example picking atoms:
http://lists.open-bio.org/pipermail/biopython/2009-May/005174.html
Alternatively, for a more low-level solution, you could do it manually:
out = open("filtered.pdb", "w")
for line in open("input.pdb") :
if (line.startswith("ATOM") or line.startswith("HETATM")) \
and line[21] not in "BC" : continue
out.write(line)
out.close()
[I'd recommend you try and learn how to use Bio.PDB as it is
much more powerful in the long run.]
Peter
More information about the Biopython
mailing list