CreateSecondaryStructure: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
*Many bugs found, need to be worked out before further use... stay tuned.
===DESCRIPTION===
===DESCRIPTION===
To enable growing of a peptide sequence of one of the terminalsThe 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.
To build a peptide sequence.   
 
Functions:
*extendHelix
*createSS
*set_phipsi


===SETUP===
===SETUP===
Line 14: Line 6:


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


===USAGE===
===USAGE===
  extendHelix selection,sequence,repeat [, phi] [, psi] [, terminal ]
*seqInfo = getTableFromCsvFile("seqInfo.csv")
set_phipsi selection, phi, psi
  with in the file something like:
MET,-54,-47
PRO,-54,-47
 
*seqInfo = [['MET',-57,-47],['PRO',-57,-47]]
*createPeptide(seqInfo)


===EXAMPLES===
===EXAMPLES===
  extendHelix('resi 1371', 'ALA,GLN,HIS,ALA', 5)
  seqInfo = [['MET',-57,-47],['PRO',-57,-47]]
set_phipsi('resi 1371', -60, -60)
createPeptide(seqInfo)


===SCRIPTS (CreateSecondaryStructures.py)===
===SCRIPTS (CreateSecondaryStructures.py)===
CreateSecondaryStructures.py  
CreateSecondaryStructures.py  
  <source lang="python">
  <source lang="python">
##############################################
##############################################
#  Author:  Dan Kulp
Original Author:  Dan Kulp
#  Date  :  9/8/2005
#  Date  :  9/8/2005
#    MOdified by Jurgen F. Doreleijers
#    For Hamid Eghbalnia             
#
#
#
#  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
#############################################
#############################################
 
# Call in window like :
import string
# @C:\Documents and Settings\jurgen.WHELK.000\workspace\Wattos\python\Wattos\Utils\CreateSecondaryStructures.py
 
# Next line is a pymol directive
# Wrapper Functions...
python
print "extendHelix(selection,sequence,repeat)"
import urllib
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")




# Well I guess one can build a protein with it but the vdw contacts would be horrible.
# Peptide needs to be at least 2 residues.
def createPeptide(seqInfo):
    cmd.delete("all")
    # Creates residue TWO
    editor.attach_amino_acid('pk1',seqInfo[1][0])
    # Creates residue ONE
    createSS('resi 2', sequence=seqInfo[0][0],terminal='N')
    print "found sequence info for number of residues: ", len(seqInfo)
    for i in range(2,len(seqInfo) ):
        # resn is the residue number of the new residue
        resn = i + 1
        print "Adding residue: ", resn,  seqInfo[i][0]
        # Note that the previous residue is numbered i.
        resi = 'resi '+`i`
        createSS(resi, sequence=seqInfo[i][0])
    for i in range( len(seqInfo) ):
        resi = 'resi '+`i+1`
#        print "Setting backbone angles for residue: ", (i+1),  seqInfo[i][0],seqInfo[i][1],seqInfo[i][2]
        set_phipsi(resi,seqInfo[i][1],seqInfo[i][2])
   
# 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,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
    # Set selection
cmd.edit(selection,None,None,None,pkresi=0,pkbond=0)
    selection = "%s and name %s" % (sel,terminal)


# Array of residues
    # Pick atom for editing - interestingly only need to do this for the first addition
seq = string.split(sequence,",")
    cmd.edit(selection,None,None,None,pkresi=0,pkbond=0)


# Get residue numbering .. potential bug here if number is inconsistent.. (Only works at c-terminal)
    # Array of residues
resi = int(cmd.get_model(sel).atom[0].resi) + 1
    seq = sequence.split(",")
# 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
    # Get residue numbering .. potential bug here if number is inconsistent.. (Only works at c-terminal)
if terminal == 'N':
    resi = int(cmd.get_model(sel).atom[0].resi) + 1
resi -= repeat
    # Loop and build new residues
    for i in range(1,repeat+1):
for i in range(0,repeat+1):
        for s in seq:
for s in seq:
#            print "residue[%i]: %s %s" % (i,s,terminal)
set_phipsi("resi %i" % (resi), phi,psi)
            editor.attach_amino_acid('pk1',s)
resi += 1


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


# Set up some variables..
    # Loop through atoms in selection      
residues = ['dummy']  # Keep track of residues already done
    for at in atoms.atom:
probs = []            # probability of each residue conformation
        if at.name == "N":
 
            # Check for a null chain id (some PDBs contain this)  
# Get atoms from selection
            unit_select = ""
atoms = cmd.get_model("byres ("+sel+")")
            if not at.chain == "":
 
              unit_select = "chain "+str(at.chain)+" and "
        # Loop through atoms in selection
   
for at in atoms.atom:
            try:
    try:
                # Define residue selections    
      # Don't process Glycines or Alanines
                residue_def_prev = unit_select+'resi '+str(int(at.resi)-1)
if at.resn == 'GLY' or at.chain+":"+at.resn+":"+at.resi in residues:
                residue_def      = unit_select+'resi '+str(at.resi)      
continue
#                print "residue_def_prev: [%s]" % residue_def_prev
 
#               print "residue_def    : [%s]" % residue_def
        residues.append(at.chain+":"+at.resn+":"+at.resi)
                if at.resn == "PRO":
 
                    print "Skipping setting phi for PRO"
        # Check for a null chain id (some PDBs contain this)  
                else:
        unit_select = ""
                    old_phi = cmd.get_dihedral(residue_def_prev+' and name C',residue_def+' and name N', residue_def+' and name CA',residue_def+' and name C')      
if not at.chain == "":
                    cmd.set_dihedral(         residue_def_prev+' and name C',residue_def+' and name N', residue_def+' and name CA',residue_def+' and name C'     ,phi)
  unit_select = "chain "+str(at.chain)+" and "
                    print "Changed residue %4s %4s phi: from %6.1f to %6.1f" % (at.resn, at.resi, old_phi, float(phi))      
 
            except:
        # Define selections for residue i-1, i and i+1   
               
residue_def = unit_select+'resi '+str(at.resi)
                print "Note skipping set of phi because of error; this is normal for a N-terminal residue"
  residue_def_prev = unit_select+'resi '+str(int(at.resi)-1)
            try:
# residue_def_next = unit_select+'resi '+str(int(at.resi)+1)
                residue_def      = unit_select+'resi '+str(at.resi)
 
                residue_def_next = unit_select+'resi '+str(int(at.resi)+1)
        # Compute phi/psi angle
#                print "residue_def    : [%s]" % residue_def
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')
#                print "residue_def_next: [%s]" % residue_def_next
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')
                old_psi = cmd.get_dihedral(residue_def     +' and name N',residue_def+' and name CA',residue_def+' and name C', residue_def_next+' and name N')
 
                cmd.set_dihedral(         residue_def     +' and name N',residue_def+' and name CA',residue_def+' and name C', residue_def_next+' and name N',psi)
print "Changing "+at.resn+str(at.resi)+" from "+str(old_phi)+","+str(old_psi)+" to "+str(phi)+","+str(psi)
                print "Changed residue %4s %4s psi: from %6.1f to %6.1f" % (at.resn, at.resi, old_psi, float(psi))       
 
            except:
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)
                print "Note skipping set of psi; this is normal for a C terminal residue"
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


def getTableFromCsvFile(urlLocation):
  result = []
  r1 = urllib.urlopen(urlLocation)
  data = r1.read()
  r1.close() 
  dataLines = data.split("\n") 
  for dataLine in dataLines:
    if dataLine:
        result.append( dataLine.split(',') )   
  return result


# next line is a pymol directive.
python end


os.chdir("C:\Documents and Settings\jurgen.WHELK.000\workspace\Wattos\python\Wattos\Utils")
seqInfo = getTableFromCsvFile("seqInfo.csv")
createPeptide(seqInfo)


</source>
</source>
Line 141: Line 145:


[[Category:Script_Library|CreateSecondaryStructure]]
[[Category:Script_Library|CreateSecondaryStructure]]
[[Category:Structural_Biology_Scripts|CreateSecondaryStructure]]
[[Category:Structural_Biology_Scripts|CreateSecondaryStructure]]

Latest revision as of 03:14, 27 November 2009

DESCRIPTION

To build a peptide sequence.

SETUP

run CreateSecondaryStructure.py

NOTES / STATUS

  • Tested on Pymolv1.0, Windows platform
  • Many bugs to be found

USAGE

  • seqInfo = getTableFromCsvFile("seqInfo.csv")
with in the file something like:
MET,-54,-47
PRO,-54,-47
  • seqInfo = [['MET',-57,-47],['PRO',-57,-47]]
  • createPeptide(seqInfo)

EXAMPLES

seqInfo = [['MET',-57,-47],['PRO',-57,-47]]
createPeptide(seqInfo)

SCRIPTS (CreateSecondaryStructures.py)

CreateSecondaryStructures.py

##############################################
#   Original Author:  Dan Kulp
#   Date  :  9/8/2005
#    MOdified by Jurgen F. Doreleijers
#    For Hamid Eghbalnia               
#
#############################################
# Call in window like : 
# @C:\Documents and Settings\jurgen.WHELK.000\workspace\Wattos\python\Wattos\Utils\CreateSecondaryStructures.py
# Next line is a pymol directive
python
import urllib


# Well I guess one can build a protein with it but the vdw contacts would be horrible.
# Peptide needs to be at least 2 residues.
def createPeptide(seqInfo):
    cmd.delete("all")
    # Creates residue TWO
    editor.attach_amino_acid('pk1',seqInfo[1][0]) 
    # Creates residue ONE
    createSS('resi 2', sequence=seqInfo[0][0],terminal='N')
    print "found sequence info for number of residues: ", len(seqInfo)
    for i in range(2,len(seqInfo) ):
        # resn is the residue number of the new residue
        resn = i + 1
        print "Adding residue: ", resn,   seqInfo[i][0]
        # Note that the previous residue is numbered i. 
        resi = 'resi '+`i`
        createSS(resi, sequence=seqInfo[i][0])
    for i in range( len(seqInfo) ):
        resi = 'resi '+`i+1`
#        print "Setting backbone angles for residue: ", (i+1),   seqInfo[i][0],seqInfo[i][1],seqInfo[i][2]
        set_phipsi(resi,seqInfo[i][1],seqInfo[i][2])
    
# Create generic secondary structure, based off a selection
def createSS(sel, sequence='ALA',repeat=1,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 = sequence.split(",")

    # 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 %s" % (i,s,terminal)
            editor.attach_amino_acid('pk1',s)

    # 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):
    # Get atoms from selection
    atoms = cmd.get_model("byres ("+sel+")")

    # Loop through atoms in selection        
    for at in atoms.atom:
        if at.name == "N":
            # Check for a null chain id (some PDBs contain this) 
            unit_select = ""
            if not at.chain == "":
               unit_select = "chain "+str(at.chain)+" and "
    
            try:
                # Define residue selections     
                residue_def_prev = unit_select+'resi '+str(int(at.resi)-1)
                residue_def      = unit_select+'resi '+str(at.resi)        
#                print "residue_def_prev: [%s]" % residue_def_prev
#                print "residue_def     : [%s]" % residue_def
                if at.resn == "PRO":
                    print "Skipping setting phi for PRO"
                else:
                    old_phi = cmd.get_dihedral(residue_def_prev+' and name C',residue_def+' and name N', residue_def+' and name CA',residue_def+' and name C')        
                    cmd.set_dihedral(          residue_def_prev+' and name C',residue_def+' and name N', residue_def+' and name CA',residue_def+' and name C'      ,phi)
                    print "Changed residue %4s %4s phi: from %6.1f to %6.1f" % (at.resn, at.resi, old_phi, float(phi))        
            except:
                
                print "Note skipping set of phi because of error; this is normal for a N-terminal residue"
            try:
                residue_def      = unit_select+'resi '+str(at.resi)
                residue_def_next = unit_select+'resi '+str(int(at.resi)+1)
#                print "residue_def     : [%s]" % residue_def
#                print "residue_def_next: [%s]" % residue_def_next
                old_psi = cmd.get_dihedral(residue_def     +' and name N',residue_def+' and name CA',residue_def+' and name C', residue_def_next+' and name N')
                cmd.set_dihedral(          residue_def     +' and name N',residue_def+' and name CA',residue_def+' and name C', residue_def_next+' and name N',psi)
                print "Changed residue %4s %4s psi: from %6.1f to %6.1f" % (at.resn, at.resi, old_psi, float(psi))        
            except:
                print "Note skipping set of psi; this is normal for a C terminal residue"

def getTableFromCsvFile(urlLocation):
  result = []
  r1 = urllib.urlopen(urlLocation)
  data = r1.read()
  r1.close()  
  dataLines = data.split("\n")   
  for dataLine in dataLines:
    if dataLine:
        result.append( dataLine.split(',') )     
  return result

# next line is a pymol directive.
python end

os.chdir("C:\Documents and Settings\jurgen.WHELK.000\workspace\Wattos\python\Wattos\Utils")
seqInfo = getTableFromCsvFile("seqInfo.csv")
createPeptide(seqInfo)