This is a read-only mirror of pymolwiki.org

Difference between revisions of "CreateSecondaryStructure"

From PyMOL Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
 
*Many bugs found, need to be worked out before further use... stay tuned.
 
*Many bugs found, need to be worked out before further use... stay tuned.
  
Line 59: Line 58:
  
 
# Create generic secondary structure, based off a selection
 
# Create generic secondary structure, based off a selection
def createSS(sel, sequence='ALA',repeat='1',phi=-60,psi=-60,terminal='C'):
+
def createSS(sel, sequence='ALA',repeat=1,phi=-60,psi=-60,terminal='C'):
  
 
# Set selection
 
# Set selection

Revision as of 17:12, 16 August 2007

  • Many bugs found, need to be worked out before further use... stay tuned.

DESCRIPTION

To enable growing of a peptide sequence of one of the terminals. The growing can be set to any secondary structure (phi,psi pairing). Only extendHelix is currently implemented, but it should be rather simple to add more functions in or tweak the existing ones.

Functions:

  • extendHelix
  • createSS
  • set_phipsi

SETUP

run CreateSecondaryStructure.py

NOTES / STATUS

  • Tested on Pymolv0.97, Windows platform
  • N-terminal growing doesn't work: adds residues, but doesn't set angles correctly
  • Many bugs found, need to be worked out before further use... stay tuned.

USAGE

extendHelix selection,sequence,repeat [, phi] [, psi] [, terminal ]
set_phipsi selection, phi, psi

EXAMPLES

extendHelix('resi 1371', 'ALA,GLN,HIS,ALA', 5)
set_phipsi('resi 1371', -60, -60)

SCRIPTS (CreateSecondaryStructures.py)

CreateSecondaryStructures.py

##############################################
#   Author:  Dan Kulp
#   Date  :  9/8/2005
#
#
#   Notes: 
#      - Simple builds a string of residues
#          and sets the phi,psi angles.
#      - No energies are computed.
#      - This will generate a starting point.
#      - Defaultly grows from C-term, 
#      - N-term growing currently broken
#############################################

import string

# Wrapper Functions...
print "extendHelix(selection,sequence,repeat)"
print "Example:\n\t extendHelix('resi 1371', 'ALA,GLN,HIS,ALA', 5)"
print "Note: simple build of residue type and phi,psi angle; no energy computed"	

def extendHelix(sel,seq,repeat=1,phi=-60,psi=-60,terminal='C'):
	createSS(sel,seq,repeat,phi,psi,string.upper(terminal))
	cmd.select("extendedHelix","all")
	cmd.deselect()
	cmd.save("./extendedHelix.pdb","extendedHelix")


# Create generic secondary structure, based off a selection
def createSS(sel, sequence='ALA',repeat=1,phi=-60,psi=-60,terminal='C'):

	# Set selection
	selection = "%s and name %s" % (sel,terminal)

	# Pick atom for editing - interestingly only need to do this for the first addition
	cmd.edit(selection,None,None,None,pkresi=0,pkbond=0)

	# Array of residues
	seq = string.split(sequence,",")

	# Get residue numbering .. potential bug here if number is inconsistent.. (Only works at c-terminal)
	resi = int(cmd.get_model(sel).atom[0].resi) + 1
	
	# Loop and build new residues
	for i in range(1,repeat+1):
		for s in seq:
			print "residue[%i]: %s" % (i,s)
			editor.attach_amino_acid('pk1',s)

	# Loop and set phi,psi angles for new residues
	if terminal == 'N':
		resi -= repeat
		
	for i in range(0,repeat+1):
		for s in seq:
			set_phipsi("resi %i" % (resi), phi,psi)
			resi += 1

	# Remove extra OXT carboxylate atom (OXT1, OXT2 ?) .. fix as needed
	if terminal == 'C':
		cmd.remove("%s and name OXT" % sel)
	
	
def set_phipsi(sel,phi,psi):

	# Set up some variables..
	residues = ['dummy']  # Keep track of residues already done
	probs = []            # probability of each residue conformation

	# Get atoms from selection
	atoms = cmd.get_model("byres ("+sel+")")

        # Loop through atoms in selection		
	for at in atoms.atom:
	    try:
	       # Don't process Glycines or Alanines
		if at.resn == 'GLY' or at.chain+":"+at.resn+":"+at.resi in residues:
			continue

	        residues.append(at.chain+":"+at.resn+":"+at.resi)

	        # Check for a null chain id (some PDBs contain this) 
	        unit_select = ""
		if not at.chain == "":
		   unit_select = "chain "+str(at.chain)+" and "

	        # Define selections for residue i-1, i and i+1    
		residue_def = unit_select+'resi '+str(at.resi)
  		residue_def_prev = unit_select+'resi '+str(int(at.resi)-1)
#		residue_def_next = unit_select+'resi '+str(int(at.resi)+1)

	        # Compute phi/psi angle
		old_phi = cmd.get_dihedral(residue_def+' and name CB',residue_def+' and name CA',residue_def+' and name N',residue_def_prev+' and name C')
		old_psi = cmd.get_dihedral(residue_def+' and name O',residue_def+' and name C',residue_def+' and name CA',residue_def+' and name CB')

		print "Changing "+at.resn+str(at.resi)+" from "+str(old_phi)+","+str(old_psi)+" to "+str(phi)+","+str(psi)

		cmd.set_dihedral(residue_def+' and name CB',residue_def+' and name CA',residue_def+' and name N',residue_def_prev+' and name C',phi)
		cmd.set_dihedral(residue_def+' and name O',residue_def+' and name C',residue_def+' and name CA',residue_def+' and name CB', psi)

	    except:
		print "Exception Thrown"
		continue