WriteSS

From PyMOLWiki
Jump to: navigation, search

Contents

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
 
from pymol import cmd
from pymol import stored
from pymol import selector
 
files = glob.glob("/tmp/thy_model/*.pdb")
 
for file in files:
        pdbName = os.path.basename(file).split(".")[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..................................................
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox