Skip to main content

A simple library for executing BLAST searches with ncbi-blast+

Project description

multiset-key-dict

This small library implements a mapping-like object whose keys are taken to be unordered multisets (Counters, bags), regardless of the type of the actual indexes used.

Example

Create a MultisetKeyDict and insert an element for the set {1, 3, 5}.

from multiset_key_dict import MultisetKeyDict
mskd = MultisetKeyDict()
mskd[[1, 3, 5]] = 19

Access the element just added.

# In a different order.
print(mskd[[3, 5, 1]]) # 19
# With a different type of collection.
print(mskd[{3, 5, 1}]) # 19

__iter__ iterates over items in the MultisetKeyDict, viewed as frozensets (i.e., not accounting for multiplicity).

# Add more data.
mskd[[1]] = 9
mskd[[5, 6]] = 12
print(list(mskd)) # [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12)]

To iterate over key-value pairs where the keys are the FrozenMultiset objects that act as the true keys in the structure, use multiset_iter or items methods instead.

mskd[[1, 1]] = 90
print(list(mskd))
# [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12),
# (frozenset({1}), 90)]

print(list(mskd.multiset_iter()))
# [(FrozenMultiset({(3, 1), (1, 1), (5, 1)}), 19), 
#  (FrozenMultiset({(1, 1)}), 9),
#  (FrozenMultiset({(6, 1), (5, 1)}), 12),
#  (FrozenMultiset({(1, 2)}), 90)]

To get the keys as frozenset objects, use set_keys. To get the keys as FrozenMultiset objects, use multiset_keys or keys.

It's sometimes useful to get the set of elements of the keys. For that, you can use the key_elements method.

print(mskd.key_elements()) # frozenset({1, 3, 5, 6})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multiset_key_dict-0.2.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multiset_key_dict-0.2.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file multiset_key_dict-0.2.2.tar.gz.

File metadata

  • Download URL: multiset_key_dict-0.2.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for multiset_key_dict-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4d308a2dd9eab8ba9966be4b469edaf0a02c0c039ef24efae475630ddca88f83
MD5 f1c4cddf5e20cc2f8933b8f1560ddf79
BLAKE2b-256 3c85b870f764e90626ce8cfc7ace0cada7e058f0929e728a24db15bdaa4daf3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.2.2.tar.gz:

Publisher: package.yml on actapia/multiset-key-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file multiset_key_dict-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for multiset_key_dict-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65352354d5b80d5c6532a2c2fb0fc02cf800189085779a91d47f316810b154db
MD5 1c59fd7517f9529c90862f10cf706e05
BLAKE2b-256 114f4aad8bffcbbe3b7cc01c4f28736ccb6a6660b1f2aaa81a37558bb9dbef38

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.2.2-py3-none-any.whl:

Publisher: package.yml on actapia/multiset-key-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page