/usr/lib/python2.7/dist-packages/biotools/IO/phylip.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 56 57 | '''
Functions for manipulating PHYLIP files.
'''
from biotools.sequence import Sequence, chop
def read(fh):
'''
Read sequences in PHYLIP format; This function is a generator that yields
`Sequence` objects.
'''
grid, seqs, names = None, [], []
try:
line = fh.next().strip()
while not line:
line = fh.next.strip()
except StopIteration:
fh.close()
raise StopIteration()
grid = [int(x) for x in line.strip()]
while True:
lines = []
try:
for i in xrange(grid[0]):
line = fh.next().strip()
while not line:
line = fh.next().strip()
lines.append(line)
if not names:
names = [l.split()[0] for l in lines]
try:
seqs = [''.join(l.split()[1:]) for l in lines]
except IndexError:
seqs = [''] * grid[0]
else:
temp = [''.join(l.split()) for l in lines]
seqs = [a + b for a, b in zip(seqs, temp)]
except StopIteration:
break
for name, seq in zip(names, seqs):
yield Sequence(name, seq)
fh.close()
raise StopIteration()
def probe(fh):
'''
'''
for line in fh:
bits = line.split()
if len(bits) == 2 and int(bits[0]) > 0 and int(bits[1]) > 0:
return {'type': 'phylip'}
else:
return False
return {'type': 'phylip'}
|