Pdb to movie.py

From Docswiki
Jump to navigation Jump to search
#! /usr/bin/env python

"""
   Calculates the movieseg or a OPTIM coord file from a given PDB file

   arguments:
    

50       format('CA: ',3(f8.3,1x),'CB: ',3(f8.3,1x),'Ox: ', 3(f8.3,1x))
334     format(4(i8,1x),' nmres nmcrd numpro nmsnap')

"""

import sys
import string
from Bio.PDB.PDBParser import PDBParser

PDBfile='1uzc'
pars = PDBParser(PERMISSIVE = 1)
struct = pars.get_structure(PDBfile.rstrip('.pdb'), PDBfile)
model = struct.child_list[0]
chain = model.child_list[0]

print "      69        3        1        1  nmres nmcrd numpro nmsnap"

for residue in chain:
  cx=0.0
  cy=0.0
  cz=0.0
  cbx=0.0
  cby=0.0
  cbz=0.0
  ox=0.0
  oy=0.0
  oz=0.0

  if residue.has_id("CA"):
      ca=residue["CA"]
      cx=ca.get_coord()[0]
      cy=ca.get_coord()[1]
      cz=ca.get_coord()[2]

  if residue.has_id("CB"):
      cb=residue["CB"]
#       print "CB"
#       print cb.get_coord()
      cbx=cb.get_coord()[0]
      cby=cb.get_coord()[1]
      cbz=cb.get_coord()[2]
  else:
      cbx=cx
      cby=cy
      cbz=cz

  if residue.has_id("O"):
      o=residue["O"]
#       print " O"
#       print o.get_coord()
      ox=o.get_coord()[0]
      oy=o.get_coord()[1]
      oz=o.get_coord()[2]

  print "CA: %8.3f %8.3f %8.3f CB: %8.3f %8.3f %8.3f OX: %8.3f %8.3f %8.3f" % (cx,cy,cz,cbx,cby,cbz,ox,oy,oz)
# Uncomment for lowest or OPTIM coord files
#   print "   %8.3f                %8.3f                 %8.3f " % (cx,cy,cz)
#   print "   %8.3f                %8.3f                 %8.3f " % (cbx,cby,cbz)
#   print "   %8.3f                %8.3f                 %8.3f " % (ox,oy,oz)