Skip to content

Commit

Permalink
Fix sourmash_lib import in lca
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Mar 9, 2018
1 parent c8a5ae0 commit de49f62
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions sourmash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .signature import (load_signatures, load_one_signature, SourmashSignature,
save_signatures)
from .sbtmh import load_sbt_index, search_sbt_index, create_sbt_index
from . import lca

# retrieve VERSION from sourmash/VERSION.
thisdir = os.path.dirname(__file__)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions sourmash_lib/lca/__main__.py → sourmash/lca/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Command-line entry point for 'python -m sourmash_lib.lca'
Command-line entry point for 'python -m sourmash.lca'
"""

import sys
import argparse

from . import classify, index, summarize_main, rankinfo_main, gather_main
from .command_compare_csv import compare_csv
from sourmash_lib.logging import set_quiet, error
from sourmash.logging import set_quiet, error

usage='''
sourmash lca <command> [<args>] - work with taxonomic information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import csv
from collections import Counter

import sourmash_lib
from sourmash_lib import sourmash_args
from sourmash_lib.logging import notify, error
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug

DEFAULT_THRESHOLD=5 # how many counts of a taxid at min

Expand Down Expand Up @@ -132,7 +132,7 @@ def classify(args):
total_n = len(inp_files)
for query_filename in inp_files:
n += 1
for query_sig in sourmash_lib.load_signatures(query_filename,
for query_sig in sourmash.load_signatures(query_filename,
ksize=ksize):
notify(u'\r\033[K', end=u'')
notify('... classifying {} (file {} of {})', query_sig.name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import argparse
from collections import defaultdict

import sourmash_lib
from sourmash_lib import sourmash_args
from sourmash_lib.logging import notify, error, print_results
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug, zip_lineage
from sourmash_lib.lca.command_index import load_taxonomy_assignments
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error, print_results
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug, zip_lineage
from sourmash.lca.command_index import load_taxonomy_assignments

def compare_csv(args):
p = argparse.ArgumentParser(prog="sourmash lca compare_csv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import csv
from collections import Counter, defaultdict, namedtuple

import sourmash_lib
from sourmash_lib import sourmash_args
from sourmash_lib.logging import notify, error, print_results
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug
from sourmash_lib.search import format_bp
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error, print_results
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug
from sourmash.search import format_bp

LCAGatherResult = namedtuple('LCAGatherResult',
'intersect_bp, f_unique_to_query, f_unique_weighted, average_abund, lineage, f_match, name, n_equal_matches')
Expand Down Expand Up @@ -284,7 +284,7 @@ def gather_main(args):
e = query_sig.minhash.copy_and_clear()
e.add_many(remaining_mins)

sourmash_lib.save_signatures([ sourmash_lib.SourmashSignature(e) ],
sourmash.save_signatures([ sourmash.SourmashSignature(e) ],
args.output_unassigned)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import csv
from collections import defaultdict

import sourmash_lib
from sourmash_lib import sourmash_args
from sourmash_lib.logging import notify, error
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug, LineagePair
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug, LineagePair


def load_taxonomy_assignments(filename, delimiter=',', start_column=2,
Expand Down Expand Up @@ -182,7 +182,7 @@ def index(args):
record_remnants = set(assignments_idx.keys())
for filename in inp_files:
n += 1
for sig in sourmash_lib.load_signatures(filename, ksize=args.ksize):
for sig in sourmash.load_signatures(filename, ksize=args.ksize):
notify(u'\r\033[K', end=u'')
notify('... loading signature {} (file {} of {})', sig.name()[:30], n, total_n, end='\r')
debug(filename, sig.name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import argparse
from collections import defaultdict

from sourmash_lib.logging import error
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug
from sourmash.logging import error
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug


def make_lca_counts(dblist):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import csv
from collections import defaultdict, Counter

import sourmash_lib
from sourmash_lib import sourmash_args
from sourmash_lib.logging import notify, error, print_results
from sourmash_lib.lca import lca_utils
from sourmash_lib.lca.lca_utils import debug, set_debug
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error, print_results
from sourmash.lca import lca_utils
from sourmash.lca.lca_utils import debug, set_debug


DEFAULT_THRESHOLD=5
Expand Down Expand Up @@ -107,7 +107,7 @@ def summarize_main(args):
hashvals = defaultdict(int)
for query_filename in inp_files:
n += 1
for query_sig in sourmash_lib.load_signatures(query_filename,
for query_sig in sourmash.load_signatures(query_filename,
ksize=ksize):
notify(u'\r\033[K', end=u'')
notify('... loading {} (file {} of {})', query_sig.name(), n,
Expand Down
6 changes: 3 additions & 3 deletions sourmash_lib/lca/lca_utils.py → sourmash/lca/lca_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from itertools import izip_longest as zip_longest
import pprint

import sourmash_lib._minhash
from sourmash_lib.logging import notify
import sourmash._minhash
from sourmash.logging import notify

# type to store an element in a taxonomic lineage
LineagePair = namedtuple('LineagePair', ['rank', 'name'])
Expand Down Expand Up @@ -226,7 +226,7 @@ def downsample_scaled(self, scaled):
elif scaled < self.scaled:
raise ValueError("cannot decrease scaled from {} to {}".format(self.scaled, scaled))

max_hash = sourmash_lib._minhash.get_max_hash_for_scaled(scaled)
max_hash = sourmash._minhash.get_max_hash_for_scaled(scaled)
new_hashvals = {}
for k, v in self.hashval_to_lineage_id.items():
if k < max_hash:
Expand Down

0 comments on commit de49f62

Please sign in to comment.