WriteSS

From PyMOLWiki
Revision as of 08:43, 30 April 2009 by Inchoate (talk | contribs)
Jump to navigation Jump to search

Overview

This script will write the secondary structural elements for each PDB file in some specified directory, for each alpha carbon in the protein, to an output text file. Residues without secondary structure definition will get a "." in the string.

This is untested code and has little chance of working for anyone but me. Although, it does work for me.

Instructions

  1. Copy the code to your machine
  2. Find FIXME in the code below and change "files" to either a glob like the one already there (for a whole directory) or a list with one element (for just one file).
  3. change the output filename. By default it's PDBCODE.ss.

The Code

import os;
import os.path;
import glob;
import string;

from pymol import cmd
from pymol import stored
from pymol import selector

files = glob.glob("/tmp/thy_model/*.pdb")

for file in files:
        pdbName = string.split(os.path.basename(file), ".")[0]
        cmd.load(file, pdbName)
        outFile = open(pdbName + '.ss', 'wb')
        stored.ss = ""
        cmd.iterate( '(n. CA)', 'stored.ss = stored.ss + ("%1s"%ss)')
        for c in stored.ss:
                if c  == " ":
                        outFile.write('.')
                else:
                        outFile.write(c)
        cmd.delete(pdbName)
        outFile.close()

Example

python ss.pym  # my directory has 1d7p.pdb in it

output for 1D7P.pdb:

...............HHH.......SSS..SSSHHHHH..................................................................SS..SS..................................................