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   
 7  import os 
 8  from string import upper 
 9  from Bio.PDB import * 
10   
11   
12 -def run_psea(fname):
13 """ 14 Run PSEA and return output filename. 15 """ 16 os.system("psea "+fname) 17 last=fname.split("/")[-1] 18 base=last.split(".")[0] 19 return base+".sea"
20
21 -def psea(pname):
22 """ 23 Parse PSEA output file. 24 """ 25 fname=run_psea(pname) 26 start=0 27 ss="" 28 fp=open(fname, 'r') 29 for l in fp.readlines(): 30 if l[0:6]==">p-sea": 31 start=1 32 continue 33 if not start: 34 continue 35 if l[0]=="\n": 36 break 37 ss=ss+l[0:-1] 38 fp.close() 39 return ss
40
41 -def psea2HEC(pseq):
42 """ 43 Translate PSEA secondary structure string into HEC. 44 """ 45 seq=[] 46 for ss in pseq: 47 if ss=="a": 48 n="H" 49 elif ss=="b": 50 n="E" 51 elif ss=="c": 52 n="C" 53 seq.append(n) 54 return seq
55
56 -def annotate(m, ss_seq):
57 c=m.get_list()[0] 58 all=c.get_list() 59 residues=[] 60 # Now remove HOH etc. 61 for res in all: 62 if is_aa(res): 63 residues.append(res) 64 L=len(residues) 65 if not (L==len(ss_seq)): 66 print "Length mismatch", L, len(ss_seq) 67 raise Exception 68 for i in range(0, L): 69 residues[i].xtra["SS_PSEA"]=ss_seq[i] 70 #os.system("rm "+fname) 71
72 -class PSEA:
73 - def __init__(self, model, filename):
74 ss_seq=psea(filename) 75 ss_seq=psea2HEC(ss_seq) 76 annotate(model, ss_seq) 77 self.ss_seq=ss_seq
78
79 - def get_seq(self):
80 """ 81 Return secondary structure string. 82 """ 83 return self.ss_seq
84 85 86 if __name__=="__main__": 87 88 import sys 89 from Bio.PDB import * 90 91 # Parse PDB file 92 p=PDBParser() 93 s=p.get_structure('X', sys.argv[1]) 94 95 # Annotate structure with PSEA sceondary structure info 96 PSEA(s[0], sys.argv[1]) 97