/usr/lib/python2.7/dist-packages/csb/bio/io/psipred.py is in python-csb 1.2.3+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | """
PSIPRED Parser
"""
import csb.core
from csb.bio.structure import SecondaryStructure, SecStructures, UnknownSecStructureError
class PSIPredParseError(ValueError):
pass
class PSIPredResidueInfo(object):
def __init__(self, rank, residue, sec_structure, helix, strand, coil):
self.rank = rank
self.residue = residue
self.sec_structure = sec_structure
self.helix = helix
self.coil = coil
self.strand = strand
class PSIPredParser(object):
"""
Simple PSI-PRED Secondary Structure Parser.
"""
def parse(self, psipred_file):
"""
@param psipred_file: source PSI-PRED *.horiz file to parse
@type psipred_file: str
@rtype: L{SecondaryStructure}
"""
ss = []
conf = []
for line in open(psipred_file):
if line.startswith('Conf:'):
conf.extend(line[6:].strip())
elif line.startswith('Pred:'):
ss.append(line[6:].strip())
ss = ''.join(ss)
conf = ''.join(conf)
if len(ss) != len(conf):
raise PSIPredParseError('Invalid PSI-PRED output file')
if ss:
return SecondaryStructure(ss, conf)
else:
return SecondaryStructure(None)
def parse_scores(self, scores_file):
"""
@param scores_file: source PSI-PRED *.ss2 file to parse
@type scores_file: str
@rtype: list of L{PSIPredResidueInfo}
"""
residues = []
for line in open(scores_file):
if line.startswith('#') or not line.strip():
continue
else:
line = line.split()
rank = int(line[0])
residue = line[1]
try:
ss = csb.core.Enum.parse(SecStructures, line[2])
except csb.core.EnumValueError as e:
raise UnknownSecStructureError(str(e))
coil, helix, strand = map(float, line[3:6])
residues.append(PSIPredResidueInfo(rank, residue, ss, helix, strand, coil))
return tuple(residues)
|