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.

msked[[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.1.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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multiset_key_dict-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7f76b886a93f28f63891d5ae6fa201abfe6b7946b42d0fec607a95d7735bd479
MD5 db3d8c7209d03b843d6200a3a0c97ff3
BLAKE2b-256 87d2bb7aadb2344749a05433a52cc6954c267ea7038b8fdc115cc171a6fa485e

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.2.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for multiset_key_dict-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91ddbf147886dd8628cade9e8d6265cd5e845df571a99af3c14e9c3edbada5c6
MD5 88cbab79842524fa10e03885650fd6b2
BLAKE2b-256 cf0da158ee23907d831dfc1f240266b7a14c04db8f2804e10a8943bcdc981eea

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.2.1-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