Package Bio :: Package PDB :: Module PSEA
[hide private]
[frames] | no frames]

Source Code for Module Bio.PDB.PSEA

  1  # Copyright (C) 2006, Thomas Hamelryck (thamelry@binf.ku.dk) 
  2  # This code is part of the Biopython distribution and governed by its 
  3  # license.  Please see the LICENSE file that should have been included 
  4  # as part of this package. 
  5   
  6  """Wrappers for PSEA, a program for secondary structure assignment. 
  7   
  8  See this citation for P-SEA, PMID: 9183534 
  9   
 10  Labesse G, Colloc'h N, Pothier J, Mornon J-P:  P-SEA: a new efficient 
 11  assignment of secondary structure from C_alpha. 
 12  Comput Appl Biosci 1997 , 13:291-295 
 13   
 14  ftp://ftp.lmcp.jussieu.fr/pub/sincris/software/protein/p-sea/ 
 15  """ 
 16   
 17  import os 
 18   
 19  from Bio.PDB.Polypeptide import is_aa 
 20   
 21   
22 -def run_psea(fname):
23 """Run PSEA and return output filename. 24 25 Note that this assumes the P-SEA binary is called "psea" and that it is 26 on the path. 27 28 Note that P-SEA will write an output file in the current directory using 29 the input filename with extension ".sea". 30 31 Note that P-SEA will write output to the terminal while run. 32 """ 33 os.system("psea "+fname) 34 last=fname.split("/")[-1] 35 base=last.split(".")[0] 36 return base+".sea"
37
38 -def psea(pname):
39 """Parse PSEA output file.""" 40 fname=run_psea(pname) 41 start=0 42 ss="" 43 fp=open(fname, 'r') 44 for l in fp.readlines(): 45 if l[0:6]==">p-sea": 46 start=1 47 continue 48 if not start: 49 continue 50 if l[0]=="\n": 51 break 52 ss=ss+l[0:-1] 53 fp.close() 54 return ss
55
56 -def psea2HEC(pseq):
57 """Translate PSEA secondary structure string into HEC.""" 58 seq=[] 59 for ss in pseq: 60 if ss=="a": 61 n="H" 62 elif ss=="b": 63 n="E" 64 elif ss=="c": 65 n="C" 66 seq.append(n) 67 return seq
68
69 -def annotate(m, ss_seq):
70 """Apply seconardary structure information to residues in model.""" 71 c=m.get_list()[0] 72 all=c.get_list() 73 residues=[] 74 # Now remove HOH etc. 75 for res in all: 76 if is_aa(res): 77 residues.append(res) 78 L=len(residues) 79 if not (L==len(ss_seq)): 80 raise ValueError("Length mismatch %i %i" % (L, len(ss_seq))) 81 for i in range(0, L): 82 residues[i].xtra["SS_PSEA"]=ss_seq[i]
83 #os.system("rm "+fname) 84
85 -class PSEA(object):
86 - def __init__(self, model, filename):
87 ss_seq=psea(filename) 88 ss_seq=psea2HEC(ss_seq) 89 annotate(model, ss_seq) 90 self.ss_seq=ss_seq
91
92 - def get_seq(self):
93 """ 94 Return secondary structure string. 95 """ 96 return self.ss_seq
97 98 99 if __name__=="__main__": 100 101 import sys 102 from Bio.PDB import PDBParser 103 104 # Parse PDB file 105 p=PDBParser() 106 s=p.get_structure('X', sys.argv[1]) 107 108 # Annotate structure with PSEA sceondary structure info 109 PSEA(s[0], sys.argv[1]) 110