1  """ 
 2  PSIPRED Parser 
 3  """ 
 4   
 5  import csb.core 
 6   
 7  from csb.bio.structure import SecondaryStructure, SecStructures, UnknownSecStructureError 
 8   
 9   
12   
13   
15       
16 -    def __init__(self, rank, residue, sec_structure, helix, strand, coil): 
 17           
18          self.rank = rank 
19          self.residue = residue 
20          self.sec_structure = sec_structure 
21          self.helix = helix 
22          self.coil = coil 
23          self.strand = strand     
  24   
25   
27      """ 
28      Simple PSI-PRED Secondary Structure Parser. 
29      """ 
30       
31 -    def parse(self, psipred_file): 
 32          """ 
33          @param psipred_file: source PSI-PRED *.horiz file to parse 
34          @type psipred_file: str 
35          @rtype: L{SecondaryStructure} 
36          """ 
37           
38          ss = [] 
39          conf = [] 
40           
41          for line in open(psipred_file): 
42               
43              if line.startswith('Conf:'): 
44                  conf.extend(line[6:].strip()) 
45                   
46              elif line.startswith('Pred:'): 
47                  ss.append(line[6:].strip()) 
48           
49          ss = ''.join(ss) 
50          conf = ''.join(conf) 
51           
52          if len(ss) != len(conf): 
53              raise PSIPredParseError('Invalid PSI-PRED output file') 
54           
55          if ss: 
56              return SecondaryStructure(ss, conf) 
57          else: 
58              return SecondaryStructure(None) 
 59   
 88