Skip to content

Commit

Permalink
fix bug in index-fastq for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
r3fang committed Apr 24, 2019
1 parent 74e2524 commit bc94988
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

snaptools_version = '1.4.6'
snaptools_version = '1.4.7'

setup(
name='snaptools',
Expand Down
2 changes: 1 addition & 1 deletion snaptools.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: snaptools
Version: 1.4.6
Version: 1.4.7
Summary: A module for working with snap files in Python
Home-page: https://github.com/r3fang/SnapTools.git
Author: Rongxin Fang
Expand Down
2 changes: 1 addition & 1 deletion snaptools/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.6'
__version__ = '1.4.7'
26 changes: 21 additions & 5 deletions snaptools/dex_fastq.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,42 @@ def dex_fastq(input_fastq,

while True:
cur_r1_name = fr1.readline().strip()[1:]
if type(cur_r1_name) is bytes:
cur_r1_name = cur_r1_name.decode();
if cur_r1_name == "": break
cur_r1_read = fr1.readline().strip()
cur_r1_plus = fr1.readline().strip()
cur_r1_qual = fr1.readline().strip()
if type(cur_r1_read) is bytes:
cur_r1_read = cur_r1_read.decode();
if type(cur_r1_qual) is bytes:
cur_r1_qual = cur_r1_qual.decode();
if type(cur_r1_plus) is bytes:
cur_r1_plus = cur_r1_plus.decode();

cur_idex_list = []
for fix in index_files:
cur_name = fix.readline().strip()[1:]
cur_read = fix.readline().strip()
cur_plus = fix.readline().strip()
cur_qual = fix.readline().strip()
if type(cur_name) is bytes:
cur_name = cur_name.decode();
if type(cur_read) is bytes:
cur_read = cur_read.decode();
if type(cur_plus) is bytes:
cur_plus = cur_plus.decode();
if type(cur_qual) is bytes:
cur_qual = cur_qual.decode();
cur_idex_list.append(cur_read)

cur_barcode = "".join(cur_idex_list)

if not (cur_name.split()[0] == cur_r1_name.split()[0]): sys.exit("read name does not match")
fout.write('@' + cur_barcode + ':' + cur_r1_name+"\n")
fout.write(cur_r1_read+"\n")
fout.write("+\n")
fout.write(cur_r1_qual+"\n")

fout.write(('@' + cur_barcode + ':' + cur_r1_name+"\n").encode('utf-8'))
fout.write((cur_r1_read+"\n").encode('utf-8'))
fout.write(("+\n").encode('utf-8'))
fout.write((cur_r1_qual+"\n").encode('utf-8'))
fout.close()
fr1.close()
for fix in index_files:
Expand Down

0 comments on commit bc94988

Please sign in to comment.