Пример #1
0
def build_seq(seq,ss=None,phi=None,psi=None):
  """
  usage: build_seq seq [, ss=helix | phi=phi, psi=psi]
  example: build_seq QGAADLESLGQYFEEMKTKLIQDMTE, ss=helix 

  will build the above sequence in a helical conformation
  ss can be: helix or h or alpha  (phi=-57, psi=-47)
             antiparallel or beta (phi=-139, psi=-135)
             parallel             (phi=-119, psi=-113)
             3/10 helix           (phi=-40.7,psi=30)
             polypro              (phi=-78, psi=149) (polyproline helix type II)

  Alternatively, you can specify the phi and psi angles directly:

  build_seq QGAADLESLGQ, phi=-60, psi=-40

  This will create an object named after the first residue: gln
  unless a pk1 selection exists, then it will build onto that atom.

  """

  if 'pk1' in cmd.get_names("selections"):
    obj='pk1'
  else:
    obj=seq[0:3]

  if phi == None or psi == None:
    if ss == None:
      phi = -139
      psi = -135
    else:
      ss = ss.lower()
      if ss[0:5] == 'helix' or ss[0] == 'h' or ss[0:5] == 'alpha':
        phi = -57
        psi = -47
      elif ss[0:5] == 'antip' or ss[0:4] == 'beta':
        phi = -139
        psi = -135
      elif ss[0:5] == 'paral':
        phi = -119
        psi = -113
      elif ss[0:4] == '3/10':
        phi = -40.7
        psi = -30
      elif ss[0:7] == 'polypro':
        phi = -78
        psi = 149

  print "Building sequence: ",seq
  seq3=seq_convert.seq1_to_seq3(seq)

  attach_amino_acid(obj,seq3[0].lower(),phi,psi)
  for aa in seq3[1:]:
    aa = aa.lower()
    attach_amino_acid('pk1',aa,phi,psi)
Пример #2
0
def build_seq_phi_psi(seq_phi_psi_filename,line_style=0):
  """
  usage: build_seq_phi_psi filename

  will build the above sequence from information in a file stored as:
  resname phi psi
  resname phi psi
  ...

  where resname is the 1-letter code for the amino acid

  The created object will be named for the first amino acid in the sequence,
  unless a pk1 selection exists, then it will build onto that atom.

  Default is now to automatically show the structure as sticks, call it with
  line_style=1 to revert to showing lines

  """

  line_style = int(line_style)
# read file of residue name with associated phi,psi values to build
  lines = open(seq_phi_psi_filename).readlines()
  sequence = ''
  phi_list = []
  psi_list = []
  sequence3 = []
  counter = 0
  for l in lines:
    if len(l.split()) == 3:
      counter += 1
      seq,phi,psi = l.split()
      if len(seq) == 3:
        sequence3.append(seq)
      elif len(seq) == 1:
        sequence += seq
      else:
        print " Error: problem with sequence file -- not 3-letter or 1-letter code for residue name"
        raise QuietException
    else:
      continue


    phi_list.append(float(phi))
    psi_list.append(float(psi))

  print "Number of amino acid/phi/psi values read: ",counter
  if counter == 0:
    print " Error: problem with sequence file -- there should be three columns: amino-acid phi psi"
    raise QuietException

  if len(sequence3) > 0:
    sequence = seq_convert.seq3_to_seq1(sequence3)
  print "Building sequence: ",sequence
  seq3=seq_convert.seq1_to_seq3(sequence)
  #print seq3[0].lower()

  if 'pk1' in cmd.get_names("selections"):
    obj='pk1'
  else:
    obj=seq[0:3]

  attach_amino_acid(obj,seq3[0].lower(),phi_list[0],psi_list[0])
  print seq3[0].lower(),phi_list[0],psi_list[0]
  for i in range(1,len(seq3)):
    aa = seq3[i].lower()
    attach_amino_acid('pk1',aa,phi_list[i],psi_list[i-1])
    print seq3[i].lower(),phi_list[i],psi_list[i-1]

# hide lines and show sticks (comment out the next two lines, if you don't like this).
  if line_style == 0:
    print "hiding lines for: ",seq3[0]
    print "showing sticks for: ",seq3[0]
    cmd.hide('lines',seq3[0])
    cmd.show('sticks',seq3[0])
Пример #3
0
def build_seq_phi_psi(seq_phi_psi_filename,line_style=0):
  """
  usage: build_seq filename

  will build the above sequence from information in a file stored as:
  resname phi psi
  resname phi psi
  ...
  
  where resname is the 1-letter code for the amino acid 

  The created object will be named for the first amino acid in the sequence,
  unless a pk1 selection exists, then it will build onto that atom.

  Default is now to automatically show the structure as sticks, call it with 
  line_style=1 to revert to showing lines

  """

  line_style = int(line_style)
# read file of residue name with associated phi,psi values to build
  lines = file(seq_phi_psi_filename).readlines()
  sequence = ''
  phi_list = []
  psi_list = []
  sequence3 = []
  for l in lines:
    seq,phi,psi = l.split()
    if len(seq) == 3:
      sequence3.append(seq)
    elif len(seq) == 1:
      sequence += seq
    else:
      print " Error: problem with sequence file -- not 3-letter or 1-letter code for residue name"
      raise QuietException

    phi_list.append(float(phi))
    psi_list.append(float(psi))

  if len(sequence3) > 0:
    sequence = seq_convert.seq3_to_seq1(sequence3)
  print "Building sequence: ",sequence
  seq3=seq_convert.seq1_to_seq3(sequence)
  #print seq3[0].lower()

  if 'pk1' in cmd.get_names("selections"):
    obj='pk1'
  else:
    obj=seq[0:3]

  attach_amino_acid(obj,seq3[0].lower(),phi_list[0],psi_list[0])
  print seq3[0].lower(),phi_list[0],psi_list[0]
  for i in xrange(1,len(seq3)):
    aa = seq3[i].lower()
    attach_amino_acid('pk1',aa,phi_list[i],psi_list[i-1])
    print seq3[i].lower(),phi_list[i],psi_list[i-1]

# hide lines and show sticks (comment out the next two lines, if you don't like this).
  if line_style == 0:
    print "hiding lines for: ",seq3[0]
    print "showing sticks for: ",seq3[0]
    cmd.hide('lines',seq3[0])
    cmd.show('sticks',seq3[0])