Example #1
0
def get_seq(selection):
  
  selection += ' & n. ca & e. c'
  m = cmd.get_model(selection)
  seq3 = []
  chains = []
  resids = []
  for i in m.atom:
    seq3.append(i.resn)
    chains.append(i.chain)
    resids.append(i.resi)

  seq1 = seq3_to_seq1(seq3)
  return seq1,chains,resids
Example #2
0
def get_seq(selection):

    selection += ' & n. ca & e. c'
    m = cmd.get_model(selection)
    seq3 = []
    chains = []
    resids = []
    for i in m.atom:
        seq3.append(i.resn)
        chains.append(i.chain)
        resids.append(i.resi)

    seq1 = seq3_to_seq1(seq3)
    return seq1, chains, resids
Example #3
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])
Example #4
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])