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
39 -def psea(pname):
40 """Parse PSEA output file.""" 41 fname=run_psea(pname) 42 start=0 43 ss="" 44 fp=open(fname, 'r') 45 for l in fp.readlines(): 46 if l[0:6]==">p-sea": 47 start=1 48 continue 49 if not start: 50 continue 51 if l[0]=="\n": 52 break 53 ss=ss+l[0:-1] 54 fp.close() 55 return ss
56 57
58 -def psea2HEC(pseq):
59 """Translate PSEA secondary structure string into HEC.""" 60 seq=[] 61 for ss in pseq: 62 if ss=="a": 63 n="H" 64 elif ss=="b": 65 n="E" 66 elif ss=="c": 67 n="C" 68 seq.append(n) 69 return seq
70 71
72 -def annotate(m, ss_seq):
73 """Apply seconardary structure information to residues in model.""" 74 c=m.get_list()[0] 75 all=c.get_list() 76 residues=[] 77 # Now remove HOH etc. 78 for res in all: 79 if is_aa(res): 80 residues.append(res) 81 L=len(residues) 82 if not (L==len(ss_seq)): 83 raise ValueError("Length mismatch %i %i" % (L, len(ss_seq))) 84 for i in range(0, L): 85 residues[i].xtra["SS_PSEA"]=ss_seq[i]
86 #os.system("rm "+fname) 87 88
89 -class PSEA(object):
90 - def __init__(self, model, filename):
91 ss_seq=psea(filename) 92 ss_seq=psea2HEC(ss_seq) 93 annotate(model, ss_seq) 94 self.ss_seq=ss_seq
95
96 - def get_seq(self):
97 """ 98 Return secondary structure string. 99 """ 100 return self.ss_seq
101 102 103 if __name__=="__main__": 104 105 import sys 106 from Bio.PDB import PDBParser 107 108 # Parse PDB file 109 p=PDBParser() 110 s=p.get_structure('X', sys.argv[1]) 111 112 # Annotate structure with PSEA sceondary structure info 113 PSEA(s[0], sys.argv[1]) 114