/
__init__.py
123 lines (97 loc) · 3.95 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"""A library for computing hash sketches from DNA sequences, comparing
them to each other, and plotting the results.
Public API:
load_file_as_signatures(...) - load `[SourmashSignature, ]` from filename
load_file_as_index(...) - load collections of `SourmashSignature`s
save_signatures(...) - save `[SourmashSignature, ]`
class SourmashSignature - one or more hash sketches
class MinHash - hash sketch class
Please see https://sourmash.readthedocs.io/en/latest/api.html for API docs.
The sourmash code is available at github.com/dib-lab/sourmash/ under the
BSD 3-Clause license.
"""
from deprecation import deprecated
__all__ = ['MinHash', 'SourmashSignature',
'load_one_signature',
'SourmashSignature',
'load_file_as_index',
'load_file_as_signatures',
'save_signatures',
'create_sbt_index',
'load_signatures', # deprecated - remove in 5.0
'load_sbt_index', # deprecated - remove in 5.0
'search_sbt_index', # deprecated - remove in 5.0
]
from ._lowlevel import ffi, lib
ffi.init_once(lib.sourmash_init, "init")
from pkg_resources import get_distribution, DistributionNotFound
try:
VERSION = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
try:
from .version import version as VERSION # noqa
except ImportError: # pragma: no cover
raise ImportError(
"Failed to find (autogenerated) version.py. "
"This might be because you are installing from GitHub's tarballs, "
"use the PyPI ones."
)
from .minhash import MinHash, get_minhash_default_seed, get_minhash_max_hash
DEFAULT_SEED = get_minhash_default_seed()
MAX_HASH = get_minhash_max_hash()
from .signature import (
load_signatures as load_signatures_private,
load_one_signature,
SourmashSignature,
save_signatures,
)
@deprecated(deprecated_in="3.5.1", removed_in="5.0",
current_version=VERSION,
details='Use load_file_as_signatures instead.')
def load_signatures(*args, **kwargs):
"""Load a JSON string with signatures into classes.
Returns list of SourmashSignature objects.
Note, the order is not necessarily the same as what is in the source file.
This function has been deprecated as of 3.5.1; please use
'load_file_as_signatures' instead. Note that in 4.0, the 'quiet' argument
has been removed and the function no longer outputs to stderr.
Moreover, do_raise is now True by default.
"""
return load_signatures_private(*args, **kwargs)
from .sbtmh import load_sbt_index as load_sbt_index_private
from .sbtmh import search_sbt_index as search_sbt_index_private
@deprecated(deprecated_in="3.5.1", removed_in="5.0",
current_version=VERSION,
details='Use load_file_as_index instead.')
def load_sbt_index(*args, **kwargs):
"""Load and return an SBT index.
This function has been deprecated as of 3.5.1; please use
'load_file_as_index' instead.
"""
return load_sbt_index_private(*args, **kwargs)
@deprecated(deprecated_in="3.5.1", removed_in="5.0",
current_version=VERSION,
details='Use the new Index API instead.')
def search_sbt_index(*args, **kwargs):
"""\
Search an SBT index `tree` with signature `query` for matches above
`threshold`.
Usage:
for match_sig, similarity in search_sbt_index(tree, query, threshold):
...
This function has been deprecated as of 3.5.1; please use
'idx = load_file_as_index(...); idx.search(query, threshold=...)' instead.
"""
return search_sbt_index_private(*args, **kwargs)
from .sbtmh import create_sbt_index
from . import lca
from . import tax
from . import sbt
from . import sbtmh
from . import sbt_storage
from . import signature
from . import sig
from . import cli
from . import commands
from .sourmash_args import load_file_as_index
from .sourmash_args import load_file_as_signatures