From b1565e7df5917a386dd1f89ae643cf4894d599bc Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Mon, 1 Oct 2018 16:50:42 -0700 Subject: [PATCH] make 10x support optional --- requirements.txt | 2 -- setup.py | 1 + sourmash/commands.py | 5 +++-- sourmash/tenx.py | 3 ++- tox.ini | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5d4c9724fb..18a36ed08b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,3 @@ sphinx alabaster recommonmark sphinxcontrib-napoleon -pathos -bamnostic>=0.9.2 \ No newline at end of file diff --git a/setup.py b/setup.py index 00839520be..085824e8dd 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,7 @@ 'test' : ['pytest', 'pytest-cov', 'numpy', 'matplotlib', 'scipy','recommonmark'], 'demo' : ['jupyter', 'jupyter_client', 'ipython'], 'doc' : ['sphinx'], + '10x': ['pathos', 'bamnostic>=0.9.2'], }, "include_package_data": True, "package_data": { diff --git a/sourmash/commands.py b/sourmash/commands.py index e5ebc32c46..4eb3f1ca1e 100644 --- a/sourmash/commands.py +++ b/sourmash/commands.py @@ -4,7 +4,6 @@ import csv import itertools import multiprocessing -import pathos.multiprocessing as mp import os import os.path import sys @@ -16,7 +15,6 @@ from . import sourmash_args from .logging import notify, error, print_results, set_quiet from .sbtmh import SearchMinHashesFindBest, SigLeaf -from .tenx import read_10x_folder from .sourmash_args import DEFAULT_LOAD_K DEFAULT_COMPUTE_K = '21,31,51' @@ -267,6 +265,9 @@ def maybe_add_alignment(alignment, cell_seqs, args, barcodes): notify('calculated {} signatures for {} sequences in {}', len(siglist), n + 1, filename) elif args.input_is_10x: + import pathos.multiprocessing as mp + from .tenx import read_10x_folder + barcodes, bam_file = read_10x_folder(filename) manager = multiprocessing.Manager() diff --git a/sourmash/tenx.py b/sourmash/tenx.py index 9fde7374f8..32fecf0d4e 100644 --- a/sourmash/tenx.py +++ b/sourmash/tenx.py @@ -1,5 +1,4 @@ import os -import bamnostic as bs def read_single_column(filename): @@ -11,6 +10,8 @@ def read_single_column(filename): def read_10x_folder(folder): """Get QC-pass barcodes, genes, and bam file from a 10x folder""" + import bamnostic as bs + barcodes = read_single_column(os.path.join(folder, 'barcodes.tsv')) bam_file = bs.AlignmentFile( diff --git a/tox.ini b/tox.ini index 7331de4ed2..2ab46bf267 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,8 @@ deps= codecov ipfsapi redis - pysam + bamnostic + pathos commands= pip install -r requirements.txt pip install -e .[test]