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