From eecfa5653020b80e31eed1ae5d2b13068e17a2df Mon Sep 17 00:00:00 2001 From: r3fang Date: Wed, 4 Sep 2019 16:30:18 -0700 Subject: [PATCH] fix barcode.txt --- setup.py | 2 +- snaptools.egg-info/PKG-INFO | 2 +- snaptools/__init__.py | 2 +- snaptools/snap.py | 4 +++- snaptools/snap_pre.py | 15 ++++++++++----- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 2b1fdc2..0e6f44e 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -snaptools_version = '1.4.7' +snaptools_version = '1.4.8' setup( name='snaptools', diff --git a/snaptools.egg-info/PKG-INFO b/snaptools.egg-info/PKG-INFO index 00d2b2f..cc346be 100644 --- a/snaptools.egg-info/PKG-INFO +++ b/snaptools.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: snaptools -Version: 1.4.7 +Version: 1.4.8 Summary: A module for working with snap files in Python Home-page: https://github.com/r3fang/SnapTools.git Author: Rongxin Fang diff --git a/snaptools/__init__.py b/snaptools/__init__.py index 1be3a88..fedbd84 100755 --- a/snaptools/__init__.py +++ b/snaptools/__init__.py @@ -1 +1 @@ -__version__ = '1.4.7' +__version__ = '1.4.8' diff --git a/snaptools/snap.py b/snaptools/snap.py index b1640bb..f244f4f 100755 --- a/snaptools/snap.py +++ b/snaptools/snap.py @@ -192,7 +192,9 @@ def getBarcodesFromTxt(fname): with open(fname) as fin: for line in fin: if line.startswith("#"): continue; - barcode = line.split()[0].upper() + if type(line) is bytes: + line = line.decode(); + barcode = line.split()[0].upper(); barcode_list.append(barcode); barocde_num = len(set(barcode_list)); if barocde_num < len(barcode_list): diff --git a/snaptools/snap_pre.py b/snaptools/snap_pre.py index 1d12ff6..f6b32d1 100755 --- a/snaptools/snap_pre.py +++ b/snaptools/snap_pre.py @@ -222,15 +222,20 @@ def snap_pre(input_file, barcode_dict = snaptools.snap.getBarcodesFromTxt(barcode_file); else: barcode_dict = snaptools.snap.getBarcodesFromInput(input_file, file_format); - - if min_cov == 0 and max_num == 10000000: - barcode_dict = barcode_dict; - else: barcode_cov = snaptools.snap.getBarcodeCov(list(barcode_dict.keys()), input_file, file_format); barcode_cov = sorted(list(barcode_cov.items()), key=operator.itemgetter(1), reverse=True); barcode_cov = barcode_cov[0:min(len(barcode_cov), max_num)]; barcodes = [key for [key, value] in barcode_cov if value > min_cov]; - barcode_dict = collections.OrderedDict(list(zip(sorted(barcodes), list(range(1,(len(barcodes)+1)))))); + barcode_dict = collections.OrderedDict(list(zip(sorted(barcodes), list(range(1,(len(barcodes)+1)))))); + + #if min_cov == 0 and max_num == 10000000: + # barcode_dict = barcode_dict; + #else: + # barcode_cov = snaptools.snap.getBarcodeCov(list(barcode_dict.keys()), input_file, file_format); + # barcode_cov = sorted(list(barcode_cov.items()), key=operator.itemgetter(1), reverse=True); + # barcode_cov = barcode_cov[0:min(len(barcode_cov), max_num)]; + # barcodes = [key for [key, value] in barcode_cov if value > min_cov]; + # barcode_dict = collections.OrderedDict(list(zip(sorted(barcodes), list(range(1,(len(barcodes)+1)))))); f = h5py.File(output_snap, "w", libver='earliest'); f.create_group("HD");