/usr/lib/python3/dist-packages/pyfastaq/caf.py is in fastaq 3.17.0-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 | from pyfastaq import sequences, utils
class Error (Exception): pass
def file_reader(fname):
f = utils.open_file_read(fname)
c = Caf()
while c.get_next_from_file(f):
yield c
utils.close(f)
class Caf:
def __init__(self):
self.id = None
self.seq = None
self.insert_min = None
self.insert_max = None
self.ligation = None
self.clone = None
self.clip_start = None
self.clip_end = None
def __eq__(self, other):
if type(other) is type(self):
return self.__dict__ == other.__dict__
return False
def get_next_from_file(self, f):
self.__init__()
line = f.readline()
if not line:
return None
while line == '\n':
line = f.readline()
if not line.startswith('DNA : '):
raise Error("Error reading caf file. Expected line starting with 'DNA : ...'")
self.id = line.rstrip().split()[2]
line = f.readline()
seq = []
while line != '\n':
seq.append(line.rstrip())
line = f.readline()
self.seq = sequences.Fasta(self.id, ''.join(seq))
line = f.readline()
if not line.startswith('BaseQuality : '):
raise Error("Error reading caf file. Expected line starting with 'BaseQuality : ...'")
quals = [int(x) for x in f.readline().rstrip().split()]
self.seq = self.seq.to_Fastq(quals)
line = f.readline()
assert line == '\n'
line = f.readline()
while line not in ['', '\n']:
a = line.rstrip().split()
if a[0] == 'Insert_size':
self.insert_min, self.insert_max = int(a[1]), int(a[2])
elif a[0] == 'Ligation_no':
self.ligation = a[1]
elif a[0] == 'Clone':
self.clone = a[1]
elif a[0] == 'Clipping' and a[1] == 'QUAL':
self.clip_start, self.clip_end = int(a[2]) - 1, int(a[3]) - 1
line = f.readline()
return True
|