Skip to content

Commit 2af3c73

Browse files
author
Wibowo Arindrarto
committed
added option for returning qual as chars
1 parent cd40043 commit 2af3c73

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

abifpy.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _extract_dir(self, dir_entry):
7878
data = struct.unpack(fmt,
7979
self._data[dir_offset:dir_offset+dir_size])[0]
8080
if tag_name == 'PCON':
81-
self.qual = self._get_qual(data)
81+
self.qual = self.get_qual(data)
8282
elif tag_name == 'PBAS':
8383
# replaces semi-ambiguous DNA characters with 'N'
8484
self.seq = re.sub("K|Y|W|M|R|S",'N',data)
@@ -99,11 +99,17 @@ def _extract_dir(self, dir_entry):
9999
if tag_name == 'HCFG':
100100
self.instrument = data
101101

102-
def _get_qual(self, qual):
102+
def get_qual(self, qual, char=False):
103103
"""Returns a list of read quality values."""
104104
qual_list = []
105-
for value in qual:
106-
qual_list.append(ord(value))
105+
if not char:
106+
for value in qual:
107+
qual_list.append(ord(value))
108+
else:
109+
for value in qual:
110+
if value > 93:
111+
value = 93
112+
qual_list.append(ord(value + 33))
107113
return qual_list
108114

109115
def _get_score(self, cutoff):

0 commit comments

Comments
 (0)