/usr/lib/python2.7/dist-packages/biotools/IO/clustal.py is in python-biotools 1.2.12-2.
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 | '''
Methods for manipulating clustalw alignment files.
'''
from biotools.sequence import Sequence
def read(fh):
def clean_alignment(x):
i = 0
for c in x:
if c != "-":
break
i += 1
j = 0
for c in reversed(x):
if c != "-":
break
j += 1
return (' ' * i + x[(i or None):(-j or None)] + ' ' * j, i, len(x) - j)
seqs = {}
for line in fh:
if line.startswith(' '):
continue
st = line.strip()
if st:
bits = st.split()
if len(bits) != 2:
continue
if bits[0] not in seqs:
seqs[bits[0]] = ''
seqs[bits[0]] += bits[1]
for k in seqs:
seq, start, end = clean_alignment(seqs[k])
yield Sequence(k, seq, start=start, end=end)
raise StopIteration()
def probe(fh):
for line in fh:
st = line.strip()
if st:
if st.startswith('CLUSTAL'):
return {'type': 'clustalw'}
return False
return {'type': 'clustalw'}
def rhook(fh):
try:
fh.next()
except StopIteration:
pass
|