Pdb to movie.py: Difference between revisions

From CUC3
Jump to navigation Jump to search
import>Mp466
No edit summary
import>Mp466
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
#! /usr/bin/env python

"""
Calculates the movieseg from a given PDB file


#! /usr/bin/env python
"""
Calculates the movieseg or a OPTIM coord file from a given PDB file
arguments:
arguments:
PDBfile - the PDB file to score
50 format('CA: ',3(f8.3,1x),'CB: ',3(f8.3,1x),'Ox: ', 3(f8.3,1x))

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')
334 format(4(i8,1x),' nmres nmcrd numpro nmsnap')
"""

"""
import sys

import sys
import string
from Bio.PDB.PDBParser import PDBParser
import string
from Bio.PDB.PDBParser import PDBParser
PDBfile='1uzc'

pars = PDBParser(PERMISSIVE = 1)
PDBfile='1uzc'
struct = pars.get_structure(PDBfile.rstrip('.pdb'), PDBfile)
pars = PDBParser(PERMISSIVE = 1)
model = struct.child_list[0]
struct = pars.get_structure(PDBfile.rstrip('.pdb'), PDBfile)
model = struct.child_list[0]
chain = model.child_list[0]
chain = model.child_list[0]
print " 69 3 1 1 nmres nmcrd numpro nmsnap"

print " 69 3 1 1 nmres nmcrd numpro nmsnap"
for residue in chain:

for residue in chain:
cx=0.0
cx=0.0
cy=0.0
cy=0.0
Line 35: Line 35:
oy=0.0
oy=0.0
oz=0.0
oz=0.0

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

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

if residue.has_id("O"):
if residue.has_id("O"):
o=residue["O"]
o=residue["O"]
# print " O"
# print " O"
# print o.get_coord()
# print o.get_coord()
ox=o.get_coord()[0]
ox=o.get_coord()[0]
oy=o.get_coord()[1]
oy=o.get_coord()[1]
oz=o.get_coord()[2]
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)
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)

Latest revision as of 19:48, 8 May 2009

#! /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)