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